function clear_links ()
{
$("a[href*='&RefineBy']")
.each(function()
{
var str_href = this.href;
var vyear= getCookie("cboYear");
var vmake= getCookie("cboMake");
var vmodel= getCookie("cboModel");
var vsubmodel= getCookie("cboModel");
if ( str_href.indexOf('SearchResults') > 0 )
{
//var temp="&searching=Y&f-year=" + vyear + "&f-make="+ vmake +"&f-model=" + vmodel + "&f-submodel=" + vsubmodel;
//var temp="&searching=Y&f-year=" + vyear + "&f-submodel=" + vsubmodel;
var temp="SearchResults.asp?"+location.search;
}
this.href = this.href.replace(temp, "");
});
if(document.URL.indexOf('SearchResults') > 0)
{
var temp="SearchResults.asp?"+location.search;
document.URL = document.URL.replace(temp, "");
}
}
function change_links (vyear,vmake,vmodel,vsubmodel)
{
$("a[href*='-s/']")
.each(function()
{
var str_href = this.href;
if((vyear!=null && vyear!="") && (vmake!=null && vmake!="") && (vmodel!=null && vmodel!="")&& (vsubmodel!=null && vsubmodel!=""))
{
var regEx = /\/(\d+)\.htm/; var nameNumber = str_href.match(regEx)[1];
this.href="https://automotiveinteriors.com/SearchResults.asp?cat=6646&f-year=" + vsubmodel;
/*if ( str_href.indexOf('?') == -1 )
{
//this.href=str_href + "?searching=Y&f-year=" + vyear + "&f-make="+ vmake +"&f-model=" + vmodel + "&f-submodel=" + vsubmodel;
//this.href=str_href + "?searching=Y&f-year=" + vyear + "&f-submodel=" + vsubmodel;
this.href=str_href + "?searching=Y&cat=6646&f-year=" + vsubmodel;
}
else
{
//this.href = str_href + "&searching=Y&f-year=" + vyear + "&f-make="+ vmake +"&f-model=" + vmodel + "&f-submodel=" + vsubmodel;
//this.href = str_href + "&searching=Y&f-year=" + vyear + "&f-submodel=" + vsubmodel;
this.href = str_href + "&searching=Y&cat=6646&f-year=" + vsubmodel;
}*/
}
});
var str_href= window.location.href;
if(str_href.indexOf('search=') != -1 && str_href.indexOf('RefineBy_submodel=') == -1)
{
var regEx = /\/(\d+)\.htm/;
window.location = window.location+"&RefineBy_submodel=" + vsubmodel ;
}
}
//START COOKIE
function del_cookie(name)
{
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; //domain=.automotiveinteriors.com; path=/';
}
function ClearAllcookie()
{
clear_links();
del_cookie("cboYear");
del_cookie("cboMake");
del_cookie("cboModel");
del_cookie("cboSubModel");
del_cookie("cboYear_text");
del_cookie("cboMake_text");
del_cookie("cboModel_text");
del_cookie("cboSubModel_text");
load_year();
window.location.href=document.URL;
}
function saveCookie()
{
if ( ($("#cboYear").val() != "-1") && ($("#cboMake").val() != "-1") && ($("#cboModel").val() != "-1") )
{
setCookie("cboYear",$("#cboYear").val(),1);
setCookie("cboMake",$("#cboMake").val(),1);
setCookie("cboModel",$("#cboModel").val(),1);
setCookie("cboSubModel",$("#cboModel").val(),1);
setCookie("cboYear_text", $("#cboYear").find("option:selected").text(),1);
setCookie("cboMake_text", $("#cboMake").find("option:selected").text(),1);
setCookie("cboModel_text",$("#cboModel").find("option:selected").text(),1);
setCookie("cboSubModel_text",$("#cboModel").find("option:selected").text(),1);
}
else
{
del_cookie("cboYear");
del_cookie("cboMake");
del_cookie("cboModel");
del_cookie("cboSubModel");
del_cookie("cboYear_text");
del_cookie("cboMake_text");
del_cookie("cboModel_text");
del_cookie("cboSubModel_text");
}
}
function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i
Year :" + getCookie("cboYear_text") + "
Make:" + getCookie("cboMake_text") + "
Model:" + getCookie("cboModel_text") ;
$('form[name="SearchBoxForm"]').append(' ');
document.getElementById('tblCombo').style.display = 'none';
document.getElementById('cookieContent').style.display = '';
document.getElementById('btnClear').style.display = '';
change_links(vyear,vmake,vmodel,vsubmodel);
return true;
}
else
{
return false;
}
}
function HideCookieNelement()
{
$("#f-year").remove();
$("#f-make").remove();
$("#f-model").remove();
$("#f-submodel").remove();
document.getElementById('tblCombo').style.display = '';
document.getElementById('cookieContent').style.display = 'none';
document.getElementById('btnClear').style.display = 'none';
}
//END COOOKIE
function load_year(){
if(CheckCookie())
{
return;
}
else
{
HideCookieNelement()
$("#cboYear").attr("disabled", true);
$("#cboMake").attr("disabled", true);
$("#cboModel").attr("disabled", true);
$("#cboSubModel").attr("disabled", true);
$.getJSON("v/vspfiles/model_selector/6646/select.asp",{dd:1, "id":"0"}, function(j){
//$.getJSON("select.asp",{dd:1, "id":"0"}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '';
}
$("#cboYear").attr("disabled", false);
$("#cboYear").html(options);
$('#cboYear option:first').attr('selected', 'selected');
$('#cboMake option:gt(0)').remove();
$("#cboMake").attr("disabled", true);
$('#cboModel option:gt(0)').remove();
$("#cboModel").attr("disabled", true);
$('#cboSubModel option:gt(0)').remove();
$("#cboSubModel").attr("disabled", true);
})
}
};
$(function(){
$("select#cboYear").change(function(){
$("#cboMake").attr("disabled", true);
$("#cboModel").attr("disabled", true);
$("#cboSubModel").attr("disabled", true);
$.getJSON("v/vspfiles/model_selector/6646/select.asp",{dd:"2",year:$("#cboYear").val(), id: $(this).val(), label: $(this).find("option:selected").text()}, function(j){
//$.getJSON("select.asp",{dd:"2", id: $(this).val(), label: $(this).find("option:selected").text()}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '';
}
$("#cboMake").attr("disabled", false);
$("#cboMake").html(options);
$('#cboMake option:first').attr('selected', 'selected');
$('#cboModel option:gt(0)').remove();
$("#cboModel").attr("disabled", true);
$('#cboSubModel option:gt(0)').remove();
$("#cboSubModel").attr("disabled", true);
})
if ( $(this).val() == "-1" )
{
$('#cboMake option:gt(0)').remove();
$("#cboMake").attr("disabled", true);
$('#cboModel option:gt(0)').remove();
$("#cboModel").attr("disabled", true);
$('#cboSubModel option:gt(0)').remove();
$("#cboSubModel").attr("disabled", true);
}
saveCookie();
});
$("select#cboMake").change(function(){
$("#cboModel").attr("disabled", true);
$("#cboSubModel").attr("disabled", true);
$.getJSON("v/vspfiles/model_selector/6646/select.asp",{dd:"3", id: $(this).val(), label: $(this).find("option:selected").text()}, function(j){
//$.getJSON("select.asp",{dd:"3", id: $(this).val(), label: $(this).find("option:selected").text()}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '';
}
$("#cboModel").attr("disabled", false);
$("#cboModel").html(options);
$('#cboModel option:first').attr('selected', 'selected');
$('#cboSubModel option:gt(0)').remove();
$("#cboSubModel").attr("disabled", true);
})
if ( $(this).val() == "-1" )
{
$('#cboModel option:gt(0)').remove();
$("#cboModel").attr("disabled", true);
}
saveCookie();
});
$("select#cboModel").change(function(){
$("#cboSubModel").attr("disabled", true);
$.getJSON("v/vspfiles/model_selector/6646/select.asp",{dd:"4", id: $(this).val(), label: $(this).find("option:selected").text()}, function(j){
//$.getJSON("select.asp",{dd:"4", id: $(this).val(), label: $(this).find("option:selected").text()}, function(j){
var options = '';
for (var i = 0; i < j.length; i++) {
options += '';
}
$("#cboSubModel").attr("disabled", false);
$("#cboSubModel").html(options);
$('#cboSubModel option:first').attr('selected', 'selected');
})
if ( $(this).val() == "-1" )
{
$('#cboSubModel option:gt(0)').remove();
$("#cboSubModel").attr("disabled", true);
}
saveCookie();
CheckCookie();
changeURL();
});
$("select#cboSubModel").change(function(){
saveCookie();
CheckCookie();
changeURL();
});
})
function changeURL()
{
var vsubmodel= getCookie("cboModel");
var vsubmodel_text =getCookie("cboModel_text");
var tempurl = location.toString().replace(location.search, "");
var tempurl1 = location.toString().replace(location.search, "");
var s="-s/";
if(tempurl.indexOf(s) == -1)
{
//tempurl=document.URL+"?searching=Y&f-year=" + vyear +"&f-submodel=" + vsubmodel;
window.location="https://automotiveinteriors.com/Category-s/6646.htm?Searching=Y&f-"+vsubmodel_text+"=" + vsubmodel;
}
if(tempurl.indexOf(s) != -1)
{
if (document.getElementById("hdnIsSubModel")!=null)
{
str_href=document.URL;
var regEx = /\/(\d+)\.htm/; var nameNumber = str_href.match(regEx)[1];
window.location="https://automotiveinteriors.com/Category-s/6646.htm?Searching=Y&f-"+vsubmodel_text+"=" + vsubmodel;
//tempurl="https://automotiveinteriors.com/SubModel-s/" + vsubmodel + ".htm";
//window.location=tempurl;
return;
}
else
{
var vyear= getCookie("cboYear");
var vmake= getCookie("cboMake");
var vmodel= getCookie("cboModel");
var vsubmodel= getCookie("cboModel");
var str_href=document.URL;
var regEx = /\/(\d+)\.htm/; var nameNumber = str_href.match(regEx)[1];
window.location="https://automotiveinteriors.com/Category-s/6646.htm?Searching=Y&f-"+vsubmodel_text+"=" + vsubmodel;
//tempurl1=tempurl1+"?searching=Y&f-year=" + vyear + "&f-make="+ vmake +"&f-model=" + vmodel +"&f-submodel=" + vsubmodel;
//tempurl1=tempurl1+"?searching=Y&f-year=" + vyear +"&f-submodel=" + vsubmodel;
//tempurl1=tempurl1+"?searching=Y&f-submodel=" + vsubmodel;
//window.location=tempurl1;
}
}
}
function SearchInfo()
{
var test=document.forms["MainForm"];
if (test==undefined)
{
//$('form[name="SearchBoxForm"]').append('