﻿// JScript File


var strmasterpage='ctl00_ContentPlaceHolder1_';

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

//Global Variables
var SearchXmlHttp;
//Creating object of XMLHTTP For AJAX Method
function CreateSearchXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		SearchXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			SearchXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			SearchXmlHttp = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!SearchXmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		SearchXmlHttp = new XMLHttpRequest();
	}
}

var XmlHttpNew;

function CreateXmlHttpNew()
{
	try
	{
		XmlHttpNew = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpNew = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpNew = null;				
		}
	}
	if(!XmlHttpNew && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpNew = new XMLHttpRequest();
	}
}

//Global Variables
var XmlHttp;
//Creating object of XMLHTTP For AJAX Method
function CreateXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		XmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			XmlHttp = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!XmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		XmlHttp = new XMLHttpRequest();
	}
}

var RXmlHttp;
//Creating object of XMLHTTP For AJAX Method
function CreateRXmlHttp()
{
	//Creating object of XMLHTTP in IE
	try
	{
		RXmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			RXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch(oc)
		{
			RXmlHttp = null;	
		}
	}
	//Creating object of XMLHTTP in Mozilla and Safari 
	if(!RXmlHttp && typeof XMLHttpRequest != "undefined") 
	{
		RXmlHttp = new XMLHttpRequest();
	}
}

function SetCookie(name, value) 
{
  var curCookie = name + "=" + escape(value) ;
  document.cookie = curCookie;
}





function GetRState(id,name,controlid,cityid)
{
   CreateRXmlHttp();
   
     var ddlState;
    if(name=="C")
    {
           ddlState = document.getElementById(controlid);
          // setblank(document.getElementById(cityid));
    }
   
   var reqiestUrl = "ajaxpage.aspx?time=" + new Date().getTime()+"&Id=" + id.value +"&name=RS";  
     if(RXmlHttp)
    {
        RXmlHttp.onreadystatechange = function(){GetRStateName(ddlState,name);};
        RXmlHttp.open("GET", reqiestUrl, true);
        RXmlHttp.send(null);
    }

   
}


