//------------------------------------------------------------------------------------
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 to validate email
//-----------------------------------------------------------------------------------
function chkEmail(tmpStr)
{
	var email_pat = /^[a-z][a-z0-9_\.\-]*[a-z0-9]@[a-z0-9]+[a-z0-9\.\-_]*\.[a-z]+$/i;
	return(email_pat.test(tmpStr));
}

//Function to change the security code
function refreshCaptcha(imgid)
{
	var img = new Image();
	img.src = 'captcha/show_captcha.php?hash='+parseInt(Math.random() * 10000000000);
	document.getElementById(imgid).src = img.src;
}

//------------------------------------------------------------------------------------
//Function to open in a new window
//-----------------------------------------------------------------------------------
function showWindow(fName)
{
	window.open(fName, '', 'width=760,height=600,left=50,top=50,scrollbars=1,toolbar=0,status=1,resizable=1,menubar=1,location=0');
}

// Function to display message in contact form
function displayMessage(labelID, boxID, message)
{
	$('#msg_blk').html(message);
	$('#'+labelID).addClass('bg1');
	$('#'+boxID).addClass('bg2	');
}

// Function to clear message in contact form
function clearMessage(labelID, boxID)
{
	$('#msg_blk').html('');
	$('#'+labelID).removeClass('bg1');
	$('#'+boxID).removeClass('bg2');
}
