
/************************************************************************************
Browsercheck and Platform Check
************************************************************************************/
var browserVer = parseInt(navigator.appVersion);
var browserType = navigator.userAgent;
var browserString = navigator.platform.toUpperCase();
var nsString = browserType.indexOf("Mozilla");
var ns6plus = ((browserVer>=5) && (nsString != -1)) ? 1:0
//alert(browserType + " " + browserVer);
var macString = browserString.indexOf("MAC");
var isMac = (macString != -1) ? 1:0


var NS4 = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;
var browser=((NS4 || ie || ns6plus) && browserVer>=4)  
/************************************************************************************/

//no right click
var messageSt="";
function clickIE() {if (document.all) {(messageSt);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(messageSt);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
/************************************************************************************/
//Book Mark
var bookmarkurl="http://www.AutoSportMall.com/"
var bookmarktitle="AutoSportMall.com- The Car People!"
function addbookmark(){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}


/************************************************************************************/

//Validate infor
function valid_info()
{
	if (Contactus.Name.value=="")
	  {
	   alert("Please Type Your Name")
	 Contactus.Name.focus()
	  return false;
	   }
	   if (Contactus.Phone.value=="")
	  {
	   alert("Please Type Your Phone Number")
	   Contactus.Phone.focus()
	   return false;
	   }
	   
	if (isNaN(Contactus.Phone.value))
	  {
	   alert("Please Type A Correct Phone Number")
		Contactus.Phone.focus()
		return false;
	   }
	   

//email check
	txt=document.Contactus.Email.value;
	if (txt.indexOf("@")<3)
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the prefix and '@' sign.");
	return false;
	}
	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
	&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)
	&&(txt.indexOf(".biz")<5)&&(txt.indexOf(".tv")<5)
	&&(txt.indexOf(".info")<5)&&(txt.indexOf(".us")<5)
	&&(txt.indexOf(".ws")<5)&&(txt.indexOf(".cc")<5))
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the suffix for accuracy. (It should include a "
	+".com, .edu, .net, .org, .gov, .biz, .tv, .info, .us, .ws, .cc or .mil)");
	return false;
	}
}
/************************************************************************************/

//Map
var totalPics = 7;
currentPicture = 4;

function mapImage1(action) 
{
if (action == 'in')
	currentPicture--;

if (action == 'out')
	currentPicture++;

if (action == 'next') 
	{
	currentPicture++;
	if (currentPicture > totalPics) 
		{
		currentPicture = 1;
		}
	}

if (currentPicture > totalPics) { currentPicture--; } 
if (currentPicture == 0 ) { currentPicture++; } 

document.mapimage1.src = "Img/Maps/Map" + currentPicture + ".gif";
}

//Send Friend
function SendFriend()
{
	if (SendFrnd.Name.value=="")
	  {
	   alert("Please Type Your Name")
	 SendFrnd.Name.focus()
	  return false;
	   }
	  if (SendFrnd.ToName.value=="")
	  {
	   alert("Please Type Your Friend Name")
	 SendFrnd.ToName.focus()
	  return false;
	   }
//email check
	txt=document.SendFrnd.Email.value;
	if (txt.indexOf("@")<3)
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the prefix and '@' sign.");
	return false;
	}
	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
	&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)
	&&(txt.indexOf(".biz")<5)&&(txt.indexOf(".tv")<5)
	&&(txt.indexOf(".info")<5)&&(txt.indexOf(".us")<5)
	&&(txt.indexOf(".ws")<5)&&(txt.indexOf(".cc")<5))
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the suffix for accuracy. (It should include a "
	+".com, .edu, .net, .org, .gov, .biz, .tv, .info, .us, .ws, .cc or .mil)");
	return false;
	}

	//email2 check
	txt2=document.SendFrnd.Email2.value;
	if (txt2.indexOf("@")<3)
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the prefix and '@' sign.");
	return false;
	}
	if ((txt2.indexOf(".com")<5)&&(txt2.indexOf(".org")<5)
	&&(txt2.indexOf(".gov")<5)&&(txt2.indexOf(".net")<5)
	&&(txt2.indexOf(".mil")<5)&&(txt2.indexOf(".edu")<5)
	&&(txt2.indexOf(".biz")<5)&&(txt2.indexOf(".tv")<5)
	&&(txt2.indexOf(".info")<5)&&(txt2.indexOf(".us")<5)
	&&(txt2.indexOf(".ws")<5)&&(txt2.indexOf(".cc")<5))
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the suffix for accuracy. (It should include a "
	+".com, .edu, .net, .org, .gov, .biz, .tv, .info, .us, .ws, .cc or .mil)");
	return false;
	}
}
/************************************************************************************/
//Send Friend
function SearchStock()
{
	if (SearchStk.Stck.value=="")
	  {
	   //alert("Please Type a valid Stock no")
	 //SearchStk.Stck.focus()
	  return true;
	   }
}
/************************************************************************************/
// The following manages auto-tabbing between related entry fields
	var isTabbingEnabled = false;
	function onFocus(currentField)
	{
		if (currentField.value.length == 0)
			isTabbingEnabled = true;
		else 
			isTabbingEnabled = false;
	}
	
	function tabWhenFull(currentField, maxSize, nextField)
	{
		if (currentField.value.length == 0 && !isTabbingEnabled)
			isTabbingEnabled = true;
		if (isTabbingEnabled && currentField.value.length == maxSize)
			nextField.focus();
	}
