var sth=/\w+\s*$/;
var word=/\w+/;
var passreg=/^[\w_\d@\.\$-]+$/;
var emlreg=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
var zipreg=/^\s*\d+\s*$/;
var phonereg=/^[+]{0,1}\d+([-]{0,1}\d+){0,2}$/;
var mobilereg=/^[+]{0,1}\d+$/;
var decreg=/^\d+[\.]{0,1}\d*/
var numreg=/\d+/

var decreg=/^\d+(\.{1}\d{1,2})?$/
var qtyreg=/^\s*\d+\s*$/;
var dtreg=/(19|20)\d\d[- \/.](0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])/;
var timereg=/((?:0?[0-9]|1[0-9]|2[0-3]):[0-5][0-9])/
var usphonereg=/^\d{3}-\d{3}-\d{4}$/;
var emailreg=emlreg;
var userreg=/^[\w\d]{6,}$/

var urlreg=/http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
function popWindow(url,wid,height1,scroll1)
{

 if(wid==undefined)
     wid=500;
	 if(height1==undefined)
	 height1=400;
left1=100+wid/2;
top1=100+height1/2;
if(scroll1==undefined)
  scroll1=0;
  
var wind=window.open(url,'file1',"width="+wid+",height="+height1+",scrollbars="+scroll1+",left="+left1+",top="+top1);
  




}
function redirect(url)
{
	if(url)
window.location.href=url;	
	
	
}
function validatead()
{

var ctl;
ctl=document.getElementById("link");
 if(ctl.value.search(sth)!=-1)

         if(ctl.value.indexOf(".")==-1 )
		 {
		 alert("Either leave url blank or fill it properly");
		 ctl.focus();
		 return false;
		 
		 }

ctl=document.getElementById("display");
 if(ctl.value.search(sth)==-1)
     {
	 
	 alert("Please enter message");
	 ctl.focus();
	 return false;
	 }



}


function getCtl(id)
{

var ctl=document.getElementById(id);
   return ctl;



}

function getValue(id)
{
//alert(id);
var ctl=document.getElementById(id);
 
   
	return ctl.value;
	




}

function setValue(id,value1)
{


var ctl1=document.getElementById(id);
       
	  ctl1.value=value1;
	     




}
function setHTML(id,value1)
{

var ctl1=document.getElementById(id);
       
	  ctl1.innerHTML=value1;




}


function getobject()
{
	
	 if(window.XMLHttpRequest) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
			
		}
    }

	
	return req;
	
	
	
}
function validateNumber(ctl)
{

if(ctl.value.search(qtyreg)==-1)
      {
	  
	  alert("Please enter a positive number");
	  ctl.focus();
	  return false;
	  
	  }


}





function validateTime(ctl)
{


if(ctl.value.search(timereg)==-1)
       {
	   
	   alert("Time is not in a proper format .Please enter time in hh:mm:ss format");
	   ctl.focus();
	   return false;
  
	   
	   }


}

function validateDate(ctl)
{

if(ctl.value.search(dtreg)==-1)
       {
	   
	   alert("Date is not in a proper format .Please enter date in yyyy-mm-dd format");
	   ctl.focus();
	   return false;
	   
	   
	   
	   }


}
function emptyDiv(divid)
 {
	 
	 
	ctl=getCtl(divid);
	
	if(ctl)
	   {
		   
		   
		ctl.innerHTML='';  
		   
	   }
	 
	 
	 
	 
 }

function validateDec(ctl)
{

if(ctl.value.search(decreg)==-1)
      {
	  
	  alert("Please enter valid decimal number upto 2 decimal places");
	  ctl.focus();
	  return false;
	  
	  }




}


  function goToUrl(ur)
  {
	  
	window.location.href=ur;  
	  
	  
	  
	  
  }

function goBack()
{
	
if(window.history.back)
    {
		
	window.history.go(-1);	
		
		
	}
	
	
	
	
	
}

function checkAll(flag,prefix,tot)
{
	
	
	
for(i=0;i<=tot;i++)
    {
		
	ctltemp=prefix+i;
	
	ctl=getCtl(ctltemp);
	
	  if(ctl)
	    {
			
		ctl.checked=flag;	
		
		
			
			
		}
		
		
		
		
	}
	
	
}
function chkAll(ctl,prefix,tot)
  {
	//alert(prefix);
	//alert(tot);
	  flag=ctl.checked;
	  
	  if(prefix==undefined)
	    prefix="checkbox";
		
		if(tot==undefined)
		tot='tot';
		
		checkAll(flag,prefix,getValue(tot));
	  
	  
  }
function hideDiv(divid)
 {
	 
	 
	  ctltemp=getCtl(divid);   
	
	  if(ctltemp)
	  ctltemp.style.display="none"; 
	 
	 
	 
 }

function showDiv(divid)
   {
	   
	   
    ctltemp=getCtl(divid);   
	
	  if(ctltemp)
	  {
	 
	  if(!document.all)
	  ctltemp.style.display="table-row";
	 else
	 ctltemp.style.display="block";
	   
	  }
	   
   }

function  confirmDelete(msg)

 {
	 
	 
	return window.confirm(msg); 
	 
	 
	 
 }
  function markSel(ind,prefix,ctl12)
        {
			if(prefix==undefined)
			prefix="tr";
	   if(getCtl('tot'))
	 tot1= getValue('tot');
	  else
	  
	  tot1=50;
	  for(i=0;i<tot1;i++)
	     {
			 tempctl=prefix+i;
			 ctl1=getCtl(tempctl);
			 if(!ctl1)
			 continue;
			if(i%2==0)
			 {
				 
				 ctl1.className="tdf";
				 
			 }
			 else
			 {
				 
				 
				ctl1.className="tds"; 
				 
				 
			 }
			 
			 
			 
		 }
		// alert(ctl12);
		 if( ctl12!=undefined)
		 {
			 //alert("if")
		 if(ctl12.checked)
			 {
			 ct=prefix+ind;
			ct1= getCtl(ct);
			ct1.className="tdsel";
			
			 }
		 
		 }
		 else
		 {
			 //alert("inelse");
			  ct="tr"+ind;
			ct1= getCtl(ct);
			ct1.className="tdsel";
			 
		 }
	 
  }
  
 function getSelectedRadio(radioctl)
    {
		
		
	radlength=radioctl.length;	
		
		for(i=0;i<radlength;i++)
		   {
			   
			 if(radioctl[i].checked)
			 
			 return i;
			   
			   
			   
		   }
		   
		   
		
		   
		   return -1;
	}
 
  
	  