
function removeAllChildNodes(node) { if ( node && node.hasChildNodes && node.removeChild ) { while ( node.hasChildNodes() ) { node.removeChild(node.firstChild); }; }; };
function days_in_month(y, m) { for ( i=31; i>27; i-- ) { if ( (new Date(y, m, i)).getMonth() == m )	{ return i; }; }; };
function str_pad(input, pad_length, pad_string, pad_direction) { if ( !isNaN(input) ) { input=""+input+""; }; if ( input.length>=pad_length ) { return input; }; var new_str=""; for ( var i=0; i<(pad_length-input.length); i++ ) { new_str+=pad_string; }; return ("PAD_LEFT" == pad_direction) ? (new_str + input) : (input + new_str); };
function msg(id, m) {	var e = el(id); if ( e ) { if ( m.replace ) { m = m.replace(/\n/ig, "<br>"); }; e.innerHTML = m + e.innerHTML; }; };
function el(id) { var e = 0; try { e = document.getElementById(id); } catch(e){ e = 0; }; return e; };
function px(n) { return n+"px"; };
function contains(a, b) { while (b.parentNode) { if ( (b = b.parentNode) == a ) { return true; }; }; return false; };
function trim(s) { return s.replace(/^\s*|\s*$/g,""); };
function nl2br(s) { return s.replace(/\n/g, "<br />"); };
function nl2brbr(s) { return s.replace(/\n/g, "<br /><br />"); };
function nl2p(s) { return s.replace(/\n/g, "<p>&nbsp;</p>"); };
function print_r(a) { var s = ""; for ( i in a ) { s += i +" => "+ a[i] +"\n"; }; return s; }

function urldecode(psEncodeString)
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}

function get_event_target(e)
{
	var t;
	
	if (!e)
	{
		var e = window.event;
	};
	
	if (e.target)
	{
		t = e.target;
	}
	else if (e.srcElement)
	{
		t = e.srcElement;
	};
	
	if (t.nodeType == 3) // defeat Safari bug
	{
		t = t.parentNode;
	};
	
	return t;
}

function find_pos_x(obj) { var curleft = 0; if ( obj.offsetParent ) { while ( obj.offsetParent ) { curleft += obj.offsetLeft; obj = obj.offsetParent; }; } else if ( obj.x ) { curleft += obj.x; }; return curleft; };
function find_pos_y(obj) { var curtop = 0; if ( obj.offsetParent ) { while ( obj.offsetParent ) { curtop += obj.offsetTop; obj = obj.offsetParent; }; } else if ( obj.y ) { curtop += obj.y; }; return curtop; };

function get_scroll_amount()
{
	var x,y;
	
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	};
	
	return {x:x,y:y};
};

function verify_form_submit(msg, form) { if ( confirm(msg) ) {  form.submit(); } else { return false; }; };
function verify_visit_url(msg, url) { if ( confirm(msg) ) { if ( '' != url ) { window.document.location = url; } else { return true; }; }; };


function load_javascript(path)
{
	if ( "" != path )
	{
		document.write('<script language="javascript" type="text/javascript" src="'+ path +'"></script>');
	};
};

function load_stylesheet(path)
{
	if ( "" != path )
	{
		document.write('<link rel="stylesheet" type="text/css" href="'+ path +'">');
	};
};


function mouse_coords(e)
{
	var posx = 0;
	var posy = 0;
	
	if ( !e )
	{
		var e = window.event;
	}
	
	if ( e.pageX || e.pageY )
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if ( e.clientX || e.clientY )
	{
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	};
		
	return {x:posx,y:posy};
};