﻿// These vars say we start filling the form with a 1-way processor and 520/810 model already selected

var oneWay = false;
var m520810 = true;
var m525 = false;

var isNS4 = (navigator.appName=="Netscape")?1:0;




// This funtion gets and displays the date-time in the appropriate formatting

function getFullDate()
{
var myDate = new Date();

var myMonth = new String(myDate.getMonth() + 1);
var myDay = new String(myDate.getDate());
var myHours = new String(myDate.getHours());
var myMinutes = new String(myDate.getMinutes());
var mySeconds = new String(myDate.getSeconds());

if (myMonth.length == 1) { myMonth = "0" + myMonth; }
if (myDay.length == 1) { myDay = "0" + myDay; }
if (myHours.length == 1) { myHours = "0" + myHours; }
if (myMinutes.length == 1) { myMinutes = "0" + myMinutes; }
if (mySeconds.length == 1) { mySeconds = "0" + mySeconds; }

var fullDate = myDate.getFullYear() + "-" + myMonth + "-" + myDay + " " + myHours + ":" + myMinutes + ":" + mySeconds;

return fullDate;
}




// Form validation BEGIN


// This function sets validation models for each type of form fields

function checkRequired(field,lengthsize,vtype)
{
	
	// if text box
	if(field.type == "TEXT" || field.type == "text")
		{
			if(field.value.length < lengthsize)
			{
				return false;
			}
		}

	
	// if textarea
	else if(field.type == "TEXTAREA" || field.type == "textarea")
		{
			if(field.value == "")
			{
				return false;
			}
		}

	//if password
	else if(field.type == "PASSWORD" || field.type == "password")
		{
			if(field.value == "")
			{
				return false;
			}
		}

	//if file upload
	else if(field.type == "FILE" || field.type == "file")
		{
			if(field.value == "")
			{
				return false;
			}
		}

	//if checkbox
	else if(field.type == "CHECKBOX" || field.type == "checkbox")
		{
			if(!field.checked)
			{
				return false;
			}
		}

	//if select
	else if(field.type == "SELECT" || field.type == "select" || field.type == "select-one" || field.type == "select-multiple")
		{
			
			/*if(!field.selectedIndex)
			{
				return false;
			}
			
			else*/ if(field.options[field.selectedIndex].value == '' || field.options[field.selectedIndex].value == 'null')
			{
				return false;
			}
			
		}

	//if radio group
	else{
			var radio = false;
			for(i=0;i<field.length;i++)
			{
				 if(field[i].checked)
				 {
				  radio = true;
				  break;
				 }
			 }
			 if(!radio)
			 {
				return false;
			 }
		}

	
	return true;

}


// Email validation 

	function Email(field)
	{
		var emailAccount=new String(field.value);
		var filter=/^[a-z0-9]([a-z0-9_]|\-|\.)+@(([a-z0-9_]|\-)+\.)+[a-z]{2,4}$/i;
		if (!filter.test(emailAccount))
		{
		return false;
		}
		else 
		{
		return true;
		} 
	}

// Serianl Number / Plant Order Number validation 

	function SnPon(field,lengthsize)
	{
		var vSnPon=new String(field.value);
		var filter=/[a-zA-Z0-9]{5}/;
		if (filter.test(vSnPon)==false || vSnPon.length != lengthsize)
		{
		return false;
		}
		else 
		{
		return true;
		} 
	}


// Additional Plant Order Number validation -- It CANNOT be only numbers nor only letters



function SnPonAlphaNum(field,lengthsize)
{
	var vSnPonAN=new String(field.value);
	var filterA=/[a-zA-Z]/;
	var filterB=/[0-9]/;
	if (filterA.test(vSnPonAN)==false || filterB.test(vSnPonAN)==false)
	{
	return false;
	}
	else 
	{
	return true;
	} 
}



