// to get base_path
function get_base_pathH(){
	return document.getElementById('ajax_basepath').value;
}
function change_func_h(){
	_url = get_base_pathH();
	id = document.getElementById('catalogH0').value;
  if(id == 00){
		id = "TOP";
	}
	$.ajax({
		url: _url+"ajaxH.php?topid="+id,
		cache: false,
		success: function(html){
		$("#appendDivH1").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{
			$("#appendDivH1").append(html);
		}
		}
	})
}
function change_func_h0(){
	_url = get_base_pathH();
	tid = document.getElementById('catalogH1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	id 	= document.getElementById('catalogH0').value;
	if(id == 00){
		id = "TOP";
	}
	$.ajax({
		url: _url+"ajaxH.php?topid="+id+"&tid="+tid,
		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(){
	_url = get_base_pathH();
	tid = document.getElementById('catalogH1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	id 	= document.getElementById('catalogH2').value;
	if(id == 00){
		id = "YEAR";
	}
	topid 	= document.getElementById('catalogH0').value;
	if(topid == 00){
		topid = "TOP";
	}
	$.ajax({
		url: _url+"ajaxH.php?yid="+id+"&tid="+tid+"&topid="+topid,
		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(){
	_url = get_base_pathH();
	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;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	topid = document.getElementById('catalogH0').value;
  if(topid == 00){
		topid = "TOP";
	}
	$.ajax({
		url: _url+"ajaxH.php?mid="+id+"&yid="+yid+"&tid="+tid+"&topid="+topid,
		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(){
	_url = get_base_pathH();
	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;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	yid 	= document.getElementById('catalogH2').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid == 00){
		yid = "YEAR";
	}
	topid = document.getElementById('catalogH0').value;
  if(topid == 00){
		topid = "TOP";
	}

	$.ajax({
		url: _url+"ajaxH.php?msid="+id+"&yid="+yid+"&mid="+mid+"&tid="+tid+"&topid="+topid,
		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(){
	_url = get_base_pathH();
	tid 	= document.getElementById('catalogH1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	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;
	topid = document.getElementById('catalogH0').value;
  if(topid == 00){
		topid = "TOP";
	}
	
	if(topid && yid && mid && msid && tid && lid){
		$.ajax({
			url: _url+"ajaxH.php?tid="+tid+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&lid="+lid+"&topid="+topid,
			cache: false,
			success: function(html){
				location.href = _url+""+html;
			}
		})
	}
}
