// General script set for Request More Information Form
function new_window(url) 
{ link3 = window.open(url,"Link3","toolbar=0,location=0,directories=0,status=o,menubar=0,scrollbars=1,resizable=1,width=780,height=550"); }

function checkInput(str){
while(''+ str.charAt(0)== ' ')
str = str.substring(1,str.length);

if(str.length == 0 || str == "" || str == null)
{
return false;
}
}

function changeToOther(itemname)
{
// This function works with a dropdown list with "Other" as an option and freeform "Other" field.
// When "Other" is selected, there is a "If other, please specify" field will be enabled and turned white;
// Otherwise, the "If other, please specify" field will be disabled and turned grey.
// parameter itemname is the name of the dropdown list. The "Other" field has to be named as itemname+'other'.

	if (eval('document.forms[0].'+itemname+'.value == "Other"'))
	{
		eval('document.forms[0].'+itemname+'other.disabled = false');
		eval('document.forms[0].'+itemname+'other.style.backgroundColor = "white"');
	}
	else
	{
		eval('document.forms[0].'+itemname+'other.value=""');
		eval('document.forms[0].'+itemname+'other.disabled = true');
		eval('document.forms[0].'+itemname+'other.style.backgroundColor = "lightgrey"');
	}
}

function setPhoneStyle(cCountryValue)
{
	/* This function sets style of phone/fax field */

	// get North American style object
	objNA = document.getElementById('naphone');
	// get other style object
	objOther = document.getElementById('otherphone');
		
	if (cCountryValue == 'CANADA' || cCountryValue == 'U.S.A.')
	{
		// show North American style 
		objNA.style.visibility = 'visible';
		objNA.innerHTML = '(<input type="text" class="inputTxt" onkeyup="keyup(this.name,3,' + "'phone2'" + ')" size="2" maxlength="3" name="phone1" value="">) <input type="text" class="inputTxt" onkeyup="keyup(this.name,3,' + "'phone3'" + ')" size="2" maxlength="3" name="phone2" value="">-<input type="text" class="inputTxt" size="3" maxlength="4" name="phone3" value="">';
		document.forms[0].phone1.value = document.forms[0].phonevalue.value.replace(/[^0-9]/g, '').substr(0,3);
		document.forms[0].phone2.value = document.forms[0].phonevalue.value.replace(/[^0-9]/g, '').substr(3,3);
		document.forms[0].phone3.value = document.forms[0].phonevalue.value.replace(/[^0-9]/g, '').substr(6,4);
		// hide free from style
		objOther.style.visibility = 'hidden';
		objOther.innerHTML = '';
	}
	else{
		// show free form style
		objOther.style.visibility = 'visible';
		objOther.innerHTML = '<input type="text" class="inputTxt" size="16" name="phone" value="">';
		document.forms[0].phone.value = document.forms[0].phonevalue.value;
		// hide North American style
		objNA.style.visibility = 'hidden';
		objNA.innerHTML = '';
	}
}

function retainPhone()
{
	// this function is used to retain phone value when country is changed
	if (document.forms[0].country.value == 'CANADA' || document.forms[0].country.value == 'U.S.A.')
	{
		document.forms[0].phonevalue.value = document.forms[0].phone1.value + document.forms[0].phone2.value + document.forms[0].phone3.value;
	}
	else
	{
		document.forms[0].phonevalue.value = document.forms[0].phone.value;
	}
}

function keyup(thisField, thisLength, nextField)
{
	txt = eval('document.forms[0].'+thisField+'.value');
	if (txt.length == thisLength) eval('document.forms[0].'+nextField+'.focus()');
}

