// JavaScript Document
function ltrim(str) 
{ 
	for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
	return str.substring(k, str.length);
}

function rtrim(str) 
{
	for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
	return str.substring(0,j+1);
}

function isWhitespace(charToCheck) 
{ 
	var whitespaceChars = " \t\n\r\f";
	return (whitespaceChars.indexOf(charToCheck) != -1);
} 

function trim(str) 
{
	if(ltrim(rtrim(str))=="")
	{
		return true;
	}
}


function isEmpty(txtInputVal) 
{
	if((txtInputVal=="")||(txtInputVal.search(/\S/) == -1)||(txtInputVal==null)||(txtInputVal.length==0))
	{
		return true;
	}
}



/******************************************************************************************/
/******************************************************************************************/
/*******************************************************************************************/
function setFocus(fieldId,fieldVal)
{
	if (fieldVal=='dd' || fieldVal=='mm' || fieldVal=='yyyy')
	{
		document.getElementById(fieldId).value="";
	}	
	
}

function removeFocus(fieldId,fieldVal,fieldInitial)
{
	if (fieldVal=="")
	{
		document.getElementById(fieldId).value=fieldInitial;
	}
	
}

function validateEnqry()
{
	if(trim(document.frmEnqry.Name.value))
	{
		alert("Please enter your name..!");
		document.frmEnqry.Name.focus();
		return false;
	}
	
	
	if(trim(document.frmEnqry.Email.value))
	{
		alert("Please enter your email..!");
		document.frmEnqry.Email.focus();
		return false;
	}
	
	
	
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(!reg.test(document.frmEnqry.Email.value))
	{
		alert('Invalid Email Address');
		document.frmEnqry.Email.focus();
		return false;
	}
	
	if(trim(document.frmEnqry.Phone.value))
	{
		alert("Please enter your phone no..!");
		document.frmEnqry.Phone.focus();
		return false;
	}
	
	if(trim(document.frmEnqry.PblmDesc.value))
	{
		alert("Please describe your problems in brief..!");
		document.frmEnqry.PblmDesc.focus();
		return false;
	}
	
	if(trim(document.frmEnqry.PrefDay.value) || document.frmEnqry.PrefDay.value=="dd")
	{
		alert("Your preferred date to call is invalid!");
		document.frmEnqry.PrefDay.focus();
		return false;
	}
	
	if(trim(document.frmEnqry.PrefMonth.value) || document.frmEnqry.PrefMonth.value=="dd")
	{
		alert("Your preferred month to call is invalid!");
		document.frmEnqry.PrefMonth.focus();
		return false;
	}
	
	if(trim(document.frmEnqry.PrefYear.value) || document.frmEnqry.PrefYear.value=="dd")
	{
		alert("Your preferred year to call is invalid!");
		document.frmEnqry.PrefYear.focus();
		return false;
	}
	
}

