/* All generic Javascript functions for app */
<!--
//This is for the item_add_start.asp page - if Material Order checkbox is checked,
//then Repair and Upgrade can't be checked.  Likewise, if either Repair and/or Upgrade
//is checked, then Material Order can't be checked.
//function checkboxCheck() {
	//alert("CheckboxCheck() called!");
	//If upgrade or repair is checked, mat order is disabled
	
	//if((document.insert.otRepair.checked == true) || (document.insert.otUpgrade.checked == true)) {
	//	document.insert.otMaterialOrder.disabled = true; 
	//	document.insert.otMaterialOrder.checked = false;
	//}
	
	//If mat order is checked, then upgrade and repair are disabled
	//if (document.insert.otMaterialOrder.checked == true) {
	//	document.insert.otRepair.disabled = true;
	//	document.insert.otUpgrade.disabled = true;
	//	document.insert.otRepair.checked = false;
	//	document.insert.otUpgrade.checked = false;
	//}
	
	//If none are checked, then none should be disabled
	//else {
	//	document.insert.otMaterialOrder.disabled = false; 
	//	document.insert.otRepair.disabled = false;
	//	document.insert.otUpgrade.disabled = false;
	//}
//}

//alert("hello world");

function CleanWordHTML( str ) {
	//alert("Running cleanwordhtml");
	
	str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
	str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
	str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
	str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
	str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
	str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
	str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
	str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
	str = str.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
	str = str.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
	str = str.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
	str = str.replace( /\s*tab-stops:[^"]*/gi, "" ) ;
	str = str.replace( /\s*face="[^"]*"/gi, "" ) ;
	str = str.replace( /\s*face=[^ >]*/gi, "" ) ;
	str = str.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;
	str = str.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	str = str.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
	str = str.replace( /\s*style="\s*"/gi, '' ) ;
	str = str.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
	str = str.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
	str = str.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
	str = str.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
	str = str.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
	str = str.replace(/<\\?\?xml[^>]*>/gi, "") ;
	str = str.replace(/<\/?\w+:[^>]*>/gi, "") ;
	str = str.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
	str = str.replace( /<H1([^>]*)>/gi, '' ) ;
	str = str.replace( /<H2([^>]*)>/gi, '' ) ;
	str = str.replace( /<H3([^>]*)>/gi, '' ) ;
	str = str.replace( /<H4([^>]*)>/gi, '' ) ;
	str = str.replace( /<H5([^>]*)>/gi, '' ) ;
	str = str.replace( /<H6([^>]*)>/gi, '' ) ;
	str = str.replace( /<\/H\d>/gi, '<br>' ) ; //remove this to take out breaks where Heading tags were
	str = str.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;
	str = str.replace( /<(B|b)>&nbsp;<\/\b|B>/g, '' ) ;
	str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
	//some RegEx code for the picky browsers
	var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;
	str = str.replace( re, "<div$2</div>" ) ;
	var re2 = new RegExp("(<font|<FONT)([^*>]*>.*?)(<\/FONT>|<\/font>)","gi") ;
	str = str.replace( re2, "<div$2</div>") ;
	str = str.replace( /size|SIZE = ([\d]{1})/g, '' ) ;
	
	
	//return str ;
	//alert(str);

}

//SOME FORM VALIDATION FUNCTIONS
function isNotNumber(theNum) {
	//See if theNum is NOT a number
	var myRegExp = /\D\W/;
	return (myRegExp.test(theNum));	
}

//TRIM FUNCTIONS
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}


function getHeight() {
	var ah;
	ah = screen.availHeight;
	return ah;
}

function getWidth() {
	var aw;
	aw = screen.availWidth;
	return aw;
}

function resizeMe() {
	var h, w;
	h = getHeight();
	w = getWidth();
	window.resizeTo(w,h);
	window.moveTo(0,0);
}

//THIS FUNCTION IS PASSED AN EMAIL ADDRESS, AND RETURNS TRUE IF IT IS VALID, FALSE IF IT IS NOT
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}	


