var _url = "http://www.radiatorsrus.com";
//var _url = "http://74.208.132.35/";

//var _url = "http://localhost/store";
//var _url = document.getElementById('baseurl').value;
/*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('');
		
		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{
			$("#appendDivH2").append(html);
		}
		}
	})
}
function change_func_h1(){
	tid = document.getElementById('catalogH1').value;
	id 	= document.getElementById('catalogH2').value;
	if(id == 00){
		id = "YEAR";
	}
	$.ajax({
		url: _url+"/ajaxH.php?yid="+id+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDivH3").html('');
			$("#appendDivH4").html('');
			$("#appendDivH5").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 = "MAKE";
	}
	yid = document.getElementById('catalogH2').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid == 00){
		yid = "YEAR";
	}
	tid = document.getElementById('catalogH1').value;
	$.ajax({
		url: _url+"/ajaxH.php?mid="+id+"&yid="+yid+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDivH4").html('');
			$("#appendDivH5").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 = "MODEL";
	}
	mid 	= document.getElementById('catalogH3').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
	tid 	= document.getElementById('catalogH1').value;
	yid 	= document.getElementById('catalogH2').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid == 00){
		yid = "YEAR";
	}

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