//given the value, str_trim trims down the string from all padded whitespaces...
function str_trim(str)
{	
	if(str.length > 0)
		while(str.charAt(0)==' ')
			str = str.substr(1);
		
	if(str.length > 0)
		while(str.charAt((str.length - 1))==' ')
			str = str.substring(0, str.length-1);
	
	return str;
}

function SetFocus(obj)
{
	obj.focus();
	obj.select();
}

function validate_email(email_txt) 
{
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@([\\w].+)\.[\\w]$";
	var regex = new RegExp(emailReg);
	return regex.test(email_txt);
}


function Check_Input(obj)
{
	if(str_trim(obj.value) != "")
		obj.className = "box";
}

function Validate_Query_Form() 
{
	var frm = document.frm_query;
	var i =0;
	
	if(str_trim(frm.txtname.value) == "")
	{
		frm.txtname.className = "errbox";
		i++;		
	}
	else
		frm.txtname.className = "box";
	
	if(str_trim(frm.txtemail.value) == "")
	{
		frm.txtemail.className = "errbox";
		i++;		
	}
	else
	{
		if(validate_email(frm.txtemail.value))
		{
			frm.txtemail.className = "box";
		}
		else
		{
			frm.txtemail.className = "errbox";
			i++;
		}
	}
	
	if(str_trim(frm.txtphone.value) == "")
	{
		frm.txtphone.className = "errbox";
		i++;		
	}
	else
		frm.txtphone.className = "box";
		
	if(str_trim(frm.txtquery.value) == "")
	{
		frm.txtquery.className = "errbox";
		i++;		
	}
	else
		frm.txtquery.className = "box";
		
	if(str_trim(frm.txtverify.value) == "")
	{
		frm.txtverify.className = "errbox";
		i++;		
	}
	else
		frm.txtverify.className = "box";
	
	if(i != 0)
	{
		document.getElementById("ERR_MSG").innerHTML = "Please Check The Compulsory Fields.";
		return false;
	}
	
	return true;
}

function doHourglass()
{
	document.body.style.cursor = 'wait';
}

function undoHourglass()
{
	document.body.style.cursor = 'default';
}