// i5/OS Eligible validation


	function valCheck(field)
	{
			var radio = false;
			for(i=0;i<field.length;i++)
			{
				 if(field[i].checked && field[i].value)
				 {
				  radio = true;
				  break;
				 }
			 }
			 if(!radio)
			 {
				return false;
			 }
	}






// Here's where we set which fields are required

function checkForm(form)
{
	var err = 0;


	// Error messages BEGIN

	var msg = "---------------------------------------------------------------------------------------\n"
	msg +=" Sorry, you missed some fields:\n"
	msg +="---------------------------------------------------------------------------------------\n";

	if (!checkRequired(form.SUBMITTER_NAME,3))
	{
	 err++; 
	 msg +="- Please, fill out your name.\n";
	}

	if (!Email(form.SUBMITTER_EMAIL))
	{
	err++; 
	msg +="- Please, provide a valid e-mail address.\n";
	}

	if (!checkRequired(form.SUBMITTER_PHONE,7))
	{
	 err++; 
	 msg +="- Please, fill out your phone number.\n";
	}

	if (!checkRequired(form.SUBMITTER_FAX,7))
	{
	 err++; 
	 msg +="- Please, fill out your fax number.\n";
	}

	if (!checkRequired(form.COMPANY_NAME,2))
	{
	 err++; 
	 msg +="- Please, fill out the company name.\n";
	}

	if (!checkRequired(form.SUBMITTER_COUNTRY))
	{
	 err++; 
	 msg +="- Please, select a country.\n";
	}

	if (!SnPon(form.COMPANY_NUMBER, 6))
	{
		if (!SnPon(form.COMPANY_NUMBER, 7))
		{
			err++; 
			msg +="- Please, fill out the IBM Customer Number of Primary System i5 with 6 or 7 digits.\n";
		}
	}

	if ( checkRequired(form.SOLUTION_APPROACH)==false || ( form.SOLUTION_APPROACH.options[form.SOLUTION_APPROACH.selectedIndex].value == "Other"  && checkRequired(form.OTHERSOL_APPROACH,2)==false ) )
	{

	 err++; 
	 msg +="- Please, indicate which company implemented the solution.\n";

	}


	if (oneWay == false)
	{

		if (!checkRequired(form.IAGREE))
		{
		 err++; 
		 msg +="- To proceed you must agree with the Terms and Conditions.\n";
		}


		if (checkRequired(form.I5OSPRIMARY,1)==false && m520810 == false && m525 == false)
		{
		 err++; 
		 msg +="- Tell us how many i5/OS processor license entitlements (above the base)\n  are on the Primary system.\n";
		}

		if (checkRequired(form.I5OSTRANSFER,1)==false && m520810 == false && m525 == false)
		{
		 err++; 
		 msg +="- Tell us how many of those i5/OS entitlements do you wish to\n  temporarily transfer to your CBU System.\n";
		}

	}



	if (!checkRequired(form.PRIMARY_SYSTEM))
	{
	 err++; 
	 msg +="- Please, select your Primary system.\n";
	}
	


	if (!checkRequired(form.CBU_SYSTEM))
	{
	 err++; 
	 msg +="- Please, select a CBU system model.\n";
	}



	if (form.ORDERINGOPTION[0].checked==false && form.ORDERINGOPTION[1].checked==false)
	{
	 err++; 
	 msg +="\n- Please, select the one of the ordering options.\n";
	}




	if (checkRequired(form.PRIMARY_SERIAL_PREFIX)==false && form.ORDERINGOPTION[0].checked)
	{
	 err++; 
	 msg +="\n- Please, select the Primary system's Serial number prefix (06, 10, 65 or 44).\n";
	}


	if (SnPon(form.PRIMARY_SERIAL,5)==false && form.ORDERINGOPTION[0].checked)
	{
	 err++; 
	 msg +="\n- Please fill out the Serial Number (5 Characters).\n";
	 msg +="  Remember you must use only alphanumerical characters.\n";
	}

 
	if (SnPon(form.PRIMARY_PLANT,6)==false && form.ORDERINGOPTION[1].checked)
	{
	 err++; 
	 msg +="\n- Please fill out the Plant order Number (6 Characters).\n";
	 msg +="  Remember you must use only alphanumerical characters.\n";
	}


	if (SnPonAlphaNum(form.PRIMARY_PLANT,6)==false && form.ORDERINGOPTION[1].checked)
	{
	 err++; 
	 msg +="\n- Plant Order Number MUST contain NUMBERS AND LETTERS,\n  please verify your Primary System Plant Order Number. \n";
	}

 
	if (!SnPon(form.CBU_PLANT,6))
	{
	 err++; 
	 msg +="\n- Please, fill out the CBU system's Plant order number (6 characters).\n";
	 msg +="  Remember you must use only alphanumerical characters.\n";
	}


	if (!SnPonAlphaNum(form.CBU_PLANT,6))
	{
	 err++; 
	 msg +="\n- Plant Order Number MUST contain NUMBERS AND LETTERS,\n  please verify your CBU System Plant Order Number. \n";
	}


	if (form.PRIMARY_PLANT.value==form.CBU_PLANT.value)
	{
	 err++; 
	 msg +="\n- Your Primary System plant order number and your CBU plant order\n";
	 msg +="  number cannot be the same. Please verify it.\n";
	}


	msg +="---------------------------------------------------------------------------------------\n";

	// Error messages END



	// Here we actually perform the form validation
		
	if(err > 0)
	{

		// Here is what happens when the form is incorretly filled out:
		// A message is displayed with the proper instructions and the form is not submitted.


		alert(msg);
		return false;   	

	}

	else
	{




		var myvar19tc = "false";
		var myvar20optinemail = "false";
		var myvar21cprivacy = "false";

		if (document.haForm.IAGREE.checked == true){myvar19tc = "true";}
		if (document.haForm.OPTINEMAIL.checked == true){myvar20optinemail = "true";}
		if (document.haForm.CPRIVACY.checked == true){myvar21cprivacy = "true";}

		var myvar8option = "a";

		if (document.haForm.ORDERINGOPTION[1].checked == true){myvar8option = "b"}

		var myRetrieveURL = "http://www.ibm.com/systems/power/hardware/cbu/retrieveform.html?" + encodeURIComponent(document.haForm.SUBMITTER_NAME.value+"&"+document.haForm.SUBMITTER_EMAIL.value+"&"+form.SUBMITTER_COUNTRY.options[form.SUBMITTER_COUNTRY.selectedIndex].value+"&"+document.haForm.SUBMITTER_PHONE.value+"&"+document.haForm.SUBMITTER_FAX.value+"&"+document.haForm.COMPANY_NAME.value+"&"+document.haForm.COMPANY_NUMBER.value+"&"+myvar8option+"&"+form.PRIMARY_SERIAL_PREFIX.options[form.PRIMARY_SERIAL_PREFIX.selectedIndex].value+"&"+document.haForm.PRIMARY_SERIAL.value+"&"+document.haForm.PRIMARY_PLANT.value+"&"+form.PRIMARY_SYSTEM.options[form.PRIMARY_SYSTEM.selectedIndex].value+"&"+document.haForm.CBU_PLANT.value+"&"+form.CBU_SYSTEM.options[form.CBU_SYSTEM.selectedIndex].value+"&"+document.haForm.I5OSPRIMARY.value+"&"+document.haForm.I5OSTRANSFER.value+"&"+form.SOLUTION_APPROACH.options[form.SOLUTION_APPROACH.selectedIndex].value+"&"+document.haForm.OTHERSOL_APPROACH.value+"&"+myvar19tc+"&"+myvar20optinemail+"&"+myvar21cprivacy+"&"+document.haForm.COMMENTS.value);
		//alert(myRetrieveURL);
		document.haForm.RETRIEVEURL.value = myRetrieveURL;



		// Destroys Option Radio buttons and Clone select list

		var remEl = document.getElementById("ORDERINGOPTIONA");
		if ( remEl.parentNode && remEl.parentNode.removeChild ) {
		remEl.parentNode.removeChild(remEl);
		}

		var remEl = document.getElementById("ORDERINGOPTIONB");
		if ( remEl.parentNode && remEl.parentNode.removeChild ) {
		remEl.parentNode.removeChild(remEl);
		}

		var remEl = document.getElementById("PRIMARY_SYSTEMclone");
		if ( remEl.parentNode && remEl.parentNode.removeChild ) {
		remEl.parentNode.removeChild(remEl);
		}


		// Updates thank you page to show Submitter name
		document.haForm.THANKYOUPAGE.value = document.haForm.THANKYOUPAGE.value + "?" + document.haForm.SUBMITTER_NAME.value ;

		// Updates thank you page if the form must be printed

		var isprintfinal = false;
		var countryName = window.document.haForm.SUBMITTER_COUNTRY[window.document.haForm.SUBMITTER_COUNTRY.selectedIndex].value;

		for(var i=0;i<countriesList.length;i++){
			if(countriesList[i]==countryName && oneWay != true && m520810 != true){
				isprintfinal=true;
				break;
			}
		}

		if (isprintfinal) { document.haForm.THANKYOUPAGE.value = document.haForm.THANKYOUPAGE.value + "&isp"; }


		// Uppercase entries:
		document.haForm.COMPANY_NUMBER.value = document.haForm.COMPANY_NUMBER.value.toUpperCase();
		document.haForm.PRIMARY_SERIAL.value = document.haForm.PRIMARY_SERIAL.value.toUpperCase();
		document.haForm.PRIMARY_PLANT.value = document.haForm.PRIMARY_PLANT.value.toUpperCase();
		document.haForm.CBU_PLANT.value = document.haForm.CBU_PLANT.value.toUpperCase();


		// Fill the TOADDR field for SendToFriend Function
		document.haForm.TOADDR.value = form.SUBMITTER_EMAIL.value;

		// At last, add the Feature Codes, according to selected Primary and CBU Systems:
		document.haForm.PRIMARY.value = form.PRIMARY_SYSTEM.value.substr(form.PRIMARY_SYSTEM.value.length-4,4);
		document.haForm.CBU.value = form.CBU_SYSTEM.value.substr(form.CBU_SYSTEM.value.length-4,4);

		// Here is where actually the form is sent
		return true;


	}
}

