function JustSubmit(){
	document.search_continent.submit();
}


function inputValidate() {

		var Result;
		Result=document.search_form.searchkeyword.value;
		if(Result==0 || Result=="Company/Name/Keyword") {
			alert("Please Enter Search Keyword");
			return false;
		}/*else if(Result.length < 2){
			alert("Please Enter keyword have Atleast String length 'Two'");
			return false;
		}*/
		else{
			return true;
		}
	}

	var xmlHttp
	function showHint_edit(str) {

		var hidcatid=document.editcategory_form.hidcatid.value;
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {

			alert ("Browser does not support HTTP Request")
			return
		}
		var url="index.php?module=admin&page=catajax&hidcatid="+hidcatid+"&actid="+str
		xmlHttp.onreadystatechange=stateChanged_edit
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}

	function show_cat(str) {

		//show_membershipfee(str) 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {

			alert ("Browser does not support HTTP Request")
			return
		}
		var url="index.php?module=admin&page=categoryajax&actid="+str
		xmlHttp.onreadystatechange=stateChanged_cat 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}

	/*	membership	fee	
	function show_membershipfee(str) {
		
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		}
		var url="index.php?module=admin&page=chapterfeeajax&actid="+str
		xmlHttp.onreadystatechange=stateChanged_membershipfee
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}*/

	function stateChanged_membershipfee() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			document.getElementById("ShowAjax2").innerHTML=xmlHttp.responseText
		}
	}
		
	function stateChanged_edit() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			document.getElementById("ShowAjax").innerHTML=xmlHttp.responseText
		}
	}
	
	function stateChanged_cat() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			document.getElementById("ShowAjax1").innerHTML=xmlHttp.responseText
		}
	}

	function GetXmlHttpObject()	{
		var xmlHttp=null;
		try	{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		    
		}
		catch (e) {
			// Internet Explorer
			try	{
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
		}
		return xmlHttp;
	}

	function showcontinent(val,key,category,direct) {
        //alert(val);
        //alert(key);
        //alert(category);
        //alert(direct);

		var id = new Array();
		var i;
		 id=document.search_continent.continent.value;

		/*for (i = 0;  i < document.search_continent.continent.length;  i++) {
			if (document.search_continent.continent[i].selected)
	          id[id.length]=search_continent.continent[i].value
		}*/

		var continent=id;
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
				alert ("Browser does not support HTTP Request")
				return
		}
		//alert(val);
			if(val=='search') {

				var url="index.php?module=home&page=country&searchkeyword="+key+"&category="+category;
			} else if(val=='power') {

				var url="index.php?module=home&page=country&From=Power";
			}	
			else {

				var url="index.php?module=home&page=country&cid="+val+"&act="+direct;
			}
			//alert(url);
			//alert(GetXmlHttpObject);
			url=url+"&q="+continent;
			xmlHttp.onreadystatechange=stateChangedCont 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
	}

	function stateChangedCont() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			document.getElementById("ShowCountry").innerHTML=xmlHttp.responseText
		}
	}

	function showcity(val,key,category,conti) {
	//alert(val);
 	//alert(key);
 	//alert(category);
	//alert(conti);
	//alert(country);
    var id = new Array();
	
		var i;
		id=document.search_continent.country.value;
		/*
		for (i = 0;  i < document.search_continent.country.length;  i++) {
			if (document.search_continent.country[i].selected)
	          id[id.length]=search_continent.country[i].value
		}
        */
		
		var country=id;
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		}
		if(country != '' ) {	
			if(val=='-1'){//search mode list 
				var url="index.php?module=home&page=country&searchkeyword="+key+"&category="+category;
			}else if(val=='-2'){//Power Search
				var url="index.php?module=home&page=country&From=Power"; 
			}else{
				var url="index.php?module=home&page=country&cid="+val+"&conti="+key+"&act="+category;
			 }

             url=url+"&c="+country;
				//alert(url);
				xmlHttp.onreadystatechange=stateChangedCountry
				xmlHttp.open("GET",url,true)
				xmlHttp.send(null)
		}
	}
	
/*	function showcity_ed(val) {

    alert(val);
 	 	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		}var url="index.php?module=home&page=country&countryID="+val;
	     url=url+"&c="+country;
		xmlHttp.onreadystatechange=stateChangedCountry_ed
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		
	}*/
	

    function display_details(val,id,key,category,direct) {
		//alert(val);
		//alert(id);
		//alert(key);
		//alert(category);
		//alert(direct);
		//alert(Condi);
		//alert(val);
		
		if(id=='-1'){//search mode list
			window.location.href="index.php?module=home&page=searchresult&city="+val+"&searchkeyword="+key+"&category="+category;	
			}
		else if(id=='-2'){//Power Search 
			window.location.href="index.php?module=home&page=searchresult&city="+val+"&From=Power";			
		}else{
			window.location.href="index.php?module=home&page=searchresult&city="+escape(val)+"&cid="+id+"&q="+key+"&c="+category+"&act="+direct;
			//document.submit();	
		  }
	 }

	function stateChangedCountry() { 
	//alert("html object--->"+xmlHttp.readyState);
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {			
			document.getElementById("ShowCity").innerHTML=xmlHttp.responseText
		}
	}

	function chkMail(cEmail) {

        firstspace=cEmail.substring(0,1);
        if(firstspace != "_") {
    	    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    		if (filter.test(cEmail))
    	        return true;
    	    else
    	        return false;
        } else {
            return false;
        }
	}

	function isAlphaNumeric(Input) {

		var numbers="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-ŒœÏïÎîÔôËÊÉÈëêéèÀàçÍíóÓéèÉÈÚúáàÁÀãñÑÖöÜüßÉéËëÏï ";
		var CharacterCheck;
		var counter = 0;

		for (var i=0; i < Input.length; i++) {
			CharacterCheck = Input.substring(i, i+1); 
            if(CharacterCheck == "@" || CharacterCheck == "#" || CharacterCheck == "$" || CharacterCheck == "%" || CharacterCheck == "^" || CharacterCheck == "&" || CharacterCheck == "*" || CharacterCheck == "(" || CharacterCheck == ")" || CharacterCheck == "+" || CharacterCheck == "|" || CharacterCheck == "/" || CharacterCheck == "`" || CharacterCheck == "," || CharacterCheck == "?") {
    			if (numbers.indexOf(CharacterCheck) != -1) {
    				counter ++;
    			}
            } else {
  				counter ++;
            }
		}

		if (counter != Input.length) {
			return true;
		}
		return false;
	}

	function isNumeric(Input) {
		var numbers="0123456789+-.";
		var CharacterCheck;
		var counter = 0; 

		for (var i=0; i < Input.length; i++) {
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1) {
				counter ++;
			}
		}
		if (counter != Input.length) {
			return true;
		}
		return false;
	}

	function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1) {
			msg+=" \n - Invalid Email ID\n";
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
			msg+=" \n - Invalid Email ID\n";
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
			msg+=" \n - Invalid Email ID\n";
			return false
		}

		 if (str.indexOf(at,(lat+1))!=-1) {
			msg+=" \n - Invalid Email ID\n";
			return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
			msg+=" \n - Invalid Email ID\n";
			return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1) {
			msg+=" \n - Invalid Email ID\n";
			return false
		 }

		 if (str.indexOf(" ")!=-1) {
			msg+=" \n - Invalid Email ID\n";
			return false
		 }
	
		 return true					
	}

	 function nullcheck(fname,fldname,disname) {
	 
		ctrl_val=eval('document.'+fname+'.'+fldname+'.value');
		ctrl_name=eval('document.'+fname+'.'+fldname+'.name');
		if(ctrl_val=='') {

			msg+="\n - "+disname+" field is mandatory.\n";
			return false;
		}
		return true;
	 }

	function pass_check(fname,fldname1)	{
		pass_val_1=eval('document.'+fname+'.'+fldname1+'.value');
		pass_val_1_length=pass_val_1.length;

		passval=pass_val_1.substring(0,3);
		alpha=isAlphabet(passval);
		
		if(alpha!='') {
			msg+="\n - Password field first 3 characters should be alphabets.\n";
		}
		if(pass_val_1!="") {
			if(pass_val_1_length<6) {
				msg+="\n - Password length should be above 6 characters\n";
				return false;
			}
		}
		return true;
	}

	function isAlphabet(Input) {
		var numbers="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		var CharacterCheck;
		var counter = 0;

		for (var i=0; i < Input.length; i++) {
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1) {
				counter ++;
			}
		}
		if (counter != Input.length) {
			return true;
		}
		return false;
	}

	function blockNonNumbers(obj, e, allowDecimal, allowNegative) {

		var key;
		var isCtrl = false;
		var keychar;
		var reg;

		if(window.event) {

            key = e.keyCode;
			isCtrl = window.event.ctrlKey
		} else if(e.which) {

			key = e.which;
			isCtrl = e.ctrlKey;
		}

		if (isNaN(key)) return true;
		keychar = String.fromCharCode(key);

		// check for backspace or delete or tab, or if Ctrl was pressed
		if (key == 8 || key == 0 || key == 9 || isCtrl) {

			return true;
		}

		reg = /\d/;
		var isFirstN = allowNegative ? keychar == '.' && obj.value.indexOf('-') == -1 : false;
		var isFirstD = allowDecimal ? keychar == ',' && obj.value.indexOf(',') == -1 : false;

		return isFirstN || isFirstD || reg.test(keychar);
	}
	
	/*	default price	*/
	function lettersOnly(evt) {
	    evt = (evt) ? evt : event;
	    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
		((evt.which) ? evt.which : 0));
		if ((charCode < 47 || charCode > 58) && charCode != 32) {
			return true;
		}
	    return false;
	}


	function confirm_delete() {
		if (confirm("Are you sure you want to delete?")==true) {
			
			return true;
		}
		else {
			//window.location.reload();
			return false;
		}
	}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s) {
	var i;
    for (i = 0; i < s.length; i++) {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag) {
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year) {
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		msg+=" \n- The date format should be : dd/mm/yyyy\n";
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		msg+=" \n- Please enter a valid month\n";
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		msg+=" \n- Please enter a valid day\n";
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		msg+=" \n- Please enter a valid 4 digit year between "+minYear+" and "+maxYear+"\n";
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		msg+=" \n- Please enter a valid date\n";
		return false
	}
return true
}
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}

	function ltrim(stringToTrim) {
		return stringToTrim.replace(/^\s+/,"");
	}
	function getContent() {
		document.templateeditor.method="POST";
		document.templateeditor.action="index.php?module=teditor&page=tempeditor";
		document.templateeditor.submit();
	}

	function getEditContent() {
		document.templateeditor.method="POST";
		document.templateeditor.action="index.php?module=teditor&page=edittemplate";
		document.templateeditor.submit();
	}

	function getAddContent() {
		document.addtemplateeditor.method="POST";
		document.addtemplateeditor.action="index.php?module=teditor&page=addnew_template";
		document.addtemplateeditor.submit();
	}

