var IE = document.all?true:false;


function iResize(obj,isize) {
	obj.width = isize;
}

function listGen(obj) {
	var n = obj.selectedIndex - 1;
	var gen = document.cform.cgen
	if (obj.selectedIndex>0) {
		gen.disabled = false;
		gen.options.length = 1;
		for (var i=0;i<cBrand[n].length;i++) {
				gen.options[i+1] = new Option(cBrand[n][i][1],cBrand[n][i][1]);
		}
	} else {
		gen.selectedIndex = 0;
		gen.disabled = true;
	}
}

function listGen2(obj,val) {
	var n = obj.selectedIndex - 1;
	var gen = document.cform.cgen
	if (obj.selectedIndex>0) {
		gen.disabled = false;
		gen.options.length = 1;
		for (var i=0;i<cBrand[n].length;i++) {
			if (cBrand[n][i][1]==val)
				gen.options[i+1] = new Option(cBrand[n][i][1],cBrand[n][i][1],true,true);
			else
				gen.options[i+1] = new Option(cBrand[n][i][1],cBrand[n][i][1]);
		}
	} else {
		gen.selectedIndex = 0;
		gen.disabled = true;
	}
}

function showLogin() {
	document.getElementById('hlink').style.display = 'none';
	document.getElementById('hlogin').style.display = 'block';
	document.flogin.uname.focus();
}

function doLogin() {
	if (document.flogin.uname.value=="")
	{
		alert("¡ÃØ³Ò¡ÃÍ¡ª×èÍ¼Ùéãªé´éÇÂ¤èÐ");
		document.flogin.uname.focus();
		return false;
	}
	else if (document.flogin.upass.value=="")
	{
		alert("¡ÃØ³Ò¡ÃÍ¡ÃËÑÊ¼èÒ¹´éÇÂ¤èÐ");
		document.flogin.upass.focus();
		return false;
	}
	document.flogin.login.value=1;
	document.flogin.submit();
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.,";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function doSearch() {
	document.cform.search.value=1;
	document.cform.submit();
}

function popupPic(id) {
	window.open('/car_pic.php?id='+id,'car','top=20,left=100,height=600,width=800,scrollbars=yes,location=no,status=no,resizable=yes');
}

function confirmLink(theLink, theSqlQuery)
{
    var is_confirmed = confirm('¤Ø³á¹èã¨ËÃ×ÍäÁè·Õè¨Ð ' + ' :\n' + theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&confirmed=1';
    }

    return is_confirmed;
}

function numberOnly(f) {
	if (!IsNumeric(f.value)) {
		f.value = f.value.substring(0,f.value.length-1);
	}
}

function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
} // end of the 'setPointer()' function

function doChkFlg() {
	document.cformr.chkflg.value=99;
}

function showcar(c) {
	if (c=="toyota") {
		document.getElementById("car_toyota").style.display = "block";
		document.getElementById("car_honda").style.display = "none";
		document.getElementById("car_isuzu").style.display = "none";
		document.getElementById("car_mazda").style.display = "none";
		document.getElementById("car_mitsubishi").style.display = "none";
	} else	if (c=="honda") {
		document.getElementById("car_toyota").style.display = "none";
		document.getElementById("car_honda").style.display = "block";
		document.getElementById("car_isuzu").style.display = "none";
		document.getElementById("car_mazda").style.display = "none";
		document.getElementById("car_mitsubishi").style.display = "none";
	} else	if (c=="isuzu") {
		document.getElementById("car_toyota").style.display = "none";
		document.getElementById("car_honda").style.display = "none";
		document.getElementById("car_isuzu").style.display = "block";
		document.getElementById("car_mazda").style.display = "none";
		document.getElementById("car_mitsubishi").style.display = "none";
	} else	if (c=="mazda") {
		document.getElementById("car_toyota").style.display = "none";
		document.getElementById("car_honda").style.display = "none";
		document.getElementById("car_isuzu").style.display = "none";
		document.getElementById("car_mazda").style.display = "block";
		document.getElementById("car_mitsubishi").style.display = "none";
	} else	if (c=="mitsubishi") {
		document.getElementById("car_toyota").style.display = "none";
		document.getElementById("car_honda").style.display = "none";
		document.getElementById("car_isuzu").style.display = "none";
		document.getElementById("car_mazda").style.display = "none";
		document.getElementById("car_mitsubishi").style.display = "block";
	}
}

function randomCar(t) {
	if (t<10)
		showcar('toyota');
	else if (t<20)
		showcar('honda');
	else if (t<30)
		showcar('isuzu');
	else if (t<40)
		showcar('mazda');
	else if (t<50)
		showcar('mitsubishi');
}