// Form validation END






// This is the list of countries which require the printed version of the registration form:

var countriesList=new Array();

countriesList[0]="Albania";
countriesList[1]="Algeria";
countriesList[2]="Angola";
countriesList[3]="Argentina";
countriesList[4]="Armenia";
countriesList[5]="Bahrain";
countriesList[6]="Bangladesh";
countriesList[7]="Belarus";
countriesList[8]="Benin";
countriesList[9]="Bolivia";
countriesList[10]="Bosnia and Herzegovina";
countriesList[11]="Botswana";
countriesList[12]="Brazil";
countriesList[13]="Bulgaria";
countriesList[14]="Burkina Faso";
countriesList[15]="Burundi";
countriesList[16]="Cambodia";
countriesList[17]="Cameroon";
countriesList[18]="Cape Verde";
countriesList[19]="Chad";
countriesList[20]="Chile";
countriesList[21]="Colombia";
countriesList[22]="Congo";
countriesList[23]="Cote d'Ivoire";
countriesList[24]="Croatia";
countriesList[25]="Czech Republic";
countriesList[26]="Djibouti";
countriesList[27]="Ecuador";
countriesList[28]="Equatorial Guinea";
countriesList[29]="Eritrea";
countriesList[30]="Ethiopia";
countriesList[31]="Fiji";
countriesList[32]="Gabon";
countriesList[33]="Gambia";
countriesList[34]="Georgia";
countriesList[35]="Ghana";
countriesList[36]="Greece";
countriesList[37]="Guinea";
countriesList[38]="Guinea-Bissau";
countriesList[39]="Hungary";
countriesList[40]="Indonesia";
countriesList[41]="Italy";
countriesList[42]="Jordan";
countriesList[43]="Kazakhstan";
countriesList[44]="Kenya";
countriesList[45]="Kuwait";
countriesList[46]="Kyrgyzstan";
countriesList[47]="Laos";
countriesList[48]="Lebanon";
countriesList[49]="Lesotho";
countriesList[50]="Liberia";
countriesList[51]="Libyan Arab Jamahiriya";
countriesList[52]="Macedonia";
countriesList[53]="Malawi";
countriesList[54]="Mali";
countriesList[55]="Malta";
countriesList[56]="Mauritania";
countriesList[57]="Mexico";
countriesList[58]="Moldavia, Republic of";
countriesList[59]="Mongolia";
countriesList[60]="Morocco";
countriesList[61]="Mozambique";
countriesList[62]="Namibia";
countriesList[63]="Nepal";
countriesList[64]="Niger";
countriesList[65]="Nigeria";
countriesList[66]="Oman";
countriesList[67]="Palestinian Territory, Occupied (PS)";
countriesList[68]="Papua New Guinea";
countriesList[69]="Paraguay";
countriesList[70]="Peru";
countriesList[71]="Poland";
countriesList[72]="Qatar";
countriesList[73]="Romania";
countriesList[74]="Russian Federation";
countriesList[75]="Rwanda";
countriesList[76]="Sao Tome and Principe";
countriesList[77]="Saudi Arabia";
countriesList[78]="Senegal";
countriesList[79]="Sierra Leone";
countriesList[80]="Slovakia";
countriesList[81]="Slovenia";
countriesList[82]="Solomon Islands";
countriesList[83]="Somalia";
countriesList[84]="Sri Lanka";
countriesList[85]="Sudan";
countriesList[86]="Swaziland";
countriesList[87]="Syrian Arab Republic";
countriesList[88]="Taiwan";
countriesList[89]="Tanzania, United Republic of";
countriesList[90]="Thailand";
countriesList[91]="Togo";
countriesList[92]="Tunisia";
countriesList[93]="Turkey";
countriesList[94]="Uganda";
countriesList[95]="Ukraine";
countriesList[96]="United Arab Emirates";
countriesList[97]="Uruguay";
countriesList[98]="Venezuela";
countriesList[99]="Vietnam";
countriesList[100]="Yemen";
countriesList[101]="Zambia";
countriesList[102]="Zimbabwe";




