var bName = navigator.appName; 

var bVer = parseInt(navigator.appVersion);

var bPlat = navigator.platform;

var detect = false;

var checked = true;

var visList = "List1";

var newList;



function setUp()

{

	document.ApplicationForm.applicant.focus();

}



function ValidateName()

{

	if (document.ApplicationForm.applicant.value == "")

	{

		alert('You did not fill in your name.');

		checked = false;

	}

	else

	{

		var digits_u="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-'. "

		var temp_u

		var test_u = "true"

		for (var i=0;i<document.ApplicationForm.applicant.value.length;i++)

		{

			temp_u=document.ApplicationForm.applicant.value.substring(i,i+1)

	

			if (digits_u.indexOf(temp_u) == -1)

			{

				var test_u = "false"

	   		}

		}

		if (test_u == "false")

		{

			alert("Please use only letters in your name.");

			checked=false;

		}

	}

	return;

}



function Validate(location,name)

{

	if (location != document.ApplicationForm.address2 && location.value == "")

	{

		alert('Please check the ' + name);

		checked=false;

	}

	else

	{

		var digits_u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&'.,- "

		var temp_u

		var test_u = "true"

		for (var i=0;i<location.value.length;i++)

		{

			temp_u=location.value.substring(i,i+1)



			if (digits_u.indexOf(temp_u) == -1)

			{

				var test_u = "false"

			}

		}

		if (test_u == "false")

		{

			alert("Please use only numbers, letters and the characters , . - ' & in the " + name);

			checked=false;

		}

	}

}



function ValidateTelno(number,name)

{

	if (name != 'fax' && number.value == "")

	{

		alert('You did not fill in your ' + name + ' number.');

		checked=false;

	}

	else

	{

		var digits_u="0123456789 +-.()"

		var temp_u

		var test_u = "true"

		for (var i=0;i<number.value.length;i++)

		{

			temp_u=number.value.substring(i,i+1)

	

			if (digits_u.indexOf(temp_u) == -1)

			{

				var test_u = "false"

	   		}

		}

		

		if (name != 'fax' && i < 10)

			test_u = "false";

			

		if (test_u == "false")

		{

			alert('Please check the ' + name + ' number.');

			checked=false;

		}

	}

}



function ValidateEmail()

{

	if (document.ApplicationForm.emailAddress.value == "")

	{

		alert('You did not fill in your Email address.');

		checked=false;

	}

	else

	{

		var digits_u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_@"

		var temp_u

		var symbol = 0

		var dotcom = 0

		var dotsafter = 0

		var valid = "No @ symbol."

		

		for (var i=0;i<document.ApplicationForm.emailAddress.value.length;i++)

		{

			temp_u=document.ApplicationForm.emailAddress.value.substring(i,i+1)

	

			if (digits_u.indexOf(temp_u) == -1)

			{

				var valid = "Invalid character."				

	   		}

	

			if (temp_u == "@")	// check for @ symbol

			{

				symbol = symbol + 1;

				

				if (symbol > 1)

				{

					valid = "Too many @s";

				}

			}

			

			if (symbol == 1)	// check . appears after @ 

			{

				if (temp_u == ".")

				{

					valid = "No domain.";

					dotsafter = dotsafter + 1;

				}

				else

					valid = "Invalid domain.";

			}

			

			if (dotsafter > 0)	// count the number of characters after the dot

			{

				dotcom = dotcom + 1;

			}

		}

		

		if (dotcom > 2)

		{

			valid = "true";

		}

		

		if (valid != "true")

		{

			alert('You do not appear to have a valid E-mail address.\nError: ' + valid);

			checked=false;

		}

	}

}



function checkIt()

