// JavaScript Document - lovekyn menu functions

function srch() {
	df=document.form;
	df.action="/used/used.php";
	df.submit();
}

function book(){
	df=document.form;
	df.action="/used/book.php";
	df.submit();
}

var targetheight;
currentheight=0;
step=20;
delay=10;

function high(el) {el.style.backgroundImage='url(/images/b_hi.gif)';}
function low(el) {el.style.backgroundImage='';}

function showmenu() {
	got("list",currentheight<1);
	targetheight=178;
	mover();
}

function hidemenu() {
	targetheight=0;
	mover();
}

function mover() {
	flg=false;
	if (currentheight<targetheight) {
		currentheight+=step;
		if (currentheight>=targetheight) currentheight=targetheight;
		if (currentheight<targetheight) flg=true;
	}
	else if (targetheight<currentheight) {
		currentheight-=step;
		if (currentheight<=targetheight) currentheight=targetheight;
		if (currentheight>targetheight) flg=true;
	}
	document.getElementById("extramenu").style.height=currentheight.toString()+'px';
	if (flg) window.setTimeout("mover()",delay);
}

w_step=20;
w_height=170;
w_delay=10;
var w_obj,w_tgt;

function gettyp(t){
	switch (t) {
		case 0:tt="list";break;
		case 1:tt="com";break;
		case 2:tt="mid";break;
		case 3:tt="mpv";break;
		case 4:tt="suv";break;
	}
	return tt;
}

function wipeout(ob) {
	w_tgt=ob;
	wobj="";
	for (i=0;i<5;i++){
		lay=document.getElementById("ex_"+gettyp(i));
		if (!lay.style.width) ix=lay;
	}
	w_obj=ix;
	if (w_obj!=w_tgt) window.setTimeout("wo("+w_height+")",w_delay);
}

function wo(w_v){
	w_v-=w_step;
	if (w_v<1) w_v=0;
	w_obj.style.height=w_v.toString()+'px';
	if (w_v>0) {window.setTimeout("wo("+w_v+")",w_delay);}
	else {
		w_obj.style.width="0px";
		w_tgt.style.width="";
		wi(0);
	}
}

function wi(w_v){
	w_v+=w_step;
	if (w_v>w_height-1) w_v=w_height;
	w_tgt.style.height=w_v.toString()+'px';
	if (w_v<w_height) {window.setTimeout("wi("+w_v+")",w_delay);}
}

function chkmenu(ev){
	if (!ev) ev=window.event;
	toele=ev.relatedTarget || ev.toElement;
	if (toele) {
		if (toele.id.substr(0,2)!="ex") {
			hidemenu();
		}
	}
}

function got(typ,q) {
	for (i=0;i<5;i++){
		thistyp=gettyp(i);
		lay=document.getElementById("ex_"+thistyp);
		if (q) {if (thistyp==typ) {lay.style.width='';lay.style.height='';} else {lay.style.width='0';lay.style.height='0';}}
		else if (thistyp==typ) wipeout(lay);
	}
}

function getobj() {
	ix="";
	for (i=0;i<5;i++){
		thistyp=gettyp(i);
		lay=document.getElementById("ex_"+thistyp);
		if (!lay.style.width) ix=thistyp;
	}
	return ("ex_"+ix);
}