// This is the list of Countries and their respective Fax numbers --- NOT IN USE

var countriesPhones=new Array();
countriesPhones[0]=new Array("Albania", "9999-9999");




// This function gets the Fax number and displays it on the page --- NOT IN USE

function getPhone(){
	var countryName, countryPhone;
	countryName=window.document.haForm.SUBMITTER_COUNTRY[window.document.haForm.SUBMITTER_COUNTRY.selectedIndex].text;

	if(typeof(countryName)!="undefined"){
		for(var i=0;i<countriesPhones.length;i++){
			if(countriesPhones[i][0]==countryName){
				countryPhone=countriesPhones[i][1];
				return(countryPhone);
				break;
			}
		}
	}
	return(null);
}




// This function gets the selected country and displays it on the page


function getCountry(){
	return(window.document.haForm.SUBMITTER_COUNTRY[window.document.haForm.SUBMITTER_COUNTRY.selectedIndex].text);
}




// This function verifies if the selected country requires or not the printed version
// It also shows/hides the form and the link to PDF

function verifyCountry(){
	var isprint = false;
	var countryName = window.document.haForm.SUBMITTER_COUNTRY[window.document.haForm.SUBMITTER_COUNTRY.selectedIndex].value;
	var cbuNumber = document.getElementById("CBU_PLANT").value;
	if (countryName != ""){
		for(var i=0;i<countriesList.length;i++){
			if(countriesList[i]==countryName){
				isprint=true;
				break;
			}
		}


	   if (isprint)
	   {
			document.getElementById("CBUprint").style.display = "block";
			document.getElementById("CBUempty").style.display = "none";
			document.getElementById("CBUform").style.display = "none";
	   }
	   else
	   {
			document.getElementById("CBUform").style.display = "block";
			document.getElementById("CBUempty").style.display = "none";
			document.getElementById("CBUprint").style.display = "none";
	   }
	}
	else {
		document.getElementById("CBUprint").style.display = "none";
		document.getElementById("CBUempty").style.display = "block";
		document.getElementById("CBUform").style.display = "none";
	}


// Form areas showed/hidden if the Primary System is 1-way processor

	if (oneWay==true)
	{
		document.getElementById("TC").style.display = "block";
		document.getElementById("RS").style.display = "none";
		document.getElementById("CBUform").style.display = "block";
		document.getElementById("CBUempty").style.display = "none";
		document.getElementById("CBUprint").style.display = "none";
	}
	else
	{
		document.getElementById("TC").style.display = "block";
		document.getElementById("RS").style.display = "block";
	}


// Form areas showed/hidden if the Primary System is a 520 or 810 model


	if (m520810==true)
	{
		document.getElementById("TC520").style.display = "block";
		document.getElementById("TC525").style.display = "none";
		document.getElementById("TC550").style.display = "none";
		document.getElementById("RS550").style.display = "none";
		document.getElementById("SC").style.display = "block";
	}
	else
	{
		// Form areas showed/hidden if the Primary System is a 525 model


			if (m525==true)
			{
				document.getElementById("TC520").style.display = "block";
				document.getElementById("TC525").style.display = "none";
				document.getElementById("TC550").style.display = "none";
				document.getElementById("RS550").style.display = "none";
				document.getElementById("SC").style.display = "block";
			}
			else
			{
				document.getElementById("TC520").style.display = "block";
				document.getElementById("TC525").style.display = "none";
				document.getElementById("TC550").style.display = "none";
				document.getElementById("RS550").style.display = "block";
				document.getElementById("SC").style.display = "none";
			}

	}

	   return(false);
	}
   	    








   	    










