var _url = "http://www.customaluminumradiator.com";
//var _url = "http://localhost/customalominium";

/*if (Drupal.jsEnabled) {
	$(document).ready(function(){
		alert('ff');
		$('#catalogH1').change(function(){
			id = document.getElementById('catalogH1').value;
			$.ajax({
				url: "http://74.208.106.104:82/store/ajaxH.php?yid="+id,
				cache: false,
				success: function(html){
				$("#appendDivH2").html('');
				$("#appendDivH3").html('');
				$("#appendDivH4").html('');
				$("#appendDivH5").html('');
				$("#appendDivH2").append(html);
				}
			})
			return false;
		});
	});
}*/
function change_func(){
	
	id = document.getElementById('catalog1').value;
	$.ajax({
		url: _url+"/ajax.php?tid="+id,
		cache: false,
		success: function(html){
		$("#appendDiv2").html('');
		$("#appendDiv3").html('');
		$("#appendDiv4").html('');
		$("#appendDiv5").html('');
        $("#appendDiv6").html('');
        $("#appendDiv7").html('');
        $("#appendDiv8").html('');
		$("#appendDiv2").append(html);
		}
	})
}
function change_func_1(){

	tid = document.getElementById('catalog1').value;
	id 	= document.getElementById('catalog2').value;
	if(id == 00){
		id = "MAKE";
	}
	$.ajax({
		url: _url+"/ajax.php?mid="+id+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDiv3").html('');
			$("#appendDiv4").html('');
			$("#appendDiv5").html('');
            $("#appendDiv6").html('');
            $("#appendDiv7").html('');
            $("#appendDiv8").html('');

			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				location.href = res;
			}
			else{
				$("#appendDiv3").append(html);
			}
		}
	})
}

function change_func_2(){
	id 	= document.getElementById('catalog3').value;
	if(id == 00){
		id = "MODEL";
	}
	mid = document.getElementById('catalog2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
	tid = document.getElementById('catalog1').value;

	$.ajax({
		url: _url+"/ajax.php?msid="+id+"&mid="+mid+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDiv4").html('');
			$("#appendDiv5").html('');
            $("#appendDiv6").html('');
            $("#appendDiv7").html('');
            $("#appendDiv8").html('');

			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				location.href = res;
			}
			else{
				$("#appendDiv4").append(html);
			}
		}
	})
}

function change_func_3(){
	id 		= document.getElementById('catalog4').value;
	if(id == 00){
		id = "YEAR";
	}
	msid 	= document.getElementById('catalog3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid == 00){
		msid = "MODEL";
	}
	tid 	= document.getElementById('catalog1').value;
	mid 	= document.getElementById('catalog2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}

	$.ajax({
		url: _url+"/ajax.php?yid="+id+"&mid="+mid+"&msid="+msid+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDiv5").html('');
            $("#appendDiv6").html('');
            $("#appendDiv7").html('');
            $("#appendDiv8").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				location.href = res;
			}
			else{
				$("#appendDiv5").append(html);
			}
		
		}
	})
}

function change_func_4(){
	id 		= document.getElementById('catalog4').value;
	if(id == 00){
		id = "YEAR";
	}
	msid 	= document.getElementById('catalog3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid == 00){
		msid = "MODEL";
	}
	tid 	= document.getElementById('catalog1').value;
	mid 	= document.getElementById('catalog2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
    lid		= document.getElementById('catalog5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}

	$.ajax({
		url: _url+"/ajax.php?yid="+id+"&mid="+mid+"&msid="+msid+"&tid="+tid+"&lid="+lid,
		cache: false,
		success: function(html){
			$("#appendDiv6").html('');
            $("#appendDiv7").html('');
            $("#appendDiv8").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				location.href = res;
			}
			else{
				$("#appendDiv6").append(html);
			}

		}
	})
}
function change_func_5(){
	id 		= document.getElementById('catalog4').value;
	if(id == 00){
		id = "YEAR";
	}
	msid 	= document.getElementById('catalog3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid == 00){
		msid = "MODEL";
	}
	tid 	= document.getElementById('catalog1').value;
	mid 	= document.getElementById('catalog2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
    lid	= document.getElementById('catalog5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
    hpid		= document.getElementById('catalog6').value;
	 if(!hpid) {
    	hpid = "HORSEPOWER";
    }
    if(hpid==0) {
    	hpid = "HORSEPOWER";
    }
	$.ajax({
		url: _url+"/ajax.php?yid="+id+"&mid="+mid+"&msid="+msid+"&tid="+tid+"&lid="+lid+"&hpid="+hpid,
		cache: false,
		success: function(html){
            $("#appendDiv7").html('');
            $("#appendDiv8").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				location.href = res;
			}
			else{
				$("#appendDiv7").append(html);
			}

		}
	})
}
function change_func_6(){
	id 		= document.getElementById('catalog4').value;
	if(id == 00){
		id = "YEAR";
	}
	msid 	= document.getElementById('catalog3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid == 00){
		msid = "MODEL";
	}
	tid 	= document.getElementById('catalog1').value;
	mid 	= document.getElementById('catalog2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
    lid	= document.getElementById('catalog5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
	hpid		= document.getElementById('catalog6').value;
    if(!hpid) {
    	hpid = "HORSEPOWER";
    }
    if(hpid==0) {
    	hpid = "HORSEPOWER";
    }
    transid		= document.getElementById('catalog7').value;
   if(!transid) {
    	transid = "TRANSMISSION";
    }
    if(transid==0) {
    	transid = "TRANSMISSION";
    }
	$.ajax({
		url: _url+"/ajax.php?yid="+id+"&mid="+mid+"&msid="+msid+"&tid="+tid+"&lid="+lid+"&hpid="+hpid+"&transid="+transid,
		cache: false,
		success: function(html){
			$("#appendDiv8").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				location.href = res;
			}
			else{
				$("#appendDiv8").append(html);
			}

		}
	})
}
function change_func_7(){
	tid 	= document.getElementById('catalog1').value;
	mid 	= document.getElementById('catalog2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid==0){
		mid = "MAKE";
	}
	msid 	= document.getElementById('catalog3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid==0){
		msid = "MODEL";
	}
	yid	= document.getElementById('catalog4').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid==0){
		yid = "YEAR";
	}
	lid	= document.getElementById('catalog5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
	hpid		= document.getElementById('catalog6').value;
    if(!hpid) {
    	hpid = "HORSEPOWER";
    }
    if(hpid==0) {
    	hpid = "HORSEPOWER";
    }
    transid		= document.getElementById('catalog7').value;
   if(!transid) {
    	transid = "TRANSMISSION";
    }
    if(transid==0) {
    	transid = "TRANSMISSION";
    }
  	coresizeid		= document.getElementById('catalog8').value;
	if(yid && mid && msid && tid && lid){
		$.ajax({
			//url: _url+"/ajaxH.php?tid="+id+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&eid="+eid,
			url: _url+"/ajax.php?tid="+tid+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&lid="+lid+"&hpid="+hpid+"&transid="+transid+"&coresizeid="+coresizeid,
			cache: false,
			success: function(html){
				location.href = _url+"/"+html;
			}
		})
	}
}