//login validation

function chkRegister() {

         var oForm=document.getElementById('frmlogin');
         var err_fields="";
		 var errorMsgLong = "";
         var inum = "0123456789 !@#$%^&*(-_)+\|";

    if (trim(oForm.fname.value) == "") {
        err_fields = err_fields + "Enter the first name"+"\n";
	} else {
        alphafname=isAlphaNumeric(oForm.fname.value);
        if(alphafname != "") {
            err_fields = err_fields + "First name should be in alpha numeric"+"\n";
        }
    }

    if (trim(oForm.lname.value) == "") {
        err_fields = err_fields + "Enter the last name"+"\n";
	} else {
        alphalname=isAlphaNumeric(oForm.lname.value);
        if(alphalname != "") {
            err_fields = err_fields + "Last name should be alpha numeric"+"\n";
        }
    }

    if (trim(oForm.email.value) == "") {
        err_fields = err_fields + "Enter the email id"+"\n";
	}
    if (oForm.email.value != "") {
     	if (chkMail(oForm.email.value) == false) {
            err_fields = err_fields + "Entered email is not valid"+"\n";
            var eflag = 1;
		 }
     }
	 if (oForm.password.value == "") {
          err_fields = err_fields + "Choose your password"+"\n";
	 }	  

	 if (oForm.password1.value == "") {
          err_fields = err_fields + "Repeat your password"+"\n";
	 }	  

	  if (oForm.password.value != "") {
	    var plen = oForm.password.value.length

        if( plen < 6 ) {
            err_fields = err_fields + "The password should have minimum 6 characters"+"\n";
        } else {
            for (var i = 0; i < 3; i++) {

                if (inum.indexOf(oForm.password.value.charAt(i)) != -1) {
                    alert ("First three characters should be alphabet");
                    oForm.password.value='';
                    oForm.password.focus();
                    return false;
                }
            }
        }
	 }

	 if(oForm.password.value != oForm.password1.value) {
		  err_fields = err_fields + "This password does not correspond"+"\n";
		  var pflag = 1 ;
	 }
  
    if (err_fields.length > 0) {
	    alert(errorMsgLong+err_fields);
		if( pflag == 1 ) {
            oForm.password1.value='';
		}
		if( eflag == 1 ) {
            oForm.email.value='';
        }
	    err_fields="";
	    return false;
	}
	else
	    return true;
 }

 function chklogin() {

         var oForm=document.getElementById('frmlogin');
         var err_fields="";
         var errorMsgLong = "";     

    if (oForm.email.value == "") {
        err_fields = err_fields + "Please enter email id"+"\n";
    }

    if (oForm.email.value != "") {
     	if (chkMail(oForm.email.value) == false) {
            err_fields = err_fields + "Please enter correct email id"+"\n";
            oForm.email.focus();
        }
    }

    if (oForm.password.value == "") {
        err_fields = err_fields + "Please enter password"+"\n";
        oForm.password.focus();
	}

    if (oForm.email.value == "" && oForm.password.value == "" || oForm.email.value == "") {
        oForm.email.focus();
    }
    if (err_fields.length > 0) {
        alert(errorMsgLong+err_fields);
        //oForm.email.value='';
        //oForm.password.value='';
        //err_fields="";
        return false;
    }
    else
        return true;
 }

function chkfpwd() {

         var oForm=document.getElementById('frmfpwd');
         var err_fields="";
       //  var errorMsgLong = "Mandatory fields not filled - Please fill all mandatory fields\n";
         var errorMsgLong = "";     

     if (oForm.email.value == "") {
          err_fields = err_fields + "Enter the value for user email"+"\n";
	 }
     if (oForm.email.value != "") {
     	if (chkMail(oForm.email.value) == false) {
          err_fields = err_fields + "Entered user email is not valid"+"\n";
		 }
     }
	 
      if (err_fields.length > 0) {
	      alert(errorMsgLong+err_fields);
		  oForm.email.value='';
	      err_fields="";
	      return false;
	   }
	  else
	      return true;
}

 function editClients(str,cid) {

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request");
			return
	}

	var url ="index.php?module=home&page=editclients_script&type=js&lang="+str+"&editclid="+cid;
	xmlHttp.onreadystatechange=stateChanged_editClients 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

 function editClients_admin(str,cid) {

	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {

			alert ("Browser does not support HTTP Request");
			return
	}

	var url ="index.php?module=admin&page=editclients_script&type=js&lang="+str+"&editclid="+cid;
	xmlHttp.onreadystatechange=stateChanged_editClients 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChanged_editClients() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		var idenlen = document.getElementById("idencnt").value;
		var perlen  = document.getElementById("percnt").value;
		var comlen  = document.getElementById("compcnt").value;


		var assignval = xmlHttp.responseText.split("||");

		document.getElementById("ShowView").innerHTML=assignval[0];
		document.getElementById("ShowViewP").innerHTML=assignval[1];
		document.getElementById("ShowViewC").innerHTML=assignval[2];
	}
}

function Pcheck_all() {

 var controlIndex;
 var count=0;
 var count1=0;
 var element
 var numberOfControls = document.getElementById('editclient_form').length;

  for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
       element = document.editclient_form[controlIndex];
       if (element.type == "checkbox") {
         if(document.editclient_form.Pallbox.checked) {
			if(element.name.match('P_')) {
				element.checked=true;
			}
            if(element.name.match('C_')) {
				element.checked=true;
			}
            if(element.name.match('Callbox')) {
				element.checked=true;
			}
 		 } else {
			if(!(element.name.match('C_')) && element.name!='Callbox') {
				element.checked=false;
			}
            if(element.name.match('C_')) {
				element.checked=true;
			}
            if(element.name.match('Callbox')) {
				element.checked=true;
			}
		 }
       }
	 }
}

function Ccheck_all() {

 var controlIndex;
 var count=0;
 var count1=0;
 var element
 var numberOfControls = document.getElementById('editclient_form').length; 

  for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
       element = document.editclient_form[controlIndex];
       if (element.type == "checkbox") {
         if(document.editclient_form.Callbox.checked) {
			if(element.name.match('C_')) {
				element.checked=true;
			}
            /*if(element.name.match('P_')) {
				element.checked=false;
			}
                            if(element.name.match('Pallbox')) {
				element.checked=false;
			}*/
 		 } else {
			if(!(element.name.match('P_')) && element.name!='Pallbox') {
				element.checked=false;
			}
            if(element.name.match('P_')) {
				element.checked=false;
			}
            if(element.name.match('Pallbox')) {
				element.checked=false;
			}
		 }
       }
    }
 }

function Cdyncheck_all(publicvalue,clubvalue) {

 var controlIndex;
 var count=0;
 var count1=0;
 var element
 var numberOfControls = document.getElementById('editclient_form').length; 

	for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
       element = document.editclient_form[controlIndex];
       if (element.type == "checkbox") {
            if(element.name.match("C_")) {
				count++;
                if(element.checked) {
					count1++;
                    //document.getElementById(publicvalue).checked=false;
                } else {
                    document.getElementById(publicvalue).checked=false;
					if(document.getElementById("Pallbox").checked == true) {
						document.getElementById("Pallbox").checked = false;
					}					
                }
            }
        }
    }
	
	if(count == count1) {
		document.getElementById("Callbox").checked = true;		
	} else {
		document.getElementById("Callbox").checked	=	false;
	}	
 }

function Pdyncheck_all(publicvalue,clubvalue) {

    var controlIndex;
    var count=0;
    var count1=0;
    var element
    
    var numberOfControls = document.getElementById('editclient_form').length;

    for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {

       element = document.editclient_form[controlIndex];
	   
       if (element.type == "checkbox") {

            if(element.name.match("P_")) {
				count++;
                if(element.checked) {
					count1++;
                    document.getElementById(clubvalue).checked=true;
                }
            }
        }
    }
	
	if(count == count1) {
		document.getElementById("Pallbox").checked = true;		
		document.getElementById("Callbox").checked = true;		
	} else {
		document.getElementById("Pallbox").checked	=	false;
	}	
}

function dateCheck(from,to) {

	var from_date=from;
	var cdate_array=from_date.split("-");
	var dd=parseInt(cdate_array[2],10);
	var mm=parseInt(cdate_array[1],10);
	var yy=parseInt(cdate_array[0],10);

	var till_date=to;
	var date_array=till_date.split("-");
	var d=parseInt(date_array[2],10);
	var m=parseInt(date_array[1],10);
	var y=parseInt(date_array[0],10);
	var check_year=0;
	var check_date=0;
	var check_month=0;
	var check_cnt=0;

    if(y > yy) {
		check_cnt=3;
	 }else if(y<yy) {
		check_cnt=0;
	 }
	 if(y==yy) {
		check_cnt=1;
	 }
	switch(check_cnt) {
	case 1:
		 if(m>mm){ check_cnt=3; }
		 if(m<mm){ check_cnt=0; }
		 if(m==mm){check_cnt=1;}
		 break;
	}
	switch(check_cnt){
	case 1:
	             if(d>dd) { check_cnt=3;}
				 if(d<dd) { check_cnt=0;}
				 if(d==dd){check_cnt=1;}
				  break;
	}
	
		if(check_cnt==0) {			
			return false;
		} else {
			return true;
		}
}

function openWindow(msg,langid) {

	if(langid == '') {
		url = "index.php?module=admin&page=uploadicon&action="+msg;
	} else {
		url = "index.php?module=admin&page=uploadicon&action="+msg+"&langid="+langid;
	}
	var X = 150; // x position
    var Y = 150; // y position
    var W = 450; // width
    var H = 350; // height
	s="resizable=no,scrollbars=no,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",width="+W+",height="+H;
	window.open(url,'',s);
}

function openpricewindow(actid) {
	url1 = "index.php?module=admin&page=viewdefaultprice&actid="+actid;
	var X = 150; // x position
    var Y = 150; // y position
    var W = 450; // width
    var H = 350; // height
	s1="resizable=no,scrollbars=yes,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",width="+W+",height="+H;
	window.open(url1,'',s1);
	
}


