function setMakeLC(frm,sM){
	var c=frm.MakeLC;
	var aM = eval("MK.split(',')");
	var j = 0;
	c.options[0]= new Option('---- เลือกยี่ห้อ ----','0');
	if(sM=='0') c.options[0].selected=true;
	for (i=0; i < (aM.length/2); i++) {
		c.options[i+1]= new Option(aM[j+1],aM[j]);
		if(aM[j]==sM && aM[j+1]!=" ") c.options[i+1].selected=true;
		j += 2;
	}	
}	
function setModelLC(frm,MkID,sM) {
	var c=frm.ModelLC;
	while (c.options.length > 0) {
			c.options[(c.options.length - 1)] = null;	
	}
	c.options[0]= new Option('---- เลือกรุ่น ----','0');
	if(sM=='0' || sM=='') c.options[0].selected=true;

	if(MkID != "0" && (MkID.substring(0,1)!="z") && MkID !="") {
	var aM = eval("MD['"+ MkID +"'].split(',')");
	var j = 0;
		if(aM != null){
		for (var i=0; i < aM.length/2; i++) {
				c.options[i+1]= new Option(aM[j+1],aM[j]);
				if(aM[j]==sM&&aM[j]!="0") c.options[i+1].selected=true;
				j += 2;				
		}
		c.disabled = false;	
	}
}
else 
{
	c.options[0].selected = true;
	c.disabled = true;
}
}	

function schCarLC(){
    var s=document.mmSchLC;
    var fnm="TbRst3.aspx";
    var sQ='mk:'+s.MakeLC.options[s.MakeLC.selectedIndex].value;
    if(s.ModelLC.selectedIndex>0)
	    sQ+='+md:'+s.ModelLC.options[s.ModelLC.selectedIndex].value;
    
    location = "../Search/"+fnm+"#"+sQ;
}
function getParamLC(key){
		var hash=location.hash;
		if(!hash) return null;
		var _hash = hash.replace("#", "").toLowerCase();
		var qParts = _hash.split("+");
		if (qParts.length > 0) {
			for (var i = 0; i < qParts.length; i++) {
				if (qParts[i].split(':')[0] == key) {
					return qParts[i].split(':')[1];
				}
			}
		}
		return '0';
	}
var f=document.mmSchLC;
setMakeLC(f,getParamLC('mk'));
setModelLC(f,f.MakeLC.options[f.MakeLC.selectedIndex].value,getParamLC('md'));

