function swapLayer(intLayer){
	for (j=0; j<=3; j++){
		if (intLayer == j){
			document.getElementById("slide-content"+j).style.visibility = "visible";
		} else {
			document.getElementById("slide-content"+j).style.visibility = "hidden";
		}
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

i = 9;
function addRow(){
	var newRow = document.getElementById("recruit").insertRow(-1);
	
	oCell = newRow.insertCell(-1);
	oCell.className = "tablebg";
	oCell.innerHTML = i+".";
	
	oCell = newRow.insertCell(-1);
	oCell.className = "tablebg";
	oCell.innerHTML = "<input name=\"recName"+i+"\" type=\"text\" maxlength=\"255\" />";
	
	oCell = newRow.insertCell(-1);
	oCell.className = "tablebg";
	oCell.innerHTML = "<input name=\"recEmail"+i+"\" type=\"text\" maxlength=\"255\" />";
	
	i++;
	
	if (i == 16){
		document.getElementById("recruit-addmore").style.visibility = "hidden";
	}
}

function chkRecruit(theform){
	if (theform.recName1.value == "" || (theform.recEmail1.value == "" || echeck(theform.recEmail1.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recName1.focus();
		return false;
	} else if (theform.recName2.value != "" && (theform.recEmail2.value == "" || echeck(theform.recEmail2.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail2.focus();
		return false;
	} else if (theform.recName3.value != "" && (theform.recEmail3.value == "" || echeck(theform.recEmail3.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail3.focus();
		return false;
	} else if (theform.recName4.value != "" && (theform.recEmail4.value == "" || echeck(theform.recEmail4.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail4.focus();
		return false;
	} else if (theform.recName5.value != "" && (theform.recEmail5.value == "" || echeck(theform.recEmail5.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail5.focus();
		return false;
	} else if (theform.recName6.value != "" && (theform.recEmail6.value == "" || echeck(theform.recEmail6.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail6.focus();
		return false;
	} else if (theform.recName7.value != "" && (theform.recEmail7.value == "" || echeck(theform.recEmail7.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail7.focus();
		return false;
	} else if (theform.recName8.value != "" && (theform.recEmail8.value == "" || echeck(theform.recEmail8.value)==false)){
		alert("At least 1 name and e-mail address is required");
		theform.recEmail8.focus();
		return false;
	} else {
		if (i > 9){
			if (theform.recName9.value != "" && (theform.recEmail9.value == "" || echeck(theform.recEmail9.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail9.focus();
				return false;
			} else if (theform.recName10.value != "" && (theform.recEmail10.value == "" || echeck(theform.recEmail10.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail10.focus();
				return false;
			} else if (theform.recName11.value != "" && (theform.recEmail11.value == "" || echeck(theform.recEmail11.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail11.focus();
				return false;
			} else if (theform.recName12.value != "" && (theform.recEmail12.value == "" || echeck(theform.recEmail12.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail12.focus();
				return false;
			} else if (theform.recName13.value != "" && (theform.recEmail13.value == "" || echeck(theform.recEmail13.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail13.focus();
				return false;
			} else if (theform.recName14.value != "" && (theform.recEmail14.value == "" || echeck(theform.recEmail14.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail14.focus();
				return false;
			} else if (theform.recName15.value != "" && (theform.recEmail15.value == "" || echeck(theform.recEmail15.value)==false)){
				alert("At least 1 name and e-mail address is required");
				theform.recEmail15.focus();
				return false;
			} else {
				return true;
			}
		} else {
			return true;
		}
	}
}

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("Invalid email")
		return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid email")
		return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid email")
		return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid email")
		return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid email")
		return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid email")
		return false
	}
	if (str.indexOf(" ")!=-1){
		alert("Invalid email")
		return false
	}
	return true
}

function checkNo(field) {
  	var valid = "0123456789"
  	var ok = "yes";
  	var temp;
		
  	for (var i=0; i<field.value.length; i++){
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
  	if (ok == "no"){
  		//alert("Invalid entry!  Only numbers are accepted!");
  		field.value = field.value.substring(0, field.value.length - 1);
  		field.focus();
	}
}

function chkRegistration(theform){
	if (theform.txtName.value == ""){
		alert("Please enter your name.");
		theform.txtName.focus();
		return false;
	} else if (isNaN(theform.txtICNo.value) || theform.txtICNo.value.length != 12){
		alert("Please enter your I/C No.");
		theform.txtICNo.focus()
		return false;
	} else if (echeck(theform.txtEmail.value)==false){
		theform.txtEmail.focus();
		return false;
	} else if (isNaN(theform.txtPrefix.value) || theform.txtPrefix.value.length != 3 || isNaN(theform.txtMobile.value) || theform.txtMobile.value.length != 7){
		alert("Please enter your mobile number.");
		return false;
	} else if (theform.rules.checked == false){
		alert("Please check the Terms & Conditions box.");
		return false;
	} else {
		return true;
	}
}

function chkRecruitEmail(theform){
	if (echeck(theform.txtEmail.value)==false){
		theform.txtEmail.focus();
		return false;
	} else {
		return true;
	}
}

function chkContact(theform){
	if (theform.txtName.value == ""){
		alert("Please enter your name.");
		theform.txtName.focus();
		return false;
	} else if (echeck(theform.txtEmail.value)==false){
		theform.txtEmail.focus();
		return false;
	} else if (isNaN(theform.txtPrefix.value) || theform.txtPrefix.value.length != 3 || isNaN(theform.txtMobile.value) || theform.txtMobile.value.length != 7){
		alert("Please enter your mobile number.");
		return false;
	} else if (theform.enquiries.value == ""){
		alert("Please enter your enquiries.");
		theform.enquiries.focus();
		return false;
	} else {
		return true;
	}
}