	var vehicle_map = new Object();
	vehicle_map['10101'] = '10201';
	vehicle_map['10102'] = '10202';
	vehicle_map['10618'] = '10718';
	vehicle_map['10623'] = '10723';
	vehicle_map['10624'] = '10724';
	vehicle_map['10625'] = '10725';
	
	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;
	var model_nval = "";
	var make_endecaid = "";
	var categoryURLDesc = "";
	var productURLDesc = "";
	var makeName = "";
	var modelName = "";
	
	
	//Added by GCI
	var productId = "";
	var itemId = "";
	
	function ref_extract_from_iframe()
	{
	try {
		if (ref_current != null)
		{	
			var current_div = mmy$(ref_current);
			var ref_dynamic_iframe_id = mmy$("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 = mmy$(ref_current);
				}
				else if (the_body.innerHTML.indexOf('ref_year_id') > 0 && (ref_current == 'ref_modelDropDown'))
				{
					ref_current = 'ref_yearDropDown';
					current_div = mmy$(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";
		}
		} 	catch (e)
	{
	}
	}

	function ref_extractIFrameBody(iFrameEl) 
	{
	try {
	  	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;
	  } 	catch (e)
		{
		}
	}
	
	function mmy$() 
	{
	try {
		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;
		}
	} 	catch (e)
	{
	}
	}	
	
	function ref_setStoreCatalog(_store, _catalog)
	{	//alert(" Called set StoreCaltalog" );
		store = _store;
		catalog = _catalog;
		vehicle_dim = vehicle_map[_catalog];
	} 
	
	function ref_setSearchTerm(_term)
	{
		search_term = _term;
	} 	
	
	function ref_updateNewModelDropDown(makeElement, modelElement) 
	{
	try {
		var idx = makeElement.selectedIndex;
		var makeId = makeElement.options[idx].value;
	
		modelElement.options.length = 0;
		modelElement.disabled = false;
	
		setModelDropDown(modelElement, makeId, "");
	} 	catch (e)
	{
	}
	}

	function setBypassYear(_bool)
	{	
		//alert(" inside set bypass" );
		//switch it off again
		//bypass_year = _bool;
		bypass_year = false;
	}	
	
	function setMakeId(_base_make)
	{
		base_make = _base_make;
	}
	
	function setModelValues(modelHTML ){
		
		try {
		//salert("Call back triggerred " + modelHTML );
		if ( modelHTML != null && !(modelHTML.indexOf('Select Year') > -1) && !(modelHTML.indexOf('yearisnull') > -1) ) {
			document.getElementById("ref_modelDropDown").innerHTML = modelHTML;
		} else if ( modelHTML != null && (modelHTML.indexOf('yearisnull') > -1) ){
				if(base == null || base == 'null') {
					base = "";
				}
				
				if(productId != ""){
					document.getElementById("ref_yearDropDown").style.display = 'none';
					document.getElementById("ref_modelDropDown").style.display = 'none';
					var newloc ="/"+makeName + "-" +  productURLDesc +"/Product.htm?" + "catalogId=" + catalog + "&productId="+productId+"&N="+ base +"+" + make_endecaid+"&displayItem=true";
					window.location = newloc ;
				}else{
					//group listing page
					var newloc ="/"+makeName + "-" +  categoryURLDesc +"/"+ base +"-"+make_endecaid+"-" +catalog + ".htm"
					window.location = newloc ;
				}
		} else {
			document.getElementById("ref_yearDropDown").style.display = 'block';
			document.getElementById("ref_yearDropDown").innerHTML = modelHTML;
		}
		} 	catch (e)
	{
	}
		
	}
	function ref_make_selected(_base)
	{	
	try {
		//alert("Base is " + _base);
		base = _base;
		
		var _neval =  mmy$("ref_make_id").value;
		
		if(_neval == ""){
			mmy$('ref_yearDropDown').innerHTML = '<select id="year" disabled name="year" class="dropdown" style="width:120px;"><option value="">Select Year</option></select>';
			mmy$('ref_modelDropDown').innerHTML = '<select id="model" disabled name="model" class="dropdown" style="width:120px"><option value="">Select Model</option></select>';
			return;
		}
		if(_neval.indexOf('_') != -1){
			_neval = _neval.substring(0,_neval.indexOf('_'));
			var makeStringValue = mmy$("ref_make_id").value;
			makeName = makeStringValue.substring(makeStringValue.indexOf('_') + 1)
		}

		make_endecaid = _neval;

		//alert("Vehicle Dimention" + vehicle_dim );
		DynamicHTML.getRefModelsHTML(vehicle_dim, _neval, _base, search_term, 'groupListing', _neval, productId, itemId, store, setModelValues );
		ref_current = 'ref_modelDropDown';
		
		if(productId != "" || itemId != "")
		{
			//alert("Setting width" );
			mmy$('ref_yearDropDown').innerHTML = '<select id="year" style="width: 120px;" disabled name="year" class="dropdown"><option value="">Select Year</option></select>';
			mmy$('ref_modelDropDown').innerHTML = '<select id="model" style="width: 120px;" disabled name="model" class="dropdown"><option value="">Select Model</option></select>';
		}
		else
		{
			mmy$('ref_yearDropDown').innerHTML = '<select id="year" disabled name="year" class="dropdown" style="width:120px;"><option value="">Select Year</option></select>';
			mmy$('ref_modelDropDown').innerHTML = '<select id="model" disabled name="model" class="dropdown" style="width:120px"><option value="">Select Model</option></select>';
		}
	} 	catch (e)
	{
	}
	}
	
	function setYearCallBack(yearHTML ){
	try {
		//alert("Got years" + yearHTML);
		if(yearHTML.indexOf('yearisnull') > -1 ){//no year drop down
			if ((search_term == null || search_term == 'null'))
			{		if(base == null || base == 'null') {
						base = "";
					}
					if(productId != ""){
						document.getElementById("ref_yearDropDown").style.display = 'none';
						var newloc ="/"+makeName + "-" + modelName+ "-" +  productURLDesc + "/Product.htm?" + "catalogId=" + catalog + "&productId="+productId+"&N="+ base +"+" + model_nval;
						window.location = newloc ;
					}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;
					}else{
						var newloc = "/"+makeName + "-" + modelName+ "-" +  categoryURLDesc + "/"+ base+"-" + model_nval + "-" +catalog + ".htm"
						window.location = newloc ;
					}
			}			
		} else {//year exists..
			document.getElementById("ref_yearDropDown").innerHTML = yearHTML;
		}
	} 	catch (e)
	{
	}
	}
	
	function ref_model_selected(_base)
	{	
	try {
		//alert(" refmodel called " );
		if (bypass_year == true)
		{
			ref_year_selected(_base);
		}	
	
		base = _base;
		var extract_nval = mmy$("ref_model_id").value;
		
		if(extract_nval == ""){
			mmy$('ref_yearDropDown').innerHTML = '<select id="year" disabled name="year" class="dropdown" style="width:120px;"><option value="">Select Year</option></select>';
			return;
		}
		
		if(extract_nval.indexOf('_') != -1){
			extract_nval = extract_nval.substring(0,extract_nval.indexOf('_'));
			var modelStringValue = mmy$("ref_model_id").value;
			modelName = modelStringValue.substring(modelStringValue.indexOf('_') + 1)
		}
		model_nval = extract_nval;
		
		var _nval = extract_nval.substring(extract_nval.indexOf('_') + 1);
		
		DynamicHTML.getRefYearsHTML(_nval, '10602', _base, search_term, 'grouplisting' , productId, itemId, store, setYearCallBack);

		ref_current = 'ref_yearDropDown';
	} 	catch (e)
	{
	}

	}
	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
  */
  try {
  		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;
  	} 	catch (e)
	{
	}
  	}
  	
  	//Added by GCI  	
  	function setProductId(_productId){
	  	productId = _productId;
  	}
	
	function setItemId(_itemId){
	  	itemId = _itemId;
  	}	

	
	function ref_year_selected(_base)
	{		
	try {
		_base = replace(_base," ","+");
		var make_nval = "";
		
		var year_nval = "";
		
		var year = "";
		
		var makeId = "";
		var modelId = "";
		makeName = "";
		modelName = "";
		
		
		
		if (mmy$("ref_make_id") != null)
		{	
			make_nval = mmy$("ref_make_id").value;
			//alert("make_nval:"+make_nval);
			if(make_nval.indexOf('_') != -1){
				makeName = make_nval.substring(make_nval.indexOf('_') + 1)
				makeName = makeName + "-";
				make_nval = make_nval.substring(0,make_nval.indexOf('_'));
				//alert("Going to call MakeID:" + make_nval) ;
				//makeId = getMakeId(make_nval);
				//alert(" MakeId:" + makeId); 
			}
			_base = replace(_base,"+" + vehicle_dim,"");
	
		}
		
		if (mmy$("ref_model_id") != null)
		{
			model_nval = mmy$("ref_model_id").value;
			//alert("model_nval:" + model_nval);
			if(model_nval.indexOf('_') != -1){
				modelName = model_nval.substring(model_nval.indexOf('_') + 1)
				modelName = modelName + "-";
				model_nval = model_nval.substring(0,model_nval.indexOf('_'));
				//alert(" Model Nval:" + model_nval);
				if(mmy$("ref_make_id") != null){
					//modelId = getModelId(make_nval, model_nval);
				}
				
				
			}
			_base = replace(_base,"+" + vehicle_dim,"");

		}
		
		if (mmy$("ref_year_id") != null)
		{	
			year_nval = mmy$("ref_year_id").value;
			//alert("year_nval:"+ year_nval);
			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;
		}	
		
		base = _base;
		
		  //Added by GCI 
		if ((search_term == null || search_term == 'null') && (_base != null && _base != 'null'))
		{		
				if(model_nval == "" ){
					model_nval = make_nval;
				}				
				if(productId != ""){
					//var newloc ="/"+makeName+modelName+productURLDesc+" /Product.htm?" + "catalogId=" + catalog + "&productId="+productId+"&N="+getModifiedNParam(_base+"+" + model_nval + "+" + year_nval)+"&displayItem=true";
					var newloc ="/"+makeName+modelName+productURLDesc+" /Product.htm?" + "catalogId=" + catalog + "&productId="+productId+"&N="+_base+"+" + model_nval + "+" + year_nval+"&displayItem=true";
					window.location = newloc ;
				}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;
				}else{
					//var newloc ="/"+makeName+modelName+categoryURLDesc+ "/"+getModifiedNParam(_base+"-" + model_nval + "-" + year_nval +  "-" +catalog) + ".htm"
					var newloc ="/"+makeName+modelName+categoryURLDesc+ "/"+_base+"-" + model_nval + "-" + year_nval +  "-" +catalog + ".htm"
					window.location = newloc ;
				}
		}
		else if (_base == null || _base == 'null')
		{
				if(productId != ""){
				    
				    if(search_term == null || search_term == 'null')
				    {
				    	//Product Page URL For Featured Items
				    	if (model_nval == null || model_nval == "") {
				    		model_nval = make_nval;
				    	}
				    	//var newURL = "/"+makeName+modelName+productURLDesc+ "/Product.htm?" + "catalogId=" + catalog + "&productId="+productId+"&N=" + getModifiedNParam(model_nval + "+" + year_nval);
				    	var newURL = "/"+makeName+modelName+productURLDesc+ "/Product.htm?" + "catalogId=" + catalog + "&productId="+productId+"&N=" + model_nval + "+" + year_nval;
						window.location = newURL;
					} 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+'?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 item
						window.location = '/autoparts/ItemBrowse/showCustom-0/showAll-1/N-' + nval + '/refId-'+make_nval+'/c-'+catalog+'/tf-Browse/itemId-'+itemId+'/s-'+store;
					}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+'/Ntk-AllTextSearchGroup?Ntt=' + search_term;
					}
				}else{
						//Group Listing Page
						//window.location = '/Sears-Auto/AutoSearch-' + catalog +'.htm?Sku=' + search_term + '&N=' +getModifiedNParam(model_nval + ' '+year_nval);
						window.location = '/Sears-Auto/AutoSearch-' + catalog +'.htm?Sku=' + search_term + '&N=' +model_nval + ' '+year_nval;  
						//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+'?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+'/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;	
				}
		}
	} 	catch (e)
	{
	}
}
	function getModifiedNParam(ids){
		var brandId = "";
		var makeModelId = "";
		var year = "";
		var catId = "";
		while(ids.indexOf("+") > -1){
		ids = ids.replace(/\+/,"-");
		}
		var modArr = new Array();
		var newArr = new Array();
		var idsArr = ids.split("-");
		for(i = 0; i < idsArr.length; i++){
			var  tempTxt = idsArr[i];
			if(tempTxt.length == 9 && tempTxt.indexOf("2") != 0 && tempTxt.indexOf("7") != 0){
				catId = tempTxt;
			}else if(tempTxt.length > 7 && tempTxt.indexOf("2") == 0){
				makeModelId = tempTxt;
			}else if(tempTxt.length == 10 && tempTxt.indexOf("4") == 0){
				brandId = tempTxt;
			}else if(tempTxt.length == 4){
				year = tempTxt;
			}else{
				modArr[modArr.length] = tempTxt;
			}
		}
		var retTxt = "";
		if(brandId.length > 0){
			newArr[newArr.length] = brandId;
		}
		if(makeModelId.length > 0){
			newArr[newArr.length] = makeModelId;
		}
		if(year.length > 0){
			newArr[newArr.length] = year;
		}
		if(catId.length > 0){
			newArr[newArr.length] = catId;
		}
		return (newArr.concat(modArr)).join("-");
	}
	
	// makemodelyeartag.js
