<!--
//*************************************************
//  Functions Related to Brand Tag
//*************************************************
function brandSelected(form){
	val = form.options[form.selectedIndex].value
	if(!(val == "default") && !(val == "")){
		location.href = val;
	}
}

// An inclusive JCW function file. 
//Please insert new non-dynamic functions here
function cpRedirect(top) {
    if (Trim(top.SearchForm.catalogId.value) == "ReplacementParts"){
      top.location.href = "http://wrenchead.carparts.com";
      return true;
    }
    return false;

}

function changeImage(thisImage,imageName2,currentImage,imageName){
            thisImage.src=imageName2;
        }
        
function changeImage2(currentImage,imageName){
                currentImage.src=imageName;
        }
        
function changeImage(currentImage,imageName){
                currentImage.src=imageName;
        }
 //*********************************
 //Functions for top nav search bar 
 //*********************************
       
	function submitSearchForm(SearchForm){
        var success = true;
        if (Trim(SearchForm.sku.value) == "" || Trim(SearchForm.sku.value) == "Keyword or Item #" || Trim(SearchForm.sku.value) == "Keyword / Catalog Item #") {
            success = false;
        }
        if(!success) {
            return false;
        }
        return true;
    }

    //Trims leading and trailing spaces
    function Trim(TRIM_VALUE){
        if(TRIM_VALUE.length < 1){
            return"";
        }
        TRIM_VALUE = RTrim(TRIM_VALUE);
        TRIM_VALUE = LTrim(TRIM_VALUE);
        if(TRIM_VALUE==""){
            return "";
        }else{
            return TRIM_VALUE;
        }
	}

	function RTrim(VALUE){
        var w_space = String.fromCharCode(32);
        var v_length = VALUE.length;
        var strTemp = "";
        if(v_length < 0){
            return"";
        }
        var iTemp = v_length -1;
        while(iTemp > -1){
            if(VALUE.charAt(iTemp) == w_space){
            }else{
                strTemp = VALUE.substring(0,iTemp +1);
                break;
            }
                iTemp = iTemp-1;
        }
        return strTemp;
	}


	function LTrim(VALUE){
	    var w_space = String.fromCharCode(32);
	    if(v_length < 1){
	        return"";
	    }
	    var v_length = VALUE.length;
	    var strTemp = "";
	    var iTemp = 0;
	    while(iTemp < v_length){
	        if(VALUE.charAt(iTemp) == w_space){}
	            else{
	                strTemp = VALUE.substring(iTemp,v_length);
	                break;
	            }
	            iTemp = iTemp + 1;
	        }
	        return strTemp;
	}
//END top nav search

//***************************
//Get email address functions
//***************************

        
        function getEmail(){
               if(submitEmailForm()){ 
                  
	                var email   = document.forms["getEmail"].email.value;
	               	var url = "http://jcwhitney.rsys1.net/servlet/campaignrespondent?_ID_=jcw.31&EMAIL="+email;
	                var newWin = window.open(url,'popup','ontop=yes,width=500,height=350,toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,menubar=no');
                    updateUserInfoCookie(email);
	                newWin.focus();
                }                
		}
        
        function submitEmailForm(getEmail)
        {
            if(ValidateForm("getEmail")) 
			{
				return true;
			}else{
				return false;
			}	
        }        

        function doFocus(){
                document.getEmail.email.focus();
        }   
//*** End get email functions


//*****************************************
// POP UP functions
//*****************************************

function checkShippingPopup() 
{
    if(document.cookie != "") {
        allCookies = document.cookie.split("; ");
        
        for(i=0; i<allCookies.length; i++) {
            if(allCookies[i].split("=")[0] == "popup2") {
                return;
            }
        }
    }
    
    openPopup('shipping_popup.html',300,300,0,0,0);
    return;
} 

/* Opens a window with the following arguments: url, width, height, scrollbars, x-coords, y-coords */
function openPopup(url,w,h,s,x,y) {
    newWindow = window.open(url,'window','width=' + w + ',height=' + h + ',scrollbars=' + s + ',screenx=' + x + ',screeny=' + y + ',left=' + x + ',top=' + y + ',toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0');
    self.name = "mainWindow";
}

