function ValidateCamp()
{
	if(!document.getElementById("campname").value)
	{
		alert("Enter Valid Campaign Name.");
		return false;
	}	
     var iChars = /^[a-z A-Z 0-9]*$/;
     var val = document.getElementById("campname").value;
     if (!val.match(iChars)) {
     alert ("Invalid Campaign Name.");
     return false;
} 
if(!document.getElementById("comments").value){
            alert("Enter your comments");
            return false;
        }
	
   if(document.getElementById("startdate").value == ""){
            alert("Campaign Start date cannot be empty");
            return false;
        }
var start = document.getElementById('startdate').value;
var sarr = start.split('-');
var syr = parseInt( sarr[0] );
var smo = parseInt( sarr[1] );
var sday = parseInt( sarr[2] );

var end = document.getElementById('enddate').value;
var earr = end.split('-');
var eyr = parseInt( earr[0] );
var emo = parseInt( earr[1] );
var eday = parseInt( earr[2] );

var sDate = new Date(syr,smo-1,sday);
var today = new Date();
diff = sDate-today;
diff = Math.ceil(diff/1000/60/60/24);
if (diff < 0) {
   alert("Invalid Start Date. Please specify a date that is in the future and not the past.");
   return false
}
		if(document.getElementById("enddate").value == ""){
            alert("Campaign End date cannot be empty");
            return false;
        }


if(syr > eyr)
{
 alert("please pick an end year later than start year");
 return false;
}
if(eyr<=syr && smo > emo)
{
 alert("please pick an end month later than start month");
    return false;
}
if(emo<=smo && sday>eday)
{
 alert("please pick an end day later than start day");
    return false;
}
return true;
}
function inputcity()
{

if(document.getElementById("city1").value=="")
{
if(document.getElementById("city2").value=="")
{
if(document.getElementById("city3").value=="")
{
if(document.getElementById("city4").value=="")
{
if(document.getElementById("city5").value=="")
{
if(document.getElementById("city6").value=="")
{
if(document.getElementById("city7").value=="")
{
if(document.getElementById("city8").value=="")
{
if(document.getElementById("city9").value=="")
{
if(document.getElementById("city10").value=="")
{
alert("Enter atleast one city");
return false;
}
}
}
}
}
}
}
}
}
}
return true;
}

function submitLogin()
{	
	if (!document.getElementById("txtusername").value )
	{
		alert ('Enter Your Username');
		document.getElementById("txtusername").focus();
		return false;			
	}
	if (document.getElementById("txtpassword").value == "")
	{
		alert ('Enter the Password');
		document.getElementById("txtpassword").focus();
		return false;
	}	
	return true;
}

function ValidateBanner()
{
	if(!document.getElementById("bannername").value)
	{
		alert("Enter Banner Name");
		return false;
	}
	 
      var iChars = "!@#$%^*-.&()_+=[]\\\';,/{}|\":<>?";
    for (var i = 0; i < document.getElementById("bannername").value; i++) {
    if (iChars.indexOf(document.getElementById("bannername").value.charAt(i)) != -1) {
  	alert ("Enter Valid Banner Name.");
  	return false;
  	} 
  	}

	 if(document.getElementById("ban_image").value==""){
            alert("Upload your Banner image");
            return false;
        }

		 if((document.getElementById("comments").value=="Enter Your comments")||(document.getElementById("comments").value=="")){
            alert("Enter your comments");
            return false;
        } 

       if(document.getElementById("destination_url").value == ""){
            alert("Please enter a Destination URL to proceed.")
            return false;
        }
        var Url="^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&*,\+?\/.=]+$";
     var Url1="^www+\\.[A-Za-z0-9-_]+\\.[A-Za-z]+$";
    var tempURL=document.getElementById("destination_url").value;
    var matchURL=tempURL.match(Url);
    var matchURL1=tempURL.match(Url1);
     if(matchURL==null&&matchURL1==null)
     {
               alert(" Destination URL does not look valid");
               return false;
     }
	 if(document.getElementById("target").value == ""){
            alert("Please enter Target URL to proceed.")
            return false;
        }

	
        if(document.getElementById("height").value == ""){
            alert("Enter Banner height to proceed.")
            return false;
        }
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("height").value;
     if (!val.match(iChars)) {
     alert ("Invalid Banner Height.");
     return false;
} 
        if(document.getElementById("width").value == ""){
            alert("Enter Banner Width to proceed.")
            return false;
        }
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("width").value;
     if (!val.match(iChars)) {
     alert ("Invalid Banner Width.");
     return false;
} 
		if(document.getElementById("startdate").value == ""){
            alert("Banner Start date cannot not be empty")
            return false;
        }
var start = document.getElementById('startdate').value;
var sarr = start.split('-');
var syr = parseInt( sarr[0] );
var smo = parseInt( sarr[1] );
var sday = parseInt( sarr[2] );

var end = document.getElementById('enddate').value;
var earr = end.split('-');
var eyr = parseInt( earr[0] );
var emo = parseInt( earr[1] );
var eday = parseInt( earr[2] );

var sDate = new Date(syr,smo-1,sday);
var today = new Date();
diff = sDate-today;
diff = Math.ceil(diff/1000/60/60/24);
if (diff < 0) {
   alert("Invalid Start Date. Please specify a date that is in the future and not the past.");
   return false
}
		
		if(document.getElementById("enddate").value == ""){
            alert("Banner End date cannot be empty")
            return false;
        }
if(syr > eyr)
{
 alert("please pick an end year later than start year");
 return false;
}
if(eyr<=syr && smo > emo)
{
 alert("please pick an end month later than start month");
    return false;
}
if(emo<=smo && sday>eday)
{
 alert("please pick an end day later than start day");
    return false;
}
		
var EDate = document.getElementById("enddate").value;
var SDate = document.getElementById("startdate").value ;

 var endDate = new Date(EDate);    	
    var startDate= new Date(SDate);
     
       if(startDate > endDate)
    {
	    alert("End Date must be greater than or equal to  Start Date.");
	  //  document.getElementById(CtrlEDate).value = "";
	    return false;
    }

        if(document.getElementById("starttime").value == ""){
            alert("Banner starttime cannot be empty")
            return false;
        }

			var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))$/;
			var timeStr = document.getElementById("starttime").value;
			var matchArray = timeStr.match(timePat);
            if (matchArray == null) {
            alert(" Start Time is not in a valid format. \n Specify time in military format");
            return false;
            }
			hour = matchArray[1];
			minute = matchArray[2];
			second = matchArray[4];
			ampm = matchArray[6];

			if (second=="") 
			{ 
			second = null;
			}
			if (ampm=="") 
			{ 
			ampm = null 
			}

		if (hour < 0  || hour > 23) 
		{
		alert("Hour must be between  0 and 23. ");
		return false;
		}
		
		if  (hour > 12 && ampm != null)
		{
		alert("You can't specify AM or PM for military time.");
		return false;
		}
		if (minute<0 || minute > 59) 
		{
		alert ("Minute must be between 0 and 59.");
		return false;
		}
		if (second != null && (second < 0 || second > 59)) 
		{
		alert ("Second must be between 0 and 59.");
		return false;
		}
		        if(document.getElementById("endtime").value == ""){
            alert("Banner End Time cannot be empty")
            return false;
        }

	    var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))$/;
			var timeStr = document.getElementById("endtime").value;
			var matchArray = timeStr.match(timePat);
            if (matchArray == null) {
            alert(" End Time is not in a valid format \n Specify time in military format");
            return false;
            }
			hour = matchArray[1];
			minute = matchArray[2];
			second = matchArray[4];
			ampm = matchArray[6];

			if (second=="") 
			{ 
			second = null;
			}
			if (ampm=="") 
			{ 
			ampm = null 
			}

		if (hour < 0  || hour > 23) 
		{
		alert("Hour must be between 0 and 23");
		return false;
		}
		
		if  (hour > 12 && ampm != null)
		{
		alert("You can't specify AM or PM for military time.");
		return false;
		}
		if (minute<0 || minute > 59) 
		{
		alert ("Minute must be between 0 and 59.");
		return false;
		}
		if (second != null && (second < 0 || second > 59)) 
		{
		alert ("Second must be between 0 and 59.");
		return false;
		}
		}


