﻿
function validation()
{
     var userid=document.form.txtUserName.value;
     if (userid=="")
            {

            
            alert(" 'UserID' can not be blank");
              document.form.txtUserName.focus();
              return false;
            }
     var pass = document.form.txtpass.value;
     if(document.form.txtpass.value=="")
     {
        alert("Please enter 'Password' ");
        document.form.txtpass.focus();
        return false;
     }
     if(pass.length<6)
     {
        alert("Password minimum 6 charactor long");
        document.form.txtpass.focus();
        return false;
     }
     if(document.form.txtConfPass.value=="")
     {
        alert("Please enter ConfPassword");
        document.form.txtConfPass.focus();
        return false;
     }       
     var pass = document.form.txtpass.value;
     var check = document.form.txtConfPass.value;     
     if(!check.match(pass))
     {
        alert("please enter right 'Password' ");
        document.form.txtConfPass.focus();
        return false;
     }      
     if(document.form.txtFN.value=="")
     {
        alert("Please enter your 'FirstName' ");
        document.form.txtFN.focus();
        return false;
     }       
     if(document.form.txtLN.value=="")
     {
        alert("Please enter your 'LastName' ");
        document.form.txtLN.focus();
        return false;
     } 
     if(document.form.txtAdd.value=="")
     {
        alert("Please enter your 'Address' ");
        document.form.txtFN.focus();
        return false;
     }
     if(document.form.txtemail.value=="")
     {
        alert("Please enter 'EmailId' ");
        document.form.txtemail.focus();
        return false;
     } 
     var emailpat= /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
     var email =  document.form.txtemail.value;
     if(!email.match(emailpat))   
     {
        alert ("Your Email address seems incorrect.Please try again !! ");
        document.form.txtemail.focus();
        return false;  
     } 
     if(document.form.txtPh.value=="")
     {
        alert("Please enter valid 'Phone no.' ");
        document.form.txtPh.focus();
        return false;
     }            
     if(document.form.country.value==0)
     {
        alert("Please Fill 'Country' !! ");
        document.form.country.focus();
        return false;
     } 
     if(document.form.state1.value==0)
     {
        alert("Please Fill 'State' !! ");
        document.form.state1.focus();
        return false;
     } 
     if(document.form.city1.value==0)
     {
        alert("Please Fill 'City' !! ");
        document.form.city1.focus();
        return false;
     } 
     if(document.form.txtzip.value==0)
     {
        alert("Please enter 'ZipCode' ");
        document.form.txtzip.focus();
        return false;
     }
     var digit = "0123456789";
     var temp;
     for (var i=0;i<document.form.txtzip.value.length;i++)
         {
            temp = document.form.txtzip.value.substring(i,i+1);
            if (digit.indexOf(temp)== -1)
               {
                        alert("Please enter correct zip code");
                        document.form.txtzip.focus();
                        return false;
               }
         } 
     return true;
}
function validation1()
{
    if(document.form.txtFN.value=="")
     {
        alert("Please enter your 'FirstName' ");
        document.form.txtFN.focus();
        return false;
     }       
     if(document.form.txtLN.value=="")
     {
        alert("Please enter your 'LastName' ");
        document.form.txtLN.focus();
        return false;
     } 
     if(document.form.txtemail.value=="")
     {
        alert("Please enter 'EmailId' ");
        document.form.txtemail.focus();
        return false;
     } 
     var emailpat= /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
     var email =  document.form.txtemail.value;
     if(!email.match(emailpat))   
     {
        alert ("Your Email address seems incorrect.Please try again !! ");
        document.form.txtemail.focus();
        return false;  
     } 
     if(document.form.txtAdd.value=="")
     {
        alert("Please enter your 'Address' ");
        document.form.txtFN.focus();
        return false;
     }
     if(document.form.txtPh.value=="")
     {
        alert("Please enter valid 'Phone no.' ");
        document.form.txtPh.focus();
        return false;
     }            
     if(document.form.country.value==0)
     {
        alert("Please Fill 'Country' !! ");
        document.form.country.focus();
        return false;
     } 
     if(document.form.state1.value==0)
     {
        alert("Please Fill 'State' !! ");
        document.form.state1.focus();
        return false;
     } 
     if(document.form.city1.value==0)
     {
        alert("Please Fill 'City' !! ");
        document.form.city1.focus();
        return false;
     } 
     if(document.form.txtzip.value==0)
     {
        alert("Please enter 'ZipCode' ");
        document.form.txtzip.focus();
        return false;
     }
     var digit = "0123456789";
     var temp;
     for (var i=0;i<document.form.txtzip.value.length;i++)
         {
            temp = document.form.txtzip.value.substring(i,i+1);
            if (digit.indexOf(temp)== -1)
               {
                        alert("Please enter correct zip code");
                        document.form.txtzip.focus();
                        return false;
               }
         } 
         return true;
}
function changepassvalidation()
{
    var Cpass=document.form.txtCpass.value;
    var Npass=document.form.txtNewPass.value;
    var Vpass=document.form.txtConfPass.value;
    if(Cpass=="")
    {
        alert("Please enter your Current Password");
        document.form.txtCpass.focus();
        return false;        
    }
    if(Npass=="")
    {
        alert("Enter new Password ");
        document.form.txtNewPass.focus();
        return false;
    }
    if(Npass.length<6)
    {
        alert("Password minimum 6 charactor long");
        document.form.txtNewPass.focus();
        return false;
    }
    if(Vpass=="")
    {
        alert("Verify Password can not blank");
        document.form.txtConfPass.focus();
        return false;
    }
    if(!Vpass.match(Npass))
    {   
        alert("Please verify currect Password");
        document.form.txtConfPass.focus();
        return false;        
    }
    return true;
}