function GetRStateName(ig_,name)
{
    if(RXmlHttp.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(RXmlHttp.status == 200)
		{		
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
		
			var strData = RXmlHttp.responseText;
			//alert(strData)
			if(strData != "") {	
			    
			    var arrcode =strData.split("-")
			   document.getElementById('ctl00_ContentPlaceHolder1_txtcountrycode').value=arrcode[1];
			   document.getElementById('ctl00_ContentPlaceHolder1_txtlandline1').value=arrcode[1];
			   document.getElementById('ctl00_ContentPlaceHolder1_txtFax1').value=arrcode[1];
			     
				var arrSchm = arrcode[0].split("|");
				ig_.length = 0; 	
				
				for(i=0; i<arrSchm.length-1; i++) {	
								
					var strSchm = arrSchm[i];
					var arrSchmCode = strSchm.split("~");
					
					ig_.options[i] = new Option();
					
					ig_.options[i].value = arrSchmCode[0];
					ig_.options[i].text = arrSchmCode[1];
				}
				
			}
			else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "No Data Found";		
				document.getElementById('ctl00_ContentPlaceHolder1_txtcountrycode').value="";
			   document.getElementById('ctl00_ContentPlaceHolder1_txtlandline1').value="";
			   document.getElementById('ctl00_ContentPlaceHolder1_txtFax1').value="";	
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
   
}






  function setblank(ig_)
	{
	                ig_.length = 0;
					ig_.options[0] = new Option(); 
					ig_.options[0].value = "";
					ig_.options[0].text = "Select";	
	}
function GetState(id,name,controlid,cityid)
{  
    CreateXmlHttp();
    //CTime=GetTime();
 //alert(id.value);
    var ddlState;
     var reqiestUrl="";
    if(name=="C")
    {
           ddlState = document.getElementById(controlid);
          // setblank(document.getElementById(cityid));
    }
    else
    {
             ddlState = document.getElementById(controlid);
    }
    
    if(cityid=="Root")
    {
         reqiestUrl = "WebSite/ajaxpage.aspx?time=" + new Date().getTime()+"&Id=" + id.value +"&name="+name;  
         
    }
    else
    {
         reqiestUrl = "ajaxpage.aspx?time=" + new Date().getTime()+"&Id=" + id.value +"&name="+name;  
    }
 
  
    if(XmlHttp)
    {
        XmlHttp.onreadystatechange = function(){GetStateName(ddlState,name);};
        XmlHttp.open("GET", reqiestUrl, true);
        XmlHttp.send(null);
    }

}


function GetStateName(ddlState,name)
{
   var StateName;
   var StateID ;
   var text; 
   var value;
   var listItem;
//  alert(XmlHttp.responseXML.documentElement);
    if(XmlHttp.readyState == 4)
    {
        if (XmlHttp.status == 200)
        {    
            var dsRoot = XmlHttp.responseXML.documentElement;               
         
            
            if(dsRoot!=null)
            {
               if(name=='C')
               {
                   if(dsRoot.getElementsByTagName('StateName')!=null)
                    {
                         StateName = dsRoot.getElementsByTagName('StateName');
                         StateID = dsRoot.getElementsByTagName('StateID');
                         
                        
                     }
                }
                else 
                    if(name=='S')
                    {
                        if(dsRoot.getElementsByTagName('CityName')!=null)
                        {
                         StateName = dsRoot.getElementsByTagName('CityName');
                         StateID = dsRoot.getElementsByTagName('CityId');
                         
                        }
                    } 
                else 
                    if(name=='L')
                    {
                        if(dsRoot.getElementsByTagName('LocationName')!=null)
                        {
                         StateName = dsRoot.getElementsByTagName('LocationName');
                         StateID = dsRoot.getElementsByTagName('LocationId');
                         
                        }
                    }   
                    
                else 
                    if(name=='P')
                    {
                        if(dsRoot.getElementsByTagName('CProType')!=null)
                        {
                         StateName = dsRoot.getElementsByTagName('CProType');
                         StateID = dsRoot.getElementsByTagName('CProid');
                         
                        }
                    }    
                     else 
                    if(name=='R')
                    {
                        if(dsRoot.getElementsByTagName('RegionName')!=null)
                        {
                         StateName = dsRoot.getElementsByTagName('RegionName');
                         StateID = dsRoot.getElementsByTagName('RegionID');
                         
                        }
                    }    
                    
                     if(StateName.length>0)
                        {
                           listItem = new Option("Select", "0");
                           ddlState.length=1;
                           ddlState.options[0] = listItem; 
                             for (var count = 0; count < StateName.length; count++)
                                {
                                    text = (StateName[count].textContent || StateName[count].innerText || StateName[count].text);
                                    value = (StateID[count].textContent || StateID[count].innerText || StateID[count].text);
                                   
                                    listItem = new Option(text, value,  false, false);
                                    ddlState.options[ddlState.length] = listItem;    
                                  
                                } 
                        }
                       else
                       {
                           listItem = new Option("Data not available", "0");
                           ddlState.length=1;
                           ddlState.options[0] = listItem; 
                       }   
                              
                                                            
            }
        }
    }   
}



function openFrenChiess(txtcontrolid,localityid,franchcontrol)
  {
      if(localityid=="")
      {
       alert("please select locality");
        return false;
      }
       var URL="FranchiseeWindow.aspx?txtcontrolid="+txtcontrolid+"&localityid="+localityid+"&franchcontrol="+franchcontrol;
      // alert(URL);
       var NewWin=window.open(URL,'Property','toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=yes,copyhistory=no,width=1200px,height=700px,screenX=0,screenY=0,left=100,top=100');
       NewWin.focus();
       return (false);
  }


 function MM_openWindow(theURL,winName,features)
 { 
  var clientid ="";//=document.getElementById("ctl00_ContentPlaceHolder1_ddclients").value


 var URL=theURL+"?Clientid="+clientid;
 var NewWin=window.open(URL,winName,features);
  NewWin.focus();
  return (false);
 }
 





function echeck(str) 
{

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (lstr==0)
		{
		return true
		}
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid Email ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid Email ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid Email ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid Email ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid Email ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid Email ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid Email ID")
		    return false
		 }

 		 return true					
	}
	
	
	
	
	//new function for email validation
	
	 function isValidEmail(email) {

    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
 // alert(parsed);
  return parsed;
}

	
	
	//
	
	
	
	
	
	function Checkvalue(id)
 {
     if(id!='1')
     {
        strmasterpage='';
     }
           // var str1=document.getElementById("txtemail").value
			//var filter1=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
			
//			 if(isValidEmail(document.getElementById(strmasterpage+"txtcname").value))
//		   {
//		   
//		   }
//		   else
//		   {		   
//		        
//				document.getElementById(strmasterpage+"txtcname").focus();
//				return (false);
//				
//		   }
			
			 var ctlutype = document.getElementsByName('rdbUtype');
			
             if(!(ctlutype[0].checked || ctlutype[1].checked ))
                {        
            alert("Please select User Type !"); 
            ctlutype[0].focus(); 
            return false;
            }
            
            
			 if (document.getElementById(strmasterpage+"txtcname").value == "")
			{
				alert("Please enter User Name !");
				document.getElementById(strmasterpage+"txtcname").focus();
				return (false);
			}
           if(!isValidEmail(document.getElementById(strmasterpage+"txtcname").value))
            {
                alert("Invalid Email ID")
                document.getElementById(strmasterpage+"txtcname").focus();
		        return false
                 
            }
            if(!CheckEmailThrly(strmasterpage+"txtcname"))
                return false;
           if (document.getElementById(strmasterpage+"txtpass").value == "")
			{
				alert("Please enter Password !");
				document.getElementById(strmasterpage+"txtpass").focus();
				return (false);
			}
			
			  if (document.getElementById(strmasterpage+"txtpass").value!= "")
			{
			     var pass= document.getElementById(strmasterpage+"txtpass").value;
			     if(pass.length<6)
			     {
				    alert("Password length should be greater than 5 character!");
				    document.getElementById(strmasterpage+"txtpass").focus();
				    return (false);
				}
			}
			
			if (document.getElementById(strmasterpage+"txtconfirmpass").value == "")
			{
			
			   	alert("Please enter Confirm Password !");
				document.getElementById(strmasterpage+"txtconfirmpass").focus();
				return (false);
			}
			
			if (document.getElementById(strmasterpage+"txtconfirmpass").value!= "")
			{
			  
			   var pass= document.getElementById(strmasterpage+"txtconfirmpass").value;
			     if(pass.length<6)
			     {
				    alert("Confirm password length should be greater than 5 character!");
				    document.getElementById(strmasterpage+"txtconfirmpass").focus();
				    return (false);
				}			
			}
			if(document.getElementById(strmasterpage+"txtpass").value != document.getElementById(strmasterpage+"txtconfirmpass").value)
			{
		        alert("Password and Confirm Password not Matching!");
			    document.getElementById(strmasterpage+"txtpass").focus();
			    return (false);
			}
			if (document.getElementById(strmasterpage+"dpdwCountry").selectedIndex == 0)//value == "" ||document.getElementById(strmasterpage+"dpdwCountry").value == "Select"   || document.getElementById(strmasterpage+"dpdwCountry").value =="Data not available")
			{
				alert("Please select Country !");
				document.getElementById(strmasterpage+"dpdwCountry").focus();
				return (false);
			}
			
			
		    if (document.getElementById(strmasterpage+"dpdwState").selectedIndex == 0)//value == "" ||document.getElementById(strmasterpage+"dpdwState").value == "Select" || document.getElementById(strmasterpage+"dpdwState").value == "Data not available")
			{
				alert("Please select State !");
				document.getElementById(strmasterpage+"dpdwState").focus();
				return (false);
			}
			
			if(document.getElementById(strmasterpage + "hdncityid").value == "" && document.getElementById(strmasterpage + "txtother").value =="Other City" )// || document.getElementById("txtcity").value == "Enter City")
			{
			    alert("Please enter City !");
				document.getElementById("txtcity").focus();
				return (false);
			}
			
			if (document.getElementById(strmasterpage+"txtfirstname").value == "" || document.getElementById(strmasterpage+"txtfirstname").value == "First Name")
			{
				alert("Please enter First Name!");
				document.getElementById(strmasterpage+"txtfirstname").focus();
				return (false);
			}
			
			if (document.getElementById(strmasterpage+"txtmiddelname").value == "" || document.getElementById(strmasterpage+"txtmiddelname").value=="Middle Name")
			{
				//alert("Please enter Middle Name!");
				document.getElementById(strmasterpage+"txtmiddelname").value == ""
				//document.getElementById(strmasterpage+"txtmiddelname").focus();
				//return (false);
			}
			
		   if (document.getElementById(strmasterpage+"txtlast").value == "" || document.getElementById(strmasterpage+"txtlast").value =="Last Name")
			{
				alert("Please enter Last Name!");
				document.getElementById(strmasterpage+"txtlast").focus();
				return (false);
			}
			
			if(document.getElementById(strmasterpage+"ddldays").selectedIndex == 0)
			{
			    alert("Please enter your Date of Birth!");
				document.getElementById(strmasterpage+"ddldays").focus();
				return (false);
			}	
			if(document.getElementById(strmasterpage+"ddlmonth").selectedIndex == 0)
			{
			    alert("Please enter your Month of Birth!");
				document.getElementById(strmasterpage+"ddlmonth").focus();
				return (false);
			}
			if(document.getElementById(strmasterpage+"ddlyear").selectedIndex == 0)
			{
			    alert("Please enter your Year of Birth!");
				document.getElementById(strmasterpage+"ddlyear").focus();
				return (false);
			}
			var ctlserver = document.getElementById('hdnserverdate').value;
			var birthdate = document.getElementById(strmasterpage+"ddlmonth").value + '/' + document.getElementById(strmasterpage+"ddldays").value + '/' + document.getElementById(strmasterpage+"ddlyear").value;
			
			if(Date.parse(birthdate) > Date.parse(ctlserver))
			{
			    alert('Please enter valid Birthdate!');
			    document.getElementById(strmasterpage+"ddldays").focus();
				return (false);
			}
//			if (document.getElementById(strmasterpage+"txtsdate").value == "")
//			{
//				alert("Please enter Date of Birth!");
//				document.getElementById(strmasterpage+"txtsdate").focus();
//				return (false);
//			}		
			
			
//		 if (document.getElementById(strmasterpage+"dpdwCity").value == "" || document.getElementById(strmasterpage+"dpdwCity").value == "Select" || document.getElementById(strmasterpage+"dpdwCity").value == "Data not available")
//			{
//				alert("Please select  City !");
//				document.getElementById(strmasterpage+"dpdwCity").focus();
//				return (false);
//			}
		  if (document.getElementById(strmasterpage+"txtaddress").value == "")
			{
				alert("Please enter Address !");
				document.getElementById(strmasterpage+"txtaddress").focus();
				return (false);
			}
		  if ((document.getElementById(strmasterpage+"txtmobile").value == "" || document.getElementById(strmasterpage+"txtmobile").value == "Mobile"))// && (document.getElementById(strmasterpage+"txtlandline").value == ""|| document.getElementById(strmasterpage+"txtlandline").value == "LandLine"))
			{
				alert("Please enter your Mobile No. !");
				document.getElementById(strmasterpage+"txtmobile").focus();
				return (false);
			}
			var ctlmobid = strmasterpage+"txtmobile";
		    if(document.getElementById(ctlmobid).value.length < 10)
		    {
    		    alert("Please enter correct Mobile No. !");
				document.getElementById(ctlmobid).focus();
				return (false);
		    }		    
            if(document.getElementById(ctlmobid).value.indexOf("9") != 0){
                alert("Please enter valid Mobile No.");
                document.getElementById(ctlmobid).focus();
                return false;}
            
		    var ctllandline = document.getElementById(strmasterpage+"txtlandline");
		    var ctllandline2 = document.getElementById(strmasterpage+"txtlandline2");
		    if(((ctllandline.value == "" || ctllandline.value == "LandLine") && (!(ctllandline2.value == "" || ctllandline2.value == "STD Code"))) || ((!(ctllandline.value == "" || ctllandline.value == "LandLine")) && (ctllandline2.value == "" || ctllandline2.value == "STD Code")))
		    {
		        alert("Please enter complete Lanline No. !");
		        if((ctllandline.value == "" || ctllandline.value == "LandLine"))
				    ctllandline.focus();
				else
				    ctllandline2.focus();
				return (false);
		    }//txtFax
		    var ctlFax = document.getElementById(strmasterpage+"txtFax");
		    var ctlFax2 = document.getElementById(strmasterpage+"txtFax2");
		    if(((ctlFax.value == "" || ctlFax.value == "FAX") && (!(ctlFax2.value == "" || ctlFax2.value == "STD Code"))) || ((!(ctlFax.value == "" || ctlFax.value == "FAX")) && (ctlFax2.value == "" || ctlFax2.value == "STD Code")))
		    {
		        alert("Please enter complete FAX No. !");
		        if((ctlFax.value == "" || ctlFax.value == "FAX"))
				    ctlFax.focus();
				else
				    ctlFax2.focus();
				return (false);
		    }
		    
//		 if (document.getElementById(strmasterpage+"txtcontacttime").value == "" )
//			{
//				alert("Please enter contact time !");
//				document.getElementById(strmasterpage+"txtcontacttime").focus();
//				return (false);
//			}
			
//		   if(echeck(document.getElementById(strmasterpage+"txtemail").value))
//		   {
//		   
//		   }
//		   else
//		   {		   
//		        
//				document.getElementById(strmasterpage+"txtemail").focus();
//				return (false);
//				
//		   }
		   
		     
			document.getElementById('ctl00_ContentPlaceHolder1_hdnstate').value= document.getElementById('ctl00_ContentPlaceHolder1_dpdwState').value;
			document.getElementById('ctl00_ContentPlaceHolder1_hdncountrycode').value= document.getElementById('ctl00_ContentPlaceHolder1_txtcountrycode').value;
			
		
		   //document.getElementById('ctl00_ContentPlaceHolder1_hdncity').value=document.getElementById('ctl00_ContentPlaceHolder1_dpdwCity').value;
 return true ;
 }
 
 
 function checkDigit(e)
 {
        k =(e.which)? e.which : e.keyCode;
    
		if(k < 48 || k > 57 )
		{
			return false;
	    }
	    else
	        return true;
	  

 }
 
 
 
 
 function NotEnter()
 {
	
		if(window.event.keyCode < 1 || window.event.keyCode > 2 )
		{
			event.returnValue = false;
	    }
	    
	  

 }
 
 //For Checking Ascci code For text box
 function checkprice(chk)
 {
	
	//var k=(event.which)? event.which : event.keyCode; return (k < 48 || k > 57) ? false : true;
	
	
	
		if(event.keyCode < 48 || event.keyCode > 57 )
		{
			event.returnValue = false;
	    }
	    
	    if(chk=="yes")
			if(event.keyCode == 46 )
			{
			event.returnValue = true;
			}

 }
 
 
 function checkmonth(id)
 {
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
var curr_year = d.getFullYear();
var currentDate = curr_date + "-" + curr_month + "-" + curr_year;   

if(id=="2")
{
 var sdate=document.getElementById("txtsdate").value;
 var edate=document.getElementById("txtedate").value;
}
else
{
 var sdate=document.getElementById("ctl00_ContentPlaceHolder1_txtsdate").value;
 var edate=document.getElementById("ctl00_ContentPlaceHolder1_txtedate").value;
 }
 var Error=document.getElementById("errormsg");

 var arrSdate=sdate.split("-");
 var arrDdate=edate.split("-");

  if (sdate != "" && edate != "" )
			{
			
			if(Date.parse(currentDate) > Date.parse(sdate)  )
			  {
		   Error.innerHTML="Please select Greater date from Today  date !";
		   if(id=="2")
{
		   document.getElementById("txtsdate").focus();
		   }
		   else
		   {
		     document.getElementById("ctl00_ContentPlaceHolder1_txtsdate").focus();
		   }
		   
	       return (false);
			  }
			
		
			if(Date.parse(sdate) == Date.parse(edate)  )
			  {
		   Error.innerHTML="Please select different date !";
		   if(id=="2")
{
		   document.getElementById("txtedate").focus();
		   }
		   else
		   {
		      document.getElementById("ctl00_ContentPlaceHolder1_txtedate").focus();
		   }
	       return (false);
			  }
			if(Date.parse(sdate) > Date.parse(edate)  )
			  {
		   Error.innerHTML="Please select Greater date from start date !";
		   if(id=="2")
{
		   document.getElementById("txtedate").focus();
		   }
		   else
		   {
		     document.getElementById("ctl00_ContentPlaceHolder1_txtedate").focus();
		   }
		   
	       return (false);
			  }
		    if(arrSdate[0] != arrDdate[0])
			  {
			     Error.innerHTML=" Start day and Expity day not match !";
		         if(id=="2")
{
		   document.getElementById("txtedate").focus();
		   }
		   else
		   {
		     document.getElementById("ctl00_ContentPlaceHolder1_txtedate").focus();
		   }
	             return (false);
			  }
			  
			  Error.innerHTML="";
			   return (true);
			 
		
			}

 }
 var checkvalue;
 
 function Filllisbox(id ,pageid)
{
var flag=0;

     if(pageid != "2") 
     {
         var soucelb =document.getElementById("ctl00_ContentPlaceHolder1_lstbx"+id );
         var ig_ =document.getElementById("ctl00_ContentPlaceHolder1_lstbxS"+id );
         var sdate=document.getElementById("ctl00_ContentPlaceHolder1_txtsdate").value;
         var edate=document.getElementById("ctl00_ContentPlaceHolder1_txtedate").value;
         var fedelay=document.getElementById("ctl00_ContentPlaceHolder1_ddfeeddelay").value;
     }
     else
     {
         var soucelb =document.getElementById("lstbx"+id );
         var ig_ =document.getElementById("lstbxS"+id );
         var sdate=document.getElementById("txtsdate").value;
         var edate=document.getElementById("txtedate").value;
         var fedelay=document.getElementById("ddfeeddelay").value;
     }
     
      
       var servicetype='';

         for(var j=2 ;j<6;j++)
          {
            if(document.getElementById("ctl00_ContentPlaceHolder1_gvrservicetype_ctl0"+j+"_chb").checked)
            {
              servicetype =document.getElementById("ctl00_ContentPlaceHolder1_gvrservicetype_ctl0"+j+"_hdn").value +","+ servicetype ;
            }
           
          }

        if(servicetype=="")
          {
          alert('Please Select Service Type');
          flag=1;
          return false;
          }
          
           
          if(sdate=="")
          {
          alert("Please select Start dates !")
          flag=1;
          return false ;
          }
          if(edate=="")
          {
          alert("Please select Expity date !")
          flag=1;
          return false ;
          }
          if(fedelay=="")
          {
          alert("Please Feeddelay time !")
          flag=1;
          return false ;
          }
              
     var w = soucelb.selectedIndex;


    if (w =="0" || w =="-1")
    {
      alert("Please select valid option !");
      flag=1;
      return false 
    }

  var i;
   if(ig_.length == 0)
     {
     i=0;
     }
     else
     {
     var s;
        for (s=0;s<ig_.length;s++)
        {

        if( ig_.options[s].value ==soucelb.value )
        {
        alert("You already seleted that Option !");
        return false ;

        }
        }
    i=ig_.length
    
     }
     
     CheckPrice(id,soucelb.value,pageid);
    
    var hdnchek= document.getElementById("ctl00_ContentPlaceHolder1_hdnCheckprice");
     alert("You select : "+soucelb[w].text) 
 //alert(checkvalue);
    if( checkvalue =='0'  )
    {
       alert("Price is not avialable for this  section !");
       flag=1;
    }
    else if(checkvalue =='1')
    {
flag=0;
    }
    
   if(flag == 1)
   {
   
   }
    else
      {
        ig_.options[i] = new Option();
         ig_.options[i].value = soucelb.value;
         ig_.options[i].text =  soucelb[w].text;
         GetPrice(id ,pageid);
         //flag=1;
      }
      //checkvalue='0';

}
var globalcheckprice='';




function CheckPrice(id,soucelb,pageid)
  {
    var hdn =document.getElementById("ctl00_ContentPlaceHolder1_hdnCheckprice");
     if(pageid != "2") 
 {
  var igc_ =document.getElementById("ctl00_ContentPlaceHolder1_lstbxS"+id );
  var sdate=document.getElementById("ctl00_ContentPlaceHolder1_txtsdate").value;
  var edate=document.getElementById("ctl00_ContentPlaceHolder1_txtedate").value;
  var fedelay=document.getElementById("ctl00_ContentPlaceHolder1_ddfeeddelay").value;
   var txtprice = document.getElementById("ctl00_ContentPlaceHolder1_txtprice"+id);
  }
  else
  {
   var igc_ =document.getElementById("lstbxS"+id );
  var sdate=document.getElementById("txtsdate").value;
  var edate=document.getElementById("txtedate").value;
  var fedelay=document.getElementById("ddfeeddelay").value;
   var txtprice = document.getElementById("txtprice"+id);
  }
  var servicetype='';

 for(var j=2 ;j<6;j++)
  {
    if(document.getElementById("ctl00_ContentPlaceHolder1_gvrservicetype_ctl0"+j+"_chb").checked)
    {
      servicetype =document.getElementById("ctl00_ContentPlaceHolder1_gvrservicetype_ctl0"+j+"_hdn").value +","+ servicetype ;
    }
   
  }

if(servicetype=="")
  {
  alert('Please Select Service Type');
  return false;
  }
  
   
  if(sdate=="")
  {
  alert("Please select Start dates !")
  return false ;
  }
  if(edate=="")
  {
  alert("Please select Expity date !")
  return false ;
  }
  if(fedelay=="")
  {
  alert("Please Feeddelay time !")
  return false ;
  }
   var Error=document.getElementById("errormsg");
 if(  Error.innerHTML !="")
 {
           alert("Please select valid date differences !")
           if(pageid != "2") 
 {
           document.getElementById("ctl00_ContentPlaceHolder1_txtedate").focus();
           }
           else
           {
              document.getElementById("txtedate").focus();
           }
	       return (false);
 
 }
  
 

  var arrSdate=sdate.split("-");
 var arrDdate=edate.split("-");
 var diffy=arrDdate[2]-arrSdate[2];
var diffm=arrDdate[1]-arrSdate[1];
var period=diffm + 12 * diffy ;



 CreateXmlHttpNew()
	document.body.style.cursor = "progress";
if(pageid != "2") 
 {
   var requestUrl = "AjaxGetSMSPrice.aspx?period="+period+"&feeddelay="+fedelay+"&section="+id+"&seccontid="+soucelb+"&serviceid="+servicetype;
 }


	if(XmlHttpNew)	{
	             
				XmlHttpNew.onreadystatechange = function(){CheckPriceresponcetest()}
				XmlHttpNew.open("GET", requestUrl,  true);
				XmlHttpNew.send(null);
			}
}


function CheckPriceresponcetest()
{

   if(XmlHttpNew.readyState == 4)
	{

		if(XmlHttpNew.status == 200)
		{		
			var strData = XmlHttpNew.responseText
            var PriceId=strData.split("|");
			 if(PriceId[0]=='0' ||PriceId[0]=='')
			 {
		        checkvalue='0';
		       document.body.style.cursor = "none";
		     
		       
			 }
			else
			{
    checkvalue='1'; 
   
            }
		}
		else {
				 checkvalue='3';
			
			}
	}
     
     
     
  }



//function CheckPriceresponce(hdn)
//{
//   
//alert(hdn);
//	if(XmlHttpNew.readyState == 4)
//	{

//		if(XmlHttpNew.status == 200)
//		{		
//			
//			var strData = XmlHttpNew.responseText
//          
//			 var PriceId=strData.split("|");
//			 
//			 if(PriceId[0]=='0' ||PriceId[0]=='')
//			 {
//			     hdn.value='0';
//			     checkvalue='0';
//			     alert(PriceId[0]);
//			     alert(checkvalue)
//			 }
//			else
//			{
////			alert(PriceId[0]);
////			alert(hdn)
////callhidden(hdn.value);
//              checkvalue='1';
//              alert(PriceId[0]);
//              alert(checkvalue)
//			 hdn.value=PriceId[0];
//			 globalcheckprice='';
//			 globalcheckprice=PriceId[0];
//			}
//			
//			
//			
//			document.body.style.cursor = "auto";	
//		}
//		else {
//					
//					document.body.style.cursor = "auto";		
//		}
//	}
//     
//     
//     
//  }


var global='';


function GetPrice(id ,pageid)
{
if(pageid != "2") 
 {
  var igc_ =document.getElementById("ctl00_ContentPlaceHolder1_lstbxS"+id );
  var sdate=document.getElementById("ctl00_ContentPlaceHolder1_txtsdate").value;
  var edate=document.getElementById("ctl00_ContentPlaceHolder1_txtedate").value;
  var fedelay=document.getElementById("ctl00_ContentPlaceHolder1_ddfeeddelay").value;
   var txtprice = document.getElementById("ctl00_ContentPlaceHolder1_txtprice"+id);
  }
  else
  {
   var igc_ =document.getElementById("lstbxS"+id );
  var sdate=document.getElementById("txtsdate").value;
  var edate=document.getElementById("txtedate").value;
  var fedelay=document.getElementById("ddfeeddelay").value;
   var txtprice = document.getElementById("txtprice"+id);
  }
  var servicetype='';

 for(var j=2 ;j<6;j++)
  {
    if(document.getElementById("ctl00_ContentPlaceHolder1_gvrservicetype_ctl0"+j+"_chb").checked)
    {
      servicetype =document.getElementById("ctl00_ContentPlaceHolder1_gvrservicetype_ctl0"+j+"_hdn").value +","+ servicetype ;
    }
   
  }

if(servicetype=="")
  {
  alert('Please Select Service Type');
  return false;
  }
  
   
  if(sdate=="")
  {
  alert("Please select Start dates !")
  return false ;
  }
  if(edate=="")
  {
  alert("Please select Expity date !")
  return false ;
  }
  if(fedelay=="")
  {
  alert("Please Feeddelay time !")
  return false ;
  }
   var Error=document.getElementById("errormsg");
 if(  Error.innerHTML !="")
 {
           alert("Please select valid date differences !")
           if(pageid != "2") 
 {
           document.getElementById("ctl00_ContentPlaceHolder1_txtedate").focus();
           }
           else
           {
              document.getElementById("txtedate").focus();
           }
	       return (false);
 
 }
  
  var ids="";
if(igc_.length == 0)
  {
  //alert("Please put items  !")
  txtprice.value='';
  return false ;
  }
 else 
  {

var i;
var opt,k='',T='';
for (i=0;i<igc_.length;i++)
{
opt=igc_.options[i];
if(opt.value!=0)
{
k +=opt.value +"," ;
T +=opt.text +"," ;

}

}

ids=k.substring(0,k.length-1);

  }

  var arrSdate=sdate.split("-");
 var arrDdate=edate.split("-");
 var diffy=arrDdate[2]-arrSdate[2];
var diffm=arrDdate[1]-arrSdate[1];
var period=diffm + 12 * diffy ;



 CreateXmlHttpNew()
	document.body.style.cursor = "progress";
if(pageid != "2") 
 {
   var requestUrl = "AjaxGetSMSPrice.aspx?period="+period+"&feeddelay="+fedelay+"&section="+id+"&seccontid="+ids+"&serviceid="+servicetype;
 }
//  alert(requestUrl);

	if(XmlHttpNew)	{

				XmlHttpNew.onreadystatechange = function()
				{
				GetPriceresponce(txtprice,pageid,id)
				}
				XmlHttpNew.open("GET", requestUrl,  true);
				XmlHttpNew.send(null);
			}
}



function GetPriceresponce(ig_,pageid,id)
{


	if(XmlHttpNew.readyState == 4)
	{

		if(XmlHttpNew.status == 200)
		{		
			
			var strData = XmlHttpNew.responseText
//            alert(strData);
			//var global='';
			 var PriceId=strData.split("|");
				 if(PriceId[0] == "0")
				{
				ig_.value ="Price not available";
				 Gettotalprice(pageid);
				}
			else	if(PriceId[0] != "") {	
			    ig_.value = PriceId[0]; 
			    //global=global+PriceId[1];
			    
			    if(id=='P')
			    {
			        document.getElementById("ctl00_ContentPlaceHolder1_hdnpp").value=PriceId[1];
			    }
			    else if(id=='E')
			    {
			       document.getElementById("ctl00_ContentPlaceHolder1_hdnpe").value=PriceId[1];
			    }
			    else if(id=='C')
			    {
			       document.getElementById("ctl00_ContentPlaceHolder1_hdnpc").value=PriceId[1];
			    }
			     else if(id=='V')
			    {
			       document.getElementById("ctl00_ContentPlaceHolder1_hdnpv").value=PriceId[1];
			    }
			     Gettotalprice(pageid);
				}
			else {
					
			ig_.value ="Price not available";			
			}
			document.body.style.cursor = "auto";	
		}
		else {
					ig_.value = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
}



    function filllistbox(id)
    {

       if(id =="P")
       {
       var hhddfield =GetCookie("tempvarPV");
       var hhfieldtest=GetCookie("tempvarP");
       }
       else if(id =="E")
       {
       var hhddfield =GetCookie("tempvarEV");
           var hhfieldtest=GetCookie("tempvarE");
       }
       else if(id =="C")
       {
       var hhddfield =GetCookie("tempvarCV");
           var hhfieldtest=GetCookie("tempvarC");
       }
       else if(id =="V")
       {
       var hhddfield =GetCookie("tempvarVV");
       var hhfieldtest=GetCookie("tempvarV");
       }
      

        
    var ig_ = document.getElementById("ctl00_ContentPlaceHolder1_lstbxS"+id);

          if(hhddfield != null) 
			{	
		
                var hhfieldtext = hhfieldtest.split(",");
			    ig_.length = 0; 	
			
				for(i=0; i<hhfieldtext.length; i++) 
				{	
				    var arrSchmCode = hhddfield.split(",");
					ig_.options[i] = new Option();
					//alert(arrSchmCode[i])
					ig_.options[i].value = arrSchmCode[i];
					ig_.options[i].text = hhfieldtext[i];
				}
				
			}
 
	}
    
    // Cookie Get functiuon
    function GetCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

//setcookie
function fillhiddenfield(id,pageid)
{

 if(pageid !="2")
 {
 var hhddfield = document.getElementById("ctl00_ContentPlaceHolder1_hhdd"+id);
 var hhddfieldtext = document.getElementById("ctl00_ContentPlaceHolder1_hhdd"+id+"text");
 var ig_ = document.getElementById("ctl00_ContentPlaceHolder1_lstbxS"+id);
 }
 else
 {
  var hhddfield = document.getElementById("hhdd"+id);
  var hhddfieldtext = document.getElementById("hhdd"+id+"text");
  var ig_ = document.getElementById("lstbxS"+id);
 }

var i;
var opt,k='',t='';
for (i=0;i<ig_.length;i++)
{
opt=ig_.options[i];
k +=opt.value +"," ;
t +=opt.text +"," ;

}
 hhddfield.value=k.substring(0,k.length-1);
 hhddfieldtext.value=t.substring(0,t.length-1);

 if(id =="P")
 {
 SetCookie ("tempvarPV", hhddfield.value);
 SetCookie ("tempvarP", hhddfieldtext.value);

 }
else if(id =="E")
 {
  SetCookie ("tempvarEV", hhddfield.value);
 SetCookie ("tempvarE", hhddfieldtext.value);

 }
 else if(id =="C")
 {
  SetCookie ("tempvarCV", hhddfield.value);
 SetCookie ("tempvarC", hhddfieldtext.value);

 }
else if(id =="V")
 {
  SetCookie ("tempvarVV", hhddfield.value);
 SetCookie ("tempvarV", hhddfieldtext.value);

 }


 
 
}




function SetCookie(name, value) 
{
  var curCookie = name + "=" + escape(value) ;
     
  document.cookie = curCookie;
}



//end

    
 //For Checking Ascci code For text box
 function chkbox(id)
 {

 if(id != "0")
 {

 document.getElementById("ctl00_ContentPlaceHolder1_txtbusiness").style.display = 'none';
}
 else
  {
  document.getElementById("ctl00_ContentPlaceHolder1_txtbusiness").style.display = 'inline';
 }

 }
 
 
 function Removeitems(id ,pageid)
{

if(pageid != "2") 
 {
   var ig_ =document.getElementById("ctl00_ContentPlaceHolder1_lstbxS"+id );
   
  
 }
 else
 {
 var ig_ =document.getElementById("lstbxS"+id );
 }
  if(ig_.selectedIndex == -1)
  {
      //alert("Please select List item !");
  }
  else
  {
  ig_.options.remove(ig_.selectedIndex);
  GetPrice(id ,pageid);
  Gettotalprice(pageid);
  }
}


function Gettotalprice(pageid)
{
   if(pageid != "2") 
    {
       var priceP =document.getElementById("ctl00_ContentPlaceHolder1_txtpriceP").value;
       var priceE =document.getElementById("ctl00_ContentPlaceHolder1_txtpriceE" ).value;
       var priceC=document.getElementById("ctl00_ContentPlaceHolder1_txtpriceC").value;
       var priceV =document.getElementById("ctl00_ContentPlaceHolder1_txtpriceV" ).value;
       var TotalPrice =document.getElementById("ctl00_ContentPlaceHolder1_txttprice" );
       var hhpriceid =document.getElementById("ctl00_ContentPlaceHolder1_hhpriceids" );
     }
     else
     {
        var priceP =document.getElementById("txtpriceP").value;
        var priceE =document.getElementById("txtpriceE" ).value;
        var priceC=document.getElementById("txtpriceC").value;
        var priceV =document.getElementById("txtpriceV" ).value;
        var TotalPrice =document.getElementById("txttprice" );
        var hhpriceid =document.getElementById("hhpriceids" );
     
     }

    if(priceP == "" && priceE == "" && priceC == "" && priceV == "" )
    {
        //alert("Please select At least one section  !"); 
        //return false ;
    }
      var chkP= (priceP == "Price not available" || priceP == "") ? "0" : priceP;
      var chkE= (priceE == "Price not available" || priceE == "") ? "0" : priceE;
      var chkC= (priceC == "Price not available" || priceC == "") ? "0" : priceC;
      var chkV= (priceV == "Price not available" || priceV == "") ? "0" : priceV;
       
       TotalPrice.value= parseFloat(chkP) + parseFloat(chkE)+ parseFloat(chkC)+ parseFloat(chkV) ;
        //hhpriceid.value=global;
        
        hhpriceid.value =document.getElementById("ctl00_ContentPlaceHolder1_hdnpp").value +","+ document.getElementById("ctl00_ContentPlaceHolder1_hdnpe").value +","+ document.getElementById("ctl00_ContentPlaceHolder1_hdnpc").value+","+ document.getElementById("ctl00_ContentPlaceHolder1_hdnpv").value;

     return true ;

}

function Getpayableamount()
{
   var TotalPrice =document.getElementById("ctl00_ContentPlaceHolder1_txttprice" ).value;
   var Payprice =document.getElementById("ctl00_ContentPlaceHolder1_txtpayableamut" );
    var Disprice =document.getElementById("ctl00_ContentPlaceHolder1_txtdiscount" ).value;
   if(TotalPrice == "" )
    {
    alert("First take Total Price !"); 
    return false ;
    }
    var disamut= ( Disprice == "") ? "0" : Disprice;
    Payprice.value= parseFloat(TotalPrice)- parseFloat(Disprice);
   document.getElementById("ctl00_ContentPlaceHolder1_hhddpayamt" ).value =Payprice.value;
    return true ;
}
function Checkvalue1()
{
    fillhiddenfield('P','1')
              fillhiddenfield('E','1')
              fillhiddenfield('C','1')
              fillhiddenfield('V','1')
}



var XmlHttpclientPage;

function CreateXmlHttpPage()
{
	try
	{
		XmlHttpclientPage = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpclientPage = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpclientPage = null;				
		}
	}
	if(!XmlHttpclientPage && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpclientPage = new XMLHttpRequest();
	}
}



function LoadPage(id)
 {
 
 
   if(id=='1')
   {
      //alert('Do you Want to update');
      
      var r=confirm('Do you Want to update');
if (r==true)
alert("Update"); 
else
alert("Cancel"); 

   }

     CreateXmlHttpPage();
	 //document.body.style.cursor = "progress";

     var requestUrl = "AjaxSMSAdminClentReport.aspx";


	if(XmlHttpclientPage)	
	       {

				XmlHttpclientPage.onreadystatechange = function()
				{
				LoadPageresponce()
				}
				XmlHttpclientPage.open("GET", requestUrl,  true);
				XmlHttpclientPage.send(null);
			}
			

}



function LoadPageresponce()
{
  var strData =document.getElementById('tdclientreport');
 //alert(strData);
	if(XmlHttpclientPage.readyState == 4)
	{

		if(XmlHttpclientPage.status == 200)
		{		
			//alert(XmlHttpclientPage.responseText);
			strData.innerHTML = XmlHttpclientPage.responseText;
       	
		}
		else 
		{
					strData.value = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
	return true;
}







var XmlHttpservicePage;

function CreateXmlHttpServicePage()
{
	try
	{
		XmlHttpservicePage = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpservicePage = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpservicePage = null;				
		}
	}
	if(!XmlHttpservicePage && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpservicePage = new XMLHttpRequest();
	}
}



function LoadservicePage()
 {

//alert("KK");
     CreateXmlHttpServicePage();
	 //document.body.style.cursor = "progress";

     var requestUrl = "AjaxSMSAdminService.aspx";


	if(XmlHttpservicePage)	
	       {

				XmlHttpservicePage.onreadystatechange = function()
				{
				LoadservicePageresponce()
				}
				XmlHttpservicePage.open("GET", requestUrl,  true);
				XmlHttpservicePage.send(null);
			}
}



function LoadservicePageresponce()
{
  var strData =document.getElementById("tdsmsreport");

	if(XmlHttpservicePage.readyState == 4)
	{

		if(XmlHttpservicePage.status == 200)
		{		
			
			 strData.innerHTML = XmlHttpservicePage.responseText;
       	
		}
		else 
		{
					strData.value = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
	return true;
}







function popupWindow(id)
{
 
  
   var url="SMSEditContact.aspx?Clientid="+id;
   window.open(url,'ContentManagement','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=yes,copyhistory=no,width=600px,height=580px,screenX=0,screenY=0,left=250,top=100');
  
 
  
  
}



var XmlHttppagingPage;

function CreateXmlHttppagingPage()
{
	try
	{
		XmlHttppagingPage = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttppagingPage = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttppagingPage = null;				
		}
	}
	if(!XmlHttppagingPage && typeof XMLHttpRequest != "undefined")
	{
		XmlHttppagingPage = new XMLHttpRequest();
	}
}


function Paging(pageno,Total,CurrentsrNo)
 {


     CreateXmlHttppagingPage();
	 //document.body.style.cursor = "progress";

     var requestUrl = "AjaxSMSAdminService.aspx?pageno="+pageno+"&Total="+Total+"&CurrentsrNo="+CurrentsrNo;


	if(XmlHttppagingPage)	
	       {

				XmlHttppagingPage.onreadystatechange = function()
				{
			       pagingresponce()
				}
				XmlHttppagingPage.open("GET", requestUrl,  true);
				XmlHttppagingPage.send(null);
			}
}



function pagingresponce()
{
  var strData =document.getElementById("tdsmsreport");

	if(XmlHttppagingPage.readyState == 4)
	{

		if(XmlHttppagingPage.status == 200)
		{		
			
			 strData.innerHTML = XmlHttppagingPage.responseText;
       	
		}
		else 
		{
					strData.value = "server is not ready";
					document.body.style.cursor = "auto";		
		}
	}
	return true;
}



function popupServiceWindow(clientid,srno)
{
  var url="SMSEditServicetype.aspx?clientid="+clientid +"&srno="+srno;
   window.open(url,'ContentManagement','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=600px,height=580px,screenX=0,screenY=0,left=250,top=100');
}

function Print(srno , rpttype, redirectid)
{

   var url ="PerformaInvoice.aspx?srno="+srno+"&rpttype="+rpttype;
   var Newwin=window.open(url,'ContentManagement','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=900px,height=600px,screenX=0,screenY=0,left=100,top=100');
   Newwin.focus();
   if(rpttype =="P")
   {
    if(redirectid == "0")
        window.parent.document.location.href = "SMSSubSuccess.aspx";
    else
        window.parent.document.location.href="AdminSMSSubSuccess.aspx";
    Newwin.focus();
   }
 
  
}
function ShowInvoice(srno , rpttype)
{
   var url ="PerformaInvoice.aspx?srno="+srno+"&rpttype="+rpttype;
   var Newwin=window.open(url,'ContentManagement','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=900px,height=600px,screenX=0,screenY=0,left=100,top=100');
   Newwin.focus();
}




 function CheckSpaceAndValue(ctlid, e)//not allow first sapce, digits 
    { //alert("");
        var ctl = document.getElementById(ctlid);
        k =(e.which)? e.which : e.keyCode;
       
        if(ctl.value.length == 0 && k == 32)
        {
            return false;
        }
        
        if((k > 64 && k < 91)|| (k > 96 && k < 123) || (k == 46)||k == 32)
		{
			return true;
	    }
	    else
	        return false;
        
       // return checkalphadegit(e);
    } 












function CheckSpChar(e)//Allows Alphabets and space, '(', ')' only 
{
    var key_code =(e.which)? e.which : e.keyCode;
    
        if((key_code > 64 && key_code < 91)|| (key_code > 96 && key_code < 123) || (key_code == 32) || (key_code == 40)|| (key_code == 41))
        {		
		   return true;
        }
        else
		    return false;	

}  
function CheckChar(e)//Allows Alphabets and space only 
{
    var key_code =(e.which)? e.which : e.keyCode;
    
        if((key_code > 64 && key_code < 91)|| (key_code > 96 && key_code < 123) || (key_code == 46))
        {		
		   return true;
        }
        else
		    return false;	

}  
function CheckAlphaSpace(e)//Allows Alphabets and space only ...New made by ashok
{
    var key_code =(e.which)? e.which : e.keyCode;
    
        if((key_code > 64 && key_code < 91)|| (key_code > 96 && key_code < 123) || (key_code == 32))
        {		
		   return true;
        }
        else
		    return false;	

}
function CheckAlphaSpaceDegit(e)//Allows Alphabets, Digit and space only ...New made by ashok
{   
    if(CheckAlphaSpace(e) || checkDigit(e))
        return true;
    else
	    return false;
}
function checkalphadegit_Email(e)
{   
    var isalpha = CheckChar(e);    
    
    var isdigit = checkDigit(e);
    
    var key_code =(e.which)? e.which : e.keyCode;
         
    if(isalpha || isdigit || (key_code == 95))
        return true;
    else
        return false;
}

function checkHeader(ctlid, e)//Allows no first space, alphabetes, digits, space, '(', ')' only....
{   
    if(!checkForFirstSpace(ctlid, e))
        return false;           
  
    return (CheckSpChar(e) || checkDigit(e));
}
function checkForFirstSpace(ctlid, e)//Allows no first space...
{
    var ctl = document.getElementById(ctlid);
    k =(e.which)? e.which : e.keyCode;
   
    if(ctl.value.length == 0 && k == 32)
        return false;
    else
        return true;
}

function checkalphadegit(e)//Allows alphabetes, digits, space, '(', ')' only.
{   
    var isalpha = CheckSpChar(e);    
    
    var isdigit = checkDigit(e);
         
    if(isalpha || isdigit)
        return true;
    else
        return false;
}
function checkalphadigitdotslash(e)//Allows alphabetes, digits, space, dot("."), slash("/"), comma(",") , braces("(", ")").  //This check can be used for address 
{ 
    key_code =(e.which)? e.which : e.keyCode;
       
    var isalphadigit = checkalphadegit(e);
    
    if((key_code > 43 && key_code < 48) || isalphadigit)
        return true;
    else
        return false;
}

function ChangeDateFormat(date, currentformat, currentformatCharacter, newformat, newformatCharacter)//To Change DateFormat
{
    if(currentformat == newformat)
        return date;
    
    if(currentformatCharacter == newformatCharacter)
        return date;
    
    if(!(date == null || date == ""))
    {
        var datemembers = date.split(currentformatCharacter);
        
        var currentFormat = currentformat.split(currentformatCharacter);
        var newFormat = newformat.split(newformatCharacter);
        
        var length = currentFormat.length;
        
        var newDate = "";
        for(var i = 0; i < length; i++)
        {
            for(var j = 0; j < length; j++)
            {
                if(currentFormat[j] == newFormat[i])
                {
                    if(i == (length - 1))
                        newDate = newDate + datemembers[j]
                    else
                        newDate = newDate + datemembers[j] + newformatCharacter;
                }
            }
        }
        
        return newDate;
    }
    
    return date;
}

function checkURL(e)//Allows alphabates, digits, dot, slash, colon, &, =, underscore(_), %, @
{
    key_code =(e.which)? e.which : e.keyCode;
        
    var isalpha = CheckSpChar(e);
        
    var isdigit = checkDigit(e);
         
    if((isalpha || isdigit || key_code == 95 || key_code == 46 || key_code == 47 || key_code == 64 || key_code == 37 || key_code == 38 || key_code == 61 || key_code == 63 || key_code == 58) && (key_code != 32))
        return true;
    else
        return false;
}
function checkaldgudscdot(e)//Allows alphabates, digits, dot, underscore
{
    key_code =(e.which)? e.which : e.keyCode;
    
    var isalphadegit = checkalphadegit(e);
    
    if((isalphadegit || key_code == 95 || key_code == 46) && (key_code != 32))
        return true;
    else
        return false;
}

function checkalphadegitslash(e)//Allows alphabates, digits, space, slash
{
    key_code =(e.which)? e.which : e.keyCode;
        
    var isalphadigit = checkalphadegit(e);
    
    if(key_code == 47 || isalphadigit)
        return true;
    else
        return false;
}
function checkDigitDot(e)//Allows digits and dot only
{         
    var kcode =(e.which)? e.which : e.keyCode;        
   
    var isdigit = checkDigit(e);     
       
    if(isdigit || kcode == 46)
        return true;
    else
        return false;
}      
/*below is function for checking required field.(Required field validation). This function has 2 parameters.
1  parameter is control name and other is the error to be fired. */
      
 function required(objVal,strError)
 {
    var objValue=document.getElementById(objVal);
    
     if(eval(objValue.value.trim().length) == 0 ) 
     {
         if(!strError || strError.length ==0) 
         {
            alert(objValue.name + " : Required Field");  
            objValue.focus();  
            return false;         
         }
      
         alert(strError);
         objValue.focus(); 
         return false;            
     }

     return true; 
 }
 /*below is function to restrict user from selecting specified number of data in dropdown. This function has 3 parameters.
1  parameter is control name, 2 one is index number in dropdown and 3rd one is the error to be fired. */
         
 function dontselect(objVal,indexNo,strError)
 {
    var objValue=document.getElementById(objVal);
    var finalerr="";
    if(objValue.selectedIndex == null) 
    { 
        finalerr="BUG: dontselect command for non-select Item";            
    }
    
    if(objValue.selectedIndex == eval(indexNo)) 
    { 
        if(!strError || strError.length ==0) 
          { 
            strError = objValue.name+": Please Select one option "; 
          }//if   
      
        finalerr=strError;                
    }
    if(finalerr.length != 0) 
    {
        alert(finalerr);
        objValue.focus();  
        return false;
    }
    return true; 
}
/*To Hide Show control, pass control id and status to be set for control i.e. to Show:1, Hide:0 */
function hide(ctltohide, status)
{
    if(status)
    {
        //ctltohide.style.visibility = "visible";
        ctltohide.style.display = '';
    }
    else
    {
        //ctltohide.style.visibility = "hidden";
        ctltohide.style.display = 'none';
   
    }
}
 //below is function for validation of email. 
  
function email(objVal,strError)
{
    objValue=document.getElementById(objVal);
    if(!validateEmailv2(objValue.value)) 
    { 
      if(!strError || strError.length ==0) 
     { 
        strError = objValue.name+": Enter a valid Email address "; 
     }//if 
     alert(strError);
     objValue.focus();  
     return false;
    } 
    
    return true;         
}
//below function is for validation of email. this function is called in other function email below
function validateEmailv2(email)
{
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null) 
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}
var XmlHttpSendMessage;
function CreateXmlHttpSendMessage()
{
	try
	{
		XmlHttpSendMessage = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpSendMessage = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpSendMessage = null;				
		}
	}
	if(!XmlHttpSendMessage && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpSendMessage = new XMLHttpRequest();
	}
}

function SendMessageToClient(mobile,message)
{
    CreateXmlHttpSendMessage();
//    alert(mobile);
//    alert(message);
    
      //var requestUrl ="http://66.235.184.9:8800/?user=netw18&password=cc123&PhoneNumber="+mobile+"&Text="+message+"&Sender=Commodity Control&ReceiptRequested=Yes";
      
      
      
      if(XmlHttpSendMessage)	{

				    XmlHttpSendMessage.onreadystatechange = function(){SendMessageReasponse()}
				    XmlHttpSendMessage.open("GET", requestUrl,  true);
				    XmlHttpSendMessage.send(null);
			       }
      
  
}
function SendMessageReasponse()
{
  
  if(XmlHttpSendMessage.readyState == 4)
	{
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpSendMessage.status == 200)
		 {		
			//alert(ig_)
			//var availSchemes   = document.getElementById(ig_);
			 XmlHttpSendMessage.responseText;  
         }
     }
}




            function ShowMenu(id)
            {
              var hdnmenu=document.getElementById("ctl00_hdnshowmenu").value;   
              var LinkId = hdnmenu.split(",");
                
                   if(hdnmenu!="")
                  {
                        for(i=0;i<LinkId.length;i++)
                        {
                           // if(LinkId[i].indexOf(ModuleId)==-1 && document.getElementById(LinkId[i])!=null)
                           //alert(LinkId[i]);
                                document.getElementById(LinkId[i]).style.display="inline";
                                document.getElementById("link"+LinkId[i]).className="MnenuLink1";
                        }
                  }
                  showmnu1(id);
                 
            
            }
            
//            function selectmenu()
//            {
//               var hdnmenu=document.getElementById("ctl00_hdnshowmenu").value;   
//              var LinkId = hdnmenu.split(",");
//            
//                   if(hdnmenu!="")
//                  {
//                        for(i=0;i<LinkId.length;i++)
//                        {
//                           if(id==LinkId[i])
//                           {
//                               document.getElementById("link"+LinkId[i]).className="LblLink";
//                               //document.getElementById("ctl00_hdnlinkid").value="link"+LinkId[i];
//                           }
//                           else
//                           {
//                              document.getElementById("link"+LinkId[i]).className="MnenuLink1";
//                             
//                           }
//                              //  document.getElementById(LinkId[i]).style.display="inline";
//                        }
//                  }
//            }
 
 
 function showmnu1(id)
{				
//    var ig_a=document.location.search.substring(1);	
//   
//    var ig_b=ig_a.split("=");	

//    if(ig_b!="")
//    {

//      var ig_result=ig_b[1].split(",");
//      
//       var ig_p =ig_result[0].split("&");
      if(id!="")
      {
        // alert(id);
         document.getElementById("link"+id).className="LblLink";
          document.getElementById("link"+id).href="#";
      }
        
    }
    
    
    		
    		

 var XmlHttpstate;
function CreateXmlHttpstate()
{
	try
	{
		XmlHttpstate = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpstate = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpstate = null;				
		}
	}
	if(!XmlHttpstate && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpstate = new XMLHttpRequest();
	}
}

