// to get base_path
function get_base_path(){
	return document.getElementById('ajax_basepath').value;
}
function change_func(){
	_url = get_base_path();
	id = document.getElementById('catalog0').value;
	if(id == 00){
		id = "TOP";
	}
	$.ajax({
		url: _url+"ajax.php?topid="+id,
		cache: false,
		success: function(html){
			$("#appendDiv1").html('');
			$("#appendDiv2").html('');
			$("#appendDiv3").html('');
			$("#appendDiv4").html('');
			$("#appendDiv5").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				goto_page(res);
			}
			else{
				$("#appendDiv1").append(html);
			}
		}
	})
}
function change_func_0(){
	_url = get_base_path();
	tid = document.getElementById('catalog1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	topid 	= document.getElementById('catalog0').value;
	if(topid == 00){
		topid = "TOP";
	}
	$.ajax({
		url: _url+"ajax.php?topid="+topid+"&tid="+tid,
		cache: false,
		success: function(html){
			$("#appendDiv2").html('');
			$("#appendDiv3").html('');
			$("#appendDiv4").html('');
			$("#appendDiv5").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				goto_page(res);
			}
			else{
				$("#appendDiv2").append(html);
			}
		}
	})
}
function change_func_1(){
	_url = get_base_path();
	tid = document.getElementById('catalog1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	id 	= document.getElementById('catalog2').value;
	if(id == 00){
		id = "YEAR";
	}
	topid 	= document.getElementById('catalog0').value;
	if(topid == 00){
		topid = "TOP";
	}
	$.ajax({
		url: _url+"ajax.php?yid="+id+"&tid="+tid+"&topid="+topid,
		cache: false,
		success: function(html){
			$("#appendDiv3").html('');
			$("#appendDiv4").html('');
			$("#appendDiv5").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				goto_page(res);
			}
			else{
				$("#appendDiv3").append(html);
			}
		}
	})
}
function change_func_2(){
	_url = get_base_path();
	id 	= document.getElementById('catalog3').value;
	if(id == 00){
		id = "MAKE";
	}
	yid = document.getElementById('catalog2').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid == 00){
		yid = "YEAR";
	}
	tid = document.getElementById('catalog1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	topid 	= document.getElementById('catalog0').value;
	if(topid == 00){
		topid = "TOP";
	}
	$.ajax({
		url: _url+"ajax.php?mid="+id+"&yid="+yid+"&tid="+tid+"&topid="+topid,
		cache: false,
		success: function(html){
			$("#appendDiv4").html('');
			$("#appendDiv5").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				goto_page(res);
			}
			else{
				$("#appendDiv4").append(html);
			}
		}
	})
}
function change_func_3(){
	_url = get_base_path();
	id 		= document.getElementById('catalog4').value;
	if(id == 00){
		id = "MODEL";
	}
	mid 	= document.getElementById('catalog3').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid == 00){
		mid = "MAKE";
	}
	tid 	= document.getElementById('catalog1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	yid 	= document.getElementById('catalog2').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid == 00){
		yid = "YEAR";
	}
	topid 	= document.getElementById('catalog0').value;
	if(topid == 00){
		topid = "TOP";
	}
	$.ajax({
		url: _url+"ajax.php?msid="+id+"&yid="+yid+"&mid="+mid+"&tid="+tid+"&topid="+topid,
		cache: false,
		success: function(html){
			$("#appendDiv5").html('');
			is_not_liter = html.indexOf("LITERSNOTINAUTO");
			if(is_not_liter > 0){
				select_index = html.indexOf("</select>");
				res = html.substring(select_index+9);
				goto_page(res);
			}
			else{
				$("#appendDiv5").append(html);
			}
		}
	})
}
function change_func_4(){
	_url = get_base_path();
	tid 	= document.getElementById('catalog1').value;
  if(tid == 00){
		tid = "PARTTYPE";
	}
	yid 	= document.getElementById('catalog2').value;
	if(!yid){
		yid = "YEAR";
	}
	if(yid==0){
		yid = "YEAR";
	}
	mid 	= document.getElementById('catalog3').value;
	if(!mid){
		mid = "MAKE";
	}
	if(mid==0){
		mid = "MAKE";
	}
	msid	= document.getElementById('catalog4').value;
	if(!msid){
		msid = "MODEL";
	}
	if(msid==0){
		msid = "MODEL";
	}
	lid		= document.getElementById('catalog5').value;
	topid 	= document.getElementById('catalog0').value;
	if(topid == 00){
		topid = "TOP";
	}
	if(yid && mid && msid && tid && lid){
		$.ajax({
			url: _url+"ajax.php?tid="+tid+"&yid="+yid+"&mid="+mid+"&msid="+msid+"&lid="+lid+"&topid="+topid,
			cache: false,
			success: function(html){
			html.replace(/&/,"%2526");
				//location.href = _url+""+html;
				goto_page(html);
			}
		})
	}
}
/*
* function to redirect
*/
function goto_page(res){
	window.location = trim(res);
}