//document.editbanner.submit();

   
function setfocus()
{
	document.getElementById("txtusername").focus();
}

function LoadPage(pageType)
{
	if (pageType == "Profile")
	{
		document.getElementById("contentFrame").src = 'personal.php';
	//	document.getElementById('displayHeadings').innerHTML = "PROFILE - PERSONAL INFORMATION >>  ";
		document.getElementById("contentFrame").style.height = "380";
		document.getElementById("contentFrame").style.width = "800";
	}
	else if  (pageType == "Campaign") 
	{
		document.getElementById("contentFrame").src = 'ClientCampaign.php';
		document.getElementById("contentFrame").style.height = "380";
		document.getElementById("contentFrame").style.width = "800";
	}
	else if  (pageType == "CallStatus") 
	{
		document.getElementById("contentFrame").src = 'ListCallCenter.php'; // ClientCallStatus.php';
		document.getElementById("contentFrame").style.height = "380";
		document.getElementById("contentFrame").style.width = "800";
	}
    else if  (pageType == "Report") 
	{
		document.getElementById("contentFrame").src = 'ListCallCenter.php?type=report'; //'ClientReport.php';
			document.getElementById("contentFrame").style.height = "380";
		document.getElementById("contentFrame").style.width = "800";
	}
	  else if  (pageType == "ViewReport") 
	{
		document.getElementById("contentFrame").src = 'AdminClients.php?type=report'; //'ClientReport.php';
			document.getElementById("contentFrame").style.height = "380";
		document.getElementById("contentFrame").style.width = "800";
	}
	else if (pageType == "CampManager")
	{
		document.getElementById("contentFrame").src = 'CampaignManager.php';
			document.getElementById("contentFrame").style.height = "380";
		document.getElementById("contentFrame").style.width = "800";
	}
	else if (pageType == "Stdcodes")
    document.getElementById("contentFrame").src = 'Inputstdcodes.php';
	else if (pageType == "ClManager")
    document.getElementById("contentFrame").src = 'ClientManager.php';
	else if (pageType == "AdminPro")
    document.getElementById("contentFrame").src = 'InputCity.php';
	else if (pageType == "report")
    document.getElementById("contentFrame").src = 'AdminClients.php?type=report';
	
}

//Trimming spaces
function trim(inputString) {
   
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} 
// Ends the "trim" function

function validateclient(type) {

//Begin Company Name Validation
if (type == "Add")
{
if(document.getElementById("clientname").value==""){
       alert("please enter your Name!!!");
        return false;
    }
    
    var s =document.getElementById("clientname").value;
    s = trim(s);
    document.getElementById("clientname").value = s;
	
   var iChars = /^[a-zA-Z ]*$/;
   var val = document.getElementById("clientname").value;
   if (!val.match(iChars)) {
  	alert ("Invalid Name.");
  	return false;
  	} 
}
	if(document.getElementById("contact").value==""){
       alert("please enter Contact Name!!!");
        return false;
    }
    
    var s =document.getElementById("contact").value;
    s = trim(s);
    document.getElementById("contact").value = s;
	
   var iChars = /^[a-zA-Z ]*$/;
   var val = document.getElementById("contact").value;
   if (!val.match(iChars)) {
  	alert ("Invalid Name.");
  	return false;
  	} 
  	
    if(document.getElementById("address").value == ""){
	alert("Please enter your Address !!!"); 
    return false;
    }
    
    var s =document.getElementById("address").value;
    s = trim(s);
    document.getElementById("address").value = s;

   var iChars = "!@$%^*()+=\\\;{}|\"<>&?";
   for (var i = 0; i < document.getElementById("address").value.length; i++) {
   if (iChars.indexOf(document.getElementById("address").value.charAt(i)) != -1) {
  	alert ("'Address' field accepts only alphabets, numeric values and special characters like  # . - : / ");
  	return false;
  	} 
  	}
   var a = document.getElementById("address").value.length;		
   var i=0;
   for(i=0; i<a; i++){
   if(i==0 && (document.getElementById("address").value.charCodeAt(i)==44 ||document.getElementById("address").value.charCodeAt(i)==45 ||document.getElementById("address").value.charCodeAt(i)==46 ||document.getElementById("address").value.charCodeAt(i)==95 ||document.getElementById("address").value.charCodeAt(i)==58||document.getElementById("address").value.charCodeAt(i)==47)){
	   	alert("OOps!!! Address cannot start with special characters except #");
	    return false;
   	}
  }
if (type == "Add")
{
if(document.getElementById("state").value == "------ Select State ------"){
	alert("Please select your State !!!");
    return false;
}

	if(document.getElementById("city").value == ""){
	alert("Please select your City !!!");
    return false;
    }
}

    var s =document.getElementById("zip").value;
    s = trim(s);
    document.getElementById("zip").value = s;
    
    if(document.getElementById("zip").value==""){
        alert("Please enter your zip code !!!");
        return false;
    }
    
   var iChars = "!@#$%^&*()-_+=[]\\\';,/{}|\":<>./?";
   for (var i = 0; i < document.getElementById("zip").value.length; i++) {
   if (iChars.indexOf(document.getElementById("zip").value.charAt(i)) != -1) {
  	alert ("Please check the 'Zip code' field as it accepts only numbers.");
  	return false;
  	} 
  	}
	
   
   var a = document.getElementById("zip").value.length;		
   var i=0;
   for(i=0; i<a; i++){
   if((document.getElementById("zip").value.charCodeAt(i)>=65 && document.getElementById("zip").value.charCodeAt(i)<=90) || (document.getElementById("zip").value.charCodeAt(i)>=97 && document.getElementById("zip").value.charCodeAt(i)<=122)){
	   	alert("Please check the 'Zip code' field as it accepts only numbers.!!!");
	    return false;
   	}
  }
	
	
   var ispec = " ";
   for (var i = 0; i < document.getElementById("zip").value.length; i++) {
   if (ispec.indexOf(document.getElementById("zip").value.charAt(i)) != -1) {
  	alert ("Please check the 'Zip code' field as it accepts only numbers.");
  	return false;
  	} 
  	}		
   

//End Zip Code Validation

var checkemail = CheckValidEmail(document.getElementById("email").value);
//alert(checkemail);
if (checkemail  == false)
{
	return false;
}
if(document.getElementById("website").value=="")
	{
		alert("Enter Your Website Address");
		return false;
		}
		   var Url="^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&*,\+?\/.=]+$";
     var Url1="^www+\\.[A-Za-z0-9-_]+\\.[A-Za-z]+$";
    var tempURL=document.getElementById("website").value;
    var matchURL=tempURL.match(Url);
    var matchURL1=tempURL.match(Url1);
     if(matchURL==null&&matchURL1==null)
     {
               alert(" Website URL does not look valid");
               return false;
     }
//Begin Phone Validation
 
	if(document.getElementById("phone").value=="")
		{
		alert("Enter your phone number.");
		return false;
		}
  	
  	var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
   for (var i = 0; i < document.getElementById("phone").value.length; i++) {
   if (iChars.indexOf(document.getElementById("phone").value.charAt(i)) != -1) {
  	alert ("Please check the 'Phone Number' field as it accepts only numbers");
  	return false;
  	} 
  	}
  

   var a = document.getElementById("phone").value.length;		
   var i=0;
   for(i=0; i<a; i++){
   if((document.getElementById("phone").value.charCodeAt(i)>=65 && document.getElementById("phone").value.charCodeAt(i)<=90) || (document.getElementById("phone").value.charCodeAt(i)>=97 && document.getElementById("phone").value.charCodeAt(i)<=122)){
	   	alert("Please check the 'Phone Number' field as it accepts only numbers");
	    return false;
   	}
  }
   
   var ispec = " ";
   for (var i = 0; i < document.getElementById("phone").value.length; i++) {
   if (ispec.indexOf(document.getElementById("phone").value.charAt(i)) != -1) {
  	alert ("Spaces Are Not Allowed In Phone number!!!");
  	return false;
  	} 
  	}
}
  	 
