	
	var vehicle_map = new Object();
	vehicle_map['10101'] = '10201';
	vehicle_map['10102'] = '10202';
	vehicle_map['10103'] = '10203';
	vehicle_map['10104'] = '10204';
	vehicle_map['10105'] = '10205';
	vehicle_map['10106'] = '10206';
	vehicle_map['10107'] = '10207';
	vehicle_map['10108'] = '10208';
	vehicle_map['10109'] = '10209';
	vehicle_map['10110'] = '10210';
	vehicle_map['10111'] = '10211';
	vehicle_map['10112'] = '10212';
	vehicle_map['10113'] = '10213';
	vehicle_map['10614'] = '10714';
	vehicle_map['10114'] = '10214';
	vehicle_map['10615'] = '10715';
	vehicle_map['10618'] = '10718';
	
	var ref_current = null;
	var store = 10101;
	var vehicle_dim = 10201;
	var catalog = 10101;
	var base_make = null;
	var base = "";
	var search_term = null;
	var bypass_year = false;
	
	//Added by GCI
	var productId = "";
	var itemId = "";
	
	function ref_extract_from_iframe()
	{
		if (ref_current != null)
		{
			var current_div = $(ref_current);
			var ref_dynamic_iframe_id = $("ref_dynamic_iframe_id");
			var the_body = ref_extractIFrameBody(ref_dynamic_iframe_id);
			
			if (the_body != null)
			{ 
				var processing_year = false;
				
				if (the_body.innerHTML.indexOf('ref_yearDropDown') > 0 && (ref_current == 'ref_modelDropDown'))
				{
					ref_current = 'ref_yearDropDown';
					current_div = $(ref_current);
				}
				else if (the_body.innerHTML.indexOf('ref_year_id') > 0 && (ref_current == 'ref_modelDropDown'))
				{
					ref_current = 'ref_yearDropDown';
					current_div = $(ref_current);
				}else if (the_body.innerHTML.indexOf('ref_year_id') > 0 && (ref_current == 'ref_yearDropDown'))
				{
					processing_year = true;
				}
				
				current_div.innerHTML = the_body.innerHTML;
				
				if (current_div.innerHTML == "")
				{
					ref_year_selected(base);
				}
				
				if (processing_year == true && bypass_year == true)
				{
				}
				else
				{
					current_div.style.visibility = 'visible';
				}
			}	
		}
		
		if(document.getElementById("ajaxImg")){
			document.getElementById("ajaxImg").style.display="none";
		}
	}

	function ref_extractIFrameBody(iFrameEl) 
	{
	  	var doc = null;

	  	if (iFrameEl.contentDocument) 
	  	{ 
			doc = iFrameEl.contentDocument; 
	  	} 
	  	else if (iFrameEl.contentWindow) 
	  	{ 
			doc = iFrameEl.contentWindow.document;
	  	} 
	  	else if (iFrameEl.document) 
	  	{ 
			doc = iFrameEl.document;
	  	} 
	  	else 
	  	{
			return null;
	  	}

	  	return doc.body;
	}
	
	function $() 
	{
		var elements = new Array();
		
		for (var i = 0; i < arguments.length; i++) 
		{
			var element = arguments[i];
		  	
			if (typeof element == 'string') 
		  	{
				if (document.getElementById) 
				{
			  		element = document.getElementById(element);
				} 
				else if (document.all) 
				{
			  		element = document.all[element];
				}
		  	}
			
		  	elements.push(element);
		}
		
		if (arguments.length == 1 && elements.length > 0) 
		{
		  	return elements[0];
		} 
		else 
		{
		  	return elements;
		}
	}	
	
	function ref_setStoreCatalog(_store, _catalog)
	{
		store = _store;
		catalog = _catalog;
		vehicle_dim = vehicle_map[_catalog];
	} 
	
	function ref_setSearchTerm(_term)
	{
		search_term = _term;
	} 	
	
	function ref_updateNewModelDropDown(makeElement, modelElement) 
	{
		var idx = makeElement.selectedIndex;
		var makeId = makeElement.options[idx].value;
	
		modelElement.options.length = 0;
		modelElement.disabled = false;
	
		setModelDropDown(modelElement, makeId, "");
	}

	function setBypassYear(_bool)
	{
		//switch it off again
		//bypass_year = _bool;
		bypass_year = false;
	}	
	
	function setMakeId(_base_make)
	{
		base_make = _base_make;
	}

	function ref_make_selected(_base)
	{
		base = _base;
		var _neval = document.ref_mmy_form.ref_make_id.value;
		
		
		if(_neval == ""){
			return;
		}
		
		if(_neval.indexOf('_') != -1){
			_neval = _neval.substring(0,_neval.indexOf('_'));
		}

		if (search_term == null)
		{
			if(productId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefModelsHTML?n=" + vehicle_dim + "&ne=" + _neval + "&base=" + _base + "&productId=" + productId+ "&makeId=" + _neval+"&storeId=" + store;
			}else if(itemId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefModelsHTML?n=" + vehicle_dim + "&ne=" + _neval + "&base=" + _base + "&itemId=" + itemId+ "&storeId=" + store;
			}else{
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefModelsHTML?n=" + vehicle_dim + "&ne=" + _neval + "&base=" + _base+"&storeId=" + store + "&style=groupListing";
			}
		}
		else
		{
			if(productId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefModelsHTML?n=" + vehicle_dim + "&ne=" + _neval + "&base=" + _base + "&searchterm=" + search_term+ "&productId=" + productId+ "&makeId=" + _neval + "&storeId=" + store;
			}else if(itemId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefModelsHTML?n=" + vehicle_dim + "&ne=" + _neval + "&base=" + _base + "&searchterm=" + search_term+ "&itemId=" + itemId+ "&storeId=" + store;
			}else{
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefModelsHTML?n=" + vehicle_dim + "&ne=" + _neval + "&base=" + _base + "&searchterm=" + search_term+"&storeId=" + store + "&style=groupListing";
			}
		}
		
		ref_current = 'ref_modelDropDown';
		
		if(productId != "" || itemId != "")
		{
			$('ref_yearDropDown').innerHTML = '<select id="year" style="width: 140px;" disabled name="year" class="dropdown"><option value="">Select Year</option></select>';
			$('ref_modelDropDown').innerHTML = '<select id="model" style="width: 140px;" disabled name="model" class="dropdown"><option value="">Select Model</option></select>';
		}
		else
		{
			$('ref_yearDropDown').innerHTML = '<select id="year" disabled name="year" class="dropdown" style="width:140px;"><option value="">Select Year</option></select>';
			$('ref_modelDropDown').innerHTML = '<select id="model" disabled name="model" class="dropdown" style="width:140px"><option value="">Select Model</option></select>';
		}
		
		if(document.getElementById("ajaxImg")){
			document.getElementById("ajaxImg").style.display="";
		}
	}
	
	function ref_model_selected(_base)
	{
		if (bypass_year == true)
		{
			ref_year_selected(_base);
		}	
	
		base = _base;
		var extract_nval = $("ref_model_id").value;
		
		if(extract_nval == ""){
			return;
		}
		
		if(extract_nval.indexOf('_') != -1){
			extract_nval = extract_nval.substring(0,extract_nval.indexOf('_'));
		}
		
		var wcs_id = extract_nval.substring(0,extract_nval.indexOf('_'));
		var _nval = extract_nval.substring(extract_nval.indexOf('_') + 1);

		if (search_term == null)
		{
			
			if(productId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefYearsHTML?n=" + _nval + "&ne=10602&base=" + _base+ "&productId=" + productId + "&style=prod_page"+"&storeId=" + store;
			}else if(itemId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefYearsHTML?n=" + _nval + "&ne=10602&base=" + _base+ "&itemId=" + itemId  + "&style=prod_page"+"&storeId=" + store;
			}else{
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefYearsHTML?n=" + _nval + "&ne=10602&base=" + _base+"&storeId=" + store + "&style=groupListing";
			}
		}
		else
		{
			if(productId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefYearsHTML?n=" + _nval + "&ne=10602&base=" + _base + "&searchterm=" + search_term + "&productId=" + productId + "&storeId=" + store  + "&style=prod_page";
			}else if(itemId != ""){
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefYearsHTML?n=" + _nval + "&ne=10602&base=" + _base + "&searchterm=" + search_term + "&itemId=" + itemId+ "&storeId=" + store  + "&style=prod_page";
			}else{
				document.getElementById("ref_dynamic_iframe_id").src = "/webapp/wcs/stores/xml/RefYearsHTML?n=" + _nval + "&ne=10602&base=" + _base + "&searchterm=" + search_term+"&storeId=" + store + "&style=groupListing";
			}
		}


		ref_current = 'ref_yearDropDown';
		
		if(document.getElementById("ajaxImg")){
			document.getElementById("ajaxImg").style.display="";
		}
	}
	function replace(s, t, u)
	{
  /*
  **  Replace a token in a string
  **    s  string to be processed
  **    t  token to be found and removed
  **    u  token to be inserted
  **  returns new String
  */
  		i = s.indexOf(t);
  		r = "";
  		if (i == -1) return s;
  		r += s.substring(0,i) + u;
  		if ( i + t.length < s.length)
    		r += replace(s.substring(i + t.length, s.length), t, u);
  		return r;
  	}
  	
  	//Added by GCI  	
  	function setProductId(_productId){
	  	productId = _productId;
  	}
	
	function setItemId(_itemId){
	  	itemId = _itemId;
  	}	

	
	function ref_year_selected(_base)
	{
		_base = replace(_base," ","+");
		var make_nval = "";
		var model_nval = "";
		var year_nval = "";
		
		var makeName = "";
		var modelName = "";
		var year = "";
		
		var makeId = "";
		var modelId = "";
		
		if ($("ref_make_id") != null)
		{
			make_nval = $("ref_make_id").value;
			if(make_nval.indexOf('_') != -1){
				makeName = make_nval.substring(make_nval.indexOf('_') + 1)
				make_nval = make_nval.substring(0,make_nval.indexOf('_'));
				makeId = getMakeId(make_nval);
			}
			_base = replace(_base,"+" + vehicle_dim,"");
		}
		
		if ($("ref_model_id") != null)
		{
			model_nval = $("ref_model_id").value;
			if(model_nval.indexOf('_') != -1){
				modelName = model_nval.substring(model_nval.indexOf('_') + 1)
				model_nval = model_nval.substring(0,model_nval.indexOf('_'));
				
				if($("ref_make_id") != null){
					modelId = getModelId(make_nval, model_nval);
				}
				
				
			}
			_base = replace(_base,"+" + vehicle_dim,"");
		}
		
		if ($("ref_year_id") != null)
		{
			year_nval = $("ref_year_id").value;
			if(year_nval.indexOf('_') != -1){
				year = year_nval.substring(year_nval.indexOf('_') + 1)
				year_nval = year_nval.substring(0,year_nval.indexOf('_'));
			}
		}	
			
		var nval = "";
		
		if (base_make != null)
		{
			_base = replace(_base,"+" + base_make,""); 
		}
		
		if (make_nval != null && make_nval != "" && model_nval == "")
		{
			nval = nval + '+' + make_nval;
		}

		if (model_nval != null && model_nval != "")
		{
			nval = nval + '+' + model_nval;
		}

		if (year_nval != null && year_nval != "")
		{
			nval = nval + '+' + year_nval;
		}	
		
		

		
		  //Added by GCI 
		if ((search_term == null || search_term == 'null') && (_base != null && _base != 'null'))
		{
				if(productId != ""){
				    //Product Page URL
					window.location = '/autoparts/ProductBrowse/showCustom-0/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/refId-'+make_nval+'/Pr-p_Product.CATENTRY_ID:'+productId+'/c-'+catalog+'/p-'+productId+'/N-'+_base + nval+'/tf-Browse/s-'+store+'/scrollToItems-true';
				}else if(itemId != ""){
				    //Itempage Url
					window.location = '/autoparts/ItemBrowse/showCustom-0/refId-'+make_nval+'/c-'+catalog+'/tf-Browse/itemId-'+itemId+'/s-'+store+'/N-'+_base + nval+'/scrollToItems-true';
				}else{
					//Group Listing Page
					window.location = '/autoparts/Browse/showCustom-0/tf-Browse/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/s-' + store + '/N-' + _base + nval + '/c-' + catalog;
				}
		}
		else if (_base == null || _base == 'null')
		{
				if(productId != ""){
				    
				    if(search_term == null || search_term == 'null')
				    {
				    	//Product Page URL For Featured Items
						window.location = '/autoparts/ProductBrowse/showCustom-0/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/showAll-1/N-' + nval + '/refId-'+make_nval+'/Pr-p_Product.CATENTRY_ID:'+productId+'/c-'+catalog+'/p-'+productId+'/tf-Browse/s-'+store+'/scrollToItems-true';
					} else {
						window.location = '/autoparts/ProductBrowse/showCustom-0/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/showAll-1/N-' + nval + '/refId-'+make_nval+'/Pr-p_Product.CATENTRY_ID:'+productId+'/c-'+catalog+'/p-'+productId+'/Nty-1/Ntx-mode+matchallpartial/Ntk-AllTextSearchGroup/N-'+ nval+'/tf-Browse/s-'+store+'/scrollToItems-true?Ntt=' + search_term;
						
					}
					
				}else if(itemId != ""){
					//Added by GCI for BUG 1023 Item Page
					if(search_term == null || search_term == 'null'){
				    	//Itempage Url for Featured items
						window.location = '/autoparts/ItemBrowse/showCustom-0/showAll-1/N-' + nval + '/refId-'+make_nval+'/c-'+catalog+'/tf-Browse/itemId-'+itemId+'/s-'+store+'/scrollToItems-true';
					}else{
						window.location = '/autoparts/ItemBrowse/showCustom-0/showAll-1/N-' + nval + '/refId-'+make_nval+'/c-'+catalog+'/Nty-1/Ntx-mode+matchall/tf-Browse/itemId-'+itemId+'/s-'+store+'/scrollToItems-true/Ntk-AllTextSearchGroup?Ntt=' + search_term;
					}
				}else{
						//Group Listing Page
						window.location = '/autoparts/Browse/showCustom-0/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/showAll-1/c-' + catalog + '/Nty-1/Ntx-mode+matchallpartial/N-' + nval + '/tf-Browse/s-' + store + '/Ntk-AllTextSearchGroup?Ntt=' + search_term;	
				}
			
		}
		else
		{
				if(productId != ""){
				    //Product Page URL
					window.location = '/autoparts/ProductBrowse/showCustom-0/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/showAll-1/N-' + _base + nval + '/refId-'+make_nval+'/Pr-p_Product.CATENTRY_ID:'+productId+'/c-'+catalog+'/p-'+productId+'/Nty-1/Ntx-mode+matchallpartial/tf-Browse/s-'+store+'/scrollToItems-true?Ntt=' + search_term;
				}else if(itemId != ""){
				    //Itempage Url
					window.location = '/autoparts/ItemBrowse/showCustom-0/showAll-1/N-' + _base + nval + '/c-'+catalog+'/Nty-1/Ntx-mode+matchall/tf-Browse/itemId-'+itemId+'/s-'+store+'/scrollToItems-true/Ntk-AllTextSearchGroup?Ntt=' + search_term;
				}else{
					window.location = '/autoparts/Browse/makeName-'+makeName+'/makeId-'+makeId+'/modelName-'+modelName+'/modelId-'+modelId+'/year-'+year+'/showCustom-0/showAll-1/c-' + catalog + '/Nty-1/Ntx-mode+matchallpartial/N-' + _base + nval + '/tf-Browse/s-' + store + '/Ntk-AllTextSearchGroup?Ntt=' + search_term;	
				}
		}
}// makemodelyeartag.js
