function numchk(e)
{
var keynum;
var keychar;
var numcheck;

if(window.event) // IE
  {
  keynum = e.keyCode;
  }
else if(e.which) // Netscape/Firefox/Opera
  {
  keynum = e.which;
  }

  
keychar = String.fromCharCode(keynum);
numcheck = /^[a-zA-Z]*$/;

return !numcheck.test(keychar);
}

function chkCombo(id) {
var dropdownIndex = document.getElementById(id).selectedIndex;
if(dropdownIndex==0)
{document.getElementById(id).style.backgroundColor = '#C8E3F9'; return false;}
else
{document.getElementById(id).style.backgroundColor = 'White';  return true;}
}
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}


function chkempty(object)
{
	if(trim(object.value)=="")
	{
		object.style.backgroundColor = '#C8E3F9';
		object.focus();
		return false;
	}
	else
	{	
	
		object.style.backgroundColor='White';
		return true;
	}
}

function passcomp(Pass1,Pass2)
{
	
	if(!(trim(Pass1.value)==trim(Pass2.value)) || trim(Pass1.value)=='' || trim(Pass2.value)=='' )
	{
		document.getElementById("confirm_pass").innerHTML='Confirm Password';
		Pass1.focus();
		return false;
	}
	else if(Pass1.value.length<6)
	{
		document.getElementById("confirm_pass").innerHTML='Password Minimum Length is 6 Characters';
		Pass1.focus();
		return false;
	}	else
	{	
		
		document.getElementById("confirm_pass").innerHTML='';
		return true;
	}
	
	
}


function chkemail(object)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if(filter.test(object.value)){
	object.style.backgroundColor = 'White';
	object.focus();
	return true;
	}
	else{
			object.style.backgroundColor='#C8E3F9';
		return false;
	}
		
}

function enqfrmchk()
{
	vresult=chkempty(document.enqform.First_Name);
	vresult=vresult&chkempty(document.enqform.Last_Name);
	vresult=vresult&chkempty(document.enqform.Phone);
	vresult=vresult&chkemail(document.enqform.Email);
	vresult=vresult&chkCombo('Country');

	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}

function regfrmchk()
{
	vresult=passcomp(document.regform.Pass,document.regform.Con_Pass);
	vresult=vresult&chkempty(document.regform.UserId);
	vresult=vresult&chkCombo('Country');
	vresult=vresult&chkemail(document.regform.Email);

var mobile= new String;
	
	mobile=document.regform.m_co_code.value;
	mobile+=document.regform.m_ci_code.value;
	mobile+=document.regform.m_number.value;
	
	if(mobile.length<10)
	{
	document.regform.m_co_code.style.backgroundColor='#C8E3F9';
	document.regform.m_ci_code.style.backgroundColor='#C8E3F9';
	document.regform.m_number.style.backgroundColor='#C8E3F9';
	vresult=vresult&false;
	}
	else
	{
	document.regform.m_co_code.style.backgroundColor='White';
	document.regform.m_ci_code.style.backgroundColor='White';
	document.regform.m_number.style.backgroundColor='White';	
	vresult=vresult&true;	
	}
	
	vresult=vresult&chkempty(document.regform.Job_Title);
	vresult=vresult&chkempty(document.regform.Last_Name);
	vresult=vresult&chkempty(document.regform.First_Name);
	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}

function loginfrmchk()
{
	vresult=chkempty(document.LoginForm.User);
	vresult=vresult&chkempty(document.LoginForm.Pass);
	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}

function stufrmchk()
{
	vresult=chkempty(document.stuform.First_Name);
	vresult=vresult&chkempty(document.stuform.Last_Name);


	var mobile= new String;
	
	mobile=document.stuform.m_co_code.value;
	mobile+=document.stuform.m_ci_code.value;
	mobile+=document.stuform.m_number.value;
	
	if(mobile.length<10)
	{
	document.stuform.m_co_code.style.backgroundColor='#C8E3F9';
	document.stuform.m_ci_code.style.backgroundColor='#C8E3F9';
	document.stuform.m_number.style.backgroundColor='#C8E3F9';
	vresult=vresult&false;
	}
	else
	{
	document.stuform.m_co_code.style.backgroundColor='White';
	document.stuform.m_ci_code.style.backgroundColor='White';
	document.stuform.m_number.style.backgroundColor='White';	
	vresult=vresult&true;
	}


	vresult=vresult&chkemail(document.stuform.Email);
	vresult=vresult&chkCombo('Country');

	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}