//THIS FUNCTION CHECKS FOR ILLEGAL CHARACTERS - USED IN THE 'REPORT NUMBER' FIELD IN THE TECH REPORTS SECTION.  THIS FIELD 
//DETERMINES THE NAME OF THE .PDF FILE, SO ONLY ALLOW NUMBERS, LETTERS, DASH AND UNDERSCORE.
function checkForValidChars(str) {
	//var validCharRegExp = /[^a-z\d ] /i;
	var isValid = true;
	var validChars = "abcdefghijklmnopqrstuvwxyz1234567890-_ "
	var charIndex;
	
	for (charIndex = 0; charIndex<str.length; charIndex++) {
		if(validChars.indexOf(str.charAt(charIndex).toLowerCase()) < 0) {
			isValid = false;
			break;
		}
	}
	return isValid;
	//alert(validCharRegExp.test(str));
	//return !(validCharRegExp.test(str));	
}
	
/* NOT USED 
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
*/

//THIS FUNCTION LIMITS THE NUMBER OF CHARACTERS IN A TEXTBOX
function textCounter(field, countfield, maxlimit) {
	//IF IT'S TOO LONG, TRIM IT!
	if (field.value.length > maxlimit) 
		field.value = field.value.substring(0, maxlimit);
	
	//OTHERWISE, UPDATE THE AMOUNT OF CHARS LEFT
	else 
		countfield.value = maxlimit - field.value.length;
}


//THIS FUNCTION IS USED IN THE isDate() FUNCTION BELOW
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this;
}

//THIS RETURNS TRUE IF DATE PASSED TO IT IS VALID, FALSE IF NOT
function isDate(dtStr){
	//ONLY RUN THE CODE IF THERE IS A VALUE HERE
	if(dtStr != '') {
		var dtCh= "/";
		var minYear=1980;
		var maxYear=2100;
		var daysInMonth = DaysArray(12);
		var pos1 = dtStr.indexOf(dtCh);
		var pos2 = dtStr.indexOf(dtCh, pos1 + 1);
		var strMonth = dtStr.substring(0, pos1);
		var strDay = dtStr.substring(pos1 + 1, pos2);
		var strYear = dtStr.substring(pos2 + 1);
		
		var errFnd = 0;
		var err = 'An invalid date has been entered. Please correct the following:\n';
		
		strYr = strYear;
		if (strDay.charAt(0) == "0" && strDay.length>1) strDay=strDay.substring(1);
		if (strMonth.charAt(0)== "0" && strMonth.length>1) strMonth=strMonth.substring(1);
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		
		month = parseInt(strMonth);
		day = parseInt(strDay);
		year = parseInt(strYr);
		
		if (pos1 == -1 || pos2 == -1){
			err += '\n- The correct format should be \'mm/dd/yyyy\'';
			errFnd = 1;
			//alert("The date format should be : mm/dd/yyyy");
			//return false
		}
		if (strMonth.length < 1 || month < 1 || month > 12){
			err += '\n- Please enter a valid month';
			errFnd = 1;
			//alert("Please enter a valid month");
			//return false
		}
		if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			err += '\n- Please enter a valid day';
			errFnd = 1;
			//alert("Please enter a valid day");
			//return false
		}
		if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear){
			err += '\n- Please enter a valid 4 digit year between ' + minYear + ' and '+ maxYear;
			errFnd = 1;
			//alert("Please enter a valid 4 digit year between " + minYear + " and "+ maxYear);
			//return false
		}
		//if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		//	alert("Please enter a valid date");
		//	return false
		//}
		
		if(errFnd == 1) {
			alert(err);
			return false;
		}
		else {
			return true;
		}
		
	//return true
	}
}