// This function shows a field "Other" if user selects "Other" on "Solution Approach" box


function setSOLUTION_APPROACH(SOLUTION_APPROACH)
{

	if (SOLUTION_APPROACH == "Other") 
	{
	document.getElementById("OTHERSOL_APPROACH_1").style.display = "block";
	}
	else
	{
	document.getElementById("OTHERSOL_APPROACH_1").style.display = "none";
	}

}



// This function shows the proper CBU version according to the selected Primary version


function setSelectList(modelType)
{

if (modelType == "7778 23X") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "7778 23X";
avoptions[1] = "7998 61X";
}

if (modelType == "7998 60X") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "7998 60X";
}

if (modelType == "7998 61X") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "7998 60X";
avoptions[1] = "7998 61X";
avoptions[2] = "7778 23X";
}

if (modelType == "8203 E4A") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "7778 23X";
avoptions[1] = "7998 61X";
avoptions[2] = "8203 E4A ";
}

if (modelType == "8204 E8A") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
avoptions[1] = "8204 E8A";
avoptions[2] = "8234 EMA";
}

if (modelType == "8234 EMA") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
avoptions[1] = "8204 E8A";
avoptions[2] = "8234 EMA";
}

if (modelType == "9117 MMA") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8204 E8A";
avoptions[1] = "8234 EMA";
avoptions[2] = "9117 MMA";
}

