// JavaScript Document
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 chkcontact()
{
	var emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
	if(trim(document.getElementById("name").value)=="")
	{
		document.getElementById("name").className = "error_form_field";
		alert("Please enter name");
		document.getElementById("name").focus();
		return false;
	}else{
		document.getElementById("name").className = "form_field";
	}
	if(trim(document.getElementById("email").value)=="")
	{
		document.getElementById("email").className = "error_form_field";
		alert("Please enter email address");
		document.getElementById("email").focus();
		return false;
	}else if(!(emailExp.test(document.getElementById("email").value))){
		document.getElementById("email").className = "error_form_field";
		alert("Please enter valid email address");
		document.getElementById("email").focus();
		return false;
	}else{
		document.getElementById("email").className = "form_field";
	}
	if(trim(document.getElementById("message").value)=="")
	{
		document.getElementById("message").className = "error_form_message";
		alert("Please enter message");
		document.getElementById("message").focus();
		return false;
	}else{
		document.getElementById("message").className = "form_message";
	}
}
function chkcareer()
{
	var emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
	if(trim(document.getElementById("name").value)=="")
	{
		document.getElementById("name").className = "error_form_field";
		alert("Please enter name");
		document.getElementById("name").focus();
		return false;
	}else{
		document.getElementById("name").className = "form_field";
	}
	if(trim(document.getElementById("email").value)=="")
	{
		document.getElementById("email").className = "error_form_field";
		alert("Please enter email address");
		document.getElementById("email").focus();
		return false;
	}else if(!(emailExp.test(document.getElementById("email").value))){
		document.getElementById("email").className = "error_form_field";
		alert("Please enter valid email address");
		document.getElementById("email").focus();
		return false;
	}else{
		document.getElementById("email").className = "form_field";
	}
	if(trim(document.getElementById("message").value)=="")
	{
		document.getElementById("message").className = "error_form_message";
		alert("Please enter message");
		document.getElementById("message").focus();
		return false;
	}else{
		document.getElementById("message").className = "form_message";
	}
	var ext = document.getElementById("resume").value.substring(document.getElementById("resume").value.lastIndexOf('.') + 1);
	
	if(trim(document.getElementById("resume").value)!="")
	{
		
		if(ext == "doc" || ext == "DOC" || ext == "docx" || ext == "DOCX" || ext == "txt" || ext == "TXT")
		{
			document.getElementById("resume").className = "";
		}else{
			document.getElementById("resume").className = "";
			alert("Please upload only .doc or txt file");
			document.getElementById("resume").focus();
			return false;
		}
	}
}
function chkrequest()
{
	var emailExp= /^\w+(\-\w+)*(\.\w+(\-\w+)*)*@\w+(\-\w+)*(\.\w+(\-\w+)*)+$/ ; 
	if(trim(document.getElementById("name").value)=="")
	{
		document.getElementById("name").className = "error_inner_field_text";
		alert("Please enter name");
		document.getElementById("name").focus();
		return false;
	}else{
		document.getElementById("name").className = "inner_field_text";
	}
	if(trim(document.getElementById("email").value)=="")
	{
		document.getElementById("email").className = "error_inner_field_text";
		alert("Please enter email address");
		document.getElementById("email").focus();
		return false;
	}else if(!(emailExp.test(document.getElementById("email").value))){
		document.getElementById("email").className = "error_inner_field_text";
		alert("Please enter valid email address");
		document.getElementById("email").focus();
		return false;
	}else{
		document.getElementById("email").className = "inner_field_text";
	}
	if(trim(document.getElementById("message").value)=="")
	{
		document.getElementById("message").className = "error_quiry-box";
		alert("Please enter message");
		document.getElementById("message").focus();
		return false;
	}else{
		document.getElementById("message").className = "quiry-box";
	}
	
}