function Getstatevalue(id)
{
  if(id!="")
    {
     // alert();
     Getcityvalue('');
    }
  
  
  document.getElementById("txtlocality").value="Enter Region";
  
   var requestUrl;
   requestUrl="ajaxstatedata.aspx?time=" + new Date().getTime()+"&country="+id;
     
      
      
      CreateXmlHttpstate();
      if(XmlHttpstate)	{

				    XmlHttpstate.onreadystatechange = function(){SendstateResponse()}
				    XmlHttpstate.open("GET", requestUrl,  true);
				    XmlHttpstate.send(null);
			       }
      
  
  
}
function SendstateResponse()
{
  
  if(XmlHttpstate.readyState == 4)
	{
		//alert(XmlHttpSendMessage.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpstate.status == 200)
		 {		
		       var Data = XmlHttpstate.responseText;
		      var StartIndex = Data.indexOf('<div>');
		      var LastIndex = Data.lastIndexOf("</form>");
		 
            var MainData =  Data.substring(StartIndex,LastIndex);
		   // alert(MainData);
			document.getElementById("tdstate").innerHTML= MainData;  
			
         }
     }
}
 
  
  
 var XmlHttpcity;
function CreateXmlHttpcity()
{
	try
	{
		XmlHttpcity = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpcity = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpstate = null;				
		}
	}
	if(!XmlHttpcity && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpcity = new XMLHttpRequest();
	}
}

