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);
		}
	}
}

//------------------------------------------------------------------------------------
function NewWindow(pageName, Width, Height)
{
	window.open(pageName, '', 'width='+Width+',height='+Height+',toolbar=0,menubar=0,location=0,left=50,top=75');
}

//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));
}


//Checks URL against pattern
function chkURL(tmpStr)
{
	var url_pat = /^(http|https|ftp):\/\/([\w-]+\.)+[\w-]+(\/[\w-\.\/?%&amp;,=#@\/:]*)?/;
	return(url_pat.test(tmpStr));
}

//Function for mouseover effect of menu button===
function changeIcon(img_name, over)
{
	if(over == "o")
		document.getElementById(img_name).src = 'images/icon_'+img_name+'_o.jpg';
	else
		document.getElementById(img_name).src = '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 = "contact_us.html";
	obj.submit();
}