//Copyright (c) 2000 direction inc. All rights reserved.
//Any reuse of this or any code in any of direction's solutions is strictly prohibited without written consent.
//Please refer to "www.directionsolutions/legal.html" for further important copyright & licensing information.


// form colors
var formOn = "#FAE3C6";
var formOff = "#FFFFFF";

/* From Old Print-Quotes Site */

function getLayer( id ) {
	var layer = null;

	if (is_nav4only) {
		layer = document.layers[id];
	} else if (is_nav5up) {
		layer = document.getElementById( id );
	} else if (is_ie4up) {
		layer = document.all[id];
	} /* end if */
	return layer;

} /* end function getLayer( menuID ) */

function pageCode() { 
	findLength();
	if (allowMenu==1) writeMenus();
	if (is_ie5) initPulls();
}


function getDiv(divID,divStyle){
	if (is_nav4only) {
		divObj = document.layers[divID];
	}
	else if (is_ie4up) {
		if (divStyle) divObj = document.all[divID].style;
		else divObj = document.all[divID];
	}	
	else {
		if (divStyle) divObj = document.getElementById(divID).style;
		else divObj = document.getElementById(divID);
	}
	return divObj;
}

function getImage( name, layer ) {
	if ( ! layer )
		layer = 'content';

	var image = null;
	if ( is_nav4only ) {
		if ( document.layers[layer] ) {
			image = document.layers[layer].document.images[name];
		} else {
			image = document.images[name];
		} // end if
	} else {
		image = document.images[name];
	} /* end if */
	return image;
} /* function getImage( name ) */



/* ------------ btn/menu scripts ------------ */ 


function btnOn( btnName ) {
	var image = getImage( btnName );
	var filename;

	if ( image ) {
		filename = image.src.substring( image.src.lastIndexOf('/') + 1 );
		image.src = '/images/buttons/on/' + filename;
	} /* end if */
	self.status = filename.substring( 0, filename.lastIndexOf('.') );

	return true;
} // end function btnOn( btnName )

function btnOff( btnName ) {
	var image = getImage( btnName );
	if ( image ) {
		var filename = image.src.substring( image.src.lastIndexOf('/') + 1 );
		image.src = '/images/buttons/off/' + filename;
	} /* end if */
	self.status = '';
} // end function btnOn( btnName )


function getStr(str,stat){
	frontEnd = str.indexOf('off/') + 4;
	backEnd = str.indexOf('.gif');
	btnID = str.substring(frontEnd,backEnd)
	if(stat) status = btnID;
	btnStr = "/images/buttons/on/" + btnID + ".gif";
	return(btnStr)
}

/* ------------ form scripts ------------ */

function on(iName){

	if ( (is_ie4up || is_nav5up) && iName && iName.style )  {
		iName.style.background = formOn;
	}

}

function off(iName){

	if ((is_ie4up || is_nav5up) && iName && iName.style )  {
		iName.style.background = formOff;
	}

}

function clearSelect( what ) {
    for ( var k = 0; k < what.options.length; k++ ) {
        what.options[k].selected = 0;
        what.options[0].selected = 1;
    } 
}

function clearForm(what) {
	for (var i=0, j=what.elements.length; i<j; i++) {
        myName = what.elements[i].type;
        if (myName.indexOf('checkbox') > -1 || myName.indexOf('radio') > -1) {
        	what.elements[i].checked = "";
		}
        if (myName.indexOf('hidden') > -1 || myName.indexOf('password') > -1 || myName.indexOf('text') > -1) {
             what.elements[i].value = "";
		}
        if (myName.indexOf('select') > -1) {
        	for (var k=0, l=what.elements[i].options.length; k<l; k++) {
            	what.elements[i].options[k].selected = 0;
             	what.elements[i].options[0].selected = 1;
			}
		}
	}          
}  

var fmChange = 0;

function fmCheck( form ) {
	if ( fmChange == 1 ) {
		if ( confirm("Are you sure you want to leave this record without saving your changes?") ) {
			fmChange == 0;
            form.submit();
		} 
	} else if (fmChange == 2) {
		fmChange = 0;
		if ( confirm("Are you sure you want to delete this record?") ) {
            form.submit();
		} 
	} else if (fmChange == 3) {
		fmChange = 0;
		if ( confirm("Are you sure you want to save your changes?") ) {
            form.submit();
		} 
	} else {
		form.submit();
	}
}

function addCheck(formName) {
	if (fmChange == 1) {
		if (confirm("Are you sure you want to create a new record, without saving your changes")) {
			clearForm(formName);
		}
	}
	else { 
		clearForm(formName);
	}
}

function submitCheck() {
	if (fmChange == 1) {
		return confirm("Are you sure you want to reset this record without saving your changes?");
	}
}



/* ----------- browser bug code ----------- */

// fix pulldowns in ie 5.0
function initPulls() {
	for ( var j=0; j < document.forms.length; j++) {
		var form = document.forms[j];
		for ( var i = 0; i < form.elements.length; i++) {
			var type = form.elements[i].type;
			if (type.indexOf('select') > -1) {
				for (var k=0; k<form.elements[i].options.length; k++) {
					if ( ! form.elements[i].options[k].selected ) on(form.elements[i].options[k]);
				}
			}
		} 
	}
}


// create scrolling
function findLength() {
 	var conObj = getDiv("content");
	if ( conObj ) {
		var scr=0;
		var pgLength;

		if (is_nav4only) {
			scr=1;
			pgLength = conObj.clip.height + conObj.top;
		} else if ((is_ie4up) && (plat == "mac")) {
			scr=1;
			pgLength = conObj.offsetHeight + conObj.offsetTop;
		}	
		if(scr) document.write('<img src="/images/header/trans.gif" width=2 height='+pgLength+'>');	
	} // end if
}


// n4 resize window 
if( is_nav4only ) {
reloadPage(true);
}
function reloadPage(init) {  
  	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
  	  		document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; 
		}
	}
  	else if (innerWidth!=document.pgW || innerHeight!=document.pgH) {
		location.reload();
	}
}


// open glossary window
var testgl = "a";
function openGlos() { 
	glossWin = window.open('/main/support/glossary/glos_'+testgl+'.html','gloss','resizable=yes,scrollbars=yes,width=254,height=242,screenX=0,screenY=0,top=0,left=0');
	glossWin.focus();
}



