/* This function remove the blank space...*/
function trim(inputString) 
{
   inputString=inputString.replace(/^\s+/g,"");
   inputString=inputString.replace(/\s+$/g,"");
   return inputString;
   
}//End of the trim function...




//Purpose	: This function is used to validate email. 
//Arguments : Email object
function ValidateEMail(objName)
{
	var sobjValue;
	var iobjLength;
	//alert("hi");
	sobjValue=trim(objName);
	iobjLength=sobjValue.length;
	iFposition=sobjValue.indexOf("@");
	iSposition=sobjValue.indexOf(".");
	iTmp=sobjValue.lastIndexOf(".");	
	iPosition=sobjValue.indexOf(",");
	iPos=sobjValue.indexOf(";");
	
	var spaceCheck = false;
  for(var i=0; i<iobjLength; i++ )
  {
    if(sobjValue.charCodeAt(i) == 32 )
    {
      spaceCheck = true;
    }
  }
  
  if(spaceCheck)
  {
    return false;
  }
	
	
	if (iobjLength!=0)
	{
		if ((iFposition == -1)||(iSposition == -1))
		{
			return false;
		}
		else if(sobjValue.charAt(0) == "@" || sobjValue.charAt(0)==".")
		{
			return false;				
		}
		else if(sobjValue.charAt(iobjLength) == "@" ||
			sobjValue.charAt(iobjLength)==".")
		{
			return false;				
		}	
		else if((sobjValue.indexOf("@",(iFposition+1)))!=-1)
		{	
			return false;
		}
		else if ((iobjLength-(iTmp+1)<2)||(iobjLength-(iTmp+1)>3))
		{
			return false;
		}
		else if ((iPosition!=-1) || (iPos!=-1))
		{
			return false;
		}	
		else
		{
			return true;
		}		
	}		
}


function CheckConfirmPassword(fldPass,fldConPass,minChars)
{
		//alert("confirm="+fldPass);
		//alert("confirm="+fldConPass);
		//return false;
		//minChars=5;
		/*if(fldPass.value.length == 0)
		{
			alert("Please enter your password");
			fldPass.focus();
			fldPass.select();
			return false;
		}*/
		h = fldPass.value.length;
		x = fldPass.value.value;

		/*for( i=0;i<h;i++)
		{
		 
			if (  h < minChars )
			{
							alert(" Password can't be less than " + minChars + " characters");
							fldPass.focus();
							fldPass.select();
							return false;
			}


		}*/
		//=============================

		if(fldConPass.length == 0)
		{
			alert("Please re-enter your password.");
			fldConPass.focus();
			fldConPass.select();
			return false;
		}
	

		if(fldPass.value != fldConPass.value)
		{
			alert("Please ensure that you have entered the same password twice.");
			fldConPass.focus();
			fldConPass.select();
			return false;
		}
	return true;

}

function check_quote_form_ext(formObj)
{
	
	if(formObj.contact_name.value=='')
	{
		alert("Please provide your name ");
		formObj.contact_name.focus();
		return false;
	}
	else if(formObj.contact_email.value=='')
	{
		alert("Please provide your e-mail ");
		formObj.contact_email.focus();
		return false;
	}
	else if(!(valid_email_ext(formObj.contact_email)))
	{
		alert("Please provide your valid e-mail ");
		formObj.contact_email.focus();
		return false;
	}
	else if(formObj.contact_message.value=='')
	{
		alert("Please provide the message ");
		formObj.contact_message.focus();
		return false;
	}
	
	return true;
}
function valid_email_ext(emailobj)
{
	email_value=emailobj.value;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email_value) == false) 
	{
		return false;
	}
	else
	{
		return true;
	}
	
}
function ValidateLoginFormoutside(formobj)
{
	
	if(formobj)
	{
		if(formobj.username.value=='')
		{
			alert("Please enter user name ");
			formobj.username.focus();
			return false;
		}
		else if(formobj.passwd.value=='')
		{
			alert("Please enter password ");
			formobj.passwd.focus();
			return false;
		}
		
		
		return true;
	}
	return false;
}