function centerMe() {
	//alert("Calling centerMe");
	//Get screen height and width and window (popup to center) height and width
	var sh, sw, wh, ww, newX, newY;
	sh = getHeight();
	sw = getWidth();
	wh = document.body.clientHeight;
	ww = document.body.clientWidth;
	newX = Math.round((sw/2) - (ww/2));
	newY = Math.round((sh/2) - (wh/2)) - 10;
	moveTo(newX, newY);
	//alert("newX: " + newX + "\nnewY: " + newY);
}

function refreshOpener() {
	window.opener.location.reload(true);
}

/* NOT USED HERE
function sessionExpireMessage() {
	timer55 = setTimeout('sessionExpire(55)', 3300000);	//Warn user at 55 min
	timer60 = setTimeout('sessionExpire(60)', 3600000);	//Log out at 60	
	//TESTING
	//timer55 = setTimeout('sessionExpire(15)', 1000);	  //Immediately
	//timer60 = setTimeout('sessionExpire(20)', 100000);	//10 sec
	//timer55 = setTimeout('sessionExpire(15)', 900000);	//Warn user at 15 min
	//timer60 = setTimeout('sessionExpire(20)', 1200000);	//Log out at 20	
}

function sessionExpire(mins) {
	//Parse the file name from the href property
	var fileName;
	fileName = window.location.href;
	
	//If this is not the 60 minute mark, and the user is NOT on one of the login/logout screens (login not needed) then show the alert
	if((mins < 60 && fileName.indexOf("/logout") == -1 && fileName.indexOf("/login") == -1 && fileName.indexOf("/access_denied") == -1) && (window.name == "")) {	
	
		MM_showHideLayers('login_timer','','show');	
		window.focus();
	}
	
	//else if the user is already on a login/logout related page, don't show any more alerts
	else if(fileName.indexOf("/logout") > -1 || fileName.indexOf("/login") > -1 || fileName.indexOf("/access_denied") > -1) {
		clearTimeout(timer55);
		clearTimeout(timer60);
	}
	
	//user has been in for 60 minutes, and has not renewed their session or logged out, so log them out
	else {
		endSession();
	}
}

function renewSession() {
	clearTimeout(timer55);
	clearTimeout(timer60);
	MM_showHideLayers('login_timer','','hide');	
	sessionExpireMessage();
}

function endSession() {
	var theFileName = window.location.href;
	//ALL POPUPS ARE NAMED, SO IF THERE IS NO NAME, IT SHOULD BE MAIN
	if(window.name != "") {
		self.close();
	}
	else {		
		if(theFileName.indexOf("https://psd.harris.com") != -1) {
			top.document.location.href="https://psd.harris.com/login/logging_out.asp";
		}
		else if (theFileName.indexOf("http://rfcweb") != -1) {
			top.document.location.href="http://rfcweb/psd/login/logging_out.asp";
		}
		else if (theFileName.indexOf("http://localhost") != -1) {
			top.document.location.href="http://localhost/psd/login/logging_out.asp";											 
		}
	}
}
*/

//Puts focus in the first editable field in a form
function placeFocus() {
if (document.forms.length > 0) {
	var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if (((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type == "radio")) && !(field.elements[i].disabled == true)) {
				document.forms[0].elements[i].focus();
				break;
         }
      }
   }
}

