function strTrim(tmpStr)
{
	tmpStr = tmpStr.replace(/^\s+/,"");//remove leading
	tmpStr = tmpStr.replace(/\s+$/,"");//remove trailing
	return tmpStr;
}
//------------------------------------------------------------------------------------
function trimFields()
{
	for(var i=0; i < obj.elements.length; i++)
	{
		if(obj.elements[i].type == "text" || obj.elements[i].type == "textarea" || obj.elements[i].type == "password")
		{
			obj.elements[i].value = strTrim(obj.elements[i].value);
		}
	}
}

//Checks email against pattern
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z0-9][a-z0-9_\.\-']*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pat.test(tmpStr));
}


//Function for mouseover effect of menu button===
function changeIcon(img_name, over)
{
	if(over == "o")
		document.getElementById(img_name).src = temp_path+'/images/icon_'+img_name+'_o.jpg';
	else
		document.getElementById(img_name).src = temp_path+'/images/icon_'+img_name+'.jpg';
}

function validateContact()
{
	trimFields();
	if(obj.first_name.value == "")
	{
		alert("Please enter your First Name.");
		obj.first_name.focus();
		return;
	}
	if(obj.last_name.value == "")
	{
		alert("Please enter your Last Name.");
		obj.last_name.focus();
		return;
	}
	if(obj.email.value == "")
	{
		alert("Please enter your Email ID.");
		obj.email.focus();
		return;
	}
	if(!chkEmail(obj.email.value))
	{
		alert("Invalid Email ID!\nPlease review and correct it.");
		obj.email.focus();
		obj.email.select();
		return;
	}
	if(obj.comments.value == "")
	{
		alert("Please enter your Comments.");
		obj.comments.focus();
		return;
	}
	if(obj.captcha.value == "")
	{
		alert("Please enter security code correctly");
		obj.captcha.focus();
		return;
	}
	//All ok
	obj.action = main_site_path+"/contact_us.php";
	obj.submit();
}