function checkLogin(chk)
{
	if(chk.userName.value.length==0)
	{
		alert("User Name can not be left blank");
		chk.userName.focus();
		return false;
	}

	if(chk.password.value.length==0)
	{
	alert("Password can not be left blank");
	chk.password.focus();
	return false;
	}
}

function trim (strVar) { 
	if(strVar.length >0)
	{
		while(strVar.charAt(0)==" ")  //Left Trim
			strVar=strVar.substring(1,strVar.length); 
		while(strVar.charAt(strVar.length-1)==" ")  //Right Trim
			strVar=strVar.substring(0,strVar.length-1);	
	}
	return strVar; 
}
function isNotAlphabets(str){
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.substring(i, i + 1);
		if((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch)) 
		{					
			return true;
		}
	}
	return false;
}
function isNotID(str){
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.substring(i, i + 1);
		if((ch < '0' || '9' < ch) && ((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch))) 
		{
			if(ch == "_") continue;
			return true;
		}
	}
	return false;
}
function isValidEmail(emailid){		
	var l=emailid.length;
	if(l==0)
	{
		return false;	
	}
	if(l!=0)
	{
		var a=emailid.indexOf('@');
		var d=emailid.lastIndexOf('.');
		var str1=emailid.substr(0,a);
		var str2=emailid.substr(a+1,d-a-1);
		var str3=emailid.substr(d+1,l);
		var len1=str1.length;
		var len2=str2.length;
		var len3=str3.length;
		if(a<0 || d<2)
		{
			alert ("Check for missing '@' or '.' ");
			return false;
		}
		else if (a>d)
		{
			alert ("Invalid email. Please enter correct email address");
			return false;
		}				
		if (len1<=1 || len2<=1 || len3 <=1)
		{
			alert ("Invalid email. Please enter correct email address");
			return false;
		}				
	}
	return true;
}
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
function EXIM_goTo( url ) {
	window.location.href = url;
}
var pop='';

function openwin(nm,width,height) {
	var name=nm;
	if (pop && !pop.closed) {
		pop.close();
	}
	pop=eval("window.open('"+name+"','NewWIN','chrome[4],toolbar=no,left=5,top=5,width="+width+",height="+height+",directories=no,menubar=no,SCROLLBARS=yes,left=2,right=2')");
	if (!pop.opener) popUpWin.opener = self;
}
function closewin()
{
	window.close();
}
/*Used in All Cp Modules*/
function checkAll(checked)
{
	for(var i=0;i<document.removeForm.elements.length;i++)
	{ 
		var e = document.removeForm.elements[i];
		if(e.type == "checkbox") e.checked = checked;
	}
}
function checkAllAuction(checked)
{
	for(var i=0;i<document.form.elements.length;i++)
	{ 
		var e = document.form.elements[i];
		if(e.type == "checkbox") e.checked = checked;
	}
}
function checkAllFreight(checked)
{
	for(var i=0;i<document.frmdelStatus.elements.length;i++)
	{ 
		var e = document.frmdelStatus.elements[i];
		if(e.type == "checkbox") e.checked = checked;
	}
}

function checkAllperm(checked)
{
	for(var i=0;i<document.showPermFrm.elements.length;i++)
	{  
		var e = document.showPermFrm.elements[i];
		if(e.type == "checkbox") e.checked = checked;
	}
}

function checkAllperm1(checked)
{
	for(var i=0;i<document.permFrm.elements.length;i++)
	{  
		var e = document.permFrm.elements[i];
		if(e.type == "checkbox") e.checked = checked;
	}
}

function deleteAlert(theForm)
{
	var records = theForm.records.value;
	var total = 0;
	var msg = "";
	if(records>0)
	{
		for(i=0; i<theForm.length; i++)
		{
			e=theForm.elements[i];
			name = e.name;
			name = name.substr(0,4);
			if (e.type=='checkbox' && name == "item")
			{
				if(eval('e.checked') == true)
				{
					total= total+1;
				}
			}
		}
		if(total >0)
		{
			msg = msg + 'Do You Like to remove ' + total +' records ?';
		}
		else
		{
			alert("Please check the items to remove !");
			return false;
		}
		if(msg.length >0)
		{
			var flag;
			flag = confirm(msg + " If Yes Press \"OK\" else Press \"Cancel\".");
			if(flag == true)
			return true;
		}
	}
	return false;
}
function isNotNumeric(str){
	for (var i = 0; i < str.length; i++)
	{
		var ch = str.substring(i, i + 1);
		if((ch < '0' || '9' < ch)) 
		{
			if(ch == "-" || ch == ".") continue;
			return true;
		}
	}
	return false;
}
function autoAlertCheck(theForm){
	//Email
	var email = theForm.email.value;
	var name = theForm.name.value;
	if(name.length == 0)
	{
		alert("Please enter Name");
		theForm.name.focus();
		return false;
	}
	if(email.length == 0)
	{
		alert("Please enter Email ID");
		theForm.email.focus();
		return false;
	}
	if(validEmail(email) == 0)
	{	
		alert("Please Enter Valid Email!!");
		theForm.email.focus();
		return false;
	}
	return true;
}

function validEmail(str)
{
	mailRE = new RegExp( );
	mailRE.compile( '^[\._a-z0-9-]+@[\.a-z0-9-]+[\.]{1}[a-z]{2,4}$', 'gi' );
	return (mailRE.test(str));
}