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 emailreg=emlreg;

function popWindow(url,wid,height1)
{



 if(wid==undefined)
     wid=500;
	 if(height1==undefined)
	 height1=400;
//left1=10+wid/2;
left1 = 100;
top1=10+height1/2;

var wind=window.open(url,'file1',"width="+wid+",height="+height1+",scrollbars=1,left="+left1+",top="+top1);
  




}
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)
	  ctltemp.style.display="block";
	   
	   
	   
   }

function  confirmDelete(msg)

 {
	 
	 
	return window.confirm(msg); 
	 
	 
	 
 }
  function markSel(ind)
        {
	   if(getCtl('tot'))
	 tot1= getValue('tot');
	  else
	  
	  tot1=50;
	  for(i=0;i<tot1;i++)
	     {
			 tempctl="tr"+i;
			 ctl1=getCtl(tempctl);
			 if(!ctl1)
			 continue;
			if(i%2==0)
			 {
				 
				 ctl1.className="tdf";
				 
			 }
			 else
			 {
				 
				 
				ctl1.className="tds"; 
				 
				 
			 }
			 
			 
			 
		 }
		 ct="tr"+ind;
		ct1= getCtl(ct);
		ct1.className="tdsel";
	  
  }

function openperent(filename)
	{
	
	  window.parent.hidePopWin();	
	  //window.parent.open(filename,  900, 500, true);
	  
	  window.parent.location.href = filename;
				
  
   }
   
   

function Show(path,evt,fleft,fright)
{
var divTag = document.getElementById("imagepoo1");
divTag.style.position = "absolute";

ke = navigator.appName;
if(ke=='Microsoft Internet Explorer' )
{
	divTag.style.left=mouseX(evt)+20;
	divTag.style.top=mouseY(evt)-150;
	
	
	
}
else
{
	divTag.style.left=evt.clientX +fleft+'px';

	divTag.style.top=evt.clientY+fright+'px';
	

//alert(document.body.scrollTop + evt.clientY - 215);
	
}



divTag.innerHTML="<img src="+ path +"  alt=Image Loding..>";
divTag.style.display = "block";
}


function Show2(path,evt,fleft,fright)
{
var divTag = document.getElementById("imagepoo1");
divTag.style.position = "absolute";

ke = navigator.appName;
if(ke=='Microsoft Internet Explorer' )
{
	divTag.style.left=mouseX(evt)-380;
	divTag.style.top=mouseY(evt)-150;
	
	
	
}
else
{
	divTag.style.left=evt.clientX +fleft+'px';

	divTag.style.top=evt.clientY+fright+'px';
	

//alert(document.body.scrollTop + evt.clientY - 215);
	
}



divTag.innerHTML="<img src="+ path +"  alt=Image Loding..>";
divTag.style.display = "block";
}


function xleft(event)
{
x1=event.screenX;

return x1;

}



function ytop(event)
{
y1=event.screenY;

return y1;

}


function mouseX(evt) {
if (evt.pageX) 
return evt.pageX;
else if (evt.clientX)
return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}
   

function createOption(ctlid ,text,value)
{
	
	
ctl=getCtl(ctlid);	

var opt=new Option(text,value);
ctl.options.add(opt);
	
	
}