/* Opens a window with the following arguments: url, width, height, scrollbars, x-coords, y-coords, resize */
function openPopup(url,w,h,s,x,y,r) {
    newWindow = window.open(url,'window','width=' + w + ',height=' + h + ',scrollbars=' + s + ',screenx=' + x + ',screeny=' + y + ',left=' + x + ',top=' + y + ',resizable=' + r + ',toolbar=0,location=0,directories=0,status=0,menubar=0');
    self.name = "mainWindow";
}

/*
 * Opens a window with the following arguments: url, window name, width, height, scrollbars, x-coords, y-coords 
 * This function should be used instead of openPopup if the window you are openning opens additional windows.
*/
function openWindow(url,name,w,h,s,x,y) {
    newWindow = window.open(url,name,'width=' + w + ',height=' + h + ',scrollbars=' + s + ',screenx=' + x + ',screeny=' + y + ',left=' + x + ',top=' + y + ',toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0');
    self.name = "mainWindow";
}


//***********************
//  End Pop up functions
//***********************



//***********************
//  Cookie / Group Functions
//***********************

function getCookie(Name)
{
	var search = Name + "=";
	if (document.cookie.length > 0) // if there are any cookies
	{ 
	  begin = document.cookie.indexOf(search);

	  if (begin != -1)  // if particular cookie exists
	  {  
		 begin += search.length;  // set index of beginning of value
		 end = document.cookie.indexOf(";", begin);

		 // set index of end of cookie value
		 if (end == -1)   
			end = document.cookie.length;
		
		 return unescape(document.cookie.substring(begin, end)) ;      
	  }    
	}
}



function getPromoImageLink(storeID, catalogID)
{
	var promo ="", link="", calcCode="";
	promo = getPromoCode(storeID);
	calcCode=getCalcCode(storeID);
	link ="/autoparts/CouponView/c-" + catalogID +"/s-" + storeID +"/calc-" + calcCode;
	
	
	if ((promo != null) && (calcCode !=null) && (promo != "null") && (calcCode !="null")){
		if(promo == "SAVENOW"){
			link = "/autoparts/ShippingView?langId=-1&catalogId=10101&storeId=10101";
		}
		document.write("<a href='"+link+"' onClick='leaving=false'><img src='/wcsstore/jcwhitney/jcw/en_US/images/promo/header/"+ promo +".gif' width='372' height='35' border='0'></a>");	      
	}else
		return "";
	
}

function getUI5PromoImageLink(storeID, catalogID)
{
	var promo ="", link="", calcCode="";
	promo = getPromoCode(storeID);
	calcCode=getCalcCode(storeID);
	link ="/autoparts/CouponView/c-" + catalogID +"/s-" + storeID +"/calc-" + calcCode;
	
	
	if ((promo != null) && (calcCode !=null) && (promo != "null") && (calcCode !="null")){
		if(promo == "SAVENOW"){
			link = "/autoparts/ShippingView?langId=-1&catalogId=10101&storeId=10101";
		}
		document.write("<a href='"+link+"' onClick='leaving=false'><img src='/wcsstore/jcwhitney/jcw/en_US/images/promo/header/ui5/"+ promo +".gif' border='0' align='absmiddle' style='float:center; margin-top:5px;'></a>");	      
	}else
		return "";
}


function getOutletUI5PromoImageLink(storeID, catalogID)
{
	var promo ="", link="", calcCode="";
	promo = getPromoCode(storeID);
	calcCode=getCalcCode(storeID);
	link ="/autoparts/CouponView/c-" + catalogID +"/s-" + storeID +"/calc-" + calcCode;
	

	if ((promo != null) && (calcCode !=null) && (promo != "null") && (calcCode !="null")){
		if(promo == "SAVENOW"){
			link = "/autoparts/ShippingView?langId=-1&catalogId=10101&storeId=10101";
		}
		document.write("<a href='"+link+"' onClick='leaving=false'><img src='/wcsstore/jcwhitney/goldwing/en_US/images/promo/header/ui5/"+ promo +".gif' border='0' vspace='5' align='absmiddle'></a>");	      
	}else
		return "";
}