//End Phone Validation

function ValidateClientDetails()
{	
	if(document.getElementById("txtaddress").value == "")
		{
    	window.alert("Please enter your Address !!!"); 
    	return false;
    	}
    
    	var s =document.getElementById("txtaddress").value;
    	s = trim(s);
    	document.getElementById("txtaddress").value = s;

   		var iChars = "!@$%^*()+=\\\;{}|\"<>&?";
   		for (var i = 0; i < document.getElementById("txtaddress").value.length; i++)
		{
   		if (iChars.indexOf(document.getElementById("txtaddress").value.charAt(i)) != -1) 
			{
  		alert ("'Address' field accepts only alphabets, numeric values and special characters like  # . - : / ");
  		return false;
  			} 
  		}
   		var a = document.getElementById("txtaddress").value.length;		
   		var i=0;
   		for(i=0; i<a; i++)
		{
   		if(i==0 && (document.getElementById("txtaddress").value.charCodeAt(i)==44 ||document.getElementById("txtaddress").value.charCodeAt(i)==45 ||document.getElementById("txtaddress").value.charCodeAt(i)==46 ||document.getElementById("txtaddress").value.charCodeAt(i)==95 ||document.getElementById("txtaddress").value.charCodeAt(i)==58||document.getElementById("txtaddress").value.charCodeAt(i)==47))
			{
	   		alert("OOps!!! Address cannot start with special characters except #");
	    	return false;
   			}
		} 	

	
	if(document.getElementById("txtphonenumber").value=="")
		{
		alert("Enter your phone number.");
		return false;
		}  	
  	var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
   	for (var i = 0; i < document.getElementById("txtphonenumber").value.length; i++) 
		{
   	if (iChars.indexOf(document.getElementById("txtphonenumber").value.charAt(i)) != -1) 
			{
  	alert ("Please check the 'Phone Number' field as it accepts only numbers");
  	return false;
  			} 
  		} 
   var a = document.getElementById("txtphonenumber").value.length;		
   var i=0;
   for(i=0; i<a; i++)
   {
   if((document.getElementById("txtphonenumber").value.charCodeAt(i)>=65 && document.getElementById("txtphonenumber").value.charCodeAt(i)<=90) || (document.getElementById("txtphonenumber").value.charCodeAt(i)>=97 && document.getElementById("txtphonenumber").value.charCodeAt(i)<=122))
   		{
	   	alert("Please check the 'Phone Number' field as it accepts only numbers");
	    return false;
   		}
  	}   
   var ispec = " ";
   for (var i = 0; i < document.getElementById("txtphonenumber").value.length; i++) 
   {
   if (ispec.indexOf(document.getElementById("txtphonenumber").value.charAt(i)) != -1)
   		{
  	alert ("Spaces Are Not Allowed In Phone number!!!");
  	return false;
  		} 
  	}
	
	if(document.getElementById("txtmobilenumber").value=="")
		{
		alert("Enter your mobile number.");
		return false;
		}  	
  	var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
   	for (var i = 0; i < document.getElementById("txtmobilenumber").value.length; i++) 
		{
   	if (iChars.indexOf(document.getElementById("txtmobilenumber").value.charAt(i)) != -1) 
			{
  	alert ("Please check the 'Mobile Number' field as it accepts only numbers");
  	return false;
  			} 
  		} 
   var a = document.getElementById("txtmobilenumber").value.length;		
   var i=0;
   for(i=0; i<a; i++)
   {
   if((document.getElementById("txtmobilenumber").value.charCodeAt(i)>=65 && document.getElementById("txtmobilenumber").value.charCodeAt(i)<=90) || (document.getElementById("txtmobilenumber").value.charCodeAt(i)>=97 && document.getElementById("txtmobilenumber").value.charCodeAt(i)<=122))
   		{
	   	alert("Please check the 'Mobile Number' field as it accepts only numbers");
	    return false;
   		}
  	}   
   var ispec = " ";
   for (var i = 0; i < document.getElementById("txtmobilenumber").value.length; i++) 
   {
   if (ispec.indexOf(document.getElementById("txtmobilenumber").value.charAt(i)) != -1)
   		{
  	alert ("Spaces Are Not Allowed In mobile number!!!");
  	return false;
  		} 
  	}
	
	var checkTLD=1;

       var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
       var emailPat=/^(.+)@(.+)$/;
       var specialChars="\\(\\)>< @,;:\\\\\\\"\\.\\[\\]";
       var validChars="\[^\\s" + specialChars + "\]";
       var quotedUser="(\"[^\"]*\")";
       var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
       var atom=validChars + '+';
       var word="(" + atom + "|" + quotedUser + ")";
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
       var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
       var matchArray=(document.getElementById("txtemailid").value).match(emailPat);
        var s =(document.getElementById("txtemailid").value);
       s = trim(s);
      (document.getElementById("txtemailid").value) = s;
    if((document.getElementById("txtemailid").value)=="")
       {
       alert("Enter Email address!");
       return false;
       }
        var ispec = " ";
       for (var i = 0; i < (document.getElementById("txtemailid").value).length; i++) {
       if (ispec.indexOf((document.getElementById("txtemailid").value).charAt(i)) != -1) {
  	   alert ("Email ID cannot start with numbers, kindly check the Email Id field.");
  	   return false;
  	  } 
  	 }	
  	 
  	  var a = (document.getElementById("txtemailid").value).length;		
   var i=0;
   for(i=0; i<a; i++){
   if(i==0 && ((document.getElementById("txtemailid").value).charCodeAt(i)>=48 && (document.getElementById("txtemailid").value).charCodeAt(i)<=57)){
	   	alert("Email ID Cannot Start With Numbers");
	    return false;
   	}
  }
  	 
		 var iChars = "!#$%^&*()-+=[]\\\';,/{}|\":<>?";
   for (var i = 0; i < (document.getElementById("txtemailid").value).length; i++) {
   if (iChars.indexOf((document.getElementById("txtemailid").value).charAt(i)) != -1) {
  	alert ("Your 'Email ID' seems to be invalid, \nremove uppercase alphabets and any special characters excluding _ , . and @ ");
  	return false;
  	} 
  	}
		 var a = (document.getElementById("txtemailid").value).length;		
         var i=0;
         for(i=0; i<a; i++){
        if((document.getElementById("txtemailid").value).charCodeAt(i)>=65 && (document.getElementById("txtemailid").value).charCodeAt(i)<=90){
	   	alert("Your 'Email ID' seems to be invalid, \nremove uppercase alphabets and any special characters excluding _ , . and @");
	    return false;
   	}
  }
  
      if((document.getElementById("txtemailid").value) != null && (document.getElementById("txtemailid").value)!="")
      {
       if (matchArray==null) {
       alert("Invalid Email Address.");
       return false;
       }
       var user=matchArray[1];
       var domain=matchArray[2];
       for (i=0; i<user.length; i++) {
       if (user.charCodeAt(i)>127) {
       alert("Ths username contains invalid characters.");
    	   return false;
          }
       }
       for (i=0; i<domain.length; i++) {
       if (domain.charCodeAt(i)>127) {
       alert("Ths domain name contains invalid characters.");
       	   return false;
          }
       }
       if (user.match(userPat)==null) {
       alert("The username doesn't seem to be valid.");
 		   return false;
       }
       var IPArray=domain.match(ipDomainPat);
       if (IPArray!=null) {
       for (var i=1;i<=4;i++) {
       if (IPArray[i]>255) {
       alert("Destination IP address is invalid!");
       	   return false;
          }
       }
       
       }
       var atomPat=new RegExp("^" + atom + "$");
       var domArr=domain.split(".");
       var len=domArr.length;
       for (i=0;i<len;i++) {
       if (domArr[i].search(atomPat)==-1) {
       alert("The domain name does not seem to be valid.");
	       return false;
          }
       }
       if (checkTLD && domArr[domArr.length-1].length!=2 &&
       domArr[domArr.length-1].search(knownDomsPat)==-1) {
       alert("The address must end in a well-known domain or two letter " + "country.");
	       return false;
       }
       if (len<2) {
       alert("This address is missing a hostname!");
	       return false;
       }
      }
return true;
}