/*//Populates the Defect Label drop down based on the value of the Defect Type drop down on the following pages:
//order/upgrade_parts_add.asp, order/upgrade_parts_edit.asp, order/repair_parts_add.asp, and order/repair_parts_edit.asp

function populateDefectLabel(defectType) {

	//Set a variable for the form
	var theForm = document.forms[0];
	
	//Get the number of items currently in the defectLabel drop down so we know how many to remove
	var defectLabelLen = theForm.defectLabel.length;
	
	//Remove all options from defectLabel, based on the length (from above).  Have to start at the 
	//bottom and decrement, since when we remove one, the index changes.
	for(var i = defectLabelLen; i >= 1; i--) {
		theForm.defectLabel.options.remove(i);
	}
	
	//Check to see which item is selected in defect type, and populate defect label accordingly.
	if (theForm.defectType.value == 'FIRMWARE') {
		var option = new Option("CORRUPTED", "CORRUPTED");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("MISMATCHED", "MISMATCHED");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("OLD REVISION/NEEDS UPGRADE", "OLD REVISION/NEEDS UPGRADE");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("REPORGRAM", "REPORGRAM");
		theForm.defectLabel.options.add(option, 4);
	}
	else if (theForm.defectType.value == 'HARDWARE') {
		var option = new Option("DAMAGED", "DAMAGED");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("DIRTY/CORRODED", "DIRTY/CORRODED");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("LOOSE", "LOOSE");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("METAL WORK DAMAGED", "METAL WORK DAMAGED");
		theForm.defectLabel.options.add(option, 4);
		var option = new Option("MISSING", "MISSING");
		theForm.defectLabel.options.add(option, 5);
		var option = new Option("WORN", "WORN");
		theForm.defectLabel.options.add(option, 6);
		var option = new Option("WRONG", "WRONG");
		theForm.defectLabel.options.add(option, 7);
	}
	
	else if (theForm.defectType.value == 'MODULE') {
		var option = new Option("BER", "BER");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("BURNT", "BURNT");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("DAMAGED", "DAMAGED");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("ELECTRICAL ALIGNMENT", "ELECTRICAL ALIGNMENT");
		theForm.defectLabel.options.add(option, 4);
		var option = new Option("FAILED TEST", "FAILED TEST");
		theForm.defectLabel.options.add(option, 5);
		var option = new Option("INTERMITTENT", "INTERMITTENT");
		theForm.defectLabel.options.add(option, 6);
		var option = new Option("MISSING", "MISSING");
		theForm.defectLabel.options.add(option, 7);
		var option = new Option("NO OUTPUT", "NO OUTPUT");
		theForm.defectLabel.options.add(option, 8);
		var option = new Option("OLD REVISION/NEEDS UPGRADE", "OLD REVISION/NEEDS UPGRADE");
		theForm.defectLabel.options.add(option, 9);
		var option = new Option("REPROGRAM", "REPROGRAM");
		theForm.defectLabel.options.add(option, 10);
	}
	
	else if (theForm.defectType.value == 'PART') {
		var option = new Option("BURNT", "BURNT");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("DAMAGED", "DAMAGED");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("ELECTRICAL ALIGNMENT", "ELECTRICAL ALIGNMENT");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("INTERMITTENT", "INTERMITTENT");
		theForm.defectLabel.options.add(option, 4);
		var option = new Option("LIFTED/BENT LEAD", "LIFTED/BENT LEAD");
		theForm.defectLabel.options.add(option, 5);
		var option = new Option("LOW OUTPUT", "LOW OUTPUT");
		theForm.defectLabel.options.add(option, 6);
		var option = new Option("MISSING", "MISSING");
		theForm.defectLabel.options.add(option, 7);
		var option = new Option("NO OUTPUT", "NO OUTPUT");
		theForm.defectLabel.options.add(option, 8);
		var option = new Option("OPEN", "OPEN");
		theForm.defectLabel.options.add(option, 9);
		var option = new Option("ORIENTATION", "ORIENTATION");
		theForm.defectLabel.options.add(option, 10);
		var option = new Option("OUT OF TOLERANCE", "OUT OF TOLERANCE");
		theForm.defectLabel.options.add(option, 11);
		var option = new Option("PREVENTATIVE MAINTENANCE", "PREVENTATIVE MAINTENANCE");
		theForm.defectLabel.options.add(option, 12);
		var option = new Option("SECONDARY FAILURE", "SECONDARY FAILURE");
		theForm.defectLabel.options.add(option, 13);
		var option = new Option("SHORT", "SHORT");
		theForm.defectLabel.options.add(option, 14);
		var option = new Option("WRONG", "WRONG");
		theForm.defectLabel.options.add(option, 15);
		var option = new Option("WRONG REVISION", "WRONG REVISION");
		theForm.defectLabel.options.add(option, 16);
	}
	
	else if (theForm.defectType.value == 'PWB') {
		var option = new Option("BER", "BER");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("BURNT", "BURNT");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("DAMAGED", "DAMAGED");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("ELECTRICAL ALIGNMENT", "ELECTRICAL ALIGNMENT");
		theForm.defectLabel.options.add(option, 4);
		var option = new Option("EXPOSED COPPER", "EXPOSED COPPER");
		theForm.defectLabel.options.add(option, 5);
		var option = new Option("FAILED TEST", "FAILED TEST");
		theForm.defectLabel.options.add(option, 6);
		var option = new Option("INTERMITTENT", "INTERMITTENT");
		theForm.defectLabel.options.add(option, 7);
		var option = new Option("INTERNAL OPEN/SHORT", "INTERNAL OPEN/SHORT");
		theForm.defectLabel.options.add(option, 8);
		var option = new Option("MISSING", "MISSING");
		theForm.defectLabel.options.add(option, 9);
		var option = new Option("NO OUTPUT", "NO OUTPUT");
		theForm.defectLabel.options.add(option, 10);
		var option = new Option("OLD REVISION/NEEDS UPGRADE", "OLD REVISION/NEEDS UPGRADE");
		theForm.defectLabel.options.add(option, 11);
		var option = new Option("OPEN TRACE", "OPEN TRACE");
		theForm.defectLabel.options.add(option, 12);
		var option = new Option("REPROGRAM", "REPROGRAM");
		theForm.defectLabel.options.add(option, 13);
		var option = new Option("SHORT TECH/TRACE", "SHORT TECH/TRACE");
		theForm.defectLabel.options.add(option, 14);
	}
	
	else if (theForm.defectType.value == 'SOLDER') {
		var option = new Option("COLD SOLDER", "COLD SOLDER");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("EXCESSIVE", "EXCESSIVE");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("FRACTURED SOLDER", "FRACTURED SOLDER");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("INSUFFICIENT", "INSUFFICIENT");
		theForm.defectLabel.options.add(option, 4);
		var option = new Option("NO SOLDER", "NO SOLDER");
		theForm.defectLabel.options.add(option, 5);
		var option = new Option("SOLDER BRIDGE", "SOLDER BRIDGE");
		theForm.defectLabel.options.add(option, 6);
	}
	
	else if (theForm.defectType.value == 'WIRE/CABLING') {
		var option = new Option("CUT", "CUT");
		theForm.defectLabel.options.add(option, 1);
		var option = new Option("DAMAGED", "DAMAGED");
		theForm.defectLabel.options.add(option, 2);
		var option = new Option("INSULATION DAMAGE", "INSULATION DAMAGE");
		theForm.defectLabel.options.add(option, 3);
		var option = new Option("NOT CONNECTED", "NOT CONNECTED");
		theForm.defectLabel.options.add(option, 4);
		var option = new Option("PINCHED", "PINCHED");
		theForm.defectLabel.options.add(option, 5);
		var option = new Option("UNSEATED", "UNSEATED");
		theForm.defectLabel.options.add(option, 6);
		var option = new Option("WRONG", "WRONG");
		theForm.defectLabel.options.add(option, 7);
	}	
}
*/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
//alert("Show hide layers() called.");
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  var popwin = window.open(theURL,winName,features);
	popwin.focus();
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function getBrowser() {
	var exclude=1;
	var agt=navigator.userAgent.toLowerCase();
	var win=0;var mac=0;var lin=1;
	if(agt.indexOf('win')!=-1){win=1;lin=0;}
	if(agt.indexOf('mac')!=-1){mac=1;lin=0;}
	var lnx=0;if(lin){lnx=1;}
	var ice=0;
	var ie=0;var ie4=0;var ie5=0;var ie6=0;var com=0;var dcm;
	var op5=0;var op6=0;var op7=0;
	var ns4=0;var ns6=0;var ns7=0;var mz7=0;var kde=0;var saf=0;
	
	if(typeof navigator.vendor!="undefined" && navigator.vendor=="KDE"){
		var thisKDE=agt;
		var splitKDE=thisKDE.split("konqueror/");
		var aKDE=splitKDE[1].split("; ");
		var KDEn=parseFloat(aKDE[0]);
		if(KDEn>=2.2){
			kde=1;
			ns6=1;
			exclude=0;
		}
	}
	
	else if(agt.indexOf('webtv')!=-1){exclude=1;}
	
	else if(typeof window.opera!="undefined"){
		exclude=0;
		if(agt.indexOf("opera/5")!=-1||agt.indexOf("opera 5")!=-1){op5=1;}
		if(agt.indexOf("opera/6")!=-1||agt.indexOf("opera 6")!=-1){op6=1;}
		if(agt.indexOf("opera/7")!=-1||agt.indexOf("opera 7")!=-1){op7=1;}
	}
	
	else if(typeof document.all!="undefined"&&!kde){
		exclude=0;
		ie=1;
		if(typeof document.getElementById!="undefined"){
			ie5=1;
			if(agt.indexOf("msie 6")!=-1){
				ie6=1;
				dcm=document.compatMode;
				if(dcm!="BackCompat"){com=1;}
			}
		}
		else{ie4=1;}
	}
	
	else if(typeof document.getElementById!="undefined"){
		exclude=0;
		if(agt.indexOf("netscape/6")!=-1||agt.indexOf("netscape6")!=-1){ns6=1;}
		else if(agt.indexOf("netscape/7")!=-1||agt.indexOf("netscape7")!=-1){ns6=1;ns7=1;}
		else if(agt.indexOf("gecko")!=-1){ns6=1;mz7=1;}
		if(agt.indexOf("safari")!=-1 || (typeof document.childNodes!="undefined" && typeof document.all=="undefined" && typeof navigator.taintEnabled=="undefined")){mz7=0;ns6=1;saf=1;}
	}
	
	else if((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)){
		exclude=0;
		ns4=1;
		if(typeof navigator.mimeTypes['*']=="undefined"){
			exclude=1;
			ns4=0;
		}
	}
	
	if(agt.indexOf('escape')!=-1){exclude=1;ns4=0;}
	
	if(typeof navigator.__ice_version!="undefined"){exclude=1;ie4=0;}

	//Alert
	//alert("OS: " + agt);
	//alert("version: " + navigator.appVersion);
	//alert("same stuff: " + agt);
	if(agt.indexOf('msie') == -1) {//It's not IE
			alert("The PSD Web Interface is built for and tested in Microsoft Internet Explorer.\nPlease close your browser and open PSD in Internet Explorer. To download\nInternet Explorer, visit www.microsoft.com.");
	}
	return agt;
}