function getPromoLink(storeID, catalogID)
{
	var promo ="", link="", calcCode="";
	promo = getPromoCode(storeID);
	calcCode=getCalcCode(storeID);
	link ="<a href='/autoparts/CouponView/c-" + catalogID +"/s-" + storeID +"/calc-" + calcCode +"'>";
	document.write(link);	      
}


function getPromoCode(storeID)
{

	var search = getCookie("GROUP_" + storeID);
	var begin, end;
    if (search != null)
	  if ((search.length > 0) && (search.split("?").length > 1)) // If Cookie
	  { 
		
		return (search.split("?")[2]);	      
	  }
	return null;
}

function getCalcCode(storeID)
{

	var search = getCookie("GROUP_" + storeID);
	var begin, end;
    if (search != null)
	  if ((search.length > 0) && (search.split("?").length > 2)) // If Cookie
	  { 
		
		return (search.split("?")[3]);	      
	  }
	return null;
}

function limitPopUp(desc)
{
	var maxLength = 700;
	if (desc.length > maxLength)
	{
		desc = desc.substring(0,maxLength);
		desc = desc + "<br><br>Click image for more ...";
	
	}
	return desc;

}


//***********************
//  End Cookie / Group functions
//***********************

//*********************
//5.2 functions from GCI
//*********************
// JavaScript Document

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//Swap Image

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadHeaderImages() {
	MM_preloadImages(
	'/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_home_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_car_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_pc_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_clearance_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_catalog_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_truck_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_mc_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_jeep_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_vw_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_rv_over.gif','/wcsstore/jcwhitney/jcw/en_US/ui5_images/mainNav_more_over.gif');
}

//***********************
//  Customer Feedback functions
//***********************
function MM_openBrWindow(theURL,winName,features) { //v2.0
 window.open(theURL,winName,features);
}


		
		function submitFeedbackForm(theURL,serverName){
			var objFeedBack = document.forms['CustomerFeedbackForm'].feedbackMessage;
			var objFeedBackType = document.forms['CustomerFeedbackForm'].feedbackType;
			
			//Added by GCI for BUG 1120
			var objCustomerFeedback = document.forms['CustomerFeedbackForm'].customerFeedback;
			var validEmail = ValidateEmail('CustomerFeedbackForm');
			//End
			
			var feedbackLength = objFeedBack.value.length;
			var feedbackTypeLength = 0;
			
			for (var iIndex =objFeedBackType.selectedIndex; iIndex < objFeedBackType.options.length; iIndex++) {
		      if (objFeedBackType.options[iIndex].selected){
		    		feedbackTypeLength = objFeedBackType.options[iIndex].value.length;
		      }
   			}
			
			if(feedbackLength > 0 && feedbackTypeLength > 0 && validEmail == true){
			
			feedbackType=document.forms['CustomerFeedbackForm'].feedbackType.value;
			feedbackMessage=document.forms['CustomerFeedbackForm'].feedbackMessage.value;
			customerFeedback=document.forms['CustomerFeedbackForm'].customerFeedback.value;
			webPageUrl=document.forms['CustomerFeedbackForm'].webPageUrl.value;
			storeId=document.forms['CustomerFeedbackForm'].storeId.value;
			mediaCode=document.forms['CustomerFeedbackForm'].mediaCode.value;
			if(null != document.forms['CustomerFeedbackForm'].groupNumber && document.forms['CustomerFeedbackForm'].groupNumber != "null"){
				groupNumber=document.forms['CustomerFeedbackForm'].groupNumber.value;
				var paramsstring='feedbackType='+feedbackType+'&feedbackMessage='+feedbackMessage+'&customerFeedback='+customerFeedback+'&groupNumber='+groupNumber+'&storeId='+storeId+'&mediaCode='+mediaCode+'&webPageUrl='+webPageUrl;
			}else{
				itemNumber=document.forms['CustomerFeedbackForm'].itemNumber.value;
				var paramsstring='feedbackType='+feedbackType+'&feedbackMessage='+feedbackMessage+'&customerFeedback='+customerFeedback+'&itemNumber='+itemNumber+'&storeId='+storeId+'&mediaCode='+mediaCode+'&webPageUrl='+webPageUrl;
			}
			var	url=serverName+'/webapp/wcs/stores/servlet/SendCustomerFeedBackForm?' + paramsstring;	
				sendData(url);
			}else if(feedbackTypeLength == 0){
					document.getElementById("errorColumn").innerHTML = "Please choose Feedback Type.";
					document.getElementById("errorRow").style.display="";
					objFeedBackType.focus();
			}else if(feedbackLength == 0){
					document.getElementById("errorColumn").innerHTML = "Please enter Feedback Message.";
					document.getElementById("errorRow").style.display="";
					objFeedBack.focus();
			}else if(!validEmail){  //Added by GCI for BUG 1120
					document.getElementById("errorColumn").innerHTML = "Please enter valid Email Address.";
					document.getElementById("errorRow").style.display="";
					objCustomerFeedback.focus();
			}
			
	}
		
		
	function init() {
		if(window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			try {
				req = new 	ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
				req = new	ActiveXObject("Microsoft.XMLHTTP");
				} catch (e1) {
				req = false;
				}
			}
		}
	}
	
	function sendData(url) {
	document.getElementById("errorColumn").innerHTML ="";
	document.getElementById("statusMessage").innerHTML ="Your Feedback is being sent...";
	document.forms['CustomerFeedbackForm'].customerFeedbackButton.disabled=true;
		init();
		req.onreadystatechange = success;
		req.open("GET", url, true);
		req.send(null);
	}

	
	function success() {
		
		if (req.readyState == 4) {
			if (req.status ==200) {
					document.getElementById("statusMessage").innerHTML ="";
					feedbackType=document.forms['CustomerFeedbackForm'].feedbackType.selectedIndex=0;
					feedbackMessage=document.forms['CustomerFeedbackForm'].feedbackMessage.value='';
					document.forms['CustomerFeedbackForm'].customerFeedbackButton.disabled=false;
					MM_openBrWindow('/wcsstore/jcwhitney/jcw/ui5/thankyou.html','winThankYou','width=480,height=205');
			}
		}
	}

