function blinkExecute(target,color){
  document.getElementById(target).style.backgroundColor = color;
}

function blinkBlink (target){
  color1 = "#feff6f"; // blinking color
  color2 = "#E8F2FF"; // background color

  setTimeout('blinkExecute("'+target+'","'+color1+'")',0);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',500);
  setTimeout('blinkExecute("'+target+'","'+color1+'")',1000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',1500);             
  setTimeout('blinkExecute("'+target+'","'+color1+'")',2000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',2500);     
  setTimeout('blinkExecute("'+target+'","'+color1+'")',3000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',3500);     
  setTimeout('blinkExecute("'+target+'","'+color1+'")',4000);
  setTimeout('blinkExecute("'+target+'","'+color2+'")',4500);             
  document.getElementById(target).focus();
}

function Locate(x)
		{									
			switch(x)
			{
				case 1:
					window.location="Overseas.asp";
					break;
				case 2:
					window.location="Facilities.asp";
					break;
				case 3:
					window.location="Vacancies.asp";
					break;
				case 4:
					window.location="International.asp";
					break;
			}					
		}




function CheckForm () { 

	var errorMsg = "";
	var error_focus=0;
	var data = "";
	
	if (document.form1.FName.value == "")
	{
		errorMsg += "\n\tFirst Name \t- Enter your First Name";
			error_focus=1;
	}
	if ((document.form1.from.value == "") || (document.form1.from.value.length > 0 && (document.form1.from.value.indexOf("@",0) == - 1 || document.form1.from.value.indexOf(".",0) == - 1))) 
	{ 
		errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
		if(error_focus!=1)
			error_focus=2;
	}

//Checking Post Code.......


PCodeStatus = 0;
 test = document.form1.pcode.value; size = test.length
 test = test.toUpperCase(); //Change to uppercase
 while (test.slice(0,1) == " ") //Strip leading spaces
  {test = test.substr(1,size-1);size = test.length
  }
 while(test.slice(size-1,size)== " ") //Strip trailing spaces
  {test = test.substr(0,size-1);size = test.length
  }

 document.form1.pcode.value = test; //write back to form field
 if (size < 6 || size > 8){ //Code length rule
	PCodeStatus = PCodeStatus + 1; //wrong length
  }
 if (!(isNaN(test.charAt(0)))){ //leftmost character must be alpha character rule
	PCodeStatus = PCodeStatus + 1; //cannot start with a number
  }
 if (isNaN(test.charAt(size-3))){ //first character of inward code must be numeric rule
	PCodeStatus = PCodeStatus + 1; //first character of inward code must be numeric rule
  }
 if (!(isNaN(test.charAt(size-2)))){ //second character of inward code must be alpha rule
	PCodeStatus = PCodeStatus + 1; //second character of inward code must be alpha rule
  }
 if (!(isNaN(test.charAt(size-1)))){ //third character of inward code must be alpha rule
	PCodeStatus = PCodeStatus + 1; //third character of inward code must be alpha rule
  }
 if (!(test.charAt(size-4) == " ")){//space in position length-3 rule
	PCodeStatus = PCodeStatus + 1; //space in position length-3 rule
   }
 count1 = test.indexOf(" ");count2 = test.lastIndexOf(" ");
 if (count1 != count2){//only one space rule
PCodeStatus = PCodeStatus + 1; //only one space allowed
  }


	if (PCodeStatus > 0)
	{ 
		errorMsg += "\n\tPost Code \t- Enter your valid Post Code";
		if((error_focus!=1) && (error_focus!=2))
			error_focus=3;
	}

// Post Code Checking Finished...
	
		
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "____________________________________________________________________\n\n";
		msg += "Your Order Catalog Form has not been sent because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "____________________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected:\t -\n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		if(error_focus==1)
		{
			if (navigator.appName == 'Microsoft Internet Explorer')			
				blinkBlink('FName');
			else
				document.form1.FName.focus();
		}
		else if(error_focus==2)
		{
			if (navigator.appName == 'Microsoft Internet Explorer')			
				blinkBlink('from');
			else
			{
			document.form1.from.focus();
			document.form1.from.select();
			}
		}
		else if(error_focus==3)
		{
			if (navigator.appName == 'Microsoft Internet Explorer')			
				blinkBlink('pcode');
			else
			{
			document.form1.pcode.focus();
			document.form1.pcode.select();
			}
		}
		return false;
	} 

		var title_temp = form1.elements["title"]
    		var new_title = title_temp[title_temp.selectedIndex].value
		data= data + "\nTitle:\t" + new_title;	

	data= data + "\nFirst Name:\t" + form1.FName.value ;

	if(document.form1.LName.value != "")
		data= data + "\nLast Name:\t" + form1.LName.value ;
	
data= data + "\nE-mail Address:\t" + form1.from.value ;

	if(document.form1.phone.value != "")
		data= data + "\nContact Number:\t" + form1.phone.value ;

if(document.form1.address.value != "")
		data= data + "\nAddress:\t" + form1.address.value ;

data= data + "\nPost code:\t" + form1.pcode.value ;


if(document.form1.city.value != "")
		data= data + "\nCity:\t" + form1.city.value ;

		var Country_temp = form1.elements["Country"]
    		var new_Country = Country_temp[Country_temp.selectedIndex].value
		data= data + "\nCountry:\t" + new_Country;	
	
data= data + "\nThe above customer ordered a catalog from Rawland Website." ;
	data= data + "\n\n************************************************************************************************************\n";
	form1.body.value=data;
	return true;
}