function CheckValidEmail(fieldname)
{
		
//Begin Email1 Validation

//    var emailpat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
    var checkTLD=1;

       var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
       var emailPat=/^(.+)@(.+)$/;
       var specialChars="\\(\\)>< @,;:\\\\\\\"\\.\\[\\]";
       var validChars="\[^\\s" + specialChars + "\]";
       var quotedUser="(\"[^\"]*\")";
       var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
       var atom=validChars + '+';
       var word="(" + atom + "|" + quotedUser + ")";
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
       var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
       var matchArray=fieldname.match(emailPat);
        var s =fieldname;
       s = trim(s);
      fieldname = s;
    if(fieldname=="")
       {
       alert("Enter Email address!");
       return false;
       }
        var ispec = " ";
       for (var i = 0; i < fieldname.length; i++) {
       if (ispec.indexOf(fieldname.charAt(i)) != -1) {
  	   alert ("Email ID cannot start with numbers, kindly check the Email Id field.");
  	   return false;
  	  } 
  	 }	
  	 
  	  var a = fieldname.length;		
   var i=0;
   for(i=0; i<a; i++){
   if(i==0 && (fieldname.charCodeAt(i)>=48 && fieldname.charCodeAt(i)<=57)){
	   	alert("Email ID Cannot Start With Numbers");
	    return false;
   	}
  }
  	 
		 var iChars = "!#$%^&*()-+=[]\\\';,/{}|\":<>?";
   for (var i = 0; i < fieldname.length; i++) {
   if (iChars.indexOf(fieldname.charAt(i)) != -1) {
  	alert ("Your 'Email ID' seems to be invalid, \nremove uppercase alphabets and any special characters excluding _ , . and @ ");
  	return false;
  	} 
  	}
		 var a = fieldname.length;		
         var i=0;
         for(i=0; i<a; i++){
        if(fieldname.charCodeAt(i)>=65 && fieldname.charCodeAt(i)<=90){
	   	alert("Your 'Email ID' seems to be invalid, \nremove uppercase alphabets and any special characters excluding _ , . and @");
	    return false;
   	}
  }
  
      if(fieldname != null && fieldname!="")
      {
       if (matchArray==null) {
       alert("Invalid Email Address.");
       return false;
       }
       var user=matchArray[1];
       var domain=matchArray[2];
       for (i=0; i<user.length; i++) {
       if (user.charCodeAt(i)>127) {
       alert("Ths username contains invalid characters.");
    	   return false;
          }
       }
       for (i=0; i<domain.length; i++) {
       if (domain.charCodeAt(i)>127) {
       alert("Ths domain name contains invalid characters.");
       	   return false;
          }
       }
       if (user.match(userPat)==null) {
       alert("The username doesn't seem to be valid.");
 		   return false;
       }
       var IPArray=domain.match(ipDomainPat);
       if (IPArray!=null) {
       for (var i=1;i<=4;i++) {
       if (IPArray[i]>255) {
       alert("Destination IP address is invalid!");
       	   return false;
          }
       }
       
       }
       var atomPat=new RegExp("^" + atom + "$");
       var domArr=domain.split(".");
       var len=domArr.length;
       for (i=0;i<len;i++) {
       if (domArr[i].search(atomPat)==-1) {
       alert("The domain name does not seem to be valid.");
	       return false;
          }
       }
       if (checkTLD && domArr[domArr.length-1].length!=2 &&
       domArr[domArr.length-1].search(knownDomsPat)==-1) {
       alert("The address must end in a well-known domain or two letter " + "country.");
	       return false;
       }
       if (len<2) {
       alert("This address is missing a hostname!");
	       return false;
       }
      }

//End Email1 Validation

}
function UpdatePassword()
{
	if (document.getElementById('txtcurrentpwd').value == "")
	{
		alert('Enter the Current Password .');
		return false
	}
	if (document.getElementById('txtnewpwd').value == "")
	{
		alert('New Password is Empty.');
		return false
	}
	if (document.getElementById('txtconfirmpwd').value == "")
	{
		alert('Confirm New Password is Empty.');
		return false
	}
	if (document.getElementById('txtconfirmpwd').value.length != document.getElementById('txtnewpwd').value.length)
	{
		alert('The New Password and Confirm New Password does not Match !')
		return false;
	}
	else if (document.getElementById('txtnewpwd').value != document.getElementById('txtconfirmpwd').value)
	{
		alert('The Passwords does not Match !')
		return false;
	}
	//document.changepassword.submit();
	//return true;
}

function ValidateCallCenterUpdate()
{	
	if(document.getElementById("txtlocation").value == "")
		{			
    	alert("Please enter your Location !!!"); 
    	return false;
    	}
    
    	var s =document.getElementById("txtlocation").value;
    	s = trim(s);
    	document.getElementById("txtlocation").value = s;

   		var iChars = "!@$%^*()+=\\\;{}|\"<>&?";
   		for (var i = 0; i < document.getElementById("txtlocation").value.length; i++)
		{
   		if (iChars.indexOf(document.getElementById("txtlocation").value.charAt(i)) != -1) 
			{
  		alert ("'Location' field accepts only alphabets, numeric values and special characters like  # . - : / ");
  		return false;
  			} 
  		}
   		var a = document.getElementById("txtlocation").value.length;		
   		var i=0;
   		for(i=0; i<a; i++)
		{
   		if(i==0 && (document.getElementById("txtlocation").value.charCodeAt(i)==44 ||document.getElementById("txtlocation").value.charCodeAt(i)==45 ||document.getElementById("txtlocation").value.charCodeAt(i)==46 ||document.getElementById("txtlocation").value.charCodeAt(i)==95 ||document.getElementById("txtlocation").value.charCodeAt(i)==58||document.getElementById("txtlocation").value.charCodeAt(i)==47))
			{
	   		alert("OOps!!! Location field cannot start with special characters except #");
	    	return false;
   			}
		} 		

	if(document.getElementById("txtebpxno").value=="")
			{
			alert("Enter your EBPX Number.");
			return false;
			}  	
		var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
		for (var i = 0; i < document.getElementById("txtebpxno").value.length; i++) 
			{
		if (iChars.indexOf(document.getElementById("txtebpxno").value.charAt(i)) != -1) 
				{
		alert ("Please check the 'EBPX Number' field as it accepts only numbers");
		return false;
				} 
			} 
	   var a = document.getElementById("txtebpxno").value.length;		
	   var i=0;
	   for(i=0; i<a; i++)
	   {
	   if((document.getElementById("txtebpxno").value.charCodeAt(i)>=65 && document.getElementById("txtebpxno").value.charCodeAt(i)<=90) || (document.getElementById("txtebpxno").value.charCodeAt(i)>=97 && document.getElementById("txtebpxno").value.charCodeAt(i)<=122))
			{
			alert("Please check the 'EBPX Number' field as it accepts only numbers");
			return false;
			}
		}   
	   var ispec = " ";
	   for (var i = 0; i < document.getElementById("txtebpxno").value.length; i++) 
	   {
	   if (ispec.indexOf(document.getElementById("txtebpxno").value.charAt(i)) != -1)
			{
		alert ("Spaces Are Not Allowed In EBPX Number!!!");
		return false;
			} 
		}
}

