// JavaScript Document

//Ajax Main Function

function GetXmlHttpObject() {
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
} 




function GenerateFlash(swffile,width,height) {
	
	//if (xdetect_easyDetect('flash')) {

		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width+'" height="'+height+'">');
		document.write('<param name="movie" value="'+swffile+'" />');
		document.write('<param name="quality" value="high" />');
		document.write('<embed src="'+swffile+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>');
		document.write('</object>');
		
	//}
	
}

function verifysignup() {
	
	var txt = "";
	
	if (document.frmsignup.name.value=="") {
	 txt = txt + "\n * Name";
	}
	
	if (document.frmsignup.surname.value=="") {
	 txt = txt + "\n * Last Name";
	}
	
	var str=document.frmsignup.email.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
	if (!filter.test(str)) {
	 txt = txt + "\n * Email is not Valid";
	}

	if (document.frmsignup.password.value=="") {
	 txt = txt + "\n * Password";
	}
	
	if (document.frmsignup.surname.value=="") {
	 txt = txt + "\n * Re-type Password";
	}
	
	for(var i = 0; i < document.frmsignup.country_id.length; i++) {
	if(document.frmsignup.country_id[i].selected) {
		if(document.frmsignup.country_id[i].value=="") {
		  txt = txt + "\n * Country";
		}
	}
	}
	

	//Check Gender
	var checkradio = -1;
	for (i=document.frmsignup.gender.length-1; i > -1; i--) {
		if (document.frmsignup.gender[i].checked) {
			checkradio = i; 
			i = -1;
		}
	}
	if (checkradio == -1) {
		 txt = txt + "\n * Gender";
	}

	
	if (document.frmsignup.nationality.value=="") {
	 txt = txt + "\n * Nationality";
	}
	if (document.frmsignup.height.value=="") {
	 txt = txt + "\n * Height";
	}
	
	//Check Smoking
	var checkradio = -1;
	for (i=document.frmsignup.smoking.length-1; i > -1; i--) {
		if (document.frmsignup.smoking[i].checked) {
			checkradio = i; 
			i = -1;
		}
	}
	if (checkradio == -1) {
		 txt = txt + "\n * Smoking";
	}
	
	//Check Driving
	var checkradio = -1;
	for (i=document.frmsignup.driving.length-1; i > -1; i--) {
		if (document.frmsignup.driving[i].checked) {
			checkradio = i; 
			i = -1;
		}
	}
	if (checkradio == -1) {
		 txt = txt + "\n * Driving";
	}
	
	if ((document.frmsignup.dob.value=="") || (document.frmsignup.dob.value=="YYYY-MM-DD")) {
	 txt = txt + "\n * Date of Birth (DOB)";
	}
	

	
	if (!document.frmsignup.terms.checked) {
	 txt = txt + "\n\n * You have to accept our terms and conditions";
	}
	
	if (txt) {
		alert ("The folowing fields are required:\n" + txt);
		return false;
	}
	
}

function verifycontact() {

	var txt = "";
	
	if (document.contactus.name.value=="") {
	 txt = txt + "\n * Name";
	}
	
	var str=document.contactus.email.value
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i 
	if (!filter.test(str)) {
	 txt = txt + "\n * Email is not Valid";
	}
	
	if (document.contactus.telephone.value=="") {
	 txt = txt + "\n * Telephone";
	}

	if (document.contactus.message.value=="") {
	 txt = txt + "\n * Message";
	}
	

	if (txt) {
		alert ("The folowing fields are required:\n" + txt);
		return false;
	}

}

function CheckCountry() {
	
	var pagesObj = document.getElementById("country_id"); 
	var country_id = pagesObj.options[pagesObj.selectedIndex].value; 
	
	if (country_id == 1) {
		document.getElementById("mobilenetid").style.display="";
		document.getElementById("recommem_1").style.display="";
		document.getElementById("recommem_2").style.display="";
	} else {
		document.getElementById("mobilenetid").style.display="none";
		document.getElementById("textinstrid").style.display="none";
		document.getElementById("recommem_1").style.display="none";
		document.getElementById("recommem_2").style.display="none";
		
		for (var i=0; i < document.getElementById("mobilenet").length; i++) {
			if (i==0) {
				frmsignup.mobilenet.options[i].selected=true      
			}
		}
		document.getElementById("pin").value="";
		document.getElementById("recommended_member").value="";
		
	}
	
}



function ShowStudentType() {
	document.getElementById("studtypebox").style.display="";
}
function HideStudentType() {
	document.getElementById("studtypebox").style.display="none";
}