function checkemail()
	{
	var stremail, strError, countAtRate, countDot, i;
	var checkAtRate, checkDot;
	var ValidChars,CountValidChars;
	ValidChars="abcdefghijklmnopqrstuvwxyz0123456789_.@ABCDEFGHIJKLMNOPQRSTUVWXYZ-";
	stremail = checkemail.arguments[0];
	countAtRate=0;
	countDot=0;
	CountValidChars=0;
	if (stremail.length >= 7)
		{
		for(i=0;i<stremail.length;i++)
			{
			if(stremail.charAt(i)=="@")
				countAtRate++;
			if(stremail.charAt(i)==".")
				countDot++;
			CountValidChars=0;
			for(j=0;j<ValidChars.length;j++)
				{
				if(stremail.charAt(i)==ValidChars.charAt(j))
					{
					CountValidChars++;
					}
				}
			if(CountValidChars==0)
				{
				strError=0;
				break;
				}
			}
		}
	checkAtRate=stremail.indexOf("@",1);
	checkDot=stremail.indexOf(".",1);
	for(i=1;i<countDot;i++)
		checkDot=stremail.indexOf(".",checkDot+1);
	if(countAtRate==1 && countDot > 0 && stremail.length >=7 && strError != 0)
		strError=1;
	else
		strError=0;
	if(checkDot>=stremail.length-2)
		strError=0;
	if(stremail.charAt(0)=="@" || stremail.charAt(stremail.length-1)=="@")
		strError=0;
	if(stremail.charAt(0)=="." || stremail.charAt(stremail.length-1)==".")
		strError=0;
	if(checkDot < checkAtRate)
		strError=0;

	return strError;
}

/*------------------------------------------------------------------------*/

function chkSpace(txtfield)
{
	var i,j;
	j=0;
	txtfield=eval(txtfield)
	var txtval=txtfield.value;
	for(i=0;i<txtval.length;i++)
	{
		j++
		if(txtval.substr(i,1)!=" ")
			break;
	}
	txtval=txtval.substr(j-1,txtval.length);
	if(txtval==" ")
	   txtval="";

	txtfield.value=txtval;
	return(txtval);

}

/*------------------------------------------------------------------------*/

function checkInt(txtfield)
{
	txtfield=eval("document.frm."+txtfield)
	txtval=txtfield.value;
	var newVal=parseInt(txtval);
	if (isNaN(newVal))
		txtfield.value=0;
	else if (newVal<0)
		txtfield.value=0;
	else
		txtfield.value=newVal;
}

/*------------------------------------------------------------------------*/

function checkCur(ObjName)
{
	ObjectName=eval("document.frm."+ObjName);
	ObjVal = '' + ObjectName.value;
	if(ObjVal=="") ObjVal="0";
		for(i=0;i<ObjVal.length;i++)
		    ObjVal=ObjVal.replace(",","");
		for(i=0;i<ObjVal.length;i++)
		    ObjVal=ObjVal.replace("-","");

	if(isNaN(ObjVal)==true)
   	{
		ObjectName.value="0.00"
   	}
	else
	{
		var NegSign="";
      	if(ObjVal.substr(0,1)=="-") {NegSign="-";}
   		ObjVal=parseFloat(ObjVal);
   		PInt=parseInt(ObjVal);
   		PtValue=".00";
   		PInt=Math.abs(PInt);
   		ObjVal=Math.abs(ObjVal);
   		PInt='' + PInt;
   		ObjVal=''+ ObjVal;
   		if(PInt.length!=ObjVal.length)
   		{
			PtValue='' + ObjVal.substr(ObjVal.indexOf("."),ObjVal.length);
		}
		if (PInt.length > 3)
   	    {
			var mod = PInt.length % 3;
       		var output = (mod > 0 ? (PInt.substring(0,mod)) : '');
       		for (i=0 ; i < Math.floor(PInt.length / 3); i++)
       		{
				if ((mod == 0) && (i == 0))
					output += PInt.substring(mod+ 3 * i, mod + 3 * i + 3);
				else
					output+= '' + PInt.substring(mod + 3 * i, mod + 3 * i + 3);
	   		}
       		ObjectName.value=NegSign+output+PtValue;
		}
		else ObjectName.value=NegSign+PInt+PtValue;
 	}
}

