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_h(){
	
	id = document.getElementById('catalogH1').value;
	$.ajax({
		url: _url+"/ajaxH.php?tid="+id,
		cache: false,
		success: function(html){
		$("#appendDivH2").html('');
		$("#appendDivH3").html('');
		$("#appendDivH4").html('');
		$("#appendDivH5").html('');
		$("#appendDivH6").html('');
		$("#appendDivH7").html('');
		$("#appendDivH8").html('');
		$("#appendDivH2").append(html);
		}
	})
}
function change_func_h1(){
	tid = document.getElementById('catalogH1').value;
	id 	= document.getElementById('catalogH2').value;
	if(id == 00){
		id = "MAKE";
	}
	$.ajax({
		url: _url+"/ajaxH.php?mid="+id+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDivH3").html('');
			$("#appendDivH4").html('');
			$("#appendDivH5").html('');
			$("#appendDivH6").html('');
			$("#appendDivH7").html('');
			$("#appendDivH8").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{
				$("#appendDivH3").append(html);
			}
		}
	})
}

function change_func_h2(){
	id 	= document.getElementById('catalogH3').value;
	if(id == 00){
		id = "MODEL";
	}
	mid = document.getElementById('catalogH2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
	tid = document.getElementById('catalogH1').value;
	$.ajax({
		url: _url+"/ajaxH.php?msid="+id+"&mid="+mid+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDivH4").html('');
			$("#appendDivH5").html('');
			$("#appendDivH6").html('');
			$("#appendDivH7").html('');
			$("#appendDivH8").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{
				$("#appendDivH4").append(html);
			}
		}
	})
}

function change_func_h3(){
	id 		= document.getElementById('catalogH4').value;
	if(id == 00){
		id = "YEAR";
	}
	msid 	= document.getElementById('catalogH3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid == 00){
		msid = "MODEL";
	}
	tid 	= document.getElementById('catalogH1').value;
	mid 	= document.getElementById('catalogH2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}

	$.ajax({
		url: _url+"/ajaxH.php?yid="+id+"&mid="+mid+"&msid="+msid+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDivH5").html('');
			$("#appendDivH6").html('');
			$("#appendDivH7").html('');
			$("#appendDivH8").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{
				$("#appendDivH5").append(html);
			}
		
		}
	})
}


function change_func_h4(){
	tid 	= document.getElementById('catalogH1').value;
	mid 	= document.getElementById('catalogH2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid==0){
		mid = "MAKE";
	}
	msid 	= document.getElementById('catalogH3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid==0){
		msid = "MODEL";
	}
	yid	= document.getElementById('catalogH4').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid==0){
		yid = "YEAR";
	}
	lid		= document.getElementById('catalogH5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
	
	if(yid && mid && msid && tid && lid){
		$.ajax({
			//url: _url+"/ajaxH.php?tid="+id+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&eid="+eid,
			url: _url+"/ajaxH.php?tid="+tid+"&mid="+mid+"&yid="+yid+"&msid="+msid+"&lid="+lid,
			cache: false,
			success: function(html){
			$("#appendDivH6").html('');
			$("#appendDivH7").html('');
			$("#appendDivH8").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{
				$("#appendDivH6").append(html);
				}
			}
		})
	}
}

function change_func_h5(){
	tid 	= document.getElementById('catalogH1').value;
	mid 	= document.getElementById('catalogH2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid==0){
		mid = "MAKE";
	}
	msid 	= document.getElementById('catalogH3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid==0){
		msid = "MODEL";
	}
	yid	= document.getElementById('catalogH4').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid==0){
		yid = "YEAR";
	}
	lid	= document.getElementById('catalogH5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
    hpid		= document.getElementById('catalogH6').value;
	 if(!hpid) {
    	hpid = "HORSEPOWER";
    }
    if(hpid==0) {
    	hpid = "HORSEPOWER";
    }
	
	if(yid && mid && msid && lid && hpid && tid){
		$.ajax({
			//url: _url+"/ajaxH.php?tid="+id+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&eid="+eid,
			url: _url+"/ajaxH.php?tid="+tid+"&mid="+mid+"&yid="+yid+"&msid="+msid+"&lid="+lid+"&hpid="+hpid,
			cache: false,
			success: function(html){
			$("#appendDivH7").html('');
			$("#appendDivH8").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{
				$("#appendDivH7").append(html);
				}
			}
		})
	}
}


function change_func_h6(){
	tid 	= document.getElementById('catalogH1').value;
	mid 	= document.getElementById('catalogH2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid==0){
		mid = "MAKE";
	}
	msid 	= document.getElementById('catalogH3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid==0){
		msid = "MODEL";
	}
	yid	= document.getElementById('catalogH4').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid==0){
		yid = "YEAR";
	}
	lid	= document.getElementById('catalogH5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
	hpid		= document.getElementById('catalogH6').value;
    if(!hpid) {
    	hpid = "HORSEPOWER";
    }
    if(hpid==0) {
    	hpid = "HORSEPOWER";
    }
    transid		= document.getElementById('catalogH7').value;
   if(!transid) {
    	transid = "TRANSMISSION";
    }
    if(transid==0) {
    	transid = "TRANSMISSION";
    }
	if(yid && mid && msid && lid && hpid && transid && tid){
		$.ajax({
			//url: _url+"/ajaxH.php?tid="+id+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&eid="+eid,
			url: _url+"/ajaxH.php?tid="+tid+"&mid="+mid+"&yid="+yid+"&msid="+msid+"&lid="+lid+"&hpid="+hpid+"&transid="+transid,
			cache: false,
			success: function(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{
				$("#appendDivH8").append(html);
				}
			}
		})
	}
}


function change_func_h7(){
	tid 	= document.getElementById('catalogH1').value;
	mid 	= document.getElementById('catalogH2').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid==0){
		mid = "MAKE";
	}
	msid 	= document.getElementById('catalogH3').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid==0){
		msid = "MODEL";
	}
	yid	= document.getElementById('catalogH4').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid==0){
		yid = "YEAR";
	}
	lid	= document.getElementById('catalogH5').value;
	if(!lid){
		lid = "LITERS";
	}
	if(lid==0){
		lid = "LITERS";
	}
	
	hpid		= document.getElementById('catalogH6').value;
    if(!hpid) {
    	hpid = "HORSEPOWER";
    }
    if(hpid==0) {
    	hpid = "HORSEPOWER";
    }
    transid		= document.getElementById('catalogH7').value;
    
    if(!transid) {
    	transid = "TRANSMISSION";
    }
    if(transid==0) {
    	transid = "TRANSMISSION";
    }
  
    coresizeid		= document.getElementById('catalogH8').value;
    
	if(yid && mid && msid && lid && hpid && transid && coresizeid && tid){
		$.ajax({
			//url: _url+"/ajaxH.php?tid="+id+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&eid="+eid,
			url: _url+"/ajaxH.php?tid="+tid+"&mid="+mid+"&yid="+yid+"&msid="+msid+"&lid="+lid+"&hpid="+hpid+"&transid="+transid+"&coresizeid="+coresizeid,
			cache: false,
			success: function(html){
			location.href = _url+"/"+html;
			}
		})
	}
}
