function isEmpty(Field, Msg)
{
	if(Field.value == ""){
		alert(Msg)
		Field.focus()
		return true
	}
	return false
}
function isNotSame(Field1, Field2, Msg)
{
	if(Field1.value != Field2.value)
	{
		alert(Msg)
		Field1.focus()
		return true
	}
	return false
}
function isNotValidEmail(Email, Msg)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   	if(reg.test(Email.value) == false) 
	{
      	alert(Msg)
		Email.focus()
      	return true
	}
	return false
}

function isNotNo(Field, Msg)
{  
	 
	if(isNaN(Field.value))
	{
		alert(Msg)
		Field.focus()
		return true
	}
	return false
}
function isInvalidLength(Field, Length, Msg)
{
	if(eval(Field.value.length) < eval(Length)||eval(Field.value.length) > eval(Length))
	{
			alert(Msg)
			Field.focus()
			return true
	}
	return false
}

	  
function Clear(Form)
{
	Form.reset
	return false
}

function isNotValidCharacters(Sec)
{
	if(! ( Sec.value == "JK904" || Sec.value == "jk904" || Sec.value == "Jk904" || Sec.value == "jK904") ) 
	{
		alert('Please Type The Correct Value You See in The Image')
		Sec.focus()
		return true 
	}	
	return false
}
/************************************************************/
function ValidateEmpty(Field, ID)
{
	var Msg = document.getElementById(ID)
	if(Field.value == "")
	{
		Msg.className = "ShowError4EmptyTextField"
		
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function ValidateEmail(Email, ID)
{
	var Msg = document.getElementById(ID)
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   	if(reg.test(Email.value) == false) 
	{
	    Msg.className = "ShowError4EmptyTextField"
		Msg.innerHTML = "Please Enter a Valid Email Address";
	
      	return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

function MatchPasswords(Pass1, Pass2, ID)
{
	var Msg = document.getElementById(ID)
	if(Pass2.value == "")
	{
		Msg.innerHTML = "Please Enter Confirm Password";
		Msg.className = "ShowError4EmptyTextField"
		
		return false
	}
	if(Pass1.value != Pass2.value)
	{
		Msg.innerHTML = "Password and Confirm Password are not same";
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

function MatchEmails(Email1, Email2, ID)
{
	var Msg = document.getElementById(ID)
	if(Email2.value == "")
	{
		Msg.innerHTML = "Please Enter a Valid Confirm Email Address";
		Msg.className = "ShowError4EmptyTextField"
		
		return false	
	}
	else if(Email1.value != Email2.value)
	{
		Msg.innerHTML = "Email and Confirm Email are not Same";
		
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function ValidateRadio(RadioFields, ID)
{
	var Msg = document.getElementById(ID)
	var nRadios = RadioFields.length
	var Marked = 0;
	for(i=0; i<nRadios; i++){
		if(RadioFields[i].checked)
			Marked++;
	}
	if(Marked == 0){
		Msg.className = "ShowError4EmptyTextField"
		return false
	}else{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function ValidateZipCode(Zip, ID)
{
	var Msg = document.getElementById(ID)
	var reg =  /^\d{5}([\-]\d{4})?$/;
	
   	if(reg.test(Zip.value) == false) 
	{
	    Msg.className = "ShowError4EmptyTextField"
		Msg.innerHTML = "Please Enter a Valid Zipcode";
	
      	return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function MatchFields(Field1, Field2, ID)
{
	var Msg = document.getElementById(ID)
	if(Field1.value != Field2.value)
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
/*function isNotNo(Field, Msg)
{
	var Msg = document.getElementById(ID)
	if(isNaN(Msg.value))
	{
		Msg.className = "ShowError4EmptyTextField"
		return false
	}
	else
	{
	Msg.className = "HideError4EmptyTextField"
		return true
	}
}*/
function ValidateCheckboxes(CheckBoxFields, ID, nChecks)
{  

	var Msg = document.getElementById(ID)
	var Marked = 0;
	
	if(nChecks == 1){
		if(CheckBoxFields.checked)
			Marked++;
	}
	else if(nChecks > 1)
	{
		for(i=0; i < nChecks; i++){
			if(CheckBoxFields[i].checked)
				Marked++;
		}
	}
	if(Marked == 0){
		Msg.className = "ShowError4EmptyTextField"
		return false
	}else{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function ValidateCheckBox(CheckBox, ID)
{
	var Msg = document.getElementById(ID)
	if(CheckBox.checked)
	{
		Msg.className = "HideError4EmptyTextField"
		return true
		
	}
	else
	{	Msg.className = "ShowError4EmptyTextField"
	
		return false
	}
}
//////////////////////////////////////////////////////////////////////
function FSfncCheckCCexpire(FormField) {
	// Check credit expiry date is in valid format
	var CCexpire=FormField.value;
	if (CCexpire=="") {alert("Please enter your credit card expiry date."); FormField.focus(); return false}
	var ArrayCCexpr=CCexpire.split("/");
	if ((ArrayCCexpr.length!=2) || (ArrayCCexpr[0]=="") || (isNaN(ArrayCCexpr[0])) || (ArrayCCexpr[1]=="") || (isNaN(ArrayCCexpr[1])) || (ArrayCCexpr[0]<1) || (ArrayCCexpr[0]>12)) {alert("Expiry date is not in correct format."); FormField.focus(); return false}
	return true;
	}

function FSfncCheckCCnum(FormField) {
	// Check credit/Switch card number is in valid format
	var ccRE=/\W/gi;
	var CCnumber=FormField.value.replace(ccRE, "");
	if (isNaN(CCnumber)) {alert("Credit card number is not numeric."); FormField.focus(); return false}
	if ((CCnumber.length!=16) && (CCnumber.length!=18)) {alert("Incorrect number of digits in credit card number."); FormField.focus(); return false}
	var cardMath=0;
	for (i=CCnumber.length; i>0; i--) {
		if (i % 2 == 1) {
			var doubled = "" + (parseInt(CCnumber.substring(i - 1, i)) * 2);
			if (doubled.length==2) {doubled = parseInt(doubled.substring(0,1)) + parseInt(doubled.substring(1,2))}
			cardMath += parseInt(doubled);
			}
		else {cardMath += parseInt(CCnumber.substring(i - 1, i))}
		}
	if (cardMath % 10 != 0) {alert("Credit card number is invalid."); FormField.focus(); return false}
	return true;
	}

                                                                                      