if (modelType == "9119 FHA") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "9119 FHA";
avoptions[1] = "9117 MMA";
}

if (modelType == "9406 520") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
}

if (modelType == "9406 525") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
}

if (modelType == "9406 550") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
avoptions[1] = "8204 E8A";
avoptions[2] = "8234 EMA";
}

if (modelType == "9406 570") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8204 E8A";
avoptions[1] = "8234 EMA";
avoptions[2] = "9117 MMA";
}

if (modelType == "9406 595") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "9117 MMA";
avoptions[1] = "9119 FHA";
}

if (modelType == "9406 MMA") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8204 E8A";
avoptions[1] = "8234 EMA";
avoptions[2] = "9117 MMA";
}

if (modelType == "9408 M25") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
}

if (modelType == "9409 M50") {
oneWay=false; //alert("noPrint!");
m520810=true; //alert("520-810");
m525=false;
var avoptions = new Array();
avoptions[0] = "8203 E4A";
avoptions[1] = "8204 E8A";
avoptions[2] = "8234 EMA";
}







	// This is where the 2nd drop-down is populated


		selectList = document.haForm.CBU_SYSTEM;
		var tempArray = avoptions;
		//alert(tempArray.length);

		selectList.length = 0;
		selectList.length = 1;
		selectList.options[0] = new Option();
		selectList.options[0].text = "Select one";
		selectList.options[0].value = "null";
		selectList.length = 2;
		selectList.options[1] = new Option();
		selectList.options[1].text = "----------";
		selectList.options[1].value = "null";


		if (modelType == "null") {
			var avoptions = new Array();
			avoptions[0] = "Please select a Primary system first";
			tempArray = avoptions;
			selectList.length = 0;
		}

		var i = 0;
		var t;
		for (i = 0 ; i < tempArray.length ; i++){
			t = selectList.length;
			selectList.length++;
			//alert("Length increased.");
			selectList.options[t] = new Option();
			//alert("New Option created.");
			selectList.options[t].text = tempArray[i];
			//alert("Text assigned.");
			selectList.options[t].value = tempArray[i];
			//alert("Value assigned.");
		}

}



