function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}
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){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
}
function validate_registerfrm(){
	var f = document.addusers.email;
	if ( ( f.value == null ) || ( f.value == "" ) )
		{
			alert("Please Enter Email address!");
			f.focus();
			return false;
		}
		if ( echeck(f.value) == false )
		{
			f.value = "";
			f.focus();
			return false;
		}
	if (document.addusers.password.value=='')
		{
			alert("Please Enter Password");
			document.addusers.password.focus();
			return false;
		}	
	if (document.addusers.firstname.value=='')
		{
			alert("Please Enter First Name");
			document.addusers.firstname.focus();
			return false;
		}
	if (document.addusers.lastname.value=='') 
		{
			alert("Please Enter Last Name");
			document.addusers.lastname.focus();
			return false;
		}
}

function validate_contactus_frm(){	
	var f = document.contactus_frm.email;	
	if ( ( f.value == null ) || ( f.value == "" ) )
		{
			alert("Please Enter Email address!");
			f.focus();
			return false;
		}
		if ( echeck(f.value) == false )
		{
			f.value = "";
			f.focus();
			return false;
		}
}

function validate_loginfrm1(){
	if(document.loginfrm1.email.value=='') {
		alert('Please Enter Username!');
		document.loginfrm1.email.focus();
		return false;
	}
	if(document.loginfrm1.password.value=='') {
		alert('Please Enter Password!');
		document.loginfrm1.password.focus();
		return false;
	}
}

function checkAll(formname)
{
	var rs = (formname.chkall.checked)?true:false;
	for(i=0;i<formname.elements.length;i++)
	{
	  	if(formname.elements[i].id == 'iId')
  		{
			formname.elements[i].checked = rs;
		}
	}  
}
function change1(mysitename)
{
	if ( mysitename == "2") {
		window.document.getElementById("a1").style.display='';
		window.document.getElementById("d1").style.display='none';
	}
	if ( mysitename == "3" || mysitename == "1") {
		window.document.getElementById("a1").style.display='none';
		window.document.getElementById("d1").style.display='';
		
	}
}
function change2(mysitename)
{
	if ( mysitename == "2") {
		window.document.getElementById("a2").style.display='';
		window.document.getElementById("d2").style.display='none';
	}
	if ( mysitename == "3" || mysitename == "1") {
		window.document.getElementById("a2").style.display='none';
		window.document.getElementById("d2").style.display='';
		
	}
}
function change3(mysitename)
{
	if ( mysitename == "2") {
		window.document.getElementById("a3").style.display='';
		window.document.getElementById("d3").style.display='none';
	}
	if ( mysitename == "3" || mysitename == "1") {
		window.document.getElementById("a3").style.display='none';
		window.document.getElementById("d3").style.display='';
		
	}
}
function generateRow() {
var d=document.getElementById("div");
d.innerHTML+="<input type='file' name='image[]'><br><br>";
}
function ahmed(getid,type) {
	if (window.confirm('Are you sure You want to Delete?')) { 
		window.open("delete.php?Id="+getid+"&type="+type,"_top");
	}
}
function validate_addlangfrm() {
	if ( document.addlangfrm.langname.value == '' ) {
		alert('Please Enter Langname Name!');
		document.addlangfrm.langname.focus();
		return false;
	}
	if ( document.addlangfrm.langsrtname.value == '' ) {
		alert('Please Enter Langname Short Name!');
		document.addlangfrm.langsrtname.focus();
		return false;
	}
	if ( document.addlangfrm.langutf.value == '' ) {
		alert('Please Enter Langname UTF!');
		document.addlangfrm.langutf.focus();
		return false;
	}
	if ( document.addlangfrm.status.value == '' ) {
		alert('Please Enter Langname Status!');
		document.addlangfrm.status.focus();
		return false;
	}

}
function validate_addwebpage() {
	if ( document.addwebpage.pagename.value == '' ) {
		alert('Please Enter Page Name!');
		document.addwebpage.pagename.focus();
		return false;
	}
	if ( document.addwebpage.disorder.value != '' ) {
	if(isNaN(document.addwebpage.disorder.value)==true) {
		alert("Please enter Numeric Data");
		document.addwebpage.disorder.focus();
		return false;
	}
	}

}