/*------------------------------------------------------------------------*/

function compose()
{
	//document.write('<form name=frm2><input name=mailer_email value='+compose.arguments[0]+'></form>')
	//alert("Send Mail to "+compose.arguments[0]);
	//document.frm2.method="post";
	//document.frm2.action="mailer.php";
	//document.frm2.submit();
	var1="mailer.php?em="+compose.arguments[0];
	window.open(var1,"Mailer","directories=no,scrollbars=yes,status=no,resizable=no,height=410,width=750,top=1,left=1");

}

/*------------------------------------------------------------------------*/

function changeST()
{
	if(document.frm.country.options[document.frm.country.selectedIndex].value!="USA")
	{
		if(document.frm.country.options[document.frm.country.selectedIndex].value!="CANADA")
		document.frm.state.selectedIndex=0;
	}

}

/*------------------------------------------------------------------------*/

function checkPhone(e)
{

	var whichCode = (window.Event) ? e.which : e.keyCode;
	if(whichCode<48 || whichCode>57)
	window.event.returnValue=false;
}

/*------------------------------------------------------------------------*/

function addMag()
{
	var var1=addMag.arguments[0];
	window.open(var1,"AddMag","directories=no,scrollbars=yes,status=yes,resizable=no,height=680,width=730,top=1,left=1");
}

/*------------------------------------------------------------------------*/

function mPlan()
{
	var var1=mPlan.arguments[0];
	window.open(var1,"MPlan","directories=no,scrollbars=yes,status=yes,resizable=no,height=220,width=730,top=1,left=1");
}

/*------------------------------------------------------------------------*/

function cnClose()
{
	//if(confirm("Are you sure to Cancel and Close the Current Window"))
		window.close();
}
/*----------------------------*/
function Addcat()
{
	var var1=Addcat.arguments[0];
	window.open(var1,"Addcat","directories=no,scrollbars=yes,status=yes,resizable=no,height=125,width=400");

}
/*----------------------------*/
function Addresource()
{
	var var1=Addresource.arguments[0];
	window.open(var1,"Addresource","directories=no,scrollbars=yes,status=yes,resizable=no,height=500,width=600");

}
/*----------------------------*/
function subcat()
{
document.frm.method="Post";
document.frm.action="AddNewCategory.php";
document.frm.submit();
}

/*----------------------------*/

function getChkStatus(chkField)
{
	var dt=0;
	for(i=0;i<chkField.length;i++)
	{
		if(chkField[i].checked)
		dt++;
	}

	if(dt==0)
		return 0;
	else
		return 1;

}

/*----------------------------*/
	var prevwnd=null;
	function Preview(fieldval)
	{
	    prevWnd=window.open("","prvw","width=500,height=400,scrollbars=yes,resizable=yes,status=0,top=0,left=0");
	    prevWnd.document.open();
		{
		    prevWnd.document.writeln('<html><title>Image Preview</title><body bgcolor=#ffffff><font size=3 face="Verdana,,Arial,Helvetica" color="brown"><b>Image Preview</b></font><p><hr noshade width="100%" color="#009999">');
		    prevWnd.document.writeln('<center><img src='+ fieldval +'></center><br><center><a href=javascript:window.close()><font size=2 face=verdana>Close Window</font></a></center>');
		}
	  }
/*----------------------------*/
function checkAll()
	{
	if(document.frm.chkid.length>=2)
	   {
		   if(document.frm.chkall.checked)
		   {
			 for(i=0;i<document.frm.chkid.length;i++)
			 document.frm.chkid[i].checked=true;
		   }
		   else
		   {
			  for(i=0;i<document.frm.chkid.length;i++)
			  document.frm.chkid[i].checked=false;
		   }
		}
	else
	   {
		   if(document.frm.chkall.checked)
			 document.frm.chkid.checked=true;
		   else
			  document.frm.chkid.checked=false;
	   }
    }