//Release 7.1 Related Links
//Code added by GCI

//***********************
//  Email This Page functions
//***********************

		
		function submitEmailPageForm(serverName){
			var objFriendsEmail = document.forms['EmailPageForm'].friendsEmailValue;
			var objSenderEmail = document.forms['EmailPageForm'].senderEmailValue;
			
			var validFriendsEmail = ValidateEmailFor(objFriendsEmail,'EmailPageForm');
			var validSenderEmail = ValidateEmailFor(objSenderEmail,'EmailPageForm');
			
			if(validFriendsEmail == true &&  validSenderEmail == true){

			friendsEmailValue=document.forms['EmailPageForm'].friendsEmailValue.value;
			senderEmailValue=document.forms['EmailPageForm'].senderEmailValue.value;
			if(document.forms['EmailPageForm'].friendsNameValue.value != null){
				friendsNameValue=document.forms['EmailPageForm'].friendsNameValue.value;
			}else{
				friendsNameValue="";
			}
			if(document.forms['EmailPageForm'].senderNameValue.value != null){
				senderNameValue=document.forms['EmailPageForm'].senderNameValue.value;
			}else{
				senderNameValue="";
			}
			webPageUrl=document.forms['EmailPageForm'].webPageUrl.value;
			var paramString='emailType=0&friendsEmailValue='+friendsEmailValue+'&friendsNameValue='+friendsNameValue+'&senderEmailValue='+senderEmailValue+'&senderNameValue='+senderNameValue+'&webPageUrl='+webPageUrl;
			url=serverName+'/webapp/wcs/stores/servlet/EmailThisPageForm?'+paramString;
					sendEmailData(url);
					//document.forms['EmailPageForm'].submit();
					//MM_openBrWindow(theURL,winName,features);
			}else if(!validFriendsEmail){
					document.getElementById("errorEmailColumn").innerHTML = "Please enter your Friend's valid Email address.";
					document.getElementById("errorEmailRow").style.display="";
					objFriendsEmail.focus();
			}else if(!validSenderEmail){
					document.getElementById("errorEmailColumn").innerHTML = "Please enter your valid Email address.";
					document.getElementById("errorEmailRow").style.display="";
					objSenderEmail.focus();
			}
			
	}
	
		function sendEmailData(url) {
			document.getElementById("errorEmailColumn").innerHTML = "";
			document.getElementById("statusEmailMessage").innerHTML ="Your Mail is being sent...";
			document.forms['EmailPageForm'].emailButton.disabled=true;						
			init();
			req.onreadystatechange = successEmail;
			req.open("GET", url, true);
			req.send(null);
		}
	
		
		function successEmail() {
			
			if (req.readyState == 4) {
				if (req.status ==200) {
						document.getElementById("statusEmailMessage").innerHTML ="";
						document.forms['EmailPageForm'].friendsEmailValue.value='';
						document.forms['EmailPageForm'].senderEmailValue.value='';
						document.forms['EmailPageForm'].friendsNameValue.value='';
						document.forms['EmailPageForm'].senderNameValue.value='';
						document.forms['EmailPageForm'].emailButton.disabled=false;	
						MM_openBrWindow('/wcsstore/jcwhitney/jcw/ui5/emailthankyou.html','winThankYou','width=480,height=180');
				}
			}
		}
				