function Charset(Input) {
		var numbers="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-";
		var CharacterCheck;
		var counter = 0;

		for (var i=0; i < Input.length; i++) {
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1) {
				counter ++;
			}
		}
		if (counter != Input.length) {
			return true;
		}
		return false;
	}

function save() {

	var controlIndex;
	var element;
	var exportvalid = 0;
	
	msg="";			
	var msg = "Please Fill the following: \n----------------------------------";
	var noErrors = msg;
	
	var numberOfControls = document.getElementById('viewclients').length; 
	if(document.viewclients.exportall.checked) {

		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {

	       element = document.viewclients[controlIndex];
	       if (element.type == "checkbox") { 	
		   
				if(element.name.match('chk')) {		
				
					if(element.checked==true) { exportvalid = 1; }
				}
			 }
	    }
	} else {

		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {

	       element = document.viewclients[controlIndex];
	       if (element.type == "checkbox") { 	

				if(element.name.match('chk')) {	

					if(element.checked==true) { exportvalid = 1; }
				}
			 }
	    }
	}	
	
	if(exportvalid ==  1) {		
		document.viewclients.action="index.php?module=admin&page=viewclients&action=export"
		document.viewclients.submit();
	} else {	
		msg+="\n - Please select the client(s) to export.\n" +"\n";			
	}
	
	// If no errors, submit the form
	if (msg == noErrors) {
		return true;
	} else {
		// If errors were found, show alert message
		alert(msg);
		return false;
	}		
}

function sendmail() {

	var controlIndex;
	var element;
	var exportvalid = 0;
	
	msg="";			
	var msg = "Please Fill the following: \n----------------------------------";
	var noErrors = msg;
		
	var toaddr = '';
	var numberOfControls = document.getElementById('viewclients').length;

	if(document.viewclients.exportall.checked) {

		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	  
	       element = document.viewclients[controlIndex];
	       if (element.type == "checkbox") { 	   
				if(element.name.match('chk')) {			 
					if(element.checked==true && element.value != '') {

						if(exportvalid == 0) {
						
							toaddr = element.value;	
							exportvalid++;
						} else 	{
						
							toaddr = toaddr + "," + element.value;	
							exportvalid++;
						}
				}
				}
			 }
	    }
	} else {
	
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	  
	       element = document.viewclients[controlIndex];
	       if (element.type == "checkbox") { 	   
				if(element.name.match('chk')) {			 
					if(element.checked==true && element.value != '') {
					
					if(exportvalid == 0) {
						
						toaddr = element.value;		
						exportvalid++;	
					} else 	{

						toaddr = toaddr + "," + element.value;	
						exportvalid++;
					}
				}
				}
			 }
	    }
	}	
	if(exportvalid !=  0) {
		//location.href = "mailto:"+toaddr;
		document.viewclients.clientidies.value = toaddr; 
	} else {
		msg+="\n - Please select the Recipient(s) to send mail.\n" +"\n";			
	}	
	
	// If no errors, submit the form
	if (msg == noErrors) {
		document.viewclients.method='post';
		document.viewclients.action='index.php?module=admin&page=sendmailtoclient';
		document.viewclients.submit();
	} else {
		// If errors were found, show alert message
		alert(msg);
		return false;
	}	
}


function export_all() {
 
	var controlIndex;
	var element;
	var numberOfControls = document.getElementById('viewclients').length; 
	for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
  
       element = document.viewclients[controlIndex];
       if (element.type == "checkbox") { 	   
         if(document.viewclients.exportall.checked) { 			
			if(element.name.match('chk')) {			 
				element.checked=true;
			}
 		 } else {
			
				element.checked=false;
			}	
		 }
    }
}

function select_export() {
 var controlIndex;
 var count=0;
 var count1=0;
 var element;
 var numberOfControls = document.getElementById('viewclients').length; 

  for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
       element = document.viewclients[controlIndex];
       if (element.type == "checkbox") { 
		if(element.name.match('chk')) {
				count1++;	
				if(element.checked) {
				  count++;
				}
			}
 		 }
    }
	if(count==count1) {
		document.viewclients.exportall.checked =true;
	} else {
		document.viewclients.exportall.checked =false;
	}
 }

function checkchgpwd() {

	var oForm=document.getElementById('frmchgpwd');
	var err_fields="";
	var errorMsgLong = "";    
	var newpwd_flag = 0;
	var inum = "0123456789 !@#$%^&*(-_)+\|";
	
		if (trim(oForm.uemail.value) == "") {

			err_fields	= "Enter your email id"+"\n";
		}
		if (trim(oForm.uemail.value) != "") {

			if (chkMail(oForm.uemail.value) == false) {

			err_fields	=	err_fields+"\n"+"Invalid email id"+"\n";
			var eflag = 1;          
/*			if (trim(oForm.curpwd.value) != "") { oForm.curpwd.value = ""; }
			if (trim(oForm.newpwd.value) != "") { oForm.newpwd.value = ""; }
			if (trim(oForm.confirm_newpwd.value) != "") { oForm.confirm_newpwd.value = ""; }*/
			}
		}
		if (trim(oForm.curpwd.value) == "") { 

			err_fields	=	err_fields+"Enter current password"+"\n";
		}
		if (trim(oForm.newpwd.value) == "") {  

			err_fields	=	err_fields+"Enter new password"+"\n";
		}
		if (trim(oForm.confirm_newpwd.value) == "") { 

			err_fields	=	err_fields+"Confirm new password"+"\n";
		}
	
	
	/*if (oForm.curpwd.value != "") {

		var plen = oForm.curpwd.value.length 

		if( plen < 6 ) {
			err_fields	=	err_fields+"\n"+"	- The current password should have minimum of 6 characters"+"\n";
		} else {
			for (var i = 0; i < 3; i++)    {

				if (inum.indexOf(oForm.curpwd.value.charAt(i)) != -1)
				{
					//err_fields	=	err_fields+"\n"+"	- First three characters of a current password should be alphabet";
					var curpwd_flag = 1;
					oForm.curpwd.value='';
					oForm.curpwd.focus();
				}
			}
		}	
	}*/
	
	if (oForm.newpwd.value != "") {
		var plen = oForm.newpwd.value.length 

		if( plen < 6 ) {
			err_fields	=	err_fields+"The new password should have minimum of 6 characters"+"\n";
		} else {
			for (var i = 0; i < 3; i++)    {

				if (inum.indexOf(oForm.newpwd.value.charAt(i)) != -1)
				{
					//err_fields	=	err_fields+"\n"+"	- First three characters of a new password should be alphabet";
					var newpwd_flag = 1;
					oForm.newpwd.value='';
					oForm.newpwd.focus();
				}
			}
		}	
	}

	if (oForm.newpwd.value != "") {
	
		if(oForm.newpwd.value != oForm.confirm_newpwd.value) {
			err_fields	=	err_fields+"This password doesn’t correspond"+"\n";
			var pflag = 1 ;
		}	  	
	}	
  
	if (err_fields.length > 0 || newpwd_flag == 1) {

		if(newpwd_flag == 1) {
		
			err_fields	=	err_fields+"First three characters of a new password should be alphabet";	
		}
	
		//err = "Please fill the following "+"\n";
		//alert(err+err_fields);
		alert(err_fields);
/*		oForm.uemail.value='';
		oForm.curpwd.value = "";
		oForm.newpwd.value = "";
		oForm.confirm_newpwd.value = "";*/
		err_fields="";
		if( pflag == 1 ) {
            oForm.confirm_newpwd.value='';
		}
		if( eflag == 1 ) {
            oForm.uemail.value='';
        }
		return false;
	}
}

/*function isUpperCase(Input) {
    		var numbers="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    		var CharacterCheck;
    		var counter = 0;

    		for (var i=0; i < Input.length; i++) {
    			CharacterCheck = Input.substring(i, i+1); 
    			if (numbers.indexOf(CharacterCheck) != -1) {
    				counter ++;
    			}
    		}
			if (counter == 1) {
    			return true;
    		}
    		return false;
}*/

function enable_update() {

 var controlIndex;
 var cnt=0;
 var element;
 var numberOfControls = document.getElementById('moderatorrole').length; 

  for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
       element = document.moderatorrole[controlIndex];
       if (element.type == "checkbox") { 
		if(element.name.match('chk_')) {
				if(element.checked) {
				  cnt++;
				}
			}
 		 }
    }
	if(cnt != 0) {
		document.moderatorrole.update.disenabled = true;
	} else {
		document.moderatorrole.update.disenabled = false;
	}
 }
 
 function mailtoselecteduser() {
 var controlIndex;
 var count=0;
 var count1=0;
 var element;
 var numberOfControls = document.getElementById('viewusers').length; 

  for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
       element = document.viewusers[controlIndex];
       if (element.type == "checkbox") { 
		if(element.name.match('chk_mailtouser')) {
				count1++;	
				if(element.checked) {
				  count++;
				}
			}
 		 }
    }
	if(count==count1) {
		document.viewusers.chk_mailtoall.checked =true;
	} else {
		document.viewusers.chk_mailtoall.checked =false;
	}
 }
 
 function mailtoalluser() {
 
	var controlIndex;
	var element;
	var numberOfControls = document.getElementById('viewusers').length; 
	for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
  
       element = document.viewusers[controlIndex];
       if (element.type == "checkbox") { 	   
         if(document.viewusers.chk_mailtoall.checked) { 			
			if(element.name.match('chk_mailtouser')) {			 
				element.checked=true;
			}
 		 } else {
			
				element.checked=false;
			}	
		 }
    }
}

/*	To send the mail to the selected users through view users page */
function sendMailToUser() {

	msg="";			
	var msg = "Please Fill the following: \n----------------------------------";
	var noErrors = msg;
	
	var controlIndex;
	var element;
	var sendMail = 0;
	var toAddr = '';
	var numberOfControls = document.getElementById('viewusers').length; 
	if(document.viewusers.chk_mailtoall.checked) {
	
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	  
	       element = document.viewusers[controlIndex];
	       if (element.type == "checkbox") { 	   
				if(element.name.match('chk_mailtouser')) {			 

					if(element.checked==true) { 

						if(sendMail == 0) {
						
							toAddr = element.value;	
							sendMail++;
						} else 	{
						
							toAddr = toAddr + "," + element.value;	
							sendMail++;
						}
				}
				}
			 }
	    }
	} else {
	
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	  
	       element = document.viewusers[controlIndex];
	       if (element.type == "checkbox") { 	   
		   
				if(element.name.match('chk_mailtouser')) {	
				
					if(element.checked==true) {
					
					if(sendMail == 0) {
						
						toAddr = element.value;		
						sendMail++;	
					} else 	{

						toAddr = toAddr + "," + element.value;	
						sendMail++;
					}
				}
				}
			 }
	    }
	
	}	
		
	if(sendMail ==  0){
		msg+="\n - Please select the user(s) to send mail.\n" +"\n";
	}	
		
	// If no errors, submit the form
	if (msg == noErrors) {
		return true;
	} else {
		// If errors were found, show alert message
		alert(msg);
		return false;
	}	
}

