var login="Member ID";
var spass="Password";
var sre="Confirm-Password";
var nam="Name";
var mail="E-Mail";
var add="Address";
var cit="City";
var stat="State";
var coun="Country";
var ref="Reference";
var mod="Mode Of Payment";
var frid="Friend User ID";
var ddn="Demand Draft Number";
var dodd="Demand Draft Date";
var bnam="Bank Name";
var bcit="Bank City";
var bcode="Bank Code";
var delid="Dealer ID";
var delpass="Dealer Password"
var sque="Question";
var sans="Answer";
//var reset1=true
/*function checkdt(dt)
{
var p=/[0-3][0-9]\/[0-1][0-2]\/[1900-9999]/;
var x=p.test(dt)
if (ValidatorEvaluateIsValid(fieldValue,expr,msg,alertStatus)
	{

	}
/*var arr=dt.split("/")
if(parseInt(dt(0))==0||x==false)
{
alert("Date is not valid")
return false*/
function checkdt(dt)
{
var p=/[0-3][0-9]\/[0-1][0-2]\/[1900-9999]/;
var x=p.test(dt)
var arr=dt.split("/")
if(parseInt(arr[0])==0||x==false)
{
alert("Date is not valid")
return false;

}
}

function CheckCountry(val)
{
if (val==-1)
{
alert("Country must be selected")
return false
}
return true
}

function isEmpty(s) {
        return ((s == null) || (s.length == 0));
}
function isWhitespace (s) {
        var i;
      if (isEmpty(s)) return true;
      for (i = 0; i < s.length; i++){
                var c = s.charAt(i);
            if (c == " ") return true;
        }
        return false;
}
function isSame(fir,sec){
        var j,k;
      var lnt;
      if(fir.length > sec.length){
                lnt=fir.length;
                        }
        else{
                lnt=sec.length;
        }
                for (j = 0; j < lnt; j++)
                {
                      if(fir.charAt(j) !=sec.charAt(j))
                          return true;}
                                return false;}
function warnEmpty (theField, s)
        {   theField.focus()
                alert( s+" can not be empty and White spaces are not allowed in   "+ s + " field. ")
                return false}
     <!--### PASSWORD  VALIDATION ###-->
function checkPassuserSame(fir,sec){
if(isSame(fir.value,sec.value))
{
return true;
}
else{
alert("Password should not  be same as User ID");
                        return false;}
}
function checkSamePass(Pas,theFields, si)
        {           var ll=theFields.value.length;
    //           if (isWhitespace(theFields.value))
      //             return warnEmpty (theFields, si);
            if(isSame(Pas.value,theFields.value)) {
            	alert("Password and Confirm Password should same so please Re-Enter Confirm-Password same as Password Field.");
            	theFields.focus();
            	return false;
            }else return true;
        }
function checkPassLen (theField, s){ 
       var l=theField.value.length;
	  var fieldValue1 = theField.value;
          if (isEmpty(theField.value)) { 
          	alert(s + " can not be empty."); 
         	theField.focus();
         	return false;
          }
           if (isWhitespace(theField.value)){
                  return warnEmpty (theField, s);
}               if(l < 5) { 
                	alert("The length of "+s+" should minimum of 5 characters.");
                      theField.focus();
                      return false;
                    }
                 if(l > 15) {
  	              alert("The length of "+s +" should not more than 15 characters");
  	               theField.focus();
  	              return false;}
                        return true;     }

function checkCorrect3(theField, s){ 
    var l=theField.value.length;
	  var fieldValue1 = theField.value;
          if (isEmpty(theField.value)) { 
          	alert(s + " can not be empty."); 
          	theField.focus();
          	return false;
          }
        return true;     
    }


<!--### E MAil Validaation ###-->