//Release 7.1 Related Links
//Code added by GCI

//***********************
//  Email This Page functions
//***********************

		
		function submitDealEmailPageForm(serverName){
			var objFriendsEmail = document.forms['EmailPageForm'].friendsEmailValue;
			var objSenderEmail = document.forms['EmailPageForm'].senderEmailValue;
			var message = "";
			
			var validFriendsEmail = ValidateEmailFor(objFriendsEmail,'EmailPageForm');
			var validSenderEmail = ValidateEmailFor(objSenderEmail,'EmailPageForm');
			
			if(validFriendsEmail == true &&  validSenderEmail == true){

			friendsEmailValue=document.forms['EmailPageForm'].friendsEmailValue.value;
			senderEmailValue=document.forms['EmailPageForm'].senderEmailValue.value;
			if(document.forms['EmailPageForm'].friendsNameValue.value != null){
				friendsNameValue=document.forms['EmailPageForm'].friendsNameValue.value;
			}else{
				friendsNameValue="";
			}
			if(document.forms['EmailPageForm'].senderNameValue.value != null){
				senderNameValue=document.forms['EmailPageForm'].senderNameValue.value;
			}else{
				senderNameValue="";
			}
			if(document.forms['EmailPageForm'].dealMessage.value != null){
				message=document.forms['EmailPageForm'].dealMessage.value;
			}else{
				message="";
			}
			webPageUrl=document.forms['EmailPageForm'].webPageUrl.value;
			var paramString='emailType=1&friendsEmailValue='+friendsEmailValue+'&friendsNameValue='+friendsNameValue+'&senderEmailValue='+senderEmailValue+'&senderNameValue='+senderNameValue+'&dealMessage='+message+'&webPageUrl='+webPageUrl;
			url=serverName+'/webapp/wcs/stores/servlet/EmailThisPageForm?'+paramString;
					sendDealEmailData(url);
					//document.forms['EmailPageForm'].submit();
					//MM_openBrWindow(theURL,winName,features);
			}else if(!validFriendsEmail){
					document.getElementById("errorEmailColumn").innerHTML = "Please enter your Friend's valid Email address.";
					document.getElementById("errorEmailRow").style.display="";
					objFriendsEmail.focus();
			}else if(!validSenderEmail){
					document.getElementById("errorEmailColumn").innerHTML = "Please enter your valid Email address.";
					document.getElementById("errorEmailRow").style.display="";
					objSenderEmail.focus();
			}
			
	}
	
		function sendDealEmailData(url) {
			document.getElementById("errorEmailColumn").innerHTML = "";
			document.getElementById("statusEmailMessage").innerHTML ="Your Mail is being sent...";
			init();
			req.onreadystatechange = successDealEmail;
			req.open("GET", url, true);
			req.send(null);
		}
	
		
		function successDealEmail() {
			
			if (req.readyState == 4) {
				if (req.status ==200) {
						document.getElementById("statusEmailMessage").innerHTML ="";
						document.forms['EmailPageForm'].friendsEmailValue.value='';
						document.forms['EmailPageForm'].senderEmailValue.value='';
						document.forms['EmailPageForm'].friendsNameValue.value='';
						document.forms['EmailPageForm'].senderNameValue.value='';
						HideProducts();
						MM_openBrWindow('/wcsstore/jcwhitney/jcw/ui5/emailthankyou.html','winThankYou','width=480,height=180');
				}
			}
		}
				