function CheckClientLogin(type)
{
if (document.getElementById('contactname').value == "")
	{
		alert('Enter the Contact Name .');
		return false
	}

var checkemail = CheckValidEmail(document.getElementById("email").value);
if (checkemail  == false)
{
	return false;
}



if (document.getElementById('username').value == "")
	{
		alert('Username should not be empty .');
		return false
	}

if (document.getElementById('password').value == "")
	{
		alert('Enter the Password .');
		return false
	}
	if(type=='add')
{
	if (document.getElementById('password').value.length != document.getElementById('repassword').value.length)
	{
		alert('Both the Passwords does not Match !')
		return false;
	}
	else if (document.getElementById('password').value != document.getElementById('repassword').value)
	{
		alert('The Passwords does not Match !')
		return false;
	}
}
if(!document.getElementById('isclientmanager').checked)
{

if(document.getElementById('callcenter').value == "0"){
alert(" Select Branch Name to Proceed .. ");
return false;
}
var selIndex = document.getElementById('callcenter').selectedIndex;
var byValue = document.getElementById('callcenter').options[selIndex].text;
if (byValue == "------ Select Branch ------" || byValue == "" || byValue == " ")
	{
		alert("Select the Branch .. ");
		return false;
	}

}	
//document.changepassword.submit();
	return true;
}

function LoadCity(state_id)
{
//alert(state_id);
var httpxml;
try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
		  try
   			 		{
   				 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
    				}
  			catch (e)
    				{
    			try
      		{
      		httpxml=new ActiveXObject("Microsoft.XMLHTTP");
     		 }
    			catch (e)
      		{
      		alert("Your browser does not support AJAX!");
      		return false;
      		}
    		}
  }
function stateck() 
    {
    if(httpxml.readyState==4)
      {
		  
document.getElementById("divcity").innerHTML=httpxml.responseText;
if (document.getElementById("divcity").innerHTML == "")
document.getElementById("divcity").innerHTML = '<select name="city" id="city" style="width:187px;" class="obj" onchange="LoadStdCode(this.value,0);"><option></option></select>';

      }
    }
	var url="loadCity.php";
url=url+"?state_id="+state_id;
//url=url+"&sid="+Math.random();
//alert(url);
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
  }


function LoadBannerCity(state_id)
{
//alert(state_id);
var httpxml;
try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  
		  try
   			 		{
   				 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
    				}
  			catch (e)
    				{
    			try
      		{
      		httpxml=new ActiveXObject("Microsoft.XMLHTTP");
     		 }
    			catch (e)
      		{
      		alert("Your browser does not support AJAX!");
      		return false;
      		}
    		}
  }
function stateck() 
    {
    if(httpxml.readyState==4)
      {
		  
document.getElementById("divcity").innerHTML=httpxml.responseText;
if (document.getElementById("divcity").innerHTML == "")
document.getElementById("divcity").innerHTML = '<select name="city" id="city" style="width:187px;" class="obj" onchange="LoadStdCode(this.value,1);"><option></option></select>';

      }
    }
	var url="loadBannerCity.php";
url=url+"?state_id="+state_id;
//url=url+"&sid="+Math.random();
//alert(url);
httpxml.onreadystatechange=stateck;
httpxml.open("GET",url,true);
httpxml.send(null);
  }




function ValidateBranch(type)
{
	if(document.getElementById("branchname").value==""){
	alert("Enter your Branch name.");
   return false;
	}
if(document.getElementById("epbx").value=="")
   {
	   alert("Call routing number cannot be empty");
	   return false;
	   }
	 var iChars = /^[a-zA-Z]*$/;
     var val = document.getElementById("epbx").value;
     if (val.match(iChars)) {
     alert ("Invalid Call routing number.");
	 return false;
	 }
	 if(document.getElementById("location").value==""){
	alert("Enter your Branch Loaction.");
	return false;
	}
	if (type == "Add")
{
	if(document.getElementById("state").value == "0"){
	alert("Please select your State !!!");
    return false;
    }
	
	if(document.getElementById("city").value == ""){
	alert("Please select your City !!!");
    return false;
    }
}

	
return true;
}

function ClearCity()
{
if(document.getElementById("city1").value !="")
{
	document.getElementById("city1").value = ""
	}

if(document.getElementById("std1").value !="")
{
	document.getElementById("std1").value = ""
	}

if(document.getElementById("city2").value !="")
{
	document.getElementById("city2").value = ""
	}

if(document.getElementById("std2").value !="")
{
	document.getElementById("std2").value = ""
	}

if(document.getElementById("city3").value !="")
{
	document.getElementById("city3").value = ""
	}
if(document.getElementById("std3").value !="")
{
	document.getElementById("std3").value = ""
	}

if(document.getElementById("city4").value !="")
{
	document.getElementById("city4").value = ""
	}
if(document.getElementById("std4").value !="")
{
	document.getElementById("std4").value = ""
	}

if(document.getElementById("city5").value !="")
{
	document.getElementById("city5").value = ""
	}
if(document.getElementById("std5").value !="")
{
	document.getElementById("std5").value = ""
	}
if(document.getElementById("city6").value !="")
{
	document.getElementById("city6").value = ""
	}
if(document.getElementById("std6").value !="")
{
	document.getElementById("std6").value = ""
	}
if(document.getElementById("city7").value !="")
{
	document.getElementById("city7").value = ""
	}	
if(document.getElementById("std7").value !="")
{
	document.getElementById("std7").value = ""
	}

if(document.getElementById("city8").value !="")
{
	document.getElementById("city8").value = ""
	}	
if(document.getElementById("std8").value !="")
{
	document.getElementById("std8").value = ""
	}
if(document.getElementById("city9").value !="")
{
	document.getElementById("city9").value = ""
	}	
if(document.getElementById("std9").value !="")
{
	document.getElementById("std9").value = ""
	}
	if(document.getElementById("city10").value !="")
{
	document.getElementById("city10").value = ""
	}	
if(document.getElementById("std10").value !="")
{
	document.getElementById("std10").value = ""
	}
}



function SortFields(byField,inForm,reField,reValue,passvalue)
{


if ((typeof(reValue) != "undefined"))
		{
			var reValue = document.getElementById(reValue).value;
		}


var httpxml;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
		httpxml=new XMLHttpRequest();
	
	}
	catch (e)  //catch 1
	  {
	  // Internet Explorer
			  try
				{
					 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch (e) // catch 2
				{
					try
					{
					httpxml=new ActiveXObject("Microsoft.XMLHTTP");
					 }
					catch (e) // catch 3
					{
					alert("Your browser does not support AJAX!");
					return false;
					}  // eo catch 3
				} // eo catch 2
       } // end of try catch 1

    
		function sortByField() 
		{
			if(httpxml.readyState==4)
			{
				document.getElementById("content").innerHTML=httpxml.responseText;
			  }
		} // eo function
	
	    var url="SortByField.php";
		url=url+"?byField="+byField;
		if (reValue != "")
		{
		url=url+"&reValue="+reValue;
		url=url+"&reField="+reField.value;
		
		}
		url=url+"&inForm="+ inForm;
		//url=url+"&sid="+Math.random();
        if (passvalue != "")
		url=url+"&passvalue="+ passvalue;
		
		//alert(url);
		httpxml.onreadystatechange=sortByField;
	    httpxml.open("GET",url,true);
	    httpxml.send(null);


}