function checkEmail(theField,s)
{

var l=theField.value.length;
var fieldvalue=theField.value;

          if (isEmpty(theField.value)) { 
          	alert(s  + "   can not be empty."); 
          	theField.focus();
          	return false;
          }
    	for(i=0;i<l;i++)
	{
		
		if(fieldvalue.charAt(i)=='@')
		{
		
			for(j=i;j<l;j++)
			{
				if(fieldvalue.charAt(j)=='.')
				{
				
					break;
				}
				
				if((j+1)==l)
				{
				
				alert(s + "  not valid");
				theField.focus();
				return false;
				break;
				}
				
			}
		
		break;
		}
	
		if((i+1)==l)
		{
			
			alert(s + "  not valid");
			theField.focus();
			return false;
			break;
			
		}		
	
	}
		

return true;						
		
}

	
function checkDealerID(theField,s)
{
if(document.all.payment.value=="By Cash")
	{
	var l=theField.value.length;
        var fieldValue1 = theField.value;
        if (isEmpty(theField.value)) 
		{ 
	       	alert(s + " can not be empty."); 
          	theField.focus();
        	return false;
        	}
	return true;
	   }
	else
	return true;
}
//----------for Numeric validation-----------
function checkNumeric(theField,s)
{	var l=theField.value.length;
	validString = "0123456789.";
	var fieldvalue = theField.value;
        if(isEmpty(theField.value))
	{
	alert(s+" can not be empty.");
	theField.focus();
	return false;
	}
	else
	{	var j;
		for (j = 0; j < l ; j++)
	        {

			if(validString.indexOf(fieldvalue.charAt(j)) == -1)
			{
				alert ("Please enter 0-9//dot(.) in"+s +" Field");
				theField.focus();
				return false;
			}
         }

	}
return true;

}

function checkNumericWithOutDot(theField,s,checkempty)
{	var l=theField.value.length;
	validString = "0123456789";
	var fieldvalue = theField.value;
	
        if(isEmpty(theField.value)&&checkempty!=false)
	{
	alert(s+" can not be empty.");
	theField.focus();
	return false;
	}
	else
	{	var j;
		for (j = 0; j < l ; j++)
	        {

			if(validString.indexOf(fieldvalue.charAt(j)) == -1)
			{
				alert ("Please enter 0-9 in"+s +" Field");
				theField.focus();
				return false;
			}
         }

	}
return true;

}
function checkAlphaNumeric(theField,s,checkempty)
{	var l=theField.value.length;
	validString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.- ,";
	var fieldvalue = theField.value;
        if(isEmpty(theField.value)&&checkempty!=false)
	{
	alert(s+" can not be empty.");
	theField.focus();
	return false;
	}
	else
	{	var j;
		for (j = 0; j < l ; j++)
	        {

			if(validString.indexOf(fieldvalue.charAt(j)) == -1)
			{
				alert ("Please enter 0-9/A-Z/a-z/ in "+ s +" Field");
				theField.focus();
				return false;
			}
         }

	}
return true;

}

//--------------for draft date--------
function checkDraftDate(form,s)
{
alert("date")
date=new Date()
			day=date.getDate()
			yy=date.getYear()
		    mm=date.getMonth()
	        if(frmMain.elements["yob"].value==yy)
			{
			 if(frmMain.elements["mob"].selectedIndex<mm)
			  {alert("Month cann't be lesser then current month")
			  return false
  			  }
			 if(frmMain.elements["mob"].selectedIndex==mm)
			 {
		      if(day>frmMain.elements["dob"].value)
			  {
			  alert("Day cann't be lesser then current day")
			  return false
			  }
			 }
			}
		  
}


<!--### USER ID VALIDATION ###-->
function checkUserID(theField,s)
{	var l=theField.value.length;
	validString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";
	var fieldvalue = theField.value;
        if(isEmpty(theField.value))
	{
	alert(s+" can not be empty.");
	theField.focus();
	return false;
	}
	else
	{	var j;
		for (j = 0; j < l ; j++)
	        {

			if(validString.indexOf(fieldvalue.charAt(j)) == -1)
			{
				alert ("Please enter 0-9/A-Z/a-z/underscore(_)/dot(.) in User ID Field");
				theField.focus();
				return false;
			}
         }

	}
return true;

}

function ValidatorEvaluateIsValid(fieldValue,expr,msg,alertStatus) {
	
    var value = fieldValue
   if (ValidatorTrim(value).length == 0)
        return true;        
    var rx = new RegExp(expr)
    var matches = rx.exec(value);
    if((matches != null && value == matches[0])==false)
    {
    if(alertStatus==true)
    {
    alert(msg)
    }
    return false
    }
    return true
}
function ValidatorTrim(s) {
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
   return (m == null) ? "" : m[1];
   // return("d")
}