function ucaseMeEx(fieldref) {
	fieldref.value = fieldref.value.toUpperCase();
}

function ucaseMe(form,field) {
	var fieldNum = 0;
	while ((arguments[0] + "." + arguments[1]) != (document.forms[0].name + "." + document.forms[0].elements[fieldNum].name)) {
		fieldNum++; 
	}
	document.forms[0].elements[fieldNum].value = document.forms[0].elements[fieldNum].value.toUpperCase();
}

function lcaseMe(form,field) {
	var fieldNum = 0;
	while ((arguments[0] + "." + arguments[1]) != (document.forms[0].name + "." + document.forms[0].elements[fieldNum].name)) {
		fieldNum++; 
	}
	document.forms[0].elements[fieldNum].value = document.forms[0].elements[fieldNum].value.toLowerCase();
}


//***********************************************
//Code to load swf for new IE patch
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
//***********************************************


/******************************************
* Find In Page Script -- Submitted/revised by Alan Koontz (alankoontz@REMOVETHISyahoo.com)
* See www.dynamicdrive.com/dynamicindex11/findpage.htm for full source code
* This notice must stay intact for use
******************************************/

var TRange = null;
var dupeRange = null;
var TestRange = null;
var win = null;


//  SELECTED BROWSER SNIFFER COMPONENTS DOCUMENTED AT
//  http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html