function SearchData(byField,inForm,inValue,message,passvalue)
{
	
if (byField.value == "")
{
	return false;
}
var inValue = document.getElementById(inValue).value;
if (inValue == "")
{
	alert(message);
    return false;	
}
///alert(byField.value);
	var httpxml;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
		httpxml=new XMLHttpRequest();
	
	}
	catch (e)  //catch 1
	  {
	  // Internet Explorer
			  try
				{
					 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch (e) // catch 2
				{
					try
					{
					httpxml=new ActiveXObject("Microsoft.XMLHTTP");
					 }
					catch (e) // catch 3
					{
					alert("Your browser does not support AJAX!");
					return false;
					}  // eo catch 3
				} // eo catch 2
       } // end of try catch 1

    
		function sortByField() 
		{
			if(httpxml.readyState==4)
			{
				document.getElementById("content").innerHTML=httpxml.responseText;
			  }
		} // eo function
	
	   var url="SearchData.php";
		url=url+"?byField="+byField.value;
		url=url+"&inForm="+ inForm;
		if(passvalue != "")
		url=url+"&passvalue="+ passvalue;
		url=url+"&inValue="+ inValue;
		//url=url+"&sid="+Math.random();
//        alert(url);
		httpxml.onreadystatechange=sortByField;
	    httpxml.open("GET",url,true);
	    httpxml.send(null);

}
function check_availability( objid, loadarea )
{
  var myobj=document.getElementById(objid)
  var address_string = "./AddClientLogin.php?username=" + myobj.value
  ajaxpage(address_string, loadarea)
}	
 
