// JavaScript Document
function validate()
{
	if(document.getElementById('software').value=='')
	{
		alert("Please select a product!");
		document.getElementById('software').focus();
		return false;
	}
	else if(document.getElementById('firstname').value=='')
	{
		alert("Please enter your name!");
		document.getElementById('firstname').focus();
		document.getElementById('firstname').select();
		return false;
	}
	else if(document.getElementById('email').value=='')
	{
		alert("Please enter your email address");
		return false;
	}

	else if(!checkemail(document.getElementById('email').value))
	{
		alert("Invalid email address");
		document.getElementById('email').focus();
		document.getElementById('email').select();
	    return false;	
		
	}
	else
	{
		return true;
	}
	
		
		
	   
		
	
	
}
function checkemail(email)
        {
             var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;
             if(emailRegxp.test(email))
             return true; 
             else 
             return false;
        }
		
function validatevendor()
{
	if(document.getElementById('name').value=='')
	{
		alert("Please enter vendor name!");
		document.getElementById('name').focus();
		document.getElementById('name').select();
		return false;
	}
	else if(document.getElementById('email').value=='')
	{
		alert("Please enter vendor email address");
		document.getElementById('email').focus();
		return false;
	}

	else if(!checkemail(document.getElementById('email').value))
	{
		alert("Invalid email address");
		document.getElementById('email').focus();
		document.getElementById('email').select();
	    return false;	
		
	}
	else if(document.getElementById('uname').value=='')
	{
		
		alert("Please enter login name!");
		document.getElementById('uname').focus();
		document.getElementById('uname').select();
		return false;
	}
	else if(document.getElementById('password').value=='')
	{
		
		alert("Please enter vendor password!");
		document.getElementById('password').focus();
		document.getElementById('password').select();
		return false;
	}
	
	else if(document.getElementById('password').value.length<6)
	{
		
		alert("password at least 6 characters long");
		document.getElementById('password').focus();
		document.getElementById('password').select();
		return false;
	}
	
	else
	{
		return true;
	}
}		
		
function validatevendorcode()
{
	if(document.getElementById('code').value=='')
	{
		alert("Please enter vendor code!");
		document.getElementById('code').focus();
		document.getElementById('code').select();
		return false;
	}
	
	else if(document.getElementById('code').value.length<6)
	{
		alert("Please enter 6 digit vendor code!");
		document.getElementById('code').focus();
		document.getElementById('code').select();
		return false;
	}
	
	
	else if(document.getElementById('discount').value=='')
	{
		
		alert("Please enter code worth!");
		document.getElementById('discount').focus();
		document.getElementById('discount').select();
		return false;
	}
	
	
	else
	{
		return true;
	}
}		


function numbersonly(e, decimal) {
var key;
var keychar;

if (window.event) {
   key = window.event.keyCode;
}
else if (e) {
   key = e.which;
}
else {
   return true;
}
keychar = String.fromCharCode(key);

if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
   return true;
}
else if ((("0123456789").indexOf(keychar) > -1)) {
   return true;
}
else if (decimal && (keychar == ".")) { 
  return true;
}
else
   return false;
}


function letternumber(e)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// alphas and numbers
else if ((("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(keychar) > -1))
   return true;
else
   return false;
}
		