function Getcityvalue(id)
{
  CreateXmlHttpcity();
  
  if(id=="")
  {
     if(document.getElementById("ctl00_ContentPlaceHolder1_ddlregion")!=null)
     {
        var dropid= document.getElementById("ctl00_ContentPlaceHolder1_ddlregion");
        setblank(dropid);
     }
     
  }
  
  
   document.getElementById("txtlocality").value="Enter Region";
  
   var requestUrl;
   requestUrl="ajaxcitydata.aspx?time=" + new Date().getTime()+"&state="+id;
     
      
      
      
      if(XmlHttpcity)	{

				    XmlHttpcity.onreadystatechange = function(){SendcityResponse()}
				    XmlHttpcity.open("GET", requestUrl,  true);
				    XmlHttpcity.send(null);
			       }
      
  
}
function SendcityResponse()
{
  
  if(XmlHttpcity.readyState == 4)
	{
		//alert(XmlHttpSendMessage.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpcity.status == 200)
		 {		
		       var Data = XmlHttpcity.responseText;
		      var StartIndex = Data.indexOf('<div>');
		      var LastIndex = Data.lastIndexOf("</form>");
		 
            var MainData =  Data.substring(StartIndex,LastIndex);
		     //alert(MainData);
			document.getElementById("tdcity").innerHTML= MainData;  
			
         }
     }
}
 
