<!--

	var last = 0;
	var index = 0;

	var brandLast = 0;
	var brandIndex = 0;
	var cosmeticsFlag = 0;
	var brandFlag = 0;
	var jobFlag = 0;
	var toptwoFlag = 0;
	var countryFlag = 0;
	var nameFlag = 0;
	var cosLast = 0;

	function countChecks(i)
	{
		var maxchecked = 2;
		var count = 0;
		if (document.pe.toptwo1.checked == true) { count++; }
		if (document.pe.toptwo2.checked == true) { count++; }
		if (document.pe.toptwo3.checked == true) { count++; }
		if (document.pe.toptwo4.checked == true) { count++; }
		if (document.pe.toptwo5.checked == true) { count++; }
		if(count > maxchecked)
		{
			document.pe.toptwo1.checked = false;
			document.pe.toptwo2.checked = false;
			document.pe.toptwo3.checked = false;
			document.pe.toptwo4.checked = false;
			document.pe.toptwo5.checked = false;
			eval('document.pe.toptwo' + last + '.checked = true');
			eval('document.pe.toptwo' + i + '.checked = true');
		}
		last = i;
	}

	function checkEmail(address) {

		var at = "@"
		var dot = "."
		var indexAt = address.indexOf(at)
		var length = address.length
		var indexDot = address.indexOf(dot)

		if (indexAt == -1)
		{		
			return false;
		}

		if (indexAt == -1 || indexAt == 0 || indexAt == length - 1)
		{
			return false;
		}
		if (indexDot == -1 || indexDot == 0 || indexDot == length - 1)
		{
			return false;
		}
		if (address.indexOf(at,(indexAt + 1)) != -1)
		{
			return false;
		}
		if (address.substring(indexAt - 1,indexAt) == dot || address.substring(indexAt + 1, indexAt + 2) == dot)
		{
			return false;
		}
		if (address.indexOf(dot,(indexAt + 2)) == -1)
		{
			return false;
		}		
		if (address.indexOf(" ") != -1){
			return false;
		}
		return true;			
	}

	function countBrandChecks(i)
	{
		var maxchecked = 2;
		var count = 0;
		if (document.pe.brand1.checked == true) { count++; }
		if (document.pe.brand2.checked == true) { count++; }
		if (document.pe.brand3.checked == true) { count++; }
		if (document.pe.brand4.checked == true) { count++; }
		if (document.pe.brand5.checked == true) { count++; }
		if (document.pe.brand6.checked == true) { count++; }

		if(count > maxchecked)
		{
			document.pe.brand1.checked = false;
			document.pe.brand2.checked = false;
			document.pe.brand3.checked = false;
			document.pe.brand4.checked = false;
			document.pe.brand5.checked = false;
			document.pe.brand6.checked = false;
			eval('document.pe.brand' + brandLast + '.checked = true');
			eval('document.pe.brand' + i + '.checked = true');
		}
		
		brandLast = i;
	}
	
	function countCosChecks(i)
	{
		var maxchecked = 2;
		var count = 0;
		
		var cosmeticsmax = 25;
		
		for (j = 1; j < cosmeticsmax + 1; j++)
		{
			temp = eval('document.pe.cos' + j + '.checked');
			if (temp == true)
			{
				count++;
			}		
		}
		if(count > maxchecked)
		{
			for (j = 1; j < cosmeticsmax + 1; j++)
			{						
				temp = eval('document.pe.cos' + j + '.checked = false')				
			}
			eval('document.pe.cos' + cosLast + '.checked = true');
			eval('document.pe.cos' + i + '.checked = true');
		}
		cosLast = i;	
	}

	function checkTopTwo()
	{
		var temp;
		var toptwomax = 5;
		var pass = false;
		
		for (i = 1; i < toptwomax + 1; i++)
		{
			temp = eval('document.pe.toptwo' + i + '.checked');
			
			if (temp)
			{
				pass = true;
			}		
		}
		
		return pass;	
	}
	
	function checkBrand()
	{
		var temp;
		var brandmax = 6;
		var pass = false;
		
		for (i = 1; i < brandmax+1; i++)
		{
			temp = eval('document.pe.brand' + i + '.checked');
			
			if (temp)
			{
				pass = true;
			}		
		}
		
		return pass;	
	}

	// Form Validation MDC

	function checkJob()
	{
		var temp;
		var jobmax = 8;
		var pass = false;
		
		for (i = 0; i < jobmax; i++)
		{
			temp = eval('document.pe.job[' + i + '].checked');
			if (temp)
			{
				pass = true;
			}		
		}
		
		return pass;	
	
	}

	function checkCosmetics()
	{
		var temp;
		var cosmeticsmax = 25;
		var pass = false;
		
		for (i = 1; i < cosmeticsmax + 1; i++)
		{
			temp = eval('document.pe.cos' + i + '.checked');
			if (temp)
			{
				pass = true;
			}		
		}
		
		return pass;	
	
	}
	
	function validate()
	{

		var n = document.pe.name;
		
		var e = document.pe.email;

		var c = document.pe.country;
		
		var o = document.pe.other;
		
		document.pe.coschoice1.value = "";
		document.pe.coschoice2.value = "";
		document.pe.top1choice.value = "";
		document.pe.top2choice.value = "";
		document.pe.br1choice.value = "";
		document.pe.br2choice.value = "";
		document.pe.jobchoice.value = "";		
		
		var flag = 0;
		cosmeticsFlag = 0;
		brandFlag = 0;
		jobFlag = 0;
		toptwoFlag = 0;
		countryFlag = 0;
		nameFlag = 0;
		emailFlag = 0;
		if (document.pe.cos25.checked)
		{							
			if (checkSpaces(document.pe.otherCos.value) == false || document.pe.otherCos.value == null || document.pe.otherCos.value == "" || document.pe.otherCos.value == " ")
			{
				cosmeticsFlag = 2;
				flag = 1;
			}			
		}
		
		if (!checkCosmetics())
		{

			cosmeticsFlag = 1;
			flag = 1;
		}
		if (document.pe.brand6.checked)
		{
			if (checkSpaces(document.pe.otherBrand.value) == false || document.pe.otherBrand.value == null || document.pe.otherBrand.value == "" || document.pe.otherBrand.value == " ")
			{
				brandFlag = 1;
				flag = 1;
			}			
		}
		if (!checkBrand())
		{
			brandFlag = 2;
			flag = 1;
		}		
		if (!checkJob())
		{
			jobFlag = 1;
			flag = 1;
		}
		if (!checkTopTwo())
		{
			toptwoFlag = 1;
			flag = 1;		
		}		
		if (document.pe.country.options[document.pe.country.selectedIndex].value == "Other")
		{
			if (checkSpaces(o.value) == false)
			{
				countryFlag = 1;
				flag = 1;
				missingcountry = true;
			}
			if (o.value == null || o.value == "" || o.value == " ")
			{
				countryFlag = 1;
				flag = 1;
				missingcountry = true;
			}
		}
		if (n.value == null || n.value == "" || n.value == " ")
		{
			nameFlag = 1;
			flag = 1;
		}
		if (checkEmail(e.value) == false)
		{
			emailFlag = 2;
			flag = 1;
		}
		if (e.value == null || e.value == "" || e.value == " ")
		{
			emailFlag = 1;
			flag = 1;
		}
		if (checkSpaces(e.value) == false)
		{
			emailFlag = 1;
			flag = 1;
		}
		if (checkSpaces(n.value) == false)
		{
			nameFlag = 1;
			flag = 1;
		}
			
		if (flag == 0)
		{
			populate();
			return true;
		}
		else
		{			
			return showErrors();
		}
	}
	
	function populate()
	{
		var cosmeticsmax = 25;
		var temp;
		var cosNum = 0;

		for (i = 1; i < cosmeticsmax + 1; i++)
		{
			temp = eval('document.pe.cos' + i);
			if (temp.checked && cosNum == 1)
			{
				document.pe.coschoice2.value = temp.value;
			}
			else if (temp.checked && cosNum != 1)
			{
				document.pe.coschoice1.value = temp.value;
				cosNum = 1;
			}
		}		
		var jobmax = 8;

		for (i = 0; i < jobmax; i++)
		{
			temp = eval('document.pe.job[' + i + ']');
			if (temp.checked)
			{
				document.pe.jobchoice.value = temp.value;
			}		
		}	

		var toptwomax = 5;
		var num = 0;
		
		for (i = 1; i < toptwomax + 1; i++)
		{
			temp = eval('document.pe.toptwo' + i);
			
			if (temp.checked && num == 1)
			{
				document.pe.top2choice.value = temp.value;				
			}	
			else if (temp.checked && num != 1)
			{
				document.pe.top1choice.value = temp.value;
				num = 1;
			}
		}
		var brandmax = 6;
		
		var bnum = 0;
		
		for (i = 1; i < brandmax+1; i++)
		{
			temp = eval('document.pe.brand' + i);
			
			if (temp.checked && bnum == 1)
			{
				document.pe.br2choice.value = temp.value;				
			}	
			else if (temp.checked && bnum != 1)
			{
				document.pe.br1choice.value = temp.value;
				bnum = 1;
			}		
		}		
	}

	function checkSpaces(strValue)
	{
	   var strTemp = strValue;
	   strTemp = trimAll(strTemp);
	   if(strTemp.length > 0)
	   {
		 return true;
	   }
	   return false;
	}

	function trimAll( strValue ) {
	 var objRegExp = /^(\s*)$/;
		//check for all spaces
		if(objRegExp.test(strValue)) {
		   strValue = strValue.replace(objRegExp, '');
		   if( strValue.length == 0)
			  return strValue;
		}

	   //check for leading & trailing spaces
	   objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	   if(objRegExp.test(strValue)) {
		   //remove leading and trailing whitespace characters
		   strValue = strValue.replace(objRegExp, '$2');
		}
	  return strValue;
	}

	function showErrors()
	{
		errorMsg = "<HTML><BODY STYLE=\"font-family: Palatino Linotype; font-size:10pt\">Sorry, these boxes have not been completed:<UL>";
		if (nameFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please enter your <B>name</B>.</LI><BR><BR>";
		}
		if (countryFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Your country is not listed, please enter your <b>country</b> in the box.</LI><BR><BR>";
		}
		if (toptwoFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please choose at least one option for <B>\"My Two Favourite Things\"</B>.</LI><BR><BR>";
		}
		if (jobFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please choose at least one option for <B>\"What I Am\"</B>.</LI><BR><BR>";
		}
		if (brandFlag == 2)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please choose at least one option for <B>\"The Brand I Love Most\"</B>.</LI><BR><BR>";
		}
		if (brandFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Your brand is not listed, please enter your <B>brand</B> in the box.</LI><BR><BR>";
		}
		if (cosmeticsFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please choose at least one option for <B>\"My Favourite Skin Care\"</B>.</LI><BR><BR>";
		}
		if (cosmeticsFlag == 2)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Your skin care brand is not listed, please enter your <B>skin care brand</B> in the box.</LI><BR><BR>";
		}
		if (emailFlag == 1)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please enter your <B>email address</B>.</LI><BR><BR>";
		}
		else if (emailFlag == 2)
		{
			errorMsg = errorMsg + "<LI STYLE=\"color:red\">Please enter a valid <B>email address</B>.</LI><BR><BR>";
		}
		errorMsg = errorMsg + "</UL><BR>Please complete the missing boxes and try again. Sorry for the inconvenience!<BR><BR><BR><CENTER><A HREF=\"javascript:self.close()\">Close</A></CENTER></BODY></HTML>";
		
		w = 560;
		startwidth = w;
		height = 420;
		width = (startwidth)? startwidth : screen.width / 2;
		var screenX = (screen.width / 2 - width / 2);
		options =  "resizable=yes,width=" + w + ",height=" + height +
					",location=no,scrollbars=yes,toolbar=no,status=no,screenx=" +
					screenX +
					",left=" +
					screenX +
					",screenY=0,top=0";
		var popupwin = window.open("", "bags",options);
		popupwin.resizeTo(w,height);
		popupwin.moveTo(screenX,0);
		popupwin.document.open();
		popupwin.document.write(errorMsg);
		popupwin.document.close();
		popupwin.focus();
		return false;
	}


	function checkOther(obj)
	{
		if (obj.options[obj.selectedIndex].value == "Other")
		{
			if (document.getElementById)
			{
				document.getElementById('otherField').style.visibility = 'visible';
			}
			else if (document.all)
			{
				document.all['otherField'].style.visibility = 'visible';
			}
			else if (document.layers)
			{
				document.otherField.visibility = 'show';
			}
		}
		else
		{
				if (document.getElementById)
				{
					document.getElementById('otherField').style.visibility = 'hidden';
				}
				else if (document.all)
				{
					document.all['otherField'].style.visibility = 'hidden';
				}
				else if (document.layers)
				{
					document.otherField.visibility = 'hide';
				}

		}

	}

//-->