// this function shows or hides the IDs passed via parameter

function showHide(spanId, imgId) {
	if (document.getElementById(spanId).className == "print-only"){
		document.getElementById(spanId).className = "print-yes";
		document.getElementById(imgId).src = "//www.ibm.com/i/v14/icons/d_bold.gif";
	}
	else {
		document.getElementById(spanId).className = "print-only";
		document.getElementById(imgId).src = "//www.ibm.com/i/v14/icons/fw_bold.gif";
	}
}



// this function sets the form field "IS_PRINTED_FORM" to "yes" if form is printed

function setAsPrinted() {
	document.haForm.IS_PRINTED_FORM.value = "yes";
	//alert(document.haForm.IS_PRINTED_FORM.value);
}





// This is a simple popup function

function popup(popupURL,w,h) 
{
 var popup = window.open(popupURL,"terms","alwaysRaised=yes,dependent=yes,toolbar=no,location=0,directories=0,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+w+",height="+h+"");
}


// This function show/hides the Serial or Plant Order number for the Primary System, depending on the option selected


function showfield(f){
if (f == "a")
{
document.getElementById("priser").style.display = "block";
document.getElementById("pripla").style.display = "none";
document.haForm.PRIMARY_PLANT.value = "";
}
else
{
document.getElementById("priser").style.display = "none";
document.getElementById("pripla").style.display = "block";
document.getElementById("PRIMARY_SERIAL_PREFIX").selectedIndex = 0;
document.haForm.PRIMARY_SERIAL.value = "";
}

}



// Clone the option a versus option b select boxes or vice-versa

function clone(ori,des){
document.getElementById(des).selectedIndex = document.getElementById(ori).selectedIndex;
document.getElementById("print_primary").innerHTML = document.getElementById(ori).options[document.getElementById(ori).selectedIndex].value;
}