{

	checked=true;

	ValidateName();

	

	if (!checked)

	{

		document.ApplicationForm.applicant.focus();

		return;

	}



	Validate(document.ApplicationForm.address1,'address');

		

	if (!checked)

	{

		document.ApplicationForm.address1.focus();

		return;

	}

		

	Validate(document.ApplicationForm.address2,'address');

		

	if (!checked)

	{

		document.ApplicationForm.address2.focus();

		return;

	}

		

	Validate(document.ApplicationForm.city,'city');

		

	if (!checked)

	{

		document.ApplicationForm.city.focus();

		return;

	}

		

	Validate(document.ApplicationForm.stateprov,'state/province');

		

	if (!checked)

	{

		document.ApplicationForm.stateprov.focus();

		return;

	}

		

	Validate(document.ApplicationForm.postalcode,'postal code');

		

	if (!checked)

	{

		document.ApplicationForm.postalcode.focus();

		return;

	}

	

	if (document.ApplicationForm.country.selectedIndex == 0)

	{

		alert ('Please select your country');

		document.ApplicationForm.country.focus();

		return;

	}

	

	ValidateTelno(document.ApplicationForm.telephone,'telephone');

	

	if (!checked)

	{

		document.ApplicationForm.telephone.focus();

		return;

	}

		

	ValidateTelno(document.ApplicationForm.fax,'fax');

	

	if (!checked)

	{

		document.ApplicationForm.fax.focus();

		return;

	}



	ValidateEmail();

	

	if (!checked)

	{

		document.ApplicationForm.emailAddress.focus();

		return;

	}



	applicant_name = document.ApplicationForm.applicant.value;

	email = document.ApplicationForm.emailAddress.value;

	alert('Thank You ' + applicant_name + '.\nOur sales team will contact you soon.');

	document.ApplicationForm.submit();

	

	if (self.name == "application")

	{

		self.close();

	}

}



function ClearIt()

{

	document.ApplicationForm.reset();

	document.ApplicationForm.applicant.focus();

}



function setVariables() 

{

	if (bName == "Netscape") 

	{

		v = ".top=";

		h = ".left=";

		dS = "document.";

		sD = "";

	}

	else 

	{

		v = ".pixelTop=";

		h = ".pixelLeft=";

		dS = "";

		sD = ".style";

	}

}



function dropDownList(z)

{

	z=parseInt(z);

	theLink="";

	listOffset=22;	//this is the number that the dropdown list needs to start from.

	

	if (z>1)

	{

		z=listOffset+z;

		theLink="List"+z;

	}

	else

	{

		theLink="List1";

	}



	swapList(theLink);

}



function swapList(n) 

{

	if (bName!="Netscape")

	{

		newList = n;

		eval(dS + visList + sD + v + (-460));

		eval(dS + visList + sD + h + 580);

		eval(dS + newList + sD + v + (+60));

		eval(dS + newList + sD + h + 580);

	}

	else

	{

		theLayer = n;

		//alert("theLayer is"+theLayer);

		for (x=1 ; x<27 ; x++)

		{

			document.layers["nnList"+x].visibility = "hide";

			//alert("nnList"+ x);

		}

		document.layers["nn"+ theLayer].visibility = "show";

		//alert("theLayer is nn"+ theLayer);

	}



	visList = newList;

}



if ((bName=="Netscape"&&bVer>=3)||(bName=="Microsoft Internet Explorer"&&bVer>=4))

{

	version = "OK";

}



if (version == "OK")

{

	button1on = new Image(117,57);

	button1on.src = "./images/gownsoff.gif";

	button2on = new Image(117,57);

	button2on.src = "./images/rompersoff.gif";

	button3on = new Image(117,57);

	button3on.src = "./images/dressesoff.gif";

	button4on = new Image(117,57);

	button4on.src = "./images/accessoff.gif";

	button5on = new Image(117,57);

	button5on.src = "./images/specialoff.gif";

	button6on = new Image(117,57);

	button6on.src = "./images/stockistsoff.gif";

	button7on = new Image(117,57);

	button7on.src = "./images/homeoff.gif";



	button1off = new Image(117,57);

	button1off.src = "./images/gownson.gif";

	button2off = new Image(117,57);

	button2off.src = "./images/romperson.gif";

	button3off = new Image(117,57);

	button3off.src = "./images/dresseson.gif";

	button4off = new Image(117,57);

	button4off.src = "./images/accesson.gif";

	button5off = new Image(117,57);

	button5off.src = "./images/specialon.gif";

	button6off = new Image(117,57);

	button6off.src = "./images/stockistson.gif";

	button7off = new Image(117,57);

	button7off.src = "./images/homeon.gif";

}



function img_act(imgName) 

{

	if (version == "OK")

	{

		imgOn = eval(imgName + "on.src");

		document [imgName].src = imgOn;

	}

}



function img_inact(imgName)

{

	if (version == "OK")

	{

		imgOff = eval(imgName + "off.src");

		document [imgName].src = imgOff;

	}

}



function launch()

{

	if (confirm ('Open in a new window ?'))

	{

		if (bName=="Netscape")

		{			

			dimensions='width=420,height=580';

		}

		else

		{

			dimensions='width=400,height=560';

		}

		

		window.open(theUrl,'application',dimensions);

	}

	else

	{

		parent.location = theUrl;

	}

}