/*	Moderator Permissions	*/
function usernames(modcnt,formref,usercount) {
	var j=0;
	var numberOfControls = document.getElementById('editmod').length; 
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	       element = document.editmod[controlIndex];
	       if (element.type == "select-one") { 	   
		   
				if(element.name.match('userid')) {	

					if(element.name.match('userid0')) { username_count = element.length; }
					j++;
				}
				if(element.name.match('roleid0')) { rolename_count = element.length;}
			}
		}				
	
	var i = 0;
	var uid = new Array();
	var uname = new Array();
	var roleid = new Array();
	var rolename = new Array();
	
	if(modcnt > 0 && j!=usercount) {

		if(username_count > 0) {

			for (i=0;i<username_count;i++)
			{
				
				uid[i] =  document.editmod.userid0.options[i].value;
				uname[i] = document.editmod.userid0.options[i].text;
			}
		}

		if(rolename_count > 0) {

			for (i=0;i<rolename_count;i++)
			{
			
				roleid[i] = document.editmod.roleid0.options[i].value;
				rolename[i] = document.editmod.roleid0.options[i].text;
			}
		}

		var user = document.createElement("select");
		user.name = "userid"+document.editmod.ucount.value;
		user.style.width = "150px";
		for(i=0;i<uid.length;i++) {
		
			user.options[i] = new Option(uname[i],uid[i]);
		}
		
		var role = document.createElement("select");
		role.style.width = "150px";
		role.name = "roleid"+document.editmod.ucount.value;
		for(i=0;i<roleid.length;i++) {
		
			role.options[i] = new Option(rolename[i],roleid[i]);
		}	
			
		//formref.appendChild(user);
		//formref.appendChild(role);
		
		document.getElementById("adduser").appendChild(user);
		document.getElementById("addrole").appendChild(role);
		document.editmod.ucount.value=modcnt-1;
	}	
}

function addrole() {

	document.moderatorrole.method="POST";
	document.moderatorrole.action="index.php?module=admin&page=moderatorrole&action=add";
	document.moderatorrole.submit();
}	

/* dynamic template page */
function addOption_list(){
	var frm = document.cdblocktype;
	var theElements = document.cdblocktype.elements.length;
	var text = "";
	var value = "";
	var selected = 0;	
	for(j=0;j<document.cdblocktype.fieldlist.length;j++) {				
		if(document.cdblocktype.fieldlist.options[j].selected == true) {		
			if(document.cdblocktype.fieldlist.options[j].text != 'Select Fields') {			
				selected ++;
			}	
		}	
	}
	if(selected > 0) { 	
		for (var count = 0; count < theElements; count++) {
			if(document.cdblocktype.elements[count].type == "select-multiple"  && document.cdblocktype.elements[count].name=="addedfieldlist[]") {
			addedfield_len = document.cdblocktype.elements[count].length;
			for(i=0;i<frm.fieldlist.options.length;i++) {
				if(frm.fieldlist.options[i].selected == true && frm.fieldlist.options[i].value != ''){
					var add = true;	
					for(j=0;j<addedfield_len;j++) {						
						if(document.cdblocktype.elements[count].options[j].value == frm.fieldlist.options[i].value){						
							var add = false;
						}
					}						
					if(add == true) {				
						var optn = document.createElement("OPTION");
						optn.text = frm.fieldlist.options[i].text;
						optn.value = frm.fieldlist.options[i].value;
						document.cdblocktype.elements[count].options.add(optn);
					}	
				}	
				}
			}
		}	
	} else {
	
		msg="Please fill the following\n___________________________________\n"+
			"\n - Please select the field to add." +"\n";
			alert(msg);
	}	
}

function removeOptions() {
	/* To remove the selected text in the template page */
	var theElements = document.cdblocktype.elements.length;
	var added_text = new Array();
	var added_value = new Array();
	var added_field = true;	
	var k = 0;
	var s = 0;
	for (var count = 0; count < theElements; count++) {
		if(document.cdblocktype.elements[count].name == "addedfieldlist[]") {		
			for(j=0;j<document.cdblocktype.elements[count].length;j++) {	
				
				if(document.cdblocktype.elements[count].options[j].selected == false && document.cdblocktype.elements[count].options[j].text != 'Added Fields') {					
				
					added_value[k]	=	document.cdblocktype.elements[count].options[j].value;
					added_text[k]	=	document.cdblocktype.elements[count].options[j].text;
					k++;
				} else {
						if(document.cdblocktype.elements[count].options[j].text != 'Added Fields') {s++;}
				}					
			}
		
			document.cdblocktype.elements[count].length = 0;	
				for(i=0;i<added_text.length;i++) {
					if(added_text[i] == "Added Fields") {					
						added_field = false;	
					}
				}
				if(added_field == true || added_text.length == 1) { 						
					var optn = document.createElement("OPTION");
					optn.text = "Added Fields";
					optn.value = "";
					document.cdblocktype.elements[count].options.add(optn);
				}
				if(s == 0) {
					if(added_text.length >= 1) {
						for(i=0;i<added_text.length;i++) {						
							var optn = document.createElement("OPTION");
							optn.text = added_text[i];
							optn.value =added_value[i];
							document.cdblocktype.elements[count].options.add(optn);
							//addedfieldlist[].options[i] = new Option(added_text[i],added_value[i]);		
						}	
					}
					msg="Please fill the following\n____________________________________\n"+
						"\n - Please select the field to remove." +"\n";
						alert(msg); 
				} else {	
					if(added_text.length >= 1) {
						for(i=0;i<added_text.length;i++) {						
							var optn = document.createElement("OPTION");
							optn.text = added_text[i];
							optn.value =added_value[i];
							document.cdblocktype.elements[count].options.add(optn);
							//addedfieldlist[].options[i] = new Option(added_text[i],added_value[i]);		
						}	
					}
				}
	     }
     }
	} 

/*	addclient template page	*/
function dynamictemp_validate() {

	var frm = document.addclienttemp;
	var theMessage = "Please fill the following\n____________________________________\n";
	var noErrors = theMessage;
	
	if(frm.tempmodel.value == '') {
		 theMessage = theMessage + "\n - Please select the Template Model." +"\n"
	}
	if(frm.r1r3width.value == '') {
		theMessage = theMessage + "\n - Please specify the Region1, Region3 width." +"\n"
	}
	if(frm.r1r3width.value != '') {
		if(isInteger(frm.r1r3width.value) == false) {
			theMessage = theMessage + "\n - The Region1, Region3 width should be in numeric." +"\n"
		}
	}
	if(frm.r2r4width.value == '') {
		theMessage = theMessage + "\n - Please specify the Region2, Region4 width." +"\n"
	}
	if(frm.r2r4width.value != '') {
		if(isInteger(frm.r2r4width.value) == false) {
			theMessage = theMessage + "\n - The Region2, Region3 width should be in numeric." +"\n"
		}
	}
	if(frm.hrspace.value == '') {
		theMessage = theMessage + "\n - Please specify the horizontal space." +"\n"
	}
	if(frm.hrspace.value != '') {
		if(isInteger(frm.hrspace.value) == false) {
			theMessage = theMessage + "\n - The horizontal space should be in numeric." +"\n"
		}
	}	
	if(frm.r1r2height.value == '') {
		theMessage = theMessage + "\n - Please specify the Region1, Region2 height." +"\n"
	}
	if(frm.r1r2height.value != '') {
		if(isInteger(frm.r1r2height.value) == false) {
			theMessage = theMessage + "\n - The Region1, Region2 height should be in numeric." +"\n"
		}
	}
	if(frm.r3r4height.value == '') {
		theMessage = theMessage + "\n - Please specify the Region3, Region4 height." +"\n"
	}
	if(frm.r3r4height.value != '') {
		if(isInteger(frm.r3r4height.value) == false) {
			theMessage = theMessage + "\n - The Region3, Region4 height should be in numeric." +"\n"
		}
	}
	if(frm.vrspace.value == '') {
		theMessage = theMessage + "\n - Please specify the vertical space." +"\n"
	}
	if(frm.vrspace.value != '') {
		if(isInteger(frm.vrspace.value) == false) {
			theMessage = theMessage + "\n - The vertical space should be in numeric." +"\n"
		}
	}		
	// If no errors, submit the form
	if (theMessage == noErrors) {
		return true;
	} else {
		// If errors were found, show alert message
		alert(theMessage);
		return false;
	}
}

/* To get the block of selected Template Model name in the dynamic template page	*/
function getblock() {

	document.addclienttemp.method="POST";
	document.addclienttemp.action="index.php?module=admin&page=addtemp&save=getblock";
	document.addclienttemp.submit();
}

function getregionsize() {

	document.addclienttemp.method="POST";
	document.addclienttemp.action="index.php?module=admin&page=addtemp&action=getsize";
	document.addclienttemp.submit();
}

function getblocktype() {

	document.addclienttemp.method="POST";
	document.addclienttemp.action="index.php?module=admin&page=addtemp&save=getblocktype";
	document.addclienttemp.submit();
}
/*	addclient template page	*/

function addtemplate_model() {

	var frm = document.addclienttemp;
	if(frm.newtemp.value != '') {
	
		/*if(isAlphaNumeric(frm.newtemp.value) == true) {
		
			msg="Please fill the following\n_______________________________\n"+
			"\n - Template Model name should be in alphanumeric." +"\n";
			alert(msg);
		} else {*/
		
			document.addclienttemp.method="POST";
			document.addclienttemp.action="index.php?module=admin&page=addtemp&save=addtemp";
			document.addclienttemp.submit();
		//}	
	} else {
	
		msg="Please fill the following\n________________________________\n"+
			"\n - Please enter the Template Model name." +"\n";
			alert(msg);
	}	
}



