/**
* textToDOM
*
* !A Helper Function
* 
* @param t a text string
* @param type the type of DOM element
* @param className the class name to assign to the DOM element
*
* @returns a DOM element 
**/
function textToDOM( type, t, className ) { 

	if ( type == 'p' || type == 'span' || type == 'div' ) { 

		var rp = document.createElement( type );
		
		if ( className ) 
			rp.className = className;

		rp.innerHTML = t;
	
		return rp;

	}

	else { 
	
		alert ( "textToDOM error :: Invalid type " + type + " passed. Valid types are 'p', 'span', 'div' " );

	}

}

/**
* PHPTimestampToDate
*
* @param t The timestamp to transform into a date object.  The timestamp must be in the format CCYY-MM-DD HH:MM:SS
* @returns A DATE object representation of the input date
**/
function PHPTimestampToDate( t ) { 

	var ret_date = new Date();
	var date_string = new String( t );
	ret_date.setYear( date_string.substring( 0, 4 ) );
	//ret_date.setYear( "2007" );
	ret_date.setMonth( date_string.substring( 5, 7 ) );
	ret_date.setDate( date_string.substring( 8, 10 ) );
	ret_date.setHours( date_string.substring( 11, 13 ) );
	ret_date.setMinutes( date_string.substring( 14, 16 ) );
	ret_date.setSeconds( date_string.substring( 17, 19 ) );

	//alert( ret_date.getYear() );

	return ret_date;

}

/**
* parseLocationSearch
*
* parses the location.search string returning an object who's properties are the variables presented in the search string and the 
* values of the properties are the values assigned in the search string
**/
function parseLocationSearch() { 

	var s_array = new Array();
	var r_object = new Object();

	if ( location.search.length <= 0 ) return false;

	s_array = ( location.search.substring(1, location.search.length) ).split('&');


	for ( var i=0; i<s_array.length; i++ ) { 
		r_object[ s_array[i].substring(0, s_array[i].indexOf( '=' ) ) ] = s_array[i].substring(s_array[i].indexOf( '=' ) + 1 );
	}

	return r_object;

}