function ajaxpage(url, c_id)
{
  var page_request = false
 
  if (window.XMLHttpRequest)     // if Mozilla, Safari etc
  {
    page_request = new XMLHttpRequest()
  }
  else if (window.ActiveXObject) // if IE
  {
    try
    {
      page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch (e)
    {
      try
      {
        page_request = new ActiveXObject("Microsoft.XMLHTTP")
      }
      catch (e){}
    }
  }
  else
    return false
 
  page_request.onreadystatechange=function()
  {
    loadpage(page_request, c_id)
  }
 
  anticache=(url.indexOf("?")!=-1) ?
            "&"+new Date().getTime() :
            "?"+new Date().getTime()
 
  page_request.open('GET', url+anticache, true)
  page_request.send(null)
}
 
function loadpage(page_request, c_id)
{
  if (page_request.readyState == 4 &&
          (page_request.status==200 ||
           window.location.href.indexOf("http")==-1))
  {
    document.getElementById(c_id).innerHTML=page_request.responseText
   }
}


function setCallStatus(byField,byValue,c_id,bannerid,campaignid,callcenterid,byMethod,type)
{
	
var url = "SetCallStatus.php";
  anticache=(url.indexOf("?")!=-1) ?
            "&bannerid="+bannerid+"&campaignid="+campaignid+"&callcenterid="+callcenterid+"&byMethod="+byMethod+"&byField="+byField.id+"&byValue="+byValue+"&type="+type :
            "?bannerid="+bannerid+"&campaignid="+campaignid+"&callcenterid="+callcenterid+"&byMethod="+byMethod+"&byValue="+byValue+"&byField="+byField.id+"&type="+type 
var hrefvalue = url + anticache;
window.location.href = hrefvalue;
}
 
function CheckBox()
{
if(!document.getElementById("isclientmanager").checked)
{
document.getElementById("callcenter").disabled = 0;
}
else
{
document.getElementById("callcenter").disabled = 1;
}
}


function SetCallRouting(clientid,callcenterid,state,centername,type)
{
	var ArrCities = new Array();
	var ArrOtherCities = new Array();
	var count = document.frmsetcallroute.elements.length;
	var c_id = document.getElementById("Message");
	var oc_id = document.getElementById("otherMessage");
	var ccount = 0;
	var occount = 0;
	//alert(c_id)			
 if (count>0)
 {
 for (i=0; i<count; i++){
     eType = document.forms[0].elements[i].type;
     eValue = document.forms[0].elements[i].value;
     if(eType == 'checkbox' && document.forms[0].elements[i].checked == true) 
	 {
		 if (document.forms[0].elements[i].name.indexOf("city_") != -1)	
		 {
			 var SplitResult = document.forms[0].elements[i].name.split("_");
			 //alert(SplitResult[1]+ callcenterid );	
			 ArrCities[ccount] = SplitResult[1];
			 ccount = ccount +1;
			 
		}
		else if (document.forms[0].elements[i].name.indexOf("cities_") != -1)
		{
			 var SplitResult = document.forms[0].elements[i].name.split("_");
			 //alert(SplitResult[1]+ callcenterid );	
			 ArrOtherCities[occount] = SplitResult[1];
			 occount = occount +1;

		}
	
      	}
 }
 		var cities= ArrCities.join(",");
		
		if (cities.length > 0 && type == "city")
		{
			var page_request = false
			if (window.XMLHttpRequest)     // if Mozilla, Safari etc
			{

			page_request = new XMLHttpRequest()
			}
			else if (window.ActiveXObject) // if IE
			{
			try
			{
				page_request = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e)
			{
			try
			{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
			}
			}
			else
			return false
			
			
			page_request.onreadystatechange=function()
			{
				SetPreCall(page_request, c_id)
			}
			var url = "SetPreDefinedCallRouting.php";
			anticache=(url.indexOf("?")!=-1) ?
			"&callcenter_id="+callcenterid+"&cities="+cities+"&state="+state+"&clientid="+clientid+"&center_name="+centername + "&type=city":
			"?callcenter_id="+callcenterid+"&cities="+cities+"&state="+state+"&clientid="+clientid+"&center_name="+centername + "&type=city"
			//alert(url+anticache)
			page_request.open('GET', url+anticache, true)
			page_request.send(null)
	//		alert(url+anticache);
		} // if cities
		else
		{
			c_id.style.display = "none";
		}

		var othercities= ArrOtherCities.join(",");
		
		if (othercities.length > 0 && type == "othercity")
		{
			var selIndex = document.getElementById('State').selectedIndex;
	
			var state = document.getElementById('State').options[selIndex].text;
			var page_request = false
			if (window.XMLHttpRequest)     // if Mozilla, Safari etc
			{

			page_request = new XMLHttpRequest()
			}
			else if (window.ActiveXObject) // if IE
			{
			try
			{
				page_request = new ActiveXObject("Msxml2.XMLHTTP")
			}
			catch (e)
			{
			try
			{
				page_request = new ActiveXObject("Microsoft.XMLHTTP")
			}
			catch (e){}
			}
			}
			else
			return false
			
			
			page_request.onreadystatechange=function()
			{
				SetPreCallOther(page_request, oc_id)
			}
			var url = "SetPreDefinedCallRouting.php";
			anticache=(url.indexOf("?")!=-1) ?
			"&callcenter_id="+callcenterid+"&othercities="+othercities+"&state="+state+"&clientid="+clientid+"&center_name="+centername + "&type=othercity" :
			"?callcenter_id="+callcenterid+"&othercities="+othercities+"&state="+state+"&clientid="+clientid+"&center_name="+centername + "&type=othercity"
			//alert(url+anticache)
			page_request.open('GET', url+anticache, true)
			page_request.send(null)
	//		alert(url+anticache);
		} // if cities
		else
		{
			oc_id.style.display = "none";
		}

//window.location.href = "SetPreDefinedCallRouting.php?callcenter_id="+callcenterid+"&cities="+cities+"&state=" + state+"&clientid="+clientid+"&center_name="+centername;
	 //formArray[i] = eType +" = " +"Checked\n";
 }

return false;
}
  
function SetPreCall(page_request, c_id)
{
  if (page_request.readyState == 4 &&
          (page_request.status==200 ||
           window.location.href.indexOf("http")==-1))
  {
	  //c_id.innerHTML=page_request.responseText;
	c_id.style.display = 'block';

	eval(c_id).innerHTML=page_request.responseText
   }
}

function SetPreCallOther(page_request, oc_id)
{
  if (page_request.readyState == 4 &&
          (page_request.status==200 ||
           window.location.href.indexOf("http")==-1))
  {
	  //c_id.innerHTML=page_request.responseText;
	oc_id.style.display = 'block';

	eval(oc_id).innerHTML=page_request.responseText
   }
}


function LoadStdCode(cityid,type)
{
	if (type > 0)
	{
	if (typeof(cityid) != "undefined" && cityid > 0)
	{
var httpxml;
try
  {
  // Firefox, Opera 8.0+, Safari
  httpxml=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
		  try
   			 		{
   				 httpxml=new ActiveXObject("Msxml2.XMLHTTP");
    				}
  			catch (e)
    				{
    			try
      		{
      		httpxml=new ActiveXObject("Microsoft.XMLHTTP");
     		 }
    			catch (e)
      		{
      		alert("Your browser does not support AJAX!");
      		return false;
      		}
    		}
  }
function stdck() 
    {
    if(httpxml.readyState==4)
      {

document.getElementById("std").value=httpxml.responseText;
//alert(cityid)
      }
    }
	var url="loadStdCode.php";
url=url+"?cityid="+cityid;
//url=url+"&sid="+Math.random();
//alert(url);
httpxml.onreadystatechange=stdck;
httpxml.open("GET",url,true);
httpxml.send(null);
	}
	}
	
}

function disable()
  {
  document.getElementById("status").disabled=0;
  }
function enable()
  {
  document.getElementById("status").disabled=1;
  }

function DisplayNumber(obj)
{
	
		if (obj == "isphone")
		{
			document.getElementById('mobile').value= 'Mobile Number';
			//document.getElementById('ismobile').checked = 0;
			//document.getElementById('divphone').style.display = 'block';
			//document.getElementById('divmobile').style.display = 'none';
			document.getElementById('mobile').disabled= true;
            document.getElementById('phone').disabled= false;
            document.getElementById('std').disabled= false;
			
		}
		else if (obj == "ismobile")
		{
			document.getElementById('phone').value = 'Phone Number';
            document.getElementById('std').value= 'STD Code'; 
			//document.getElementById('divmobile').style.display = 'block';
			//document.getElementById('divphone').style.display = 'none';
			document.getElementById('phone').disabled= true;
            document.getElementById('std').disabled= true;   
            document.getElementById('mobile').disabled= false;
			
		}
	
	/*else if (!obj.checked)
	{
		if (obj.name == "isphone")
		{
			
			//document.getElementById('divphone').style.display = 'none';
			document.getElementById('phone').value= '';
			document.getElementById('std').value= '';
		}
		else if (obj.name == "ismobile")
		{
			//document.getElementById('divmobile').style.display = 'none';
			document.getElementById('mobile').value= '';
			//document.getElementById('std')value= '';
		}
	}*/
}


function CheckClick2call()
{
	if (document.getElementById('name').value == "Name" || document.getElementById('name').value == " ")
	{
		alert("Enter Your Name !!"); 
		return false;
	}
	var selIndex = document.getElementById('state').selectedIndex;
	var byValue = document.getElementById('state').options[selIndex].text;
	if (byValue == "------ Select State ------" || byValue == "" || byValue == "Select State")
	{
		alert("Select the State .. ");
		return false;
	}
	var selIndex = document.getElementById('city').selectedIndex;
	var byValue = document.getElementById('city').options[selIndex].text;
	if (byValue == "----- Select City -----" || byValue == "" || byValue == "Select City")
	{
		alert("Select the City .. ");
		return false;
	}
	if (document.getElementById('mobile').disabled == false)
	{
		if (document.getElementById('mobile').value == "Mobile Number" || document.getElementById('mobile').value == "")
			{
				alert("Enter Your Mobile Number !!");
				return false;
			}
		var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
		for (var i = 0; i < document.getElementById("mobile").value.length; i++) 
			{
			if (iChars.indexOf(document.getElementById("mobile").value.charAt(i)) != -1) 
				{
				alert ("Please check the 'Mobile Number' field as it accepts only numbers");
				return false;
  				} 
  			}
	 	var a = document.getElementById("mobile").value.length;		
	    var i=0;
	    for(i=0; i<a; i++)
	   	{
	   		if((document.getElementById("mobile").value.charCodeAt(i)>=65 && document.getElementById("mobile").value.charCodeAt(i)<=90) || (document.getElementById("mobile").value.charCodeAt(i)>=97 && document.getElementById("mobile").value.charCodeAt(i)<=122))
			{
			alert("Please check the 'Mobile Number' field as it accepts only numbers");
			return false;
   			}
  		}   
  		var ispec = " ";
   		for (var i = 0; i < document.getElementById("mobile").value.length; i++) 
   		{
  			 if (ispec.indexOf(document.getElementById("mobile").value.charAt(i)) != -1)
   			{
  				alert ("Spaces Are Not Allowed In mobile number!!!");
  				return false;
  			} 
  		} 

	}
	if ((document.getElementById('isphone').disabled == false)&&(document.getElementById('std').disabled == false))
	{
			if (document.getElementById('phone').value == "Phone Number" || document.getElementById('phone').value == " ")
		{
			alert("Enter Your Phone Number !!");
			return false;
		}
		var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
   		for (var i = 0; i < document.getElementById("phone").value.length; i++) 
			{
   				if (iChars.indexOf(document.getElementById("phone").value.charAt(i)) != -1) 
				{
  				alert ("Please check the 'Phone Number' field as it accepts only numbers");
  				return false;
  				} 
  			} 
	   var a = document.getElementById("phone").value.length;		
	   var i=0;
	   for(i=0; i<a; i++)
			if (document.getElementById('std').value == "STD Code" || document.getElementById('std').value == " ")
			{
			alert("Enter the Std Code !!");
			return false;

			}
		var iChars = "!@#$%^-&*()_+=[]\\\';,./{}|\":<>?";
		for (var i = 0; i < document.getElementById("std").value.length; i++) 
			{
			if (iChars.indexOf(document.getElementById("std").value.charAt(i)) != -1) 
				{
				alert ("Please check the 'Std Code' field as it accepts only numbers");
				return false;
  				} 
  			}
	 	var a = document.getElementById("std").value.length;		
	    var i=0;
	    for(i=0; i<a; i++)
	   	{
	   		if((document.getElementById("std").value.charCodeAt(i)>=65 && document.getElementById("std").value.charCodeAt(i)<=90) || (document.getElementById("std").value.charCodeAt(i)>=97 && document.getElementById("std").value.charCodeAt(i)<=122))
			{
			alert("Please check the 'Std Code' field as it accepts only numbers");
			return false;
   			}
  		}   
	
	 var a = document.getElementById("phone").value.length;		
     var i=0;
     for(i=0; i<a; i++)
   {
   if((document.getElementById("phone").value.charCodeAt(i)>=65 && document.getElementById("phone").value.charCodeAt(i)<=90) || (document.getElementById("phone").value.charCodeAt(i)>=97 && document.getElementById("phone").value.charCodeAt(i)<=122))
   		{
	   	alert("Please check the 'Phone Number' field as it accepts only numbers");
	    return false;
   		}
  	}   
   var ispec = " ";
   for (var i = 0; i < document.getElementById("phone").value.length; i++) 
   {
   if (ispec.indexOf(document.getElementById("phone").value.charAt(i)) != -1)
   		{
  	alert ("Spaces Are Not Allowed In Phone number!!!");
  	return false;
  		} 
  	}
}
	if ((!document.getElementById('ismobile').checked) && (!document.getElementById('isphone').checked))
	{
				alert("Choose Your Contact Number Type  !!");
			return false;
	
	}
//return false;
}
function stdvalidation()
{
 if(!document.getElementById("std1").value == ""){
           
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std1").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std1").focus();
     return false;
} 
}
 if(!document.getElementById("std2").value == ""){
     
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std2").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std2").focus();
     return false;
} 
}
 if(!document.getElementById("std3").value == ""){
            
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std3").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std3").focus();
     return false;
} 
}
 if(!document.getElementById("std4").value == ""){
       
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std4").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std4").focus();
     return false;
} 
}
 if(!document.getElementById("std5").value == ""){
           
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std5").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std5").focus();
     return false;
} 
}
 if(!document.getElementById("std6").value == ""){
           
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std6").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std6").focus();
     return false;
} 
}
 if(!document.getElementById("std7").value == ""){
         
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std7").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std7").focus();
     return false;
} 
}
 if(!document.getElementById("std8").value == ""){
           
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std8").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std8").focus();
     return false;
}
} 
 if(!document.getElementById("std9").value == ""){
           
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std9").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std9").focus();
     return false;
} 
}
 if(!document.getElementById("std10").value == ""){
           
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("std10").value;
     if (!val.match(iChars)) {
     alert ("Invalid STD CODE.");
      document.getElemntById("std10").focus();
     return false;
} 
}
}
function clrdate()
{
if(!document.getElementById("enddate").value)
{
document.getElementById("enddate").value = "";
return false;
}
}
function ValidateEmail()
{
var checkTLD=1;

       var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
       var emailPat=/^(.+)@(.+)$/;
       var specialChars="\\(\\)>< @,;:\\\\\\\"\\.\\[\\]";
       var validChars="\[^\\s" + specialChars + "\]";
       var quotedUser="(\"[^\"]*\")";
       var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
       var atom=validChars + '+';
       var word="(" + atom + "|" + quotedUser + ")";
       var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
       var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
       var matchArray=(document.getElementById("txtuseremailid").value).match(emailPat);
        var s =(document.getElementById("txtuseremailid").value);
       s = trim(s);
      (document.getElementById("txtuseremailid").value) = s;
    if((document.getElementById("txtuseremailid").value)=="")
       {
       alert("Enter Email address!");
       return false;
       }
        var ispec = " ";
       for (var i = 0; i < (document.getElementById("txtuseremailid").value).length; i++) {
       if (ispec.indexOf((document.getElementById("txtuseremailid").value).charAt(i)) != -1) {
  	   alert ("Email ID cannot start with numbers, kindly check the Email Id field.");
  	   return false;
  	  } 
  	 }	
  	 
  	  var a = (document.getElementById("txtuseremailid").value).length;		
   var i=0;
   for(i=0; i<a; i++){
   if(i==0 && ((document.getElementById("txtuseremailid").value).charCodeAt(i)>=48 && (document.getElementById("txtuseremailid").value).charCodeAt(i)<=57)){
	   	alert("Email ID Cannot Start With Numbers");
	    return false;
   	}
  }
  	 
		 var iChars = "!#$%^&*()-+=[]\\\';,/{}|\":<>?";
   for (var i = 0; i < (document.getElementById("txtuseremailid").value).length; i++) {
   if (iChars.indexOf((document.getElementById("txtuseremailid").value).charAt(i)) != -1) {
  	alert ("Your 'Email ID' seems to be invalid, \nremove uppercase alphabets and any special characters excluding _ , . and @ ");
  	return false;
  	} 
  	}
		 var a = (document.getElementById("txtuseremailid").value).length;		
         var i=0;
         for(i=0; i<a; i++){
        if((document.getElementById("txtuseremailid").value).charCodeAt(i)>=65 && (document.getElementById("txtuseremailid").value).charCodeAt(i)<=90){
	   	alert("Your 'Email ID' seems to be invalid, \nremove uppercase alphabets and any special characters excluding _ , . and @");
	    return false;
   	}
  }
  
      if((document.getElementById("txtuseremailid").value) != null && (document.getElementById("txtuseremailid").value)!="")
      {
       if (matchArray==null) {
       alert("Invalid Email Address.");
       return false;
       }
       var user=matchArray[1];
       var domain=matchArray[2];
       for (i=0; i<user.length; i++) {
       if (user.charCodeAt(i)>127) {
       alert("Ths username contains invalid characters.");
    	   return false;
          }
       }
       for (i=0; i<domain.length; i++) {
       if (domain.charCodeAt(i)>127) {
       alert("Ths domain name contains invalid characters.");
       	   return false;
          }
       }
       if (user.match(userPat)==null) {
       alert("The username doesn't seem to be valid.");
 		   return false;
       }
       var IPArray=domain.match(ipDomainPat);
       if (IPArray!=null) {
       for (var i=1;i<=4;i++) {
       if (IPArray[i]>255) {
       alert("Destination IP address is invalid!");
       	   return false;
          }
       }
       
       }
       var atomPat=new RegExp("^" + atom + "$");
       var domArr=domain.split(".");
       var len=domArr.length;
       for (i=0;i<len;i++) {
       if (domArr[i].search(atomPat)==-1) {
       alert("The domain name does not seem to be valid.");
	       return false;
          }
       }
       if (checkTLD && domArr[domArr.length-1].length!=2 &&
       domArr[domArr.length-1].search(knownDomsPat)==-1) {
       alert("The address must end in a well-known domain or two letter " + "country.");
	       return false;
       }
       if (len<2) {
       alert("This address is missing a hostname!");
	       return false;
       }

}
}
function ValidateEditBanner()
{
if(document.getElementById("height").value == ""){
            alert("Enter Banner height to proceed.");
            return false;
        }
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("height").value;
     if (!val.match(iChars)) {
     alert ("Invalid Banner Height.");
     return false;
} 
        if(document.getElementById("width").value == ""){
            alert("Enter Banner Width to proceed.");
            return false;
        }
		 var iChars = /^[0-9]*$/;
     var val = document.getElementById("width").value;
     if (!val.match(iChars)) {
     alert ("Invalid Banner Width.");
     return false;
} 
var start = document.getElementById('startdate').value;
var sarr = start.split('-');
var syr = parseInt( sarr[0] );
var smo = parseInt( sarr[1] );
var sday = parseInt( sarr[2] );

var end = document.getElementById('enddate').value;
var earr = end.split('-');
var eyr = parseInt( earr[0] );
var emo = parseInt( earr[1] );
var eday = parseInt( earr[2] );

var eDate = new Date(eyr,emo-1,eday);
var today = new Date();
diff = eDate-today;
diff = Math.ceil(diff/1000/60/60/24);
if (diff < 0) {
   alert("Invalid End Date. Please specify a date that is in the future and not the past.");
   return false
}
if(document.getElementById("enddate").value == ""){
            alert("Banner End date cannot be empty")
            return false;
        }
if(syr > eyr)
{
 alert("please pick an end year later than start year");
 return false;
}
if(eyr<=syr && smo > emo)
{
 alert("please pick an end month later than start month");
    return false;
}
if(emo<=smo && sday>eday)
{
 alert("please pick an end day later than start day");
    return false;
}
return true;
}
function NameClick()
{
document.getElementById("name").value = ""
}
function NameOut()
{
if(document.getElementById("name").value == "")
{
document.getElementById("name").value = "Name"
}
}

