// cross platform equiv. to document.getElementById
function gGetElementById(s) {

  var o = (document.getElementById ? document.getElementById(s) : document.all[s]);

  return o == null ? false : o;

}

function checkEmail(objTxt) 
{
	var GoodChars = "@_-.:/ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	var UpperEmail = objTxt.value.toUpperCase()
	var ValidChars = true;
	
	for (tfCharNum = 0; tfCharNum > objTxt.value.length; tfCharNum++) {
		Char = UpperEmail.charAt(tfCharNum);
		for (gcCharNum = 0;  gcCharNum < GoodChars.length;  gcCharNum++) {
				 if (Char == GoodChars.charAt(gcCharNum))
			     break;
		}
				 
		if (gcCharNum == GoodChars.length)   {
		     ValidChars = false;
		     break;
   		}
	}
	
	if (!ValidChars || objTxt.value.length < 7 || 
		objTxt.value.indexOf("@") == "-1" ||
		objTxt.value.indexOf(".") == "-1" || 
		objTxt.value.indexOf("..") != "-1" || 
		objTxt.value.indexOf("@.") != "-1" || 
		objTxt.value.indexOf("@:") != "-1" || 
		objTxt.value.indexOf("@/") != "-1" || 
		objTxt.value.indexOf("@-") != "-1" || 
		objTxt.value.indexOf("@_") != "-1" || 
		objTxt.value.indexOf(".@") != "-1" || 
		objTxt.value.indexOf(":@") != "-1" || 
		objTxt.value.indexOf("/@") != "-1" || 
		objTxt.value.indexOf("-@") != "-1" || 
		objTxt.value.indexOf("_@") != "-1" || 
		objTxt.value.indexOf("@") != objTxt.value.lastIndexOf("@")) {
		objTxt.focus();
			return (false);
	}
	return (true);
}
/************************************************** Project/ */
function inquiry_validate(){
	//name = gGetElementById('CasualClientName');
	//email = gGetElementById('CasualClientEmail');
	no_of_person = gGetElementById('CasualClientNoOfPersons');	
	start_date = gGetElementById('CasualClientStartDate');	
	end_date = gGetElementById('CasualClientEndDate');		
	/*
		if(name.value == ''){
		alert('Please enter name');	
		name.focus();
		return false;
	}
		if(email.value == ''){
		alert('Please enter email');	
		email.focus();
		return false;
	}else{
		if(checkEmail(email) == false){
			alert('Please enter valid email');	
			email.focus();
			return false;
		}
	}
	*/
	if(no_of_person.value == ''){			
		alert('Please enter no of Person');	
		no_of_person.focus();
		return false;
	}else if(isNaN(no_of_person.value) == true){
		alert('Please enter numeric value');	
		no_of_person.focus();
		return false;
	}
	if(start_date.value == ''){
		alert('Please enter start date');	
		start_date.focus();
		return false;
	}	
	if(end_date.value == ''){
		alert('Please enter end date');	
		end_date.focus();
		return false;
	}	
}
function sorting(){
	if(document.getElementById('CasualClientSort').value != '')
	{
		var str = document.getElementById('CasualClientSort').value;
		var ary = str.split(".");
		if(ary.length>=2){
			window.location.href = "?sortBy="+ary[1]+"&sortByClass="+ary[0];
		}else{
			window.location.href = "";
		}
	}
}
function resetAndSubmit(strFormName) 
{
	var frm= gGetElementById(strFormName);
	var ele=frm.elements;
	for(var i=0;i<ele.length;i++)
	{
		if(ele[i].type == "hidden" || ele[i].type == "text") {
			ele[i].value="";
		} else if(ele[i].type == "select-one") {
			ele[i].options[0].selected=true;
		} else {
		}
	}
 	return true;
}
function SelectPaymentType()
{	
	var paypal = gGetElementById('paypal');
	var manual = gGetElementById('manual');	
	var div_paypal = gGetElementById('div_paypal');		
	var div_manual = gGetElementById('div_manual');		
	if(paypal.checked == true){
		div_paypal.style.display = '';
		div_manual.style.display = 'none';			
	}else if(manual.checked == true){
		div_paypal.style.display = 'none';
		div_manual.style.display = '';			
	}else{
		div_manual.style.display = 'none';
		div_paypal.style.display = 'none';
	}
}