var nom = navigator.appName.toLowerCase();
var agt = navigator.userAgent.toLowerCase();
var is_major   = parseInt(navigator.appVersion);
var is_minor   = parseFloat(navigator.appVersion);
var is_ie      = (agt.indexOf("msie") != -1);
var is_ie4up   = (is_ie && (is_major >= 4));
var is_not_moz = (agt.indexOf('netscape')!=-1)
var is_nav     = (nom.indexOf('netscape')!=-1);
var is_nav4    = (is_nav && (is_major == 4));
var is_mac     = (agt.indexOf("mac")!=-1);
var is_gecko   = (agt.indexOf('gecko') != -1);
var is_opera   = (agt.indexOf("opera") != -1);


//  GECKO REVISION

var is_rev=0
if (is_gecko) {
temp = agt.split("rv:")
is_rev = parseFloat(temp[1])
}


//  USE THE FOLLOWING VARIABLE TO CONFIGURE FRAMES TO SEARCH
//  (SELF OR CHILD FRAME)

//  If you want to search another frame, change from "self" to
//  the name of the target frame:
//  e.g., var frametosearch = 'main'

//var frametosearch = 'main';
var frametosearch = self;


function search(whichform, whichframe) {

//  TEST FOR IE5 FOR MAC (NO DOCUMENTATION)

if (is_ie4up && is_mac) return;

//  TEST FOR NAV 6 (NO DOCUMENTATION)

if (is_gecko && (is_rev <1)) return;

//  TEST FOR Opera (NO DOCUMENTATION)

if (is_opera) return;

//  INITIALIZATIONS FOR FIND-IN-PAGE SEARCHES

if(whichform.findthis.value!=null && whichform.findthis.value!='') {

       str = whichform.findthis.value;
       win = whichframe;
       var frameval=false;
       if(win!=self)
{

       frameval=true;  // this will enable Nav7 to search child frame
       win = parent.frames[whichframe];

}

    
}

else return;  //  i.e., no search string was entered

var strFound;

//  NAVIGATOR 4 SPECIFIC CODE

if(is_nav4 && (is_minor < 5)) {
   
  strFound=win.find(str); // case insensitive, forward search by default

//  There are 3 arguments available:
//  searchString: type string and it's the item to be searched
//  caseSensitive: boolean -- is search case sensitive?
//  backwards: boolean --should we also search backwards?
//  strFound=win.find(str, false, false) is the explicit
//  version of the above
//  The Mac version of Nav4 has wrapAround, but
//  cannot be specified in JS

 
        }

//  NAVIGATOR 7 and Mozilla rev 1+ SPECIFIC CODE (WILL NOT WORK WITH NAVIGATOR 6)

if (is_gecko && (is_rev >= 1)) {
   
    if(frameval!=false) win.focus(); // force search in specified child frame
    strFound=win.find(str, false, false, true, false, frameval, false);

//  The following statement enables reversion of focus 
//  back to the search box after each search event 
//  allowing the user to press the ENTER key instead
//  of clicking the search button to continue search.
//  Note: tends to be buggy in Mozilla as of 1.3.1
//  (see www.mozilla.org) so is excluded from users 
//  of that browser.

    if (is_not_moz)  whichform.findthis.focus();

//  There are 7 arguments available:
//  searchString: type string and it's the item to be searched
//  caseSensitive: boolean -- is search case sensitive?
//  backwards: boolean --should we also search backwards?
//  wrapAround: boolean -- should we wrap the search?
//  wholeWord: boolean: should we search only for whole words
//  searchInFrames: boolean -- should we search in frames?
//  showDialog: boolean -- should we show the Find Dialog?


}

 if (is_ie4up) {

  // EXPLORER-SPECIFIC CODE revised 5/21/03

  if (TRange!=null) {
	  
   TestRange=win.document.body.createTextRange();
 
	  

   if (dupeRange.inRange(TestRange)) {

   TRange.collapse(false);
   strFound=TRange.findText(str);
    if (strFound) {
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = win.document.body.scrollTop + TRange.offsetTop;
        TRange.select();
        }


   }
   
   else {

     TRange=win.document.body.createTextRange();
     TRange.collapse(false);
     strFound=TRange.findText(str);
     if (strFound) {
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = TRange.offsetTop;
        TRange.select();
        }

   }
  }
  
   if (TRange==null || strFound==0) {
   TRange=win.document.body.createTextRange();
   dupeRange = TRange.duplicate();
   strFound=TRange.findText(str);
    if (strFound) {
        //the following line added by Mike and Susan Keenan, 7 June 2003
        win.document.body.scrollTop = TRange.offsetTop;
        TRange.select();
        }

   
   }

 }

  if (!strFound) alert ("String '"+str+"' not found!") // string not found

        
}
// -->