/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(str, formName) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
			if(formName == "getEmail")
			   alert("Invalid E-mail ID");
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
   			if(formName == "getEmail")
			   alert("Invalid E-mail ID");

		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
   			if(formName == "getEmail")
			   alert("Invalid E-mail ID");

		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
   			if(formName == "getEmail")
			   alert("Invalid E-mail ID");

		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
   			if(formName == "getEmail")
			   alert("Invalid E-mail ID");

		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
   			if(formName == "getEmail")
			   alert("Invalid E-mail ID");

		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){

   			if(formName == "getEmail")
			   alert("Invalid E-mail ID");

		    return false
		 }

 		 return true					
	}

	function ValidateForm(formName){
		var emailID="";
		if(formName == "CustomerFeedbackForm"){
			emailID=document.forms["CustomerFeedbackForm"].customerFeedback;
		}else if(formName == "getEmail"){
			emailID=document.forms["getEmail"].email;
		}
	
		if ((emailID.value==null)||(emailID.value=="")){
	
			if(formName != "CustomerFeedbackForm"){
				alert("Please Enter your Email ID")
			}
	
			emailID.focus()
			return false
		}
		if (echeck(emailID.value, formName)==false){
			emailID.value=""
			emailID.focus()
			return false
		}
		return true
 }
 
 function checkFeedbackMessage(element, maxvalue) 
 { 
 	var q = element.value.length;
 	var r = maxvalue - q; 
 	 	 	
 	var msg = "Maximum allowed characters is " + maxvalue; 
 	if (q > maxvalue){
 		alert(msg);
 		element.value = element.value.substring(0,maxvalue);
 		element.focus();
 	}
 }
 
 	
/**
 * 	Added by GCI for BUG 1120 
 *  For email validation 
 *  Return type is boolean
 *  IF invalid form name is send THEN returns false (Should not be used for any other email validation) 
 *  IF email input box is filled THEN it should be a valid email. (as it is a optional field) 
 */
 function ValidateEmail(formName)
 {
 	var emailID="";
	if(formName == "CustomerFeedbackForm"){
		emailID=document.forms["CustomerFeedbackForm"].customerFeedback;
		
		if(emailID.value == "Customer Feedback") {
			return true;
		}
		else if(emailID.value.length == 0) {
			return true;
		}
		else {
			return echeck(emailID.value, formName);
		}	
 	}
 	
 	return false;
 }	
 

/**
 * 	Release 7.1 Related Links
 *  Code added by GCI
 *  For email validation 
 *  Return type is boolean
 */
 
 function ValidateEmailFor(emailID,formName)
 {
 	if(emailID.value.length == 0) {
		return false;
	}
	else {
		return echeck(emailID.value, formName);
	}	
 	return false;
 }	

/**
 * 	Release 7.1 Related Links
 *  Code added by GCI
 */
function replaceAll(OldString,FindString,ReplaceString) {
	
   var SearchIndex = 0;
   var NewString = ""; 
   
   if(OldString != null && OldString != "null") {
      while (OldString.indexOf(FindString,SearchIndex) != -1) {
		   NewString += OldString.substring(SearchIndex,OldString.indexOf(FindString,SearchIndex));
		   NewString += ReplaceString;
		   SearchIndex = (OldString.indexOf(FindString,SearchIndex) + FindString.length); 
	   }
	   NewString += OldString.substring(SearchIndex,OldString.length);
	   return NewString;
	}
	
   return null;
}