/*	To validate */
function editclientvalidate() {

	var frm = document.editclienttemp;
	var theMessage = "Please fill the following\n________________________________\n";
	var noErrors = theMessage;
	
	if(frm.tempmodel.value == '') {
		 theMessage = theMessage + "\n - Please select the Template Model." +"\n"
	}
	if(frm.r1r3width.value == '') {
		theMessage = theMessage + "\n - Please specify the Region1, Region3 width." +"\n"
	}
	if(frm.r1r3width.value != '') {
		if(isInteger(frm.r1r3width.value) == false) {
			theMessage = theMessage + "\n - The Region1, Region3 width should be in numeric." +"\n"
		}
	}
	if(frm.r2r4width.value == '') {
		theMessage = theMessage + "\n - Please specify the Region2, Region4 width." +"\n"
	}
	if(frm.r2r4width.value != '') {
		if(isInteger(frm.r2r4width.value) == false) {
			theMessage = theMessage + "\n - The Region2, Region3 width should be in numeric." +"\n"
		}
	}
	if(frm.hrspace.value == '') {
		theMessage = theMessage + "\n - Please specify the horizontal space." +"\n"
	}
	if(frm.hrspace.value != '') {
		if(isInteger(frm.hrspace.value) == false) {
			theMessage = theMessage + "\n - The horizontal space should be in numeric." +"\n"
		}
	}	
	if(frm.r1r2height.value == '') {
		theMessage = theMessage + "\n - Please specify the Region1, Region2 height." +"\n"
	}
	if(frm.r1r2height.value != '') {
		if(isInteger(frm.r1r2height.value) == false) {
			theMessage = theMessage + "\n - The Region1, Region2 height should be in numeric." +"\n"
		}
	}
	if(frm.r3r4height.value == '') {
		theMessage = theMessage + "\n - Please specify the Region3, Region4 height." +"\n"
	}
	if(frm.r3r4height.value != '') {
		if(isInteger(frm.r3r4height.value) == false) {
			theMessage = theMessage + "\n - The Region3, Region4 height should be in numeric." +"\n"
		}
	}
	if(frm.vrspace.value == '') {
		theMessage = theMessage + "\n - Please specify the vertical space." +"\n"
	}
	if(frm.vrspace.value != '') {
		if(isInteger(frm.vrspace.value) == false) {
			theMessage = theMessage + "\n - The vertical space should be in numeric." +"\n"
		}
	}		
	// If no errors, submit the form
	if (theMessage == noErrors) {
		return true;
	} else {
		// If errors were found, show alert message
		alert(theMessage);
		return false;
	}
}

/*function addblockvalidate() {

	var frm = document.addblock;
	var theMessage = "Please fill the following\n__________________________________\n";
	var noErrors = theMessage;
	
	if(frm.tempmodel.value == '') {
	
		 theMessage = theMessage + "\n - Please select the template." +"\n"
	}
	if(frm.region.value == '') {
	
		theMessage = theMessage + "\n - Please select the region." +"\n"
	}	
	if(frm.blocktype.value == '') {
	
		theMessage = theMessage + "\n - Please select the block type." +"\n"
	}
	if(frm.blockname.value == '') {
	
		theMessage = theMessage + "\n - Please select the block name." +"\n"
	}
	if(frm.blockorder.value == '') {
	
		theMessage = theMessage + "\n - Please specify the block order." +"\n"
	}
	if(isInteger(frm.blockorder.value) == false) {
		
		theMessage = theMessage + "\n - The block order should be in numeric." +"\n"
	}
	// If no errors, submit the form
	if (theMessage == noErrors) {
		return true;

	} else {

		// If errors were found, show alert message
		alert(theMessage);
		return false;
	}
}*/

/*	block type validation */
	function getfield() {
		document.cdblocktype.method="POST";
		document.cdblocktype.action="index.php?module=admin&page=blocktype&save=getfield";
		document.cdblocktype.submit();
	}
	function blocktype_validate() {
	
		var frm = document.cdblocktype;
		var theMessage = "Please fill the following\n___________________________\n";
		var noErrors = theMessage;
		
		if(frm.blocktype.value == '') {
		
			 theMessage = theMessage + "\n - Please select the block type." +"\n"
		}
		var l = 0;
		var theElements = document.cdblocktype.elements.length;
		for (var count = 0; count < theElements; count++) {

			if(document.cdblocktype.elements[count].name == "addedfieldlist[]") {
			
				for(j=0;j<document.cdblocktype.elements[count].length;j++) {
					
					if(document.cdblocktype.elements[count].options[j].value != '') {
						
						document.cdblocktype.elements[count].options[j].selected = true;
						l++;
					}	
				}

				if(l==0) {
				
					theMessage = theMessage + "\n - Please select one or more fields." +"\n";
				}	
			}
		}

		// If no errors, submit the form
		if (theMessage == noErrors) {
			return true;

		} else {

			// If errors were found, show alert message
			alert(theMessage);
			return false;
		}	
	}
	
	function addblocktype() {
	
		if(document.cdblocktype.newblocktype.value != '' ) {
		
			document.cdblocktype.method="POST";
			document.cdblocktype.action="index.php?module=admin&page=blocktype&save=addblocktype";
			document.cdblocktype.submit();
		} else {

				msg="Please fill the following\n_________________________________\n"+
				"\n - Please enter the blocktype name." +"\n";
				alert(msg);
		}
	}

/* add block page */
function selectedtemplate() {

	document.addblock.method="POST";
	document.addblock.action="index.php?module=admin&page=addblocktoregion&save=refresh";
	document.addblock.submit();
}

function selectedblocktype() {

	document.addblock.method="POST";
	document.addblock.action="index.php?module=admin&page=addblocktoregion&save=getblocktype";
	document.addblock.submit();
}

function selectedblock() {

	document.addblock.method="POST";
	document.addblock.action="index.php?module=admin&page=addblocktoregion&save=getblock";
	document.addblock.submit();
}

function addnewblock() {
	
	var frm = document.addblock;
	var add = true;
	var theMessage = "Please fill the following\n__________________________________\n";
	var noErrors = theMessage;
	if(frm.newblockname.value != '' && frm.blocktype.value != '' && frm.tempmodel.value != '' && frm.region.value != '') {
	
		document.addblock.method="POST";
		document.addblock.action="index.php?module=admin&page=addblocktoregion&save=add";
		document.addblock.submit();
	} else {
			
			if(frm.tempmodel.value == '') {

				theMessage = "\n - Please select the Template Model." +"\n";	
			}
			if(frm.region.value == '') {

				theMessage = theMessage + "\n - Please select the region." +"\n";		
			}
			if(frm.blocktype.value == '') {
	
				theMessage = theMessage + "\n - Please select the block type." +"\n"
			}
			if(frm.newblockname.value == '' ) {

				theMessage = theMessage + "\n - Please enter the block name." +"\n";	
			}
			if (theMessage == noErrors) {

				return true;
			} else {

				// If errors were found, show alert message
				alert(theMessage);
				return false;
			}
		}	
}
/* add block page */

function editregion() {

	document.editclienttemp.method="POST";
	document.editclienttemp.action="index.php?module=admin&page=edittemp&action=region";
	document.editclienttemp.submit();
}	

function getblocktype() {

	document.cdtemp.method="POST";
	document.cdtemp.action="index.php?module=admin&page=cdtemp&save=getblocktype";
	document.cdtemp.submit();
}

function editregionsize() {

	document.editclienttemp.method="POST";
	document.editclienttemp.action="index.php?module=admin&page=edittemp&action=editsize";
	document.editclienttemp.submit();
}

//For Power Search 
function ValidatePower()	{
	var controlIndex;
	var count=0;
 	var element;
	var numberOfControls = document.powersearch.length;
 	for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
    	element = document.powersearch[controlIndex];
      	if ((element.type=="text")&&(element.value!='')){
 		    count++;
       }
  }
	if(count==0){
		alert("\n Please enters the value to search.\n");	
		return false;
		}
	else{
		return true;
	}
			
 }

function enable_chapter() {
	//document.getElementById('chaptername').value = 0;
	if(document.getElementById('general_membership').checked == false) {
		document.getElementById('chaptername').disabled = true;
		//document.getElementById('chaptername').options[0].selected;
	} else {
		document.getElementById('chaptername').disabled = false;
		//document.getElementById('chaptername').options[0].selected;
	}
}		