function stdclick()
{
document.getElementById("std").value = ""
}
function stdout()
{
if(document.getElementById("std").value == "")
{
document.getElementById("std").value = "STD Code"
}
}

function phoneclick()
{
document.getElementById("phone").value = ""
}
function phoneout()
{
if(document.getElementById("phone").value == "")
{
document.getElementById("phone").value = "Phone Number"
}
}

function mobileclick()
{
document.getElementById("mobile").value = ""
}
function mobileout()

{
if(document.getElementById("mobile").value == "")
{
document.getElementById("mobile").value = "Mobile Number"
}
}
function changecolor(i)
{
document.i.fontcolor = "red";
/*if(document.getElementById)
document.getElementById(i).color = "red";
else if(document.all)
document.all[i].color = "red";

// makes it so the page does not go to test.html
return false;*/
}
function validateSize1()
{
document.getElementById("size").value="0";
document.getElementById("dimensions").disabled=true; 
document.getElementById("height").disabled=false; 
document.getElementById("width").disabled=false; 
}
function validateSize2()
{
document.getElementById("size").value="1";
document.getElementById("height").disabled=true; 
document.getElementById("width").disabled=true; 
document.getElementById("dimensions").disabled=false; 
}
function checkradio()
{
if (document.getElementById("size").value =="on") 
{
alert("Choose any one radio button to continue."); 
return false;
}
}

