// JavaScript Document
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 isNumber(Field, Msg)
{
	
	//var reg = /^\d{5}([\-]\d{4})?$/;
	var reg = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
 
 	///^([0-9]+)$/;
	
   	if(reg.test(Field.value) == false) 
	{
	   	alert(Msg)
		Field.focus()
      	return true
	}
	return false
}
function isZipCode(Field, Msg)
{
	var reg =  /^\d{5}([\-]\d{4})?$/;
	
   	if(reg.test(Field.value) == false) 
	{
	   	alert(Msg)
		Field.focus()
      	return true
	}
	return false
}
function isZipCodes(Zip, Msg)
{
	var reg =  /^\d{5}([\-]\d{4})?$/;
	
   	if(reg.test(Zip.value) == false) 
	{
	   	alert(Msg)
		Zip.focus()
      	return true
	}
	return false
}
function isCountry(Zip)
{
	var reg = /^([A-Za-z_\-\.])$/;
	//var reg =  /^\d{5}([\-]\d{4})?$/;
	
   	if(reg.test(Zip.value) == false) 
	{
	    alert(Msg)
		Email.focus()
      	return true
	}
	else
	{
		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))
	{
			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 ValidateSponsorCode(Field, ID)
{
	var Msg = 'cod2';
	if(Field.value == "")
	{
		Msg.className = "ShowError4EmptyTextField"
		Msg.value = ID;
		return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
function ValidateDuplicateEmail(Field, ID)
{
	var Msg = document.getElementById('peml');
	if(Field.value == "")
	{
		Msg.className = "ShowError4EmptyTextField"
		Msg.innerHTML = "Email address already exist.";
		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 ValidateCountry(Zip, ID)
{
	var Msg = document.getElementById(ID)
	var reg = /^([A-Za-z_\-\.])$/;
	//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(Field, Msg)
{
	if(!Field.checked ){
		alert(Msg)
		Field.focus()
		return true
	}
	return false
}
function valid(form)
	{
	 if(form.code.value == "" || isNaN(form.code.value))
	
		{
		alert("Please provide 3 digit (numerics) comapny code");
		form.code.focus();
		return false;
	   }
	   return true;
	}
function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }
function ValidateList(List, ID)
{
	
	var Msg = document.getElementById(ID)
	if(List.value == '') {
		
		Msg.className = "ShowError4EmptyTextField"
		return false;
	}
	else {
		Msg.className = "HideError4EmptyTextField"
		return true;
	}
}
// validate three digits phone number
function Lengthphone1(Field, ID)
{
	var Msg = document.getElementById(ID)
	var reg =  /^\d{3}([\-]\d{4})?$/;
	
   	if(reg.test(Field.value) == false) 
	{
	    Msg.className = "ShowError4EmptyTextField"
		Msg.innerHTML = "Please Enter a Valid Phone Number";
	
      	return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}
// Validate 4 digits phone number
function Lengthphone2(Field, ID)
{
	var Msg = document.getElementById(ID)
	var reg =  /^\d{4}([\-]\d{4})?$/;
	
   	if(reg.test(Field.value) == false) 
	{
	    Msg.className = "ShowError4EmptyTextField"
		Msg.innerHTML = "Please Enter a Valid Phone Number";
	
      	return false
	}
	else
	{
		Msg.className = "HideError4EmptyTextField"
		return true
	}
}

//////////////////////////////////////////////////////
/*function setvalues(id)
{
	var str = "?id="+id; 
	
	var strURL="setvalues.php"+str;
	alert(strURL)
	var xmlhttp = getNewHTTPObject();

   if (xmlhttp)
   {

     xmlhttp.onreadystatechange = function()
     {
      if (xmlhttp.readyState == 4)
      {
	
	 if (xmlhttp.status == 200)
         {
		
	   document.getElementById('progad').innerHTML=xmlhttp.responseText;
		
		
	 } else {
   	   alert("There was a problem while using XMLHTTP:\n" + xmlhttp1.statusText);
	 }
       }
      }
   xmlhttp.open("POST", strURL, true);
   xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 

	xmlhttp.send(str);


  
   }
}*/
function setTotal() 
{
     var PFee;
      var Payment
    if(!/\S/.test(this.value))this.value='0.00'
    if(document.getElementById('ctl00_ContentPlaceHolder1_txtProcessingFee').value=="")
    {
         PFee=0;
    }
    else
    {
    PFee=document.getElementById('ctl00_ContentPlaceHolder1_txtProcessingFee').value;
    }
        if(document.getElementById('ctl00_ContentPlaceHolder1_txtPaymentAmount').value=="")
    {
         Payment=0;
    }
    else
    {
    Payment=document.getElementById('ctl00_ContentPlaceHolder1_txtPaymentAmount').value;
    }
	 var sum = parseFloat(PFee)+parseFloat(Payment);
    var result = sum.toFixed(2); 
  
 
       document.getElementById('ctl00_ContentPlaceHolder1_txtTotalAmount').value = result ;
}
