///////////////////////// COMMON JAVASCRIPT FILE ////////////////////////////
//																		   //
// 	  COMMON JAVASCRIPT FILE FOR ALL THE SCRIPTS USED ALLOVER THE SITE     //
//																		   //
/////////////////////////////////////////////////////////////////////////////


/*----------------- Vehicle Reviews start ----------------------*/
function myvalidnumber(e)
{
var mykey = window.event ? e.keyCode : e.which;
		if ((mykey <= 47 || mykey > 57) && mykey !=13 && mykey !=0 && mykey != 8) 
			{
//			alert ("Enter number only");
		return false;
			}
return true;			
}
// First Name Validation
function isValidFirstName(FirstName)
{
	FirstName.value=removeLeadingAndTrailingChar(FirstName.value);
	if ((FirstName.value==""))
		{
			alert("Enter First Name ");
			FirstName.focus();
			return false;
		}
return true;
}


  // Last Name Validation
function isValidLastName(LastName)
{
	LastName.value=removeLeadingAndTrailingChar(LastName.value);
	if ((LastName.value==""))
		{
			alert("Enter Last Name ");
			LastName.focus();
			return false;

		}
return true;
}
function isValidNMLastName(LastName)
{
	LastName.value=removeLeadingAndTrailingChar(LastName.value);
	return true;
}

// Email Validation

function isValidEmail(Email)
{
	if (Email.value=="")
	{
		alert("Enter E-mail Id");
		Email.focus();
		return false;
	}

	if (Email.value!="" && !validemail(Email.value))
	{ 
		alert("Enter Valid E-mail Id");
		Email.focus();
		return false;		
	}
return true;
}

function isValidZip(Zip)
{
	Zip.value=removeLeadingAndTrailingChar(Zip.value);		
	if(isNaN(Zip.value))
	{
		alert("Zip Code should be Numeric");	
		Zip.select();
		return false;
	}			
	if (Zip.value=="")
	{
		alert("Enter Zip Code");
		Zip.focus();
		return false;
	}
	if(Zip.value.length<5)
	{
		alert("Enter Five Digit Zip Code");
		Zip.focus();
		return false;
	}		
return true;
}

// Mandatory Phone Validation
 function isValidMPhone(ph1,ph2,ph3,ph,phtype)
 {
	if (phtype == undefined)  { phtype =' Phone '  ; }
	ph1.value=removeLeadingAndTrailingChar(ph1.value);	
	ph2.value=removeLeadingAndTrailingChar(ph2.value);	
	ph3.value=removeLeadingAndTrailingChar(ph3.value);

	if(isNaN(ph1.value))
		{
			alert(phtype +" should be Numeric");	
			ph1.select();
			return false;
		}
	if(isNaN(ph2.value))
		{
			alert(phtype +" should be Numeric");	
			ph2.select();
			return false;
		}
	if(isNaN(ph3.value))
		{
			alert(phtype +" should be Numeric");	
			ph3.select();
			return false;
		}		

	if (ph1.value.length<3)
	{
		alert("Enter " + phtype);
		ph1.focus();
		return false;
	}
	if (ph2.value.length<3)
	{
		alert("Enter " + phtype);
		ph2.focus();
		return false;
	}
	if (ph3.value.length<4)
	{
		alert("Enter " + phtype);
		ph3.focus();
		return false;
	}	
	if(ph1.value.length==3 &&ph2.value.length==3 && ph3.value.length==4) {
		ph.value="("+ph1.value+") "+ph2.value+"-"+ph3.value;
	}
return true;
 }

/*----------------- Vehicle Reviews end ----------------------*/