<!--  EXAMPLE FORM OF FIND-IN-PAGE SEARCH USING SUBMIT (ALLOWING 'ENTER/RETURN' KEY PRESS EVENT) -->
<!-- <form name="form1" onSubmit="search(document.form1, frametosearch); return false"><input type="text" name="findthis" size="15" title="Press 'ALT s' after clicking submit to repeatedly search page"> <input type="submit" value="Find in Page" ACCESSKEY="s"></form> -->





//Makes the isDirty variable such that user is warned if they make changes and then try to leave
/*	NOT WORKING!!!
var isDirty = false;

function setIsDirty(i) {
	isDirty = i;
	alert("Set isDirty to " + i);
}

function checkIsDirty() {
	if(isDirty) {
		msg="You have not saved your changes. Click OK to continue without saving, or Cancel to return to the page to save your changes."
		if(confirm(msg)) {
			alert("You clicked OK in the confirm dialog box - you will go to the next page.");
		}
		else {
			alert("You clicked Cancel in the confirm dialog box - you should not go anywhere.");
			return false;
		}
	}
}
*/


/*
//Find in page functionality - not used right now

// Set browser variables   
var IE4 = (document.all); 
var NS4 = (document.layers);

// Set browser window for searching
var win = window;     
var n   = 0; 

function FindString(str) 
{ 
 var PageText, Found, i; 

 if (str == "") 
   return false; 
   
 // Sniff for browser
 // Look for match starting at the current point winding around to first match

 if (NS4) 
 { 
   if (!win.find(str)) 
     while(win.find(str, false, true)) 
       n++; 
   else 
     n++; 

   // If not send message. 

   if (n == 0) 
     alert(" Not Found on Page."); 
 } 

 if (IE4) 
 { 
// Set search object to whole page 
   PageText = win.document.body.createTextRange(); 

// Search for nth match from top. 
   for (i = 0; i <= n && (Found = PageText.findText(str))  != false; i++) 
   { 
     PageText.moveEnd("textedit"); 
     PageText.moveStart("character", 1); 
   } 

   //  Scroll to and mark text if Found.
   if (Found) 
   { 
     PageText.moveStart("character", -1); 
     PageText.findText(str); 
     PageText.scrollIntoView();
     PageText.select();  
     n++; 
   } 

   // Else, goto top of the page and find first match. 

   else 
   { 
     if (n > 0) 
     { 
       n = 0; 
       FindString(str); 
     } 

   // Not Found then send message. 

     else 
       alert("Not Found on Page"); 
   } 
 } 

 return false; 
} 
*/



//-->