/* ajax function for select country-state-city */
function ajaxFunction()
{
var xmlhttp;
var country = document.getElementById('country');
country = country.options[country.selectedIndex].value;
if(country == 0){
	document.getElementById('state').innerHTML ='<select name="state1" id="state1" onChange="ajaxFunction1()" style="width:135px; font-family:Verdana; font-size:11px"><option value="0">-Select State-</option></select>';
	return;
}
//alert(country);
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  //alert(xmlhttp.responseText);
  var abc = xmlhttp.responseText;
  var str = abc.indexOf('<option');
  abc = abc.substring(str,abc.length);
  abc = abc.substring(0,abc.length-24);
  var str1 = abc.split('</select>');
  
  document.getElementById('state').innerHTML='<select name="state1" id="state1" onChange="ajaxFunction1()"  style="width:135px; font-family:Verdana; font-size:11px"><option value="">-Select State-</option>'+str1[0]+'</select>';
// alert(document.getElementById('state').innerHTML);
  }
}
xmlhttp.open("GET","state.aspx?country="+country,true);
xmlhttp.send(null);
}
function ajaxFunction1()
{
//alert('haha');
var xmlhttp;
var country = document.getElementById('state1');
country = country.options[country.selectedIndex].value;
//alert(country);
if(country == 0){
//	alert('haha');
	document.getElementById('city').innerHTML = '<select name="city1" id="city1" style="width:135px; font-family:Verdana; font-size:11px"><option value="">-Select City-</option>		</select>';
	return;
}

if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  //alert(xmlhttp.responseText);
  var abc = xmlhttp.responseText;
  var str = abc.split('<select');
  //alert(str[1]);
  var str1 = str[1].split('</select>');
  //str1 = '<select'+str1[0]+'</select>';
  //alert(str1);
  document.getElementById('city').innerHTML='<select name="city1" id="city1" style="width:135px; font-family:Verdana; font-size:11px" ><option value="">-Select City-</option>'+str1[0]+'</select>';
  }
}
xmlhttp.open("GET","city.aspx?state="+country,true);
xmlhttp.send(null);
}




/* Image Rotation Script start here!!!!!!!!!!!!! */

index=0
    function startTimer()
    {      myArray=new Array("AllImg/Image1/keshyog-ayesha.jpg","AllImg/Image1/keshmukt-divya.jpg","AllImg/Image1/roopayan-jaya.jpg","AllImg/Image1/hanuman-kawach.jpg","AllImg/Image1/3gmagnum-fuel.jpg","AllImg/Image1/english-tutor.jpg","AllImg/Image1/rashi-ratan-sangrah.jpg");
	        if(index>6)
		    {		
		    index=0	
		    document.form1.hello.src=myArray[index]	
		    index++	
		    }
	        else
		    {		
			    document.form1.hello.src=myArray[index]		
			    index++
	        }
        }
    function rotateimg()
    {	
	ref=setInterval("startTimer()",2000)
    }
    
    
    
/* Functions for Franchisee state/city/number!!!!!!!!!! */
function ajaxFunction2()
{
var xmlhttp;
var country = document.getElementById('state1');
country = country.options[country.selectedIndex].value;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
  var abc = xmlhttp.responseText;
  var str = abc.indexOf('<option');
  abc = abc.substring(str,abc.length);
  abc = abc.substring(0,abc.length-24);
  var str1 = abc.split('</select>');
  document.getElementById('city').innerHTML='<select name="city1" id="city1" onChange="ajaxFunction3()" style="width:135px; font-family:Verdana; font-size:11px"><option value ="">Select City</option>'+str1[0]+'</select>';
  }
}
xmlhttp.open("GET","FranchiseCity.aspx?state="+country,true);
xmlhttp.send(null);
}
function ajaxFunction3()
{
var xmlhttp;
var country = document.getElementById('city1');
country = country.options[country.selectedIndex].value;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  var abc = xmlhttp.responseText;
  var str = abc.split('&');
  document.getElementById('phnumber').innerHTML=str[1];
  }
}
xmlhttp.open("GET","FranchiseNo.aspx?cid="+country,true);
xmlhttp.send(null);
}
 
 
/* function for contactus state-city!!!!!!!!!!! */
function ajaxFunction4()
{
//alert('haha');
var xmlhttp;
var country = document.getElementById('state1');
country = country.options[country.selectedIndex].value;
//alert(country);
if(country == 0){
//	alert('haha');
	document.getElementById('city').innerHTML = '<select name="city1" id="city1" style="width:135px; font-family:Verdana; font-size:11px"><option value="">-Select City-</option></select>';
	return;
}

if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  //alert(xmlhttp.responseText);
  var abc = xmlhttp.responseText;
  var str = abc.split('<select');
  //alert(str[1]);
  var str1 = str[1].split('</select>');
  //str1 = '<select'+str1[0]+'</select>';
  //alert(str1);
  document.getElementById('city').innerHTML='<select name="city1" id="city1" style="width:135px; font-family:Verdana; font-size:11px"><option value="">-Select City-</option>'+str1[0]+'</select>';
  }
}
xmlhttp.open("GET","city.aspx?state="+country,true);
xmlhttp.send(null);
}
