function FormChk(pcstrForm, pastrFields)
{
	var lvobjForm;
	var lvstrMessage='';
	var lvstrDate;
	lvobjForm=document.getElementById(pcstrForm);
		
	for(i=0;i<pastrFields.length;i++)
	{	
		if (trim(lvobjForm[pastrFields[i]].value)=='')
		{
			lvstrMessage = lvstrMessage + "\n" + ' * ' + pastrFields[i];
		}
		
	}
	if ((lvstrMessage)!='')
	{
		lvstrMessage='The following fields are required:'+lvstrMessage;
		alert(lvstrMessage);
		return false;
	}
	return true;
}
function QuantitySet(pcobjForm, pcobjField)
{
	if (QuantityChk(pcobjField.value))
	{
		pcobjForm.submit();
		return true;
	}
	else
	{
		alert('Quantity must above 1');
		return false; 
	}
}
function QuantityChk(pcintQuantity)
{
	if (pcintQuantity>0)
		return true;
	else
		return false;
}
function CancelEnter(pcobjField)
{	//alert(window.event.keyCode);
	if (window.event.keyCode==13)
	{
		window.event.keyCode=9;
		pcobjField.focus();
		
	}
	return true;

}

function OpenWindow(pcstrLink, pcintWidth, pcintHeight)
{
		window.open(pcstrLink,'','height=' + pcintHeight + ',width='+ pcintWidth );
}

function isEmail(email)  
{
	var lvbooValid=true;
	if (email.value=='') 
		lvbooValid=true;
	else if (email.value.indexOf('@') == -1)  
		lvbooValid=false;
	else if (email.value.indexOf('.') == -1)  
		lvbooValid=false;
		
	if (lvbooValid==false) 
	{
			alert('Your e-mail address is not in the correct format.  Please enter a correct e-mail address so that we can get your information to you.');
			email.focus()
			return false   
	}
	return true;
}
/*
==================================================================
ltrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function ltrim(str)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to ltrim
*/
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...

      var j=0, i = s.length;

      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      // Get the substring from the first non-whitespace
      // character to the end of the string...
      s = s.substring(j, i);
   }
   return s;
}

/*
==================================================================
rtrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function rtrim(str)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to rtrim

*/
{
   // We don't want to trip JUST spaces, but also tabs,
   // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...

      var i = s.length - 1;       // Get length of string

      // Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;


      // Get the substring from the front of the string to
      // where the last non-whitespace character is...
      s = s.substring(0, i+1);
   }

   return s;
}

/*
=============================================================
trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function trim(str)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to trim

   RETVAL: A trimmed string!
*/
{
	
   return rtrim(ltrim(str));
}

function numericOnly() {

	if (event.keyCode < 48 || event.keyCode > 57) return false;
}