function getDefaultMMYYear()
	{
		try{
			var cookieString=readCookie("JCWMakeModel");
			if(cookieString == null || cookieString == "null"){
				return null;
			}
			else{
				var MMYArr=new Array();
				cookieString=cookieString.substring((cookieString.lastIndexOf("?")+1));
				MMYArr=cookieString.split("|");
				var year=MMYArr[1];
				if(year == null || year == "null")
					return null;
				else
					return year;						
			}
		}catch(err){
			return null;			
		}
	}
	
function getDefaultMMYMake()
	{
		try{
			var cookieString=readCookie("JCWMakeModel");
			if(cookieString == null || cookieString == "null"){
				return null;
			}
			else{
				var MMYArr=new Array();
				cookieString=cookieString.substring((cookieString.lastIndexOf("?")+1));
				MMYArr=cookieString.split("|");
				
				makeid=MMYArr[2].substring(MMYArr[2].lastIndexOf("+")+1,MMYArr[2].length);
			
				if(makeid == null || makeid == "null")
					return null;
				else
					return makeid;
			}
		}catch(err){
			return null;			
		}	
	}

function getDefaultMMYModel()
	{
		try{
			var cookieString=readCookie("JCWMakeModel");
			if(cookieString == null || cookieString == "null"){
				return null;
			}
			else{
				var MMYArr=new Array();
				cookieString=cookieString.substring((cookieString.lastIndexOf("?")+1));
				MMYArr=cookieString.split("|");
				modelid=MMYArr[3].substring(MMYArr[3].lastIndexOf("+")+1,MMYArr[3].length);
				if(modelid.indexOf("#")>0){
					modelid=modelid.substring(0,modelid.indexOf("#"));
				}				
				if(modelid == null || modelid == "null")
					return null;
				else
					return modelid;
			}
		}catch(err){
			return null;			
		}				
	}
	//Function to get the PromoCode Value from Cookie
	
	function getPromoCodeValue(cookieName){

		var promoCodeVal = null;
		var cookieValue = readCookie(cookieName);
		if ( cookieValue != null ) {
			arr=cookieValue.split("?");

			if (arr.length > 2 ){
				promoCodeVal =arr[2];
			}
		}
		return promoCodeVal;
	}	
	
	//get Phone number from cookie Group_Storeid 
	function getTelephoneNumberFromCookie(cookieName){
	
		    var telephoneNum = null;
            var cookieValue = readCookie(cookieName);
            
            if ( cookieValue != null ) {
                  arr=cookieValue.split("?");
                  if (arr.length > 4 ){
                        telephoneNum =arr[4];
                  }
            }
            return telephoneNum;
      }

//***********************
//  Attribute Dimension Popups
//***********************      
	function openAttributePopUp(attributeId){
		if(attributeId != null && attributeId != ''){
			var dd = location.host;
			window.open('http://' + dd + '/wcsstore/jcwhitney/attributes/'+attributeId+'.html','popup','ontop=yes,width=500,height=250,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,menubar=no');
		}
	}
	function openMore(){
		var moreBrandsDivEle = document.getElementById("MoreBrands");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "block";
		}
		moreBrandsDivEle = document.getElementById("More");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "none";
		}
	}
	function closeMore(){
		var moreBrandsDivEle = document.getElementById("More");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "block";
		}
		moreBrandsDivEle = document.getElementById("MoreBrands");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "none";
		}
	}
	
	function openMoreCats(){
		var moreBrandsDivEle = document.getElementById("MoreCats");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "block";
		}
		moreBrandsDivEle = document.getElementById("MoreCat");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "none";
		}
	}
	function closeMoreCats(){
		var moreBrandsDivEle = document.getElementById("MoreCat");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "block";
		}
		moreBrandsDivEle = document.getElementById("MoreCats");
		if(null != moreBrandsDivEle){
			moreBrandsDivEle.style.display = "none";
		}
	}
	
	
	
	
	function isInteger(s){
    if(s==null || s == undefined)
	    return false;
     else{
	     var val = Trim(s)
         if(val =="")
				return false
		 else{
		     for (i = 0; i < val.length; i++)
		     {
				var c = val.charAt(i);
				if (!isDigit(c)) return false;
			  }
	      }
		}
	   return true;
	}
	
	function isDigit (c){
		return ((c >= "0") && (c <= "9"))
	}
	

//-->