function checkEmail(str) {
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1) {
	   alert("Email is invalid!");
	   return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
	   alert("Email is invalid!");
	   return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
	    alert("Email is invalid!");
	    return false;
	}
	if (str.indexOf(at,(lat+1))!=-1) {
		alert("Email is invalid!");
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
		alert("Email is invalid!");
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1) {
		alert("Email is invalid!");
		return false;
	}
	if (str.indexOf(" ")!=-1) {
		alert("Email is invalid!");
		return false;
	}
	
	return true;
}

function validateForm(myForm) {
	if (myForm.firstname.value == "") {
	  alert('First Name is required!');
	  myForm.firstname.focus();
	  return false;
	}
	if (myForm.lastname.value == "") {
	  alert('Last Name is required!');
	  myForm.lastname.focus();
	  return false;
	}
	if (myForm.email.value == "") {
	  alert('Email address is required!');
	  myForm.email.focus();
	  return false;
	}
	if (checkEmail(myForm.email.value) == false) {
	  myForm.email.focus();
	  return false;
	}
	
	return true;
}

//------------------------------------------------------------------------------
// Validate inputs based on a list of allowable characters
// For enter key: trigger onblur event (to force a calculation)
//------------------------------------------------------------------------------
function checkInput(goodChars)
{
	var keyChar, keyCode, object, isNetscape;
	
	isNetscape = (document.layers);
	if (isNetscape)
	{
		keyCode = keystroke.which;
		object = keystroke.srcElement;
	}
	else
	{
		keyCode = event.keyCode;
		object = event.srcElement;
	}
	if (keyCode == null) return true;
	
	// get character
	keyChar = String.fromCharCode(keyCode);
	keyChar = keyChar.toLowerCase();
	goodChars = goodChars.toLowerCase();
	
	// check goodChars
	if (goodChars.indexOf(keyChar) != -1) return true;
	
	// control keys
	if ( keyCode==null || keyCode==0 || keyCode==8 || keyCode==9 || keyCode==27 ) return true;
	
	// enter key: trigger onblur event
	if (keyCode == 13)
	{
		object.blur();
		object.focus();
		return true;
	}
	
	// else return false
	return false;
}

//------------------------------------------------------------------------------
// printerFriendly
//------------------------------------------------------------------------------
function printerFriendly()
{
	var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";
		disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25";
	var content_vlue = document.getElementById("print_content").innerHTML;
	
	var docprint=window.open("", "", disp_setting);
	docprint.document.open();
	docprint.document.write('<html><head>');
	//docprint.document.write('<meta name="description" content="' + getMetaContents('description') + '" />');
	docprint.document.write('<meta name="description" content="An Easy-to-Use and proven 500+% ROI Solution for all your remote stockroom items in an On-Demand Point-of-Use PDA enabled stockroom management system." />');
	//docprint.document.write('<meta name="keywords" content="' + getMetaContents('keywords') + '" />');
	docprint.document.write('<meta name="keywords" content="Point-of-Use, Inventory Management, Replenishment, Vehicle Parts Management, Cycle Counting" />');
	docprint.document.write('<title>' + document.title + '</title>');
	docprint.document.write('<link href="styles/global.css" rel="stylesheet" type="text/css" />');
	docprint.document.write('</head><body">');
	docprint.document.write('<div align="center"><img src="images/global/logo.jpg" width=261 height=136 /></div><br />');
	docprint.document.write(content_vlue);
	docprint.document.write('<br /><br /><p align="center">');
	docprint.document.write('<img src="images/global/logo.jpg" width=261 height=136 /><br /><br />');
	docprint.document.write('<font size="+1"><strong><em><font color="#ff0000">e</font>Turns</em>, Inc.</strong></font><br />');
	docprint.document.write('5 Hutton Centre Drive, Suite 1400<br />');
	docprint.document.write('Santa Ana, CA 92707<br />');
	docprint.document.write('949-265-2626<br />');
	docprint.document.write('<strong>REMOTE INVENTORY SOLUTIONS</strong></p>');
	docprint.document.write('</body></html>');
	docprint.document.close();
	docprint.focus();
}

//------------------------------------------------------------------------------
// getYear
//------------------------------------------------------------------------------
function getYear()
{
	var dDate = new Date();
	document.write(dDate.getFullYear());
}