function deselect_viewclients() {

	document.viewclients.exportall.checked = false;
	var numberOfControls = document.getElementById('viewclients').length; 
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {

	       element = document.viewclients[controlIndex];
	       if (element.type == "checkbox") { 	
		   
				if(element.name.match('chk')) {		
				
					element.checked=false;
				}
			 }
	    }
}
	function isNumericvat(Input) {
		var numbers="0123456789+ - ,.";
		var CharacterCheck;
		var counter = 0; 

		for (var i=0; i < Input.length; i++) {
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1) {
				counter ++;
			}
		}
		if (counter != Input.length) {
			return true;
		}
		return false;
	}
	function chkdigist(cdigist) {
	    var filter1=/^\d{1,2}(|,\d{1,4})$/
	    if (filter1.test(cdigist))
	        return true;
	    else
	        return false;
	}

	function isNumericperiod(Input) {
		var numbers="0123456789 .";
		var CharacterCheck;
		var counter = 0; 

		for (var i=0; i < Input.length; i++) {
			CharacterCheck = Input.substring(i, i+1); 
			if (numbers.indexOf(CharacterCheck) != -1) {
				counter ++;

			}
		}
		if (counter != Input.length) {
			return true;
		}
		return false;
	}
	function chkperiod(cperiod) {
	    var period=/^\d{1,2}(|.[0,5]{1})$/
	    if (period.test(cperiod))
	        return true;
	    else
	        return false;
	}
	
	/* Invoice Display	*/
	function invoicevalidate(count) {
		
		var i =0;
		var numberOfControls = document.getElementById('invoicelist').length; 
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
		  
			element = document.invoicelist[controlIndex];
			if(element.name == 'client' && element.checked == true) {
			
				i++;
			}			
		}	
		
		if(i == 0)	{
		
			alert("Please fill the following\n__________________________________\n"+
			"\n - Please select the client to generate invoice." +"\n");
			return false;	
		}
	}
	
	function displayall() {
	
		document.invoicelist.method="POST";
		document.invoicelist.action = 'index.php?module=admin&page=invoiceclient&action=displayall';
		document.invoicelist.submit();
	}
	
	function notgenerated() {
	
		document.invoicelist.method="POST";
		document.invoicelist.action = 'index.php?module=admin&page=invoiceclient&action=notgenerated';
		document.invoicelist.submit();
	}
	
	function editinvoice(client) {
	
		document.generateinvoice.method="POST";
		document.generateinvoice.action = 'index.php?module=admin&page=invoice&action=edit&clientid='+client;
		document.generateinvoice.submit();
	}
	
	function saveinvoice(client) {
	
		document.generateinvoice.method="POST";
		document.generateinvoice.action = 'index.php?module=admin&page=invoice&action=save&clientid='+client;
		document.generateinvoice.submit();
	}
	
	function previewinvoice(client) {
	
		var theMessage = "Please fill the following\n_________________________________\n";
		var noErrors = theMessage;
	
		if(document.getElementById('companyname').value == '' ) {
			
			theMessage = theMessage+"\n - Please enter the client company name." +"\n";	
		}
		if(document.getElementById('firstname').value == '' ) {
			
			theMessage = theMessage+"\n - Please enter the client first name." +"\n";	
		}
		if(document.getElementById('lastname').value == '' ) {
			
			theMessage = theMessage+"\n - Please enter the client last name." +"\n";	
		}
		if(document.getElementById('cstreet').value == '' ) {
			
			theMessage = theMessage+"\n - Please enter the client street address." +"\n";	
		}
		if(document.getElementById('czip').value == '' ) {
			
			theMessage = theMessage+"\n - Please enter the client zip." +"\n";	
		}
		if(document.getElementById('ccity').value == '' ) {
			
			theMessage = theMessage+"\n - Please enter the client city." +"\n";	
		}
		
		if(noErrors != theMessage) {
		
			alert(theMessage);
			return false;
		} else {
		
			document.generateinvoice.method="POST";
			document.generateinvoice.action = 'index.php?module=admin&page=invoice&action=preview&clientid='+client;
			document.generateinvoice.submit();
		}	
	}
	
	function invoiceprint(client) {
	
		var X = 150; // x position
		var Y = 150; // y position
		var W = 500; // width
		var H = 550; // height
		s="toolbar=no,location=no,directories =no,status=no,menubar=no,resizable=no,scrollbars=no,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",width="+W+",height="+H;
		window.open('index.php?module=admin&page=invoiceprint&action=preview&clientid='+client,'',s);
		//window.print();
		//window.close();
	}
	
	/* import csv	*/
	function mailtoimportedusers() {

		var controlIndex;
		var element;
		var categorised = 0;
		var uncategorised = 0;
		
		var msg='';
		var msg = "Please Fill the following: \n----------------------------------";
		var noErrors = msg;
		
		var numberOfControls = document.getElementById('sendmailtoimported').length; 
		
		/*	categorised list	*/	
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
		  
			element = document.sendmailtoimported[controlIndex];
			if (element.type == "checkbox") { 	
				if((element.checked == true  && element.name.match('chkall_inserted')) || 
				(element.checked == true  && element.name.match('chk_inserted'))) {

					categorised++;	
				}
		/*	uncategorised list	*/
				if((element.checked == true  && element.name.match('chkall_uncategorised')) 
				|| (element.checked == true  && element.name.match('chk_uncategorised'))) {

					uncategorised++;	
				}
			}
		}

		if(uncategorised == 0 && categorised == 0) {		
			msg+="\n - Please select the client(s) to send mail.\n" +"\n";				
		}	
		// If no errors, submit the form
		if (msg == noErrors) {
			return true;
		} else {
			// If errors were found, show alert message
			alert(msg);
			return false;
		}	
	}
	
	function checkimporteduser() {
	
		var controlIndex;
		var count=0;
		var count1=0;
		var element;
		var numberOfControls = document.getElementById('sendmailtoimported').length; 

		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
		   element = document.sendmailtoimported[controlIndex];
		   if (element.type == "checkbox") { 
			if(element.name.match('chk_inserted')) {
					count1++;	
					if(element.checked) {
					  count++;
					}
				}
			 }
		}
		if(count==count1) {
			document.sendmailtoimported.chkall_inserted.checked =true;
		} else {
			document.sendmailtoimported.chkall_inserted.checked =false;
		}
	}
 
	function checkallimporteduser() {
	 
		var controlIndex;
		var element;
		var numberOfControls = document.getElementById('sendmailtoimported').length; 
		
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	  
	       element = document.sendmailtoimported[controlIndex];
	       if (element.type == "checkbox") { 	   
	         if(document.sendmailtoimported.chkall_inserted.checked) { 			
				if(element.name.match('chk_inserted')) {			 
					element.checked=true;
				}
	 		 } else {
				
					if(element.name.match('chk_inserted')) {element.checked=false;}
				}	
			 }
	    }
	}
	
	function checkuncategoriseduser() {
	
		 var controlIndex;
		 var count=0;
		 var count1=0;
		 var element;
		 var numberOfControls = document.getElementById('sendmailtoimported').length; 

		  for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
		  
		       element = document.sendmailtoimported[controlIndex];
		       if (element.type == "checkbox") { 
			   
				if(element.name.match('chk_uncategorised')) {
				
						count1++;	
						if(element.checked) {
						
						  count++;
						}
					}
		 		 }
		    }
			if(count==count1) {
			
				document.sendmailtoimported.chkall_uncategorised.checked =true;
			} else {
			
				document.sendmailtoimported.chkall_uncategorised.checked =false;
			}
	}
		 
	function checkalluncategoriseduser() {
	 
		var controlIndex;
		var element;
		var numberOfControls = document.getElementById('sendmailtoimported').length; 
		
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
	  
		   element = document.sendmailtoimported[controlIndex];
		   if (element.type == "checkbox") { 	   
			 if(document.sendmailtoimported.chkall_uncategorised.checked) { 			
				if(element.name.match('chk_uncategorised')) {			 
					element.checked=true;
				}
			 } else {
				
					if(element.name.match('chk_uncategorised')) { element.checked=false;}
				}	
			 }
		}
	}
	
	/*	send mail to client	*/
	function checkallclients_tosendemail() {	 
		var controlIndex;
		var element;
		var numberOfControls = document.getElementById('sendemailtoclient').length; 
			for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
				element = document.sendemailtoclient[controlIndex];
				if (element.type == "checkbox") { 	   
					if(document.sendemailtoclient.checkallclients.checked) { 			
						if(element.name.match('chk')) {			 
							element.checked=true;
						}
					} else if(!document.sendemailtoclient.checkallclients.checked) { 			
						if(element.name.match('chk')) {			 
							element.checked=false;
						}	
					}
				}
			}	
	}
	
	function checkallclients_tosendemail_I() {	 
		var controlIndex;
		var element;
		var count =0;
		var countI =0;
		var numberOfControls = document.getElementById('sendemailtoclient').length; 
			for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
				element = document.sendemailtoclient[controlIndex];
				if (element.type == "checkbox") { 	   				
					if(element.name.match('chk')) {
						count ++;	
						if (element.checked == true) {			 
							countI ++;
						}					
					}
				}	
			}
			if(count==countI) {
			
				document.sendemailtoclient.checkallclients.checked =true;
			} else {
			
				document.sendemailtoclient.checkallclients.checked =false;
			}
	}
	
	function sendemailtoclient_validate() {	
		var msg="";
		var msg = "Please Fill the following: \n----------------------------------";
		var noErrors = msg;
		
		if(trim(document.getElementById('subject').value)=='') {
			msg+="\n-Please fill the subject\n";
		}
		if(trim(document.getElementById('fromname').value)==''){
			msg+="\n-Please fill the sender name\n";
		}
		if(trim(document.getElementById('fromemail').value)==''){
			msg+="\n-Please fill the sender email\n";
		}
		if(trim(document.getElementById('fromemail').value)!=''){
			var txtEmail = trim(document.getElementById('fromemail').value);
			if (chkMail(txtEmail) == false) {
				msg+="\n-Sender email is invalid\n";
			}
			
			if (chkMail(txtEmail) != false) {
				if (isInteger(txtEmail.substring(0,1)) == true) {
                    msg+="\n-First character of Email ID should not be a number.\n";
				}
			}	
		}
		
		
		/*if(trim(document.getElementById('FCKeditor1').value) == "") {
			msg+="\n-Please enter the email content\n";
		}*/
		
		/*if(document.getElementById('replyto').value==''){
			msg+="\n-Please specify the replyto\n";
		}
		if(document.getElementById('replyto').value!=''){
			if (chkMail(document.getElementById('replyto').value) == false) {
				msg+="\n-Replyto is invalid\n";
			}
		}*/
		
		var controlIndex;
		var element;
		var count =0;
		var numberOfControls = document.getElementById('sendemailtoclient').length; 
			for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
				element = document.sendemailtoclient[controlIndex];
				if (element.type == "checkbox") { 	   				
					if(element.name.match('chk')) {
						if (element.checked == true) {			 
							count ++;
						}					
					}
				}	
			}
		if(count == 0) {
			msg+="\n-Please select the Recipient(s) to send email";
		}
		
		if(msg == noErrors) {
			return true;
		} else {
			alert(msg);
			return false;
		}
	}
	
	function sendtestmail_validate() {		
		msg="";			
		var msg = "Please Fill the following: \n----------------------------------";
		var noErrors = msg;		
		
		if(trim(document.getElementById('subject').value)=='') {
			msg+="\n-Please enter the subject\n";
		}
		if(trim(document.getElementById('fromname').value)==''){
			msg+="\n-Please enter the sender name\n";
		}
		if(trim(document.getElementById('fromemail').value)==''){
			msg+="\n-Please enter the sender email\n";
		}
		if(trim(document.getElementById('fromemail').value)!=''){
			var txtEmail = trim(document.getElementById('fromemail').value);
			if (chkMail(txtEmail) == false) {
				msg+="\n-Sender email is invalid\n";
			}
			
			if (chkMail(txtEmail) != false) {
				if (isInteger(txtEmail.substring(0,1)) == true) {
                    msg+="\n-First character of Email ID should not be a number.\n";
				}
			}
		}		
		
		/*if(trim(document.getElementById('FCKeditor1').value) == "") {
			msg+="\n-Please enter the email content\n";
		}*/
		
		if(trim(document.getElementById('txtsendtestemail').value)==''){
			msg+="\n-Please enter the email id to send the testmail\n";
		}
		if(trim(document.getElementById('txtsendtestemail').value)!=''){
		
			var txtEmail = trim(document.getElementById('txtsendtestemail').value);
			if (chkMail(txtEmail) == false) {
				msg+="\n-Invalid email id\n";
			}
			if (chkMail(txtEmail) != false) {
				if (isInteger(txtEmail.substring(0,1)) == true) {
                    msg+="\n-First character of Email ID should not be a number.\n";
				}
			}
		}
		if (msg == noErrors) {
			document.sendemailtoclient.method='post';
			document.sendemailtoclient.action='index.php?module=admin&page=sendmailtoclient&action=sendtestemail';
			document.sendemailtoclient.submit();
		} else {
			// If errors were found, show alert message
			alert(msg);
			return false;
		}			
	}
	
	function saveemail_validate() {
		
		msg="";			
		var msg = "Please Fill the following: \n----------------------------------";
		var noErrors = msg;
		
		var controlIndex;
		var element;
		var count =0;
		var numberOfControls = document.getElementById('sendemailtoclient').length; 
			for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
				element = document.sendemailtoclient[controlIndex];
				if (element.type == "checkbox") { 	   				
					if(element.name.match('chk')) {
						if (element.checked == true) {			 
							count ++;
						}					
					}
				}	
			}
		if(trim(document.getElementById('subject').value)=='') {
			msg+="\n-Please enter the subject\n";
		}
		if(trim(document.getElementById('fromname').value)==''){
			msg+="\n-Please enter the sender name\n";
		}
		if(trim(document.getElementById('fromemail').value)==''){
			msg+="\n-Please enter the sender email\n";
		}
		if(trim(document.getElementById('fromemail').value)!=''){
			var txtEmail = trim(document.getElementById('fromemail').value);
			if (chkMail(txtEmail) == false) {
				msg+="\n-Sender email is invalid\n";
			}
			
			if (chkMail(txtEmail) != false) {
				if (isInteger(txtEmail.substring(0,1)) == true) {
                    msg+="\n-First character of Email ID should not be a number.\n";
				}
			}	
		}
		
		/*if(trim(document.getElementById('FCKeditor1').value) == "") {
			msg+="\n-Please enter the email content\n";
		}*/
		if(count == 0) {
			msg+="\n-Please select the Recipient(s)";
		}
		if(msg == noErrors) {
			document.sendemailtoclient.method='post';
			document.sendemailtoclient.action='index.php?module=admin&page=sendmailtoclient&action=saveemail';
			document.sendemailtoclient.submit();
		} else {
			alert(msg);
			return false;
		}
	}	
		
	function saveandclose_validate() {
		msg="";			
		var msg = "Please Fill the following: \n----------------------------------";
		var noErrors = msg;
		
		var controlIndex;
		var element;
		var count =0;
		var numberOfControls = document.getElementById('sendemailtoclient').length; 
			for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
				element = document.sendemailtoclient[controlIndex];
				if (element.type == "checkbox") { 	   				
					if(element.name.match('chk')) {
						if (element.checked == true) {			 
							count ++;
						}					
					}
				}	
			}
			
		if(trim(document.getElementById('subject').value)=='') {
			msg+="\n-Please fill the subject\n";
		}
		if(trim(document.getElementById('fromname').value)==''){
			msg+="\n-Please fill the sender name\n";
		}
		if(trim(document.getElementById('fromemail').value)==''){
			msg+="\n-Please fill the sender email\n";
		}
		if(trim(document.getElementById('fromemail').value)!=''){
			var txtEmail = trim(document.getElementById('fromemail').value);
			if (chkMail(txtEmail) == false) {
				msg+="\n-Sender email is invalid\n";
			}
			
			if (chkMail(txtEmail) != false) {
				if (isInteger(txtEmail.substring(0,1)) == true) {
                    msg+="\n -First character of Email ID should not be a number.\n";
				}
			}	
		}	
		/*if(trim(document.getElementById('FCKeditor1').value) == "") {
			msg+="\n-Please enter the email content\n";
		}*/
		if(count == 0) {
			msg+="\n-Please select the Recipient(s)";
		}
		
		if(msg == noErrors) {
			document.sendemailtoclient.method='post';
			document.sendemailtoclient.action='index.php?module=admin&page=sendmailtoclient&action=saveandclose';
			document.sendemailtoclient.submit();
		} else {
			alert(msg);
			return false;
		}
	}
	
	function show_viewclients() {
		window.location.href =	"index.php?module=admin&page=viewclients";
	}
	
    //sumathra 13 dec
    function CheckAll(frm,value,value1) {

    	if(frm.checked == true) {

    		value.checked   = true;
    		value1.checked  = true;
    	}
    }

    function ClearAll(frm,value,value1) {

    	if(frm.checked == false) {

    		value.checked   = false;
    		value1.checked  = false;
    	}
    }

    function CheckOne(frm,value,value1) {

    	if(frm.checked == true) {

    		value.checked = true;
    	} else if(frm.checked == false) {

    		value1.checked = false;
    	}
    }
	
	/*	tell a friend validate	*/
	function tellafriendvalidate() {
			
		var theMessage = '';
		
			if(document.getElementById('senderemail').value == '') {
				theMessage = theMessage + "Please enter your emailid." +"\n";	
			}
			
			if(document.getElementById('senderemail').value != '') {
				if(chkMail(document.getElementById('senderemail').value)==false){
					theMessage = theMessage + "Your emailid is invalid." +"\n";	
				}
			}
			
			if(document.getElementById('friendsemail').value == '') {
				theMessage = theMessage + "Please enter your friend emailid." +"\n";	
			}
								
			if(theMessage != '') {		
				alert(theMessage);	
				return false;
			} else {
				return true;
			}	
	}	

	function movepic(img_name,img_src) {

		document.getElementById(img_name).src=img_src;
	}
	
	function redirectto_platinumpayment() {
		
		document.platinumcheckout.method="POST";
		//document.platinumcheckout.action ="https://www.paypal.com/cgi-bin/webscr";
		//document.platinumcheckout.action ="index.php?module=home&page=upgrade";
		document.platinumcheckout.submit();
	}
	
	function redirectto_goldpayment() {
		
		document.goldcheckout.method="POST";
		//document.goldcheckout.action ="https://www.paypal.com/cgi-bin/webscr";
		//document.goldcheckout.action ="index.php?module=home&page=upgrade";
		document.goldcheckout.submit();
	}
	
	/*function ShowHide(BlockID) {

		var ie4=document.all&&navigator.userAgent.indexOf("mozilla")==-1

		if (ie4==true) {
			if(document.getElementById("BImg" + BlockID).clicksts=="0") {
				document.getElementById("BImg" + BlockID).src='/smarty/templates/images/bizeve_plus.gif'
				document.getElementById("BImg" + BlockID).clicksts="1";
				document.getElementById("BImg" + BlockID).alt="Expand";
			} else {
				document.getElementById("BImg" + BlockID).src='/smarty/templates/images/bizEve_minus.gif';
				document.getElementById("BImg" + BlockID).clicksts="0";
				document.getElementById("BImg" + BlockID).alt="Collapse";
			}
		}
		else {

			if(document.getElementById("BImg" + BlockID).clicksts=="0") {
				document.getElementById("BImg" + BlockID).src='/smarty/templates/images/bizEve_minus.gif'
				document.getElementById("BImg" + BlockID).clicksts="1";
				document.getElementById("BImg" + BlockID).alt="Collapse";
			} else {
				document.getElementById("BImg" + BlockID).src='/smarty/templates/images/bizeve_plus.gif';
				document.getElementById("BImg" + BlockID).clicksts="0";
				document.getElementById("BImg" + BlockID).alt="Expand";
			}
		}

		if(document.getElementById("b" + BlockID).style.display=='none')
			document.getElementById("b" + BlockID).style.display='block'
		else
			document.getElementById("b" + BlockID).style.display='none'
	}*/
	
	/*	for vat page	*/
	function vatblockNonNumbers(obj, e, allowDecimal, allowNegative) {
		var key;
		var isCtrl = false;
		var keychar;
		var reg;

		if(window.event) {

            key = e.keyCode;
			isCtrl = window.event.ctrlKey
		}
		else if(e.which) {

			key = e.which;
			isCtrl = e.ctrlKey;
		}

		if (isNaN(key)) return true;
		keychar = String.fromCharCode(key);

		// check for backspace or delete, or if Ctrl was pressed
		if (key == 8 || isCtrl) {

			return true;
		}

		reg = /\d/;
		var isFirstD = allowDecimal ? keychar == ',' && obj.value.indexOf(',') == -1 : false;
		return isFirstD || reg.test(keychar);
	}

	function languagevalidate() {
			msg="";
			var msg = "Please Fill the following: \n----------------------------------";
            var noErrors = msg

			var LangInter=trim(document.addlanguage.txtLangInter.value);
			if(LangInter=='') {
				msg+="\n - Please enter the international language.\n";
			}
			var LangLocal=trim(document.addlanguage.txtLangLocal.value);
			if(LangLocal=='') {
				msg+="\n - Please enter the local language.\n";
			}

			var Abbr=trim(document.addlanguage.txtAbbr.value);
			if(Abbr=='') {
				msg+="\n - Please enter the abbreviation.\n";
			}
			var CharSet=trim(document.addlanguage.txtCharSet.value);
			if(CharSet=='') {
				msg+="\n - Please enter the charSet for templates.\n";
			}

			if(LangInter!='') {
				Fieldname=isAlphabet(LangInter);
				if(Fieldname!='') {
					msg+="\n - Language(Int.) field should be in alphaphet.\n";
				}
			}

			if(LangLocal!='') {
				Fieldname=isAlphabet(LangLocal);
				if(Fieldname!='') {
					document.addlanguage.txtLangLocal.value="";
					msg+="\n - Language(Local) field should be in alphaphet.\n";
				}
			}

			if(Abbr!='') {
				Fieldname=isAlphabet(Abbr);
				if(Fieldname!='') {
					document.addlanguage.txtAbbr.value="";
					msg+="\n - Abbreviation field should be in alphaphet.\n";
				}
			}

			if(CharSet!="") {
				Fieldname=Charset(CharSet);
				if(Fieldname!='') {
					document.addlanguage.txtCharSet.value="";
					msg+="\n - Charset field should be in alphaphet.\n";
				}
			}

			var stat = document.addlanguage.LangStatus.value;
			if(stat=="") {
				msg+="\n - Please select the status.\n";
			}

			// If no errors, submit the form
            if (msg == noErrors) {
                return true;
            } else {
                // If errors were found, show alert message
                alert(msg);
                return false;
            }	
		}
		
		/*	to open the duplicate user page through view users page	*/
		function openDuplicateUser(userID) {
		
			var X = 150; // x position
			var Y = 150; // y position
			var W = 550; // width
			var H = 350; // height
			s="resizable=no,scrollbars=no,left="+X+",top="+Y+",screenX="+X+",screenY="+Y+",width="+W+",height="+H;
			window.open ('index.php?module=admin&page=duplicateuser&userid='+userID,'',s);
		}
		
		/*	validation for duplicate user 	*/
		function duplicateUserValidate() {
			msg="";

			if(document.duplicateuser_form.txtEmail.value!='') {
				if (chkMail(document.duplicateuser_form.txtEmail.value) == false)
				msg+="\n - Invlaid Email ID.\n";
			}
			nullcheck('duplicateuser_form','txtEmail','Email ID');
			//nullcheck('duplicateuser_form','txtPassword','Password');

			if(msg!='') {
				msg="Please fill the following\n_____________________________\n"+
				msg +"\n";
				alert(msg);
				return false;
			}
		}

		function duplicateUserwindowclose() {

			opener.top.location.reload();
			window.close();
		}

		function addcategoryvalidate()	{
			msg="";
			var txtName=document.category_form.txtName1.value;

			if(txtName=='') {
			
				msg+="\n - Please enter Category Name.\n";
			}

			if(txtName !='' ) {
                if(trim(txtName) == '') {

				msg+="\n - Please enter Category Name.\n";
                }
			}

			var cboParentcat1=document.category_form.cboParentcat1.value;
			if(cboParentcat1=='') {
				msg+="\n - Please select the parent category.\n";
			}

			var txtName2=document.category_form.txtName2.value;
			var txtPagetitle2=document.category_form.txtPagetitle2.value;
			var catDescription2=document.category_form.catDescription2.value;

			var cboLanguage2=document.category_form.cboLanguage2.value;
			if(txtName2!='' || txtPagetitle2!='' || catDescription2!='') {
				if(cboLanguage2=='') {
					msg+="\n - Please select the language.\n";
				}
			}

           if(cboLanguage2 != '') {
                var txtName2=document.category_form.txtName2.value;

    			if(txtName2!='') {
    				if(trim(txtName2)=="") {
    					msg+="\n - Please enter Category Name for Second Language.\n";
    				}
    			}
           }

            var CatURL  = document.category_form.chapterurl.value;
            chkCatURL   = checkURL(CatURL,"Chapter URL");

		   if(document.category_form.paypalaccount.value != '') {
			   if (chkMail(document.category_form.paypalaccount.value) == false) {
				
					msg+="\n - Invalid email id.\n";	
			   }
		   }

			if(msg!='') {
				msg="Please fill the following\n___________________________\n"+
				msg +"\n";
				alert(msg);
				return false;
			}
        }

		function editcategoryvalidate()	{
			msg="";			

			var txtName=document.editcategory_form.txtName1.value;
			if(txtName=='') {
			
				msg+="\n - Please enter Category Name.\n";
			}		
		
			if(txtName!='') {				
				if(trim(txtName)=="") {
					msg+="\n - Please enter Category Name.\n";
				}
			}			

			/*	if the categoryname is Business Directory (or) AGBC, no need to select the parent category, their
			parent category id will be zero.	*/

			if(document.editcategory_form.hidcatid.value!=1 && document.editcategory_form.hidcatid.value!=2) {
				var cboParentcat1=document.editcategory_form.cboParentcat1.value;
				if(cboParentcat1=='') {
					msg+="\n - Please select the parent category.\n";
				}
			}
			
			var txtName2=document.editcategory_form.txtName2.value;
			var txtPagetitle2=document.editcategory_form.txtPagetitle2.value;
			var catDescription2=document.editcategory_form.catDesc2.value;

			var cboLanguage2=document.editcategory_form.cboLanguage2.value;
			if(txtName2!='' || txtPagetitle2!='' || catDescription2!='') {
				if(cboLanguage2=='') {
					msg+="\n - Please select the language.\n";
				}
			}

           if(cboLanguage2 != '') {
                var txtName2=document.editcategory_form.txtName2.value;

    			if(txtName2!='') {
    				if(trim(txtName2)=="") {
    					msg+="\n - Please enter Category Name for Second Language.\n";
    				}
    			}
           }

		   var CatURL  = document.editcategory_form.chapterurl.value;
			if(CatURL != "") {
				chkCatURL   = checkURL(CatURL,"Chapter URL");
			}
			
		   if(document.editcategory_form.paypalaccount.value != '') {	
			   if (chkMail(document.editcategory_form.paypalaccount.value) == false) {

					msg+="\n - Invalid email id.\n";	
			   }
		   }

			if(msg!=''){
				msg="Please fill the following\n___________________________________\n"+
				msg +"\n";
				alert(msg);
				return false;
			}
		}

	function addclientemailValidate() {
		
		msg="";
		
		var numberOfControls = document.getElementById('checkemail').length; 				
		for (controlIndex = 0; controlIndex < numberOfControls; controlIndex++) {
			element = document.checkemail[controlIndex];
			if(element.name	== "txtFEmail") {
				
				var txtFEmail = trim(document.checkemail.txtFEmail.value);
				if(txtFEmail=='') {

					alert('Please enter email to find');
					return false;
				}

				if(txtFEmail!='') {
					if (chkMail(document.checkemail.txtFEmail.value) == false) {

						alert("\n Invlaid Email ID.\n");
						document.checkemail.txtFEmail.value = "";
						return false;
					}
				}					
			}				
		}
	}
	
	function addclientvalidate()	{

		msg="";
		
		var txtFname=document.addclient.txtFname.value;
		if(txtFname!='') {
			Fieldname=isAlphaNumeric(txtFname);
			if(Fieldname!='') {
				msg+="\n - First name should be alpha numeric.\n";
			}
			//firstspace=txtFname.substring(0,1);
			if(trim(txtFname)=="") {
				msg+="\n - Please enter first name.\n";
			}
		}

		nullcheck('addclient','txtFname','First Name');

		var txtLname=document.addclient.txtLname.value;
		if(txtLname!='') {
			Fieldlname=isAlphaNumeric(txtLname);
			if(Fieldlname!='') {
				msg+="\n - Last name should be alpha numeric.\n";
			}
			//lnamespace=txtLname.substring(0,1);
			if(trim(txtLname)=="") {
				msg+="\n - Please enter last name.\n";
			}
		}
		nullcheck('addclient','txtLname','Last Name');
		nullcheck('addclient','txtEmail','Email');

		if(document.addclient.txtEmail.value!='') {
			if (chkMail(document.addclient.txtEmail.value) == false)
			msg+="\n - Invlaid Email ID.\n";
			document.addclient.txtEmail.focus();
		}

		nullcheck('addclient','txtPassword','Password');
		pass_check('addclient','txtPassword');

		cboCategory=document.addclient.cboCategory.value;

		if(cboCategory=="") {
			msg+="\n - Please select main category.\n";
		}

		if(msg!=''){
			msg="Please fill the following\n_____________________________________\n"+
			msg +"\n";
			alert(msg);
			return false;
		}
	}

	function showviewclientfromaddclient() {
		msg="";

		var txtFname=document.addclient.txtFname.value;
		if(txtFname!='') {
			Fieldname=isAlphaNumeric(txtFname);
			if(Fieldname!='') {
				msg+="\n - First name should be alpha numeric.\n";
			}
			firstspace=txtFname.substring(0,1);
			if(trim(txtFname)=="") {
				msg+="\n - Please enter first name.\n";
			}
		}
		nullcheck('addclient','txtFname','First Name');
		var txtLname=document.addclient.txtLname.value;
		if(txtLname!='') {
			Fieldlname=isAlphaNumeric(txtLname);
			if(Fieldlname!='') {
				msg+="\n - Last name should be alpha numeric.\n";
			}
			lnamespace=txtLname.substring(0,1);
			if(trim(txtLname)=="") {
				msg+="\n - Please enter last name.\n";
			}
		}
		nullcheck('addclient','txtLname','Last Name');
		nullcheck('addclient','txtEmail','Email');
		if(document.addclient.txtEmail.value!='') {
			if (chkMail(document.addclient.txtEmail.value) == false)
			msg+="\n - Invlaid Email ID.\n";
		}
				
		nullcheck('addclient','txtPassword','Password');
		pass_check('addclient','txtPassword');			

		cboCategory=document.addclient.cboCategory.value;

		if(cboCategory=="") {
			msg+="\n - Please select main category.\n";
		}

		if(msg!=''){
			msg="Please fill the following\n_____________________________________\n"+
			msg +"\n";
			alert(msg);
			return false;
		}

		document.addclient.method="post";
		document.addclient.action="index.php?module=admin&page=addclient&action=view";
		document.addclient.submit();
	}

    /*function checkURL(value,concatinatemsg) {

		if(value != "") {
	       var urlregex = new RegExp("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$");
			if(urlregex.test(value)) {

				return(true);
			}
	        msg+="\n - "+concatinatemsg+" is not valid.\n";
	        return(false);
		}
	}*/
	
	function checkURL(value,concatinatemsg){ 
		if(value!="") {
		    var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.|http:\/\/){1}[0-9A-Za-z\.\-]*\.[0-9A-Za-z\.\-]*$"); 
		    if(urlregex.test(value)){ 
		        return true; 
		    }else{ 
				 msg+="\n - "+concatinatemsg+" is not valid.\n";
		        return false; 
		    } 
		}	
	} 
	
	function deleteblocktype() {
	
		var frm = document.cdblocktype;
		var theMessage = "Please fill the following\n___________________________\n";
		var noErrors = theMessage;
		
		if(frm.blocktype.value == '') {
		
			theMessage = theMessage + "\n - Please select the block type." +"\n"
			// If no errors, submit the form
			if (theMessage == noErrors) {
				return true;

			} else {

				// If errors were found, show alert message
				alert(theMessage);
				return false;
			}	
		} else {
			document.cdblocktype.method="post";
			document.cdblocktype.action="index.php?module=admin&page=blocktype&action=delete";
			document.cdblocktype.submit();
		}
	}
	
	/*function delete_blocktype(bid) {

		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {

			alert ("Browser does not support HTTP Request");
			return
		}

		var url ="index.php?module=admin&page=viewblocktype&type=js&blocktypeid="+bid;
		xmlHttp.onreadystatechange="" 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}

	function blocktype_confirm_delete(blocktypeid) {
	
		if (confirm("Are you sure you want to delete?")==true) {
			delete_blocktype(blocktypeid)
			return true;
		} else {
			//window.location.reload();
			return false;
		}
	}*/