function stu2frmchk()
{
	vresult=chkempty(document.stu2form.Subject);
	
	if(!chkempty(document.stu2form.Type))
	{
		vresult=vresult & chkempty(document.stu2form.OtherType)
	}
	else
	{
		document.stu2form.OtherType.style.backgroundColor='White';
	}
	
	if(!chkempty(document.stu2form.Brand))
	{
		vresult=vresult & chkempty(document.stu2form.OtherBrand);
	}
	else
	{
		document.stu2form.OtherBrand.style.backgroundColor='White';
	}

	vresult=vresult&chkempty(document.stu2form.Pic);
	vresult=vresult&chkempty(document.stu2form.OfferPrice);
	vresult=vresult&chkempty(document.stu2form.Model);

	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}

function gefrmchk(obj)
{
	vresult=chkempty(obj.Subject);
	vresult=vresult&chkempty(obj.EnquiryDetail);

	if((!chkempty(obj.Type)) || obj.Type.value=="Other Type" )
	{
		vresult=vresult & chkempty(obj.OtherType)
	}
	else
	{
		obj.OtherType.style.backgroundColor='White';
	}
	
if(obj.logedin.value=="no")
{
	
	var mobile= new String;
	
	mobile=obj.m_co_code.value;
	mobile+=obj.m_ci_code.value;
	mobile+=obj.m_number.value;
	
	if(mobile.length<10)
	{
	obj.m_co_code.style.backgroundColor='#C8E3F9';
	obj.m_ci_code.style.backgroundColor='#C8E3F9';
	obj.m_number.style.backgroundColor='#C8E3F9';
	vresult=vresult&false;
	}
	else
	{
	obj.m_co_code.style.backgroundColor='White';
	obj.m_ci_code.style.backgroundColor='White';
	obj.m_number.style.backgroundColor='White';	
	vresult=vresult&true;
	}
	
	vresult=vresult&chkemail(obj.Email);
	vresult=vresult&chkCombo('Country');
	vresult=vresult&chkempty(obj.Name);
}
	
	if(obj.security.value!="")
	{
	alert("Sorry can't submit. seems bot!");
	return false;
	}
	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}


function sarfrmchk()
{
	vresult=chkempty(document.sar2form.Subject);
	
	if(!chkempty(document.sar2form.Type))
	{
		
		if(vresult=vresult & chkempty(document.sar2form.OtherType))
		{
			document.sar2form.Type.style.backgroundColor='White';
		}
	}
	else
	{
		document.sar2form.OtherType.style.backgroundColor='White';
	}
	
	if(!chkempty(document.sar2form.Brand))
	{
		if(vresult=vresult & chkempty(document.sar2form.OtherBrand))
		{
		document.sar2form.Brand.style.backgroundColor='White';	
		}
	}
	else
	{
		document.sar2form.OtherBrand.style.backgroundColor='White';
	}
																	
	vresult=vresult&chkempty(document.sar2form.ProblemDetail);
	vresult=vresult&chkempty(document.sar2form.Model);

	
	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}


function cufrmchk()
{
	vresult=chkempty(document.cuform.Name);

	var mobile= new String;
	
	mobile=document.cuform.m_co_code.value;
	mobile+=document.cuform.m_ci_code.value;
	mobile+=document.cuform.m_number.value;

	if(mobile.length<10)
	{
	document.cuform.m_co_code.style.backgroundColor='#C8E3F9';
	document.cuform.m_ci_code.style.backgroundColor='#C8E3F9';
	document.cuform.m_number.style.backgroundColor='#C8E3F9';
	vresult=vresult&false;
	}
	else
	{
	document.cuform.m_co_code.style.backgroundColor='White';
	document.cuform.m_ci_code.style.backgroundColor='White';
	document.cuform.m_number.style.backgroundColor='White';
	vresult=vresult&true;
	}

vresult=vresult&chkemail(document.cuform.Email);

vresult=vresult&chkCombo('Country');
vresult=vresult&chkempty(document.cuform.Enqbox);

	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	return true;
}

///////////////////////////////////////////////////////////

function upload_file_frmchk(obj)
{
	
vresult=chkempty(obj.Title);

vresult=vresult&chkempty(obj.Priv);

	if(vresult==false)
	{
	alert("Enter Information in Highlighted fields");
	return false;
	}
	filesubmited()
	return true;
}