var XmlHttpAddress;

function CreateXmlHttpAddress()
{
 try
	{
		XmlHttpAddress = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			XmlHttpAddress = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(oc)
		{
			XmlHttpAddress = null;				
		}
	}
	if(!XmlHttpAddress && typeof XMLHttpRequest != "undefined")
	{
		XmlHttpAddress = new XMLHttpRequest();
	}
}

function GetAddress(id)
{
  if(id=="0")
  {
      document.getElementById("tdaddress").style.display = 'none';
  }
  
   CreateXmlHttpAddress();
   
   document.getElementById("tdaddress").style.display = 'inline';
   document.getElementById("tdaddress").innerHTML="<img src='../Images/autocomplete_spinne.gif' alt =''>";
  
   var requestUrl;
   requestUrl="AjaxAddress.aspx?time=" + new Date().getTime()+"&pid="+id;
     
      //alert(requestUrl);
      
      
      if(XmlHttpAddress)	{

				    XmlHttpAddress.onreadystatechange = function(){GetAddressResponse()}
				    XmlHttpAddress.open("GET", requestUrl,  true);
				    XmlHttpAddress.send(null);
			       }
      
}

function GetAddressResponse()
{
     if(XmlHttpAddress.readyState == 4)
	{
		//alert(XmlHttpAddress.responseText);
		// To make sure valid response is received from the server, 200 means response received is OK
		if(XmlHttpAddress.status == 200)
		 {		
		       var Data = XmlHttpAddress.responseText;
		      var StartIndex = Data.indexOf('<div>');
		      var LastIndex = Data.lastIndexOf("</form>");
		 
            var MainData =  Data.substring(StartIndex,LastIndex);
		     //alert(MainData);
			document.getElementById("tdaddress").innerHTML= MainData;  
			
         }
     }
}



  function Popup(id)
  {
   //alert();
     var url;
     url="PopupFranchdetail.aspx?Franchiseecode="+id;
     window.open(url,"open" ,'toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=yes,copyhistory=no,width=780px,height=400px,screenX=0,screenY=0,left=100,top=100');
  }
  