function checkImage(field,emptyflag,str,format)
{
value=field.value
var divHtml,imgsrc,ss
var divHtml1,imgHt,imgWt,imgSize,name
//imgHt=height //frm.hdnHeight.value
//imgWt=width //frm.hdnWidth.value
//imgsrc=value//frm.imgFile.value
//imgSize=size//frm.hdnSize.value
var str,arrStr,fileName,filen,filearr

	filearr=value.split('.');
	filearr.reverse()
filen=filearr[0];

if(emptyflag==true)
{
	if(value=="")
	{
 alert(str+" can't be empty!")
 field.focus()
 return false
	}
}

if(filen.toUpperCase()!="JPEG"&&filen.toUpperCase()!="JPG"&&filen.toUpperCase()!="GIF"&&filen.toUpperCase()!="")
{
alert(str+" should be jpeg/jpg/gif .");
return false;
}

return true
}

function GetFileExtension(val,type,msg)
{
var arr=val.split(".")
if((arr[arr.length-1]).toUpperCase()!=type.toUpperCase())
{
 alert(msg)
 return false
}
}
function checkFile1(x)
{
document.getElementById("div1").style.visibility="hidden"
if (frm.file.value=="")
{
	return 0;
	}
document.getElementById("div1").style.visibility="visible"
document.getElementById("1").src=frm.file.value
}

function checkFile2(x)
{
document.getElementById("div2").style.visibility="hidden"
if (frm.file2.value=="")
{
	return 0;
}
document.getElementById("div2").style.visibility="visible"
document.getElementById("2").src=frm.file2.value
}
function checkFile3(x)
{
document.getElementById("div3").style.visibility="hidden"
if (frm.file3.value=="")
{
	return 0;
	}
document.getElementById("div3").style.visibility="visible"
document.getElementById("3").src=frm.file3.value
}


function checksynphone(dt)
{

var p=/\d{3,5}[" "]\d{6,8}$/;
var q=/\(\d{3,5}\)[" "]\d{6,8}$/;
var x=p.test(dt)
var y=q.test(dt)
//var arr=dt.split("/")

if(x==true ||y==true )
{}
else
{
alert("Phone No. is not valid")
return false;

}
}

function checksynpostcode(dt)
{
var p=/\D{2}\d{1,2}[" "]\d{1}\D{2}/;
var q=/\D{1}\d{2,3}[" "]\d{1}\D{2}/;

var x=p.test(dt)
	var y=q.test(dt)

//var arr=dt.split("/")
if(x==true ||y==true )
{}
else
{
alert("Post code is not valid")
return false;

}
}

function resetall()
{
	
	//alert(document.getElementById("div1").style.visibility)
//document.getElementById("div1").style.visibility="hidden"
//document.getElementById("div2").style.visibility="hidden"
//document.getElementById("div3").style.visibility="hidden"
document.getElementById("1").src="http://localhost/synergy/images/spacer.gif"
document.getElementById("2").src=""
document.getElementById("3").src=""
	//document.getElementById("2").src=""
	//	document.getElementById("3").src=""
		reset1=true
//alert(document.getElementById("div1").childNodes.length)

//document.getElementById("div1").removeChild(document.getElementById("div1").lastChild)

//document.getElementById("1").src="./spacer.gif"
//document.getElementById("1").alt=""
}
function checkFile1(x)
{
	
document.getElementById("div1").style.visibility="hidden"
if (frm.file.value=="")
{
	return 0;
	}
document.getElementById("div1").style.visibility="visible"
document.getElementById("1").src=frm.file.value
}

