<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

MM_reloadPage(true);

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_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); 
    if (val) { if (args[i+1]!="") nm=args[i+1]; else nm=val.name; if ((val=trim(val.value))!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number (without commas or spaces).\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
  document.my_errors += errors;
}

function validateLoginForm() {
    document.my_errors='';
    //set up validation for fields in required order        
    MM_validateForm('Username','','R');
    username=MM_findObj('Username');
    validate_name(username);

    MM_validateForm('Password','','R');
    password=MM_findObj('Password');
    validate_name(password);

    if (document.my_errors) alert('The following error(s) occurred:\n'+document.my_errors);
    return (document.my_errors == '');
}

function validate_name(somename) { //username or password
    var valid_characters;
    for (var i = 1; i < somename.value.length; i++)
    {
        valid_characters = new RegExp ("[a-zA-Z0-9_.!%&@\-]", "g");
        part_user_name = somename.value.charAt (i);
        if (!valid_characters.test (part_user_name))
        {
            document.my_errors+='- Special characters like ' + part_user_name + ' are not allowed in Username / Password\n';
            return;
        }
        valid_characters = null;
    }
}

function validate_stub(mystub) { 
    var valid_characters;
    for (var i = 1; i < mystub.value.length; i++)
    {
        valid_characters = new RegExp ("[a-zA-Z0-9_-]", "g");
        part_user_name = mystub.value.charAt (i);
        if (!valid_characters.test (part_user_name))
        {
            document.my_errors+='- Stub can have only letters, numbers, hyphen and underscore\n';
            return;
        }
        valid_characters = null;
    }
}

function addRowToTable(tblName)
{
  var tbl = document.getElementById(tblName);
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  var i= iteration%2 +1;
  row.setAttribute('class', 'row'+i);
  row.setAttribute('className', 'row'+i);

  //based on table name, add another row to the table	
  switch (tblName)	{
	case 'StatesRegisteredTbl': 
		var cell_1 = row.insertCell(0);
		var sel=dropDownStates('States Registered ' + iteration);
		cell_1.appendChild(sel);

		var cell_2 = row.insertCell(1);
		var textNode = document.createTextNode("::");
	  	cell_2.appendChild(textNode);
		cell_2.setAttribute('align', 'center');

		var cell_3 = row.insertCell(2);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'States Registered License ' + iteration;
		el.id = el.name;
		el.size = 60;
		el.maxlength=250;
		
		cell_3.appendChild(el);	 

		document.getElementById('States_Registered_Num').value=iteration;
		break;

	case 'BranchOfficeTbl':
		var cell_1 = row.insertCell(0);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Branch Office City ' + iteration;
		el.id = el.name;
		el.size = 20;
		el.maxlength=250;
		
		cell_1.appendChild(el);	 

		var cell_2 = row.insertCell(1);
		var sel=dropDownStates('Branch Office State ' + iteration);
		cell_2.appendChild(sel);

		var cell_3 = row.insertCell(2);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Branch Office Years ' + iteration;
		el.id = el.name;
		el.size = 20;
		el.maxlength=250;
		
		cell_3.appendChild(el);	 

		var cell_4 = row.insertCell(3);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Branch Office Employees ' + iteration;
		el.id = el.name;
		el.size = 20;
		el.maxlength=250;
		
		cell_4.appendChild(el);	 

		document.getElementById('Branch_Offices_Num').value=iteration;
		break;

	case 'ProjectTbl':
		var cell_1 = row.insertCell(0);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Project ' + iteration;
		el.id = el.name;
		el.size = 10;
		el.maxlength=250;
		
		cell_1.appendChild(el);	 

		var cell_2 = row.insertCell(1);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Project Owner ' + iteration;
		el.id = el.name;
		el.size = 12;
		el.maxlength=250;
		
		cell_2.appendChild(el);	 

		var cell_3 = row.insertCell(2);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Project Phone ' + iteration;
		el.id = el.name;
		el.size = 10;
		el.maxlength=250;
		
		cell_3.appendChild(el);	 

		var cell_4 = row.insertCell(3);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Project Manufacturer' + iteration;
		el.id = el.name;
		el.size = 12;
		el.maxlength=250;
		
		cell_4.appendChild(el);	 

		var cell_5 = row.insertCell(4);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Project Contract ' + iteration;
		el.id = el.name;
		el.size = 10;
		el.maxlength=250;
		
		cell_5.appendChild(el);	 

		var cell_6 = row.insertCell(5);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Project Date ' + iteration;
		el.id = el.name;
		el.size = 10;
		el.maxlength=250;
		
		cell_6.appendChild(el);	 

		document.getElementById('Projects_Num').value=iteration;
		break;
	case 'BuiltupManufacturerTbl':
		var cell_1 = row.insertCell(0);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Builtup Manufacturer ' + iteration;
		el.id = el.name;
		el.size = 30;
		el.maxlength=250;
		
		cell_1.appendChild(el);	 

		var cell_2 = row.insertCell(1);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Builtup Manufacturer First Date ' + iteration;
		el.id = el.name;
		el.size = 30;
		el.maxlength=250;
		
		cell_2.appendChild(el);	 

		var cell_3 = row.insertCell(2);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Builtup Manufacturer Years ' + iteration;
		el.id = el.name;
		el.size = 30;
		el.maxlength=250;
		
		cell_3.appendChild(el);	 

		document.getElementById('Builtup_Num').value=iteration;
		break;

	case 'SingleplyManufacturerTbl':
		var cell_1 = row.insertCell(0);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Singleply Manufacturer ' + iteration;
		el.id = el.name;
		el.size = 30;
		el.maxlength=250;
		
		cell_1.appendChild(el);	 

		var cell_2 = row.insertCell(1);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Singleply Manufacturer First Date ' + iteration;
		el.id = el.name;
		el.size = 30;
		el.maxlength=250;
		
		cell_2.appendChild(el);	 

		var cell_3 = row.insertCell(2);
		var el = document.createElement('input');
		el.type = 'text';
		el.name = 'Singleply Manufacturer Years ' + iteration;
		el.id = el.name;
		el.size = 30;
		el.maxlength=250;
		
		cell_3.appendChild(el);	 

		document.getElementById('Singleply_Num').value=iteration;
		break;

	}

}

function dropDownStates(fldName){
	var sel = document.createElement('select');
	sel.name = fldName;
	sel.id=sel.name;

	
	sel.options[0] = new Option('--Select State--', '');

	sel.options[1] = new Option('Alabama', 'Alabama');
	sel.options[2] = new Option('Alaska', 'Alaska');
	sel.options[3] = new Option('Arizona', 'Arizona');
	sel.options[4] = new Option('Arkansas', 'Arkansas');
	sel.options[5] = new Option('California', 'California');

	sel.options[6] = new Option('Colorado', 'Colorado');
	sel.options[7] = new Option('Connecticut', 'Connecticut');
	sel.options[8] = new Option('Delaware', 'Delaware');
	sel.options[9] = new Option('District of Columbia', 'District of Columbia');
	sel.options[10] = new Option('Florida', 'Florida');

	sel.options[11] = new Option('Georgia', 'Georgia');
	sel.options[12] = new Option('Hawaii', 'Hawaii');
	sel.options[13] = new Option('Idaho', 'Idaho');
	sel.options[14] = new Option('Illinois', 'Illinois');
	sel.options[15] = new Option('Indiana', 'Indiana');

	sel.options[16] = new Option('Iowa', 'Iowa');
	sel.options[17] = new Option('Kansas', 'Kansas');
	sel.options[18] = new Option('Kentucky', 'Kentucky');
	sel.options[19] = new Option('Louisiana', 'Louisiana');
	sel.options[20] = new Option('Maine', 'Maine');

	sel.options[21] = new Option('Maryland', 'Maryland');
	sel.options[22] = new Option('Masschusetts', 'Masschusetts');
	sel.options[23] = new Option('Michigan', 'Michigan');
	sel.options[24] = new Option('Minnesota', 'Minnesota');
	sel.options[25] = new Option('Mississippi', 'Mississippi');

	sel.options[26] = new Option('Missouri', 'Missouri');				
	sel.options[27] = new Option('Montana', 'Montana');
	sel.options[28] = new Option('Nebraska', 'Nebraska');
	sel.options[29] = new Option('Nevada', 'Nevada');
	sel.options[30] = new Option('New Hampshire', 'New Hampshire');

	sel.options[31] = new Option('New Jersey', 'New Jersey');				
	sel.options[32] = new Option('New Mexico', 'New Mexico');
	sel.options[33] = new Option('New York', 'New York');
	sel.options[34] = new Option('North Carolina', 'North Carolina');
	sel.options[35] = new Option('North Dakota', 'North Dakota');

	sel.options[36] = new Option('Ohio', 'Ohio');	
	sel.options[37] = new Option('Oklahoma', 'Oklahoma');
	sel.options[38] = new Option('Oregon', 'Oregon');
	sel.options[39] = new Option('Pennsylvania', 'Pennsylvania');
	sel.options[40] = new Option('Puerto Rico', 'Puerto Rico');

	sel.options[41] = new Option('Rhode Island', 'Rhode Island');	
	sel.options[42] = new Option('South Carolina', 'South Carolina');
	sel.options[43] = new Option('South Dakota', 'South Dakota');
	sel.options[44] = new Option('Tennessee', 'Tennessee');
	sel.options[45] = new Option('Texas', 'Texas');

	sel.options[46] = new Option('Utah', 'Utah');	
	sel.options[47] = new Option('Vermont', 'Vermont');
	sel.options[48] = new Option('Virginia', 'Virginia');
	sel.options[49] = new Option('Washington', 'Washington');
	sel.options[50] = new Option('West Virginia', 'West Virginia');

	sel.options[51] = new Option('Wisconsin', 'Wisconsin');	
	sel.options[52] = new Option('Wyoming', 'Wyoming');	

	sel.options[0].selected=true;

	return sel;
}

function showHelp() {
	document.getElementById("introtext").style.display = "block";	
	return false;
}

function hideHelp() {
	document.getElementById("introtext").style.display = "none";	
	return false;
}

function createRequest() {
	var request = null;
	try  {
	  // Firefox, Opera 8.0+, Safari
	  request=new XMLHttpRequest();
	}
	catch (e) {
	  // Internet Explorer
	  try {
		request=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	  catch (e) {
		try {
		  request=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e) {
		  request = null;
	   }
	  }
	}	
	if (request == null) {
		alert("Error creating request object!");
	}
	else {
		return request;	
	}
}

function sendRequest(request, url){
	request.open("GET", url, true);
	request.onreadystatechange = updatePage;
	request.send(null);	
}

function sendRequestRFI(request, url){
	request.open("GET", url, true);
	request.onreadystatechange = updateRFI;
	request.send(null);	
}

function sendRequestDailyQC(request, url){
	request.open("GET", url, true);
	request.onreadystatechange = updateDailyQC;
	request.send(null);	
}

function sendRequestCOR(request, url){
	request.open("GET", url, true);
	request.onreadystatechange = updateCOR;
	request.send(null);	
}

function sendRequestSearch(request, url){
	request.open("GET", url, true);
	request.onreadystatechange = updateSearch;
	request.send(null);	
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}


function padlength(what){
	var output=(what.toString().length==1)? "0"+what : what;
	return output;
}

function displaytime(){
	serverdate.setSeconds(serverdate.getSeconds()+1);
	var timestring=padlength(serverdate.getHours()-1)+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds());
	document.getElementById("servertime").innerHTML='<span style="color:red; font-weight:bold">Current Time: '+timestring+' PST</span>';
}
  
function validateRFQ()
{
	if (!document.getElementById('Disclaimer').checked)
	{
		alert ('Please check the box at the top of the RFQ to indicate you have read the disclaimer.');
		return false;
	}
	var x = confirm('Are you sure you want to submit this RFQ?\n');
	return x;
} 
-->

