function loginValidate(theForm)
{
	if (!validateSpecial(theForm.username,"User Name"))
			return false;
	if (!BlankField(theForm.password,"Password"))
			return false;

	return true;
}
function validateSpecial(formField,fieldLabel)
	{
		var result = true;
		if (Trim(formField.value) == "")
		{
			alert("Please specify " + fieldLabel + "!");
			formField.focus();
			result = false;
		}
		else
		{
		var vDigit=Trim(formField.value);
		var stLen=vDigit.length;
		var b=false;
		var blank=false;
			for(ct=0;ct<stLen;ct++)
			{
				var viDigit = vDigit.charAt(ct);
				if((viDigit == ",") || (viDigit == "@") || (viDigit == "#") || (viDigit == "$") || (viDigit == "%") || (viDigit == "^") || (viDigit == "&") || (viDigit == "*") || (viDigit == "~") ||  (viDigit == "?") ||  (viDigit == "?") ||  (viDigit == "<") ||  (viDigit == ">") ||  (viDigit == "|") || (viDigit == "'") || (viDigit == "=") || (viDigit == "+") || (viDigit == ";") || (viDigit == "/")|| (viDigit == ")") || (viDigit == "(")) 
				{
					b=true;					
				}
				
				if (viDigit == " ")
				{
					blank=true;
				}
				
			}
			if(b==true)
				{
					alert('Special characters are not allowed.');
					formField.focus();
					formField.select();
					result =false;
				}
				
				}
	return result;
	}

function BlankField(formField,fieldLabel)
	{
	var result = true;
	
		if (Trim(formField.value) == "")
		{
			alert("Please specify " + fieldLabel + "!");
			formField.focus();
			result=false;
		}		
	return result;
	}

	
function RTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

function LTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
       while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}


function Trim(str)
{
   return RTrim(LTrim(str));
}

function ItemSelect(index)
{
		if(document.forms[index].SKU.selectedIndex == 0)
		{
			alert("Please select an item. " );
			document.forms[index].SKU.focus();
			return false;
		}
		return true;
}
function numbersonly(myfield, e, dec)
	{
	var key;
	var keychar;
	if (window.event)
	 key = window.event.keyCode;
	else if (e)
	 key = e.which;
	else
	 return true;
	keychar = String.fromCharCode(key);
	// control keys
	if ((key==null) || (key==0) || (key==8) || 
	 (key==9) || (key==13) || (key==27) )
	 return true;
	// numbers
	else if ((("0123456789").indexOf(keychar) > -1))
	 return true;
	// decimal point jump
	else if (dec && (keychar == "."))
	 {
	 myfield.form.elements[dec].focus();
	 return false;
	 }
	else
	 return false;
	}

	function CheckBlank(theForm)
	{
		if(theForm.QTTY.value=="" || theForm.QTTY.value==0)
				theForm.QTTY.value=1
	}