//<script>

window.onload			= init;

// GET PHP VALUES FOR BASE_DIR & DEBUG_MODE
var BASE_DIR			= '';
var IS_DEBUG_MODE		= false;

// BROWSER SNIFFING FOR DYNAMIC BROWSER CAPABILITIES
var AGENT				= navigator.userAgent.toLowerCase();
var IS_DYNAMIC_BROWSER  = document.all || document.getElementById;
var IS_IE				= AGENT.indexOf("msie") != -1 && AGENT.indexOf("opera") == -1;
var IS_NETSCAPE         = AGENT.indexOf('mozilla')!=-1 && AGENT.indexOf('spoofer')==-1 && AGENT.indexOf('compatible') == -1 && AGENT.indexOf('opera')==-1 && AGENT.indexOf('webtv')==-1 && AGENT.indexOf('hotjava')==-1;
var IS_COMPAT_MODE		= document.compatMode == "CSS1Compat";

// IMG ROLLOVER SETTINGS <img class='rollover' src='path/to/img_out.jpg' />
var g_strImgClass		= "rollover";
var g_strOver_ext		= "_over";
var g_strOut_ext		= "_out";

// called "onload"...all onload functions should be called within init()
function init() {
    processImages();
}
function addRollover( p_oTag ) {
	if( p_oTag.className == g_strImgClass ) {
		var preload;
		var strSrc           = p_oTag.src;
		preload		         = new Image();
		preload.src          = strSrc.replace( g_strOut_ext, g_strOver_ext );
		p_oTag.onmouseover   = toggleImgOver;
		p_oTag.onmouseout    = toggleImgOver;
	}
}
function fixPNG( p_oTag ) {
	if(IS_IE) {
	  var version			 		= parseFloat( navigator.appVersion.split("MSIE")[1] );
	  if( version >= 5.5 && version < 7 && document.body.filters ) {
	    strSrc				 		= p_oTag.src;
		strSrc_lower				= strSrc.toLowerCase();
		if( strSrc_lower.substring(strSrc_lower.length-3, strSrc_lower.length) == "png" ) {
		  p_oTag.src		 		= BASE_DIR + "/lib/images/spacer.gif";
		  p_oTag.style.cssText		= "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + strSrc + "', sizingMethod='scale');" + p_oTag.style.cssText;
		}
	  }
	}
}
function processImages() {
    if( document.getElementsByTagName ) {
        var arrIMGTags       = document.getElementsByTagName("IMG");
        var arrINPUTTags     = document.getElementsByTagName("INPUT");

        for(i=0,j=0; i < arrIMGTags.length; i++) {
			addRollover( arrIMGTags[i] );
			fixPNG( arrIMGTags[i] );
        }
        for(i=0,j=0; i < arrINPUTTags.length; i++) {
		  if( arrINPUTTags[i].type == "image" ) {
			addRollover( arrINPUTTags[i] );
			fixPNG( arrINPUTTags[i] );
		  }
        }
    }
}
function toggleImgOver(e) {
    if(!e) e = event;
	this.src = e.type=="mouseover" ? this.src.replace( g_strOut_ext, g_strOver_ext ) : this.src.replace( g_strOver_ext,g_strOut_ext );
}

function limitKeyStrokes(p_oElement, p_oCounter, i) {
	bOkay									= p_oElement.value.length <= i;
	p_oCounter.value						= p_oElement.value.length;
	p_oCounter.style.backgroundColor		= bOkay ? "white"          : "red";
	p_oCounter.style.color					= bOkay ? "black"          : "white";

	if( !bOkay ) { p_oElement.value         = p_oElement.value.substring(0,i); }
}

function checkAll(p_oTag, p_strElements) {
	oForm							= p_oTag.form;
	arrCheckboxes					= oForm.elements[p_strElements];

	for( i=0; i<arrCheckboxes.length; i++ ) {
		arrCheckboxes[i].checked	= p_oTag.checked;
	}
}
function clearDefault(p_obj, p_strDefault) {
	if( p_obj.value == p_strDefault ) p_obj.value = "";
}
function bookmark() {
	strURL			= window.location.href;
	strTitle		= document.title.replace(/\:+/g,"-");
	if( document.all )        { window.external.AddFavorite(strURL, strTitle); }
	else if( window.sidebar ) { window.sidebar.addPanel(strTitle, strURL, ""); }
}
function toggleChild( p_oTag ) {
	strDisplay		= getTagByID( p_oTag.id+"_child").style.display;
	getTagByID(p_oTag.id+"_child").style.display		= strDisplay=="block" ? "none" : "block";
}
function getBody() {
	return( document.body.parentNode ? document.body.parentNode : document.body );
}
function getTagByID( p_strID ) {
    return( document.all ? document.all[p_strID] : document.getElementById(p_strID) );
}
function outputEmail( p_strName, p_strDomain ) {
	strEmail		= p_strName + "@" + p_strDomain;
	document.write("<a href='mailto:"+strEmail+"'>"+strEmail+"</a>");
}
function debugWrite( p_strText ) {
	if( IS_DEBUG_MODE ) { alert( p_strText ); }
}
function doNothing() { return }
