// JavaScript Document

	function isEmpty(fname)
	{
		invalid = " ";
	
		flag = 1;
		for(ttt=0;ttt<fname.value.length;ttt++)
		{
			if(fname.value.charAt(ttt)!=invalid)
			{
				//alert('sdf');
				break;
			}
		}
		if(ttt==fname.value.length) flag = 0;
		if(flag==0) return true;
		if((fname.value=="") ||(fname.value==invalid))
			return true;
		else
			return false;
	}
	
	function checkValidURL(field)
	{
		var httpregex=/^([a-zA-Z]+:\/\/)/
		var urlregex=/^\w+.[.\w]*\w$/;
		var value=field.value;
		var match=value.match(httpregex); // has a protocol indicator
		 if (match){
			  match=field.value.substr(match[1].length,value.length)
			  match=match.match(urlregex);
		 }else{
			  var match=value.match(urlregex);
		 }
		 if(!match){
			 
			  return false;
		 }else return true;
	}
	

	
	

	function check_url(address) 
	{
		if (((address.indexOf ('http://') == -1) && (address.indexOf ('https://') == -1)) || (address.indexOf('.') == -1))
			return false; 
		/*else
		re =	 /\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov|biz)$/i;
		if (!re.test(address)) 
		{
			return false;
		}*/
		return true;
	}

	function emailCheck(email)
	{
		var tmp = "" + email + "", s = tmp.replace(/^\s*|\s*$/g, "");
		var re = /^(\w|[^_]\.|[\-])+((\@){1}([^_]))(([a-z]|[\d]|[\-]|\.)+|([^_]\.[^_])*)+\.[a-z]{2,3}$/i
		if (!re.test(s)) 
		{
			return false;
		}
		re =	 /\.(a[c-gil-oq-uwz]|b[a-bd-jm-or-tvwyz]|c[acdf-ik-orsuvx-z]|d[ejkmoz]|e[ceghr-u]|f[i-kmorx]|g[abd-ilmnp-uwy]|h[kmnrtu]|i[delm-oq-t]|j[emop]|k[eg-imnprwyz]|l[a-cikr-vy]|m[acdghk-z]|n[ace-giloprtuz]|om|p[ae-hk-nrtwy]|qa|r[eouw]|s[a-eg-ort-vyz]|t[cdf-hjkm-prtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[admrw]|com|edu|net|org|mil|gov|biz)$/i
		if (!re.test(s)) 
		{
			return false;
		}
		re = /\@\@/
		return(!re.test(s));
	}
	function textCounter(field, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	//else 
	//countfield.value = maxlimit - field.value.length;
	}
	

	function CheckAll(frmNam)
	{
		var intCounter = 0 ;
		var tot=0;
		tot = eval("document."+frmNam+".elements."+"length");
		box = eval("document."+frmNam+".elements");
		tot = tot - 1;
		var intCounter = 0 ;
		for(intCounter=0;intCounter<=tot;intCounter++) 
		{
			if(box[intCounter].type=="checkbox")
			{
				box[intCounter].checked=true;
			} 
		} 
			
	}
	
	function goCan(loc)
	{
		window.location = loc;
	}
	
	function ClearAll(frmNam)
	{
		var intCounter = 0 ;
		var tot=0;
		tot = eval("document."+frmNam+".elements."+"length");
		box = eval("document."+frmNam+".elements");
		tot = tot - 1;
		var intCounter = 0 ;
		for(intCounter=0;intCounter<=tot;intCounter++) 
		{
			if(box[intCounter].type=="checkbox")
			{
				box[intCounter].checked=false;
			} 
		} 
			
	}	
	
	function updateOrder(cnt,formname,page)
	{
		fname = eval("document."+formname);
		var orders = "";
		for(j=1;j<=cnt;j++)
		{
			order = eval("document."+formname+".order" + j);			
			box = eval("document."+formname+".unchk" + j);			
			orders = orders + box.value + "=" +order.value + ",";
		}
		orders = orders.substring(0,orders.length-1);
		//alert(orders);
		fname.itemorder.value = orders;
		fname.action = page;
		fname.option.value = "updateOrder";
		fname.submit();
	}
	
	function DeleteChecked(cnt,formname,page)
	{
		var flag = 0;
		fname = eval("document."+formname);
		//alert("JJ"); return;
		for(j=1;j<=cnt;j++)
		{
			box = eval("document."+formname+".unchk" + j);
			//alert(box.value);
			if(box.checked == true)
			{
				flag = 1;
				break;
			}
		}
		if(flag==0) //if any item not selected
		{
			if(cnt==0) alert("No record to delete");
			else alert("Please select record to delete");
		}
		else
		{
			var ids = "";
			var x = confirm("Are you sure you want to delete?");
			if(x) //to delete selected menu and its submenus
			{
				for(j=1;j<=cnt;j++)
				{
					box = eval("document."+formname+".unchk" + j);
					//alert(box.value);
					if(box.checked == true)
						ids = ids + box.value + ",";
				}
				ids = ids.substring(0,ids.length-1);
				fname.appid.value = ids;
				fname.action = page;
				fname.submit();
			}
			else
			{
				for(j=1;j<=cnt;j++)
				{
					box = eval("document."+formname+".unchk" + j);
					box.checked = false;
				}
			}
		}
	}
	
	function SendMail(cnt,formname,page)
	{
		var flag = 0;
		fname = eval("document."+formname);
		var actval = "";
		actval = eval("document."+formname+".act");
		
		for(j=1;j<=cnt;j++)
		{
			box = eval("document."+formname+".unchk" + j);
			//alert(box.value);
			if(box.checked == true)
			{
				flag = 1;
				break;
			}
		}
		if(flag==0) //if any item not selected
		{
			if(cnt==0) alert("No record to send mail");
			else alert("Please select record to send mail");
		}
		else
		{
			var x = confirm("Are you sure you want to send group mail?");
			if(x) //to delete selected menu and its submenus
			{
				var ids = "";
				for(j=1;j<=cnt;j++)
				{
					box = eval("document."+formname+".unchk" + j);
					//alert(box.value);
					if(box.checked == true)
						ids = ids + box.value + ",";
				}
				ids = ids.substring(0,ids.length-1);
				fname.option.value = "SendMail";
				fname.appid.value = ids;
				fname.action = page;
				fname.submit();
			}
			else
			{
				for(j=1;j<=cnt;j++)
				{
					box = eval("document."+formname+".unchk" + j);
					box.checked = false;
				}
			}
		}
	}
	
	function ExtendChecked(cnt,formname,page)
	{
		var flag = 0;
		fname = eval("document."+formname);
		var actval = "";
		actval = eval("document."+formname+".act");
		
		for(j=1;j<=cnt;j++)
		{
			box = eval("document."+formname+".approv" + j);
			//alert(box.value);
			if(box.checked == true)
			{
				flag = 1;
				break;
			}
		}
		if(flag==0) //if any item not selected
		{
			if(cnt==0) alert("No record to extend date");
			else alert("Please select record to extend date");
		}
		else
		{
			var x = confirm("Are you sure you want to extend date?");
			if(x) //to delete selected menu and its submenus
			{
				actval.value = "Approve";
				fname.action = page;
				fname.submit();
			}
			else
			{
				for(j=1;j<=cnt;j++)
				{
					box = eval("document."+formname+".approv" + j);
					box.checked = false;
				}
			}
		}
	}
	function IsInti(sText)
	{
		var ValidChars = "0123456789";
		var IsNumber=true;
		var Char;
		
		var check = 0;
		for (i = 0; i < sText.length && IsNumber == true; i++) 
		{ 
			Char = sText.charAt(i);
			
			if (ValidChars.indexOf(Char) == -1) 
			{
				IsNumber = false;
			}
		}
	   return IsNumber;
	   
	}
	
	function AllDigits()
	{
	  	if (!(window.event.keyCode>=48 && window.event.keyCode <=57)) 
			window.event.keyCode = 8;
	}
	
	function AllDigits_Paste()
	{	var str=window.clipboardData.getData('Text');
		if(isNaN(str))
		{
			return false;
		}
	}
	
	function WindowPopup(url, width_in, height_in) 
	{
		new_window = window.open(url,'window','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,top=50,left=100,scrollbars=yes,width=' + width_in + ',height=' + height_in);
		new_window.focus();
	}

	function WindowPop(url, width_in, height_in) 
	{
		new_window = window.open(url,'window','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,top=50,left=100,scrollbars=yes,width=' + width_in + ',height=' + height_in);
		new_window.focus();
	}
	
	function WindowPopup1(url, width_in, height_in) 
	{
		new_window = window.open(url,'window','toolbar=no,location=yes,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,top=50,left=100,scrollbars=yes,width=' + width_in + ',height=' + height_in);
		new_window.focus();
	}
	
	
	function PhoneDigits()
	{
	 	if (!(window.event.keyCode>=48 && window.event.keyCode <=57) && !(window.event.keyCode==32)&& !(window.event.keyCode==45)) 
		{
			window.event.keyCode = 8
		} 
	
	}
	function gotoPage(pagename)
	{
		document.frmtop.option.value=pagename;		
		document.frmtop.submit();
	}
	function gotoPage1(idtype,id)
	{
		document.frmleft.option.value=idtype;		
		document.frmleft.appid.value=id;		
		document.frmleft.submit();
	}
	function gotoLevel2(idtype,id)
	{
		document.frmleft.option.value=idtype;		
		document.frmleft.appid.value=id;		
		document.frmleft.action='level2.php';		
		document.frmleft.submit();
	}
	function gotoLevel3(idtype,id)
	{
		document.frmleft.option.value=idtype;		
		document.frmleft.appid.value=id;		
		document.frmleft.action='level3.php';		
		document.frmleft.submit();
	}
	function openwindow(src)
	{
		window.open(src,'view','width=400,height=300,top=50,left=100,scrollbars=no');
		return;
	}
// Set the horizontal and vertical position for the popup

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}