/************************************************************************************/
	function valid_fiance()
{
	if (ApplyOnline.txtFirstName.value=="")
	  {
	   alert("Please Type Your First Name")
	  ApplyOnline.txtFirstName.focus()
	  return false;
	   }
	if (ApplyOnline.txtLastName.value=="")
	  {
	   alert("Please Type Your Last Name")
	 ApplyOnline.txtLastName.focus()
	  return false;
	   }
	  if (ApplyOnline.txtAddress.value=="")
	  {
	   alert("Please Type Your Address")
	  ApplyOnline.txtAddress.focus()
	 return false;
	  }
	
	if (ApplyOnline.txtZip.value=="" || ApplyOnline.txtZip.value.length !=5)
	  {
	   alert("Please enter 5 digit zipcode.")
	    ApplyOnline.txtZip.focus()
	   return false;
	   }
	   
	  if (isNaN(ApplyOnline.txtZip.value))
		{
	    alert ("Please Type A Corect Zipe Code")
		ApplyOnline.txtZip.focus()
		return false;
		}
	if (ApplyOnline.phone_ac.value=="")
	  {
	   alert("Please Type Your Area Code")
	   ApplyOnline.phone_ac.focus()
	   return false;
	   }
	   
	if (isNaN(ApplyOnline.phone_ac.value))
	  {
	   alert("Please Type A Correct Phone Number")
		ApplyOnline.phone_ac.focus()
		return false;
	   }
	   
	if (ApplyOnline.phone_prefix.value=="")
	  {
	   alert("Please Type Your Phone Number")
	   ApplyOnline.phone_prefix.focus()
	   return false;
	   }
	   
	if (isNaN(ApplyOnline.phone_prefix.value))
	  {
	   alert("Please Type A Correct Phone Number")
	ApplyOnline.phone_prefix.focus()
	return false;
	   }
	   
	if (ApplyOnline.phone_suffix.value=="")
	  {
	   alert("Please Type Your Phone Number")
	     ApplyOnline.phone_suffix.focus()
	   return false;
	   }
	   
	if (isNaN(ApplyOnline.phone_suffix.value))
	  {
	   alert("Please Type A Correct Phone Number")
	ApplyOnline.phone_suffix.focus()
	return false;
	   }
	   if (ApplyOnline.ss_ac.value=="")
	  {
	   alert("Please Type Your ssn")
	   ApplyOnline.ss_ac.focus()
	   return false;
	   }
	   
	if (isNaN(ApplyOnline.ss_ac.value))
	  {
	   alert("Please Type A Correct ss Number")
		ApplyOnline.ss_ac.focus()
		return false;
	   }
	   
	if (ApplyOnline.ss_prefix.value=="")
	  {
	   alert("Please Type Your ss Number")
	   ApplyOnline.ss_prefix.focus()
	   return false;
	   }
	   
	if (isNaN(ApplyOnline.ss_prefix.value))
	  {
	   alert("Please Type A Correct ss Number")
	ApplyOnline.ss_prefix.focus()
	return false;
	   }
	   
	if (ApplyOnline.ss_suffix.value=="")
	  {
	   alert("Please Type Your ss Number")
	     ApplyOnline.ss_suffix.focus()
	   return false;
	   }
	   
	if (isNaN(ApplyOnline.ss_suffix.value))
	  {
	   alert("Please Type A Correct ss Number")
	ApplyOnline.ss_suffix.focus()
	return false;
	   }
	   
	//email check
	txt=document.ApplyOnline.Email.value;
	if (txt.indexOf("@")<3)
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the prefix and '@' sign.");
	return false;
	}
	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)
	&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)
	&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)
	&&(txt.indexOf(".biz")<5)&&(txt.indexOf(".tv")<5)
	&&(txt.indexOf(".info")<5)&&(txt.indexOf(".us")<5)
	&&(txt.indexOf(".ws")<5)&&(txt.indexOf(".cc")<5))
	{
	alert("I'm sorry. This email address seems wrong. Please"
	+" check the suffix for accuracy. (It should include a "
	+".com, .edu, .net, .org, .gov, .biz, .tv, .info, .us, .ws, .cc or .mil)");
	return false;
	}
	if (ApplyOnline.txtBirth.value=="")
	  {
	   alert("Please Type Your Date Of Birth")
	 ApplyOnline.txtBirth.focus()
	  return false;
	   }
}

	