var sx; //clientwidth
var sy; //clientheight
var ow; //scrollwidth
var oy; //scrollheight

function pagesizecalculator() {
    sx = document.documentElement.clientWidth;
    sy = document.documentElement.clientHeight;

    ow = document.body.scrollWidth;
    oy = document.body.scrollHeight;


    var browser = navigator.userAgent;
    var intflag = browser.indexOf("Firefox");


    browser = navigator.appName;

    if (browser == "Microsoft Internet Explorer" || intflag != -1) {
        ow = document.documentElement.scrollWidth;

    }


    



}

function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

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){
		   
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false
		 }

 		 return true					
	}
function validstring(data){
   var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~_"; 
   for (var i = 0; i < data.length; i++) {
  	  if (iChars.indexOf(data.charAt(i)) != -1) {
  	  	return false;
  	  }
   }
   return true;
}
function validemail(str){
	var emailID=str;
	
	if ((emailID==null)||(emailID=="")){
		return false
	}
	if (echeck(emailID)==false){
		return false
	}
	return true
 }

function validmobile(str)
{
var x = str;
if(isNaN(x)||x.indexOf(" ")!=-1)
{

return false
}
return true
}
/*function Validate()     for both mobile and phone no.
{
var x = document.form1.txtPhone.value;
var y = document.form1.txtMobile.value;
if(isNaN(x)||x.indexOf(" ")!=-1)
{
alert("Enter numeric value")
return false;
}
if (x.length>8)
{
alert("enter 8 characters");
return false;
}
if (x.charAt(0)!="2")
{
alert("it should start with 2 ");
return false
}

if(isNaN(y)||y.indexOf(" ")!=-1)
{
alert("Enter numeric value")
return false;
}
if (y.length>10)
{
alert("enter 10 characters");
return false;
}
if (y.charAt(0)!="9")
{
alert("it should start with 9 ");
return false
}
}*/
function validurl(str) {
     var theurl=str;
     var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(theurl))
     {
         return true;
     }
     else
     {
           return false; 
     }
}
function validnumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   function validnumericwithdesh(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function textarealen(ctl1,ctl2,lent)
{

 var str=document.getElementById(ctl1).value;
 var a = str.length;
 if(a>lent)
 {
 str=str.substring(0,lent);
 document.getElementById(ctl1).value=str;
 a = str.length;
 }
 document.getElementById(ctl2).innerHTML=lent-a;
 
}
function escapeHTML(strXML) {

    var reGT = />/gi;
    var reLT = /</gi;
    var reQUOT = /"/gi;
    var reAMP = /&/gi;
    var reAPOS = /'/gi;
    strXML = strXML.replace(reAMP, "&amp;").replace(reQUOT, "&quot;").replace(reLT, "&lt;").replace(reGT, "&gt;").replace(reAPOS, "&apos;");
	return(strXML);
}
function convertand(strXML){
	strXML=strXML.replace(/&/g,"%26");
	return(strXML);
}
function validno(str)
{
var x =  document.getElementById(str).value;
if(isNaN(x)||x.indexOf(" ")!=-1)
{
alert('Please Enter Correct Mobile No.');
return false;
}
return true;
}

function printPartOfPage(elementId,loc) {
	
	var i=document.getElementById('lvalue').value;

for(var j=i;j>=1;j--)
{
	document.getElementById('a'+j).style.display="none";
}

var printContent = document.getElementById(elementId);
var windowUrl = 'about:blank';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');

printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();

window.location=loc;

}

function chkemail()
{
	var x=document.getElementById('email').value;
	
	if(x=="" || x=="Email Address")
	{
		alert("Email Id");
		return false;
	}
	
	if(validemail(x))
	{
		
	}
	else
	{
		alert("Please Enter Correct Email Address");
		return false;
	}
	
	x=document.getElementById('question').value;
	if(x=="" || x=="Your question here...")
	{
		alert("Please Ask A Question To Be Send ..");
		return false;
	}
	return true;
	
}

function chkcontact()
{
	var x=document.getElementById('uname').value;
	if(x=="" || x=="Name")
	{
		alert("Please Enter Your Name ");
		return false;
	}
	
	var x=document.getElementById('comment').value;
	if(x=="" || x=="Comment")
	{
		alert("Please Enter Your Comment ");
		return false;
	}
	
	var x=document.getElementById('email').value;
	
	if(x=="" || x=="Email Id")
	{
		alert("Please Enter Your Email ");
		return false;
	}
	
	if(validemail(x))
	{
		
	}
	else
	{
		alert("Please Enter Correct Email Address");
		return false;
	}
	

	return true;
}