function checkFile2(x)
{
document.getElementById("div2").style.visibility="hidden"
if (frm.file2.value=="")
{
	return 0;
}
document.getElementById("div2").style.visibility="visible"
document.getElementById("2").src=frm.file2.value
}
function checkFile3(x)
{
document.getElementById("div3").style.visibility="hidden"
if (frm.file3.value=="")
{
	return 0;
	}
document.getElementById("div3").style.visibility="visible"
document.getElementById("3").src=frm.file3.value
}
function DateDiff(date1,date2)
{
	var s,s1
s=date1
s1=date2

var d=Date.parse(s)

var myd=new Date(d)
var d1=Date.parse(s1)

var myd1=new Date(d1)

if((myd1-myd)<0)
	{
	 alert("End date should be greater than start date")
        return false
	}
	 return true
}

	 function checkAllImage()
	 {
      for (var i=1;i<=3;i++)
	{

    j=i
 	if (document.getElementById(j).src!="" && document.getElementById(j).width>200)
	{
	if(j==1&&frm.file.value!="")
	{
	alert("Image"+j+" width can not be more than 200px ")
	frm.file.focus()
	document.getElementById("div1").style.visibility="hidden"
	
	return false
	}
	if(j==2&&frm.file2.value!="")
	{

	alert("Image"+j+" width can not be more than 200px ")
	frm.file2.focus()
	document.getElementById("div2").style.visibility="hidden"
	return false
	}
	if(j==3&&frm.file3.value!="")
	{	
		alert("Image"+j+" width can not be more than 200px ")
	frm.file3.focus()
	document.getElementById("div3").style.visibility="hidden"
	return false
	}

	}
 }

 return true
	 }

function checkdiscount(field)
{
	var val=field.value;
	if (val<=0 || val>100)
	{
		alert("Discount can be between 1 to 100 percent")
		return false
	}
}
function ValidateNumeric() 
{
	var keyCode = window.event.keyCode; 
	if (keyCode > 57 || keyCode < 48) 
	  window.event.returnValue = false; 
} 

function Validate_restrictedwords() 
{
	var keyCode = window.event.keyCode;
	if (!(keyCode > 57 || keyCode < 48))
	{	
		alert('Numbers and some symbols are not permitted in this box. Please use letters to write a number. It is Strictly Forbidden to write contact details in this box. This includes Addresses, Phone Numbers, Websites and Emails.')
		window.event.returnValue = false;
	}
	else if (keyCode==64)
	{
		alert('Numbers and some symbols are not permitted in this box. Please use letters to write a number. It is Strictly Forbidden to write contact details in this box. This includes Addresses, Phone Numbers, Websites and Emails.')
		window.event.returnValue = false;
	}
} 
function checklength(ControllId,TotalLength)
{
	ControllLength=document.getElementById(ControllId).value.length
	if(ControllLength>TotalLength)
	{
		alert("There is a maximum limit of "+TotalLength+" characters for this answer box.")
		return false;
	}
//	Validate_restrictedwords();
}
function hide_div(var1,var2){
	if (document.getElementById(var1).value=="")
		document.getElementById(var2).style.display="block";
	else
		document.getElementById(var2).style.display="none";
}
function ready_date_div(var1)
{
	if (document.getElementById("ready_date_day").value=="" || document.getElementById("ready_date_month").value=="" ||	document.getElementById("ready_date_year").value=="" )
	{
		document.getElementById(var1).style.display="block";
	}
	else
	{
		document.getElementById(var1).style.display="none";
	}
}
function postcode_div(var1)
{
	if (document.getElementById("postcode1").value=="")
	{
		document.getElementById(var1).style.display="block";
	}
	else
	{
		document.getElementById(var1).style.display="none";
	}
}
function hide_div_terms(var1)
{
	if(document.frm.chkterms.checked==false)
	{
		document.getElementById(var1).style.display="block";
	}
	else
	{
		document.getElementById(var1).style.display="none";
	}
}
  function hide_div_language(var1)
  {
	if (document.getElementById("list2").options.length==0)
	{
		document.getElementById(var1).style.display="block";
	}
	else
	{
		document.getElementById(var1).style.display="none";
	}
  }
function change_citybox()
	{
		if (document.getElementById("country").value=="United Kingdom")
		{
			document.getElementById("city").style.display="block"
			document.getElementById("city2").style.display="none"
		}
		else
		{
			document.getElementById("city").style.display="none"
			document.getElementById("city2").style.display="block"
		}
			
	}
function onclk2(boxID,initText)
{
	if (document.getElementById(boxID).value==initText)
	{
		document.getElementById(boxID).value="";
		document.getElementById(boxID).style.color="#000000";
	}
}
function onblr2(boxID,initText)
{
	if (document.getElementById(boxID).value=="")
	{
		document.getElementById(boxID).value=initText;
		document.getElementById(boxID).style.color="#686868";
	}
}
