function paivita_auto(){
	malli2(2);
}

function tyhjennaLomake(){

	//document.form1.arr.selectedIndex = 1;
	//document.form1.aikajakso.selectedIndex = 4;
	document.form1.arrtarkka.selectedIndex = 1;
	document.form1.aikajaksotarkka.selectedIndex = 4;

	if (document.form1.vm_alk.options[0].value == 0){
		document.form1.vm_alk.selectedIndex = 0;
	}else{
		document.form1.vm_alk.selectedIndex = 2;
	}
	if (document.form1.vm_lop.options[0].value == 2100){
		document.form1.vm_lop.selectedIndex = 0;
	}else{
		document.form1.vm_lop.selectedIndex = 2;
	}
	document.form1.Merkki.options[0]=new Option('Valitse','');
	document.form1.Merkki.selectedIndex=0;

	document.form1.Malli.options.length=0;

	if (document.form1.ml_alk.options[0].value == 0){
		document.form1.ml_alk.selectedIndex=0;
	}else{
		document.form1.ml_alk.selectedIndex=2;
	}

	if (document.form1.ml_lop.options[0].value == 90000){
		document.form1.ml_lop.selectedIndex=0;
	}else{
		document.form1.ml_lop.selectedIndex=2;
	}



	document.form1.h_alk.value='';
	document.form1.h_lop.value='';
	document.form1.maakunta.selectedIndex=0;
	document.form1.sijaintikooste.options.length=0;

	if (document.form1.korim.options[0].value == ''){
		document.form1.korim.selectedIndex=0;
	}else{
		document.form1.korim.selectedIndex=2;
	}

	if (document.form1.kvoima.options[0].value == ''){
		document.form1.kvoima.selectedIndex=0;
	}else{
		document.form1.kvoima.selectedIndex=2;
	}
	if (document.form1.vaihteisto.options[0].value == ''){
		document.form1.vaihteisto.selectedIndex=0;
	}else{
		document.form1.vaihteisto.selectedIndex=2;
	}
	if (document.form1.ovet.options[0].value == ''){
		document.form1.ovet.selectedIndex=0;
	}else{
		document.form1.ovet.selectedIndex=2;
	}

	if (document.form1.teho_alk.options[0].value == 0){
		document.form1.teho_alk.selectedIndex=0;
	}else{
		document.form1.teho_alk.selectedIndex=2;
	}

	if (document.form1.teho_lop.options[0].value == 9999){
		document.form1.teho_lop.selectedIndex=0;
	}else{
		document.form1.teho_lop.selectedIndex=2;
	}
	document.form1.vapaa.value='';
	document.form1.ilmastointi.checked = false;
	//document.form1.ilmastointi_lisa[0].checked = true;
	document.form1.ohjaustehostin.checked = false;
	document.form1.ABS_jarrut.checked = false;
	document.form1.keskuslukitus.checked = false;
	document.form1.airbag.checked = false;
	document.form1.istuinlämmittimet.checked = false;
	document.form1.sähkölasit.checked = false;
	document.form1.vetokoukku.checked = false;
	document.form1.lohkolämmitin.checked = false;
	document.form1.vakionopeudensäädin.checked = false;
	document.form1.ajotietokone.checked = false;
	document.form1.kattoluukku.checked = false;
	document.form1.sahkosaatistuimet.checked = false;
	document.form1.sähköpeilit.checked = false;
	document.form1.peruutustutka.checked = false;
	document.form1.luistonesto.checked = false;
	document.form1.nahkasisusta.checked = false;
	document.form1.xenon_valot.checked = false;
	document.form1.navigaattori.checked = false;
	document.form1.sadetunnistin.checked = false;
	document.form1.huoltokirja.checked = false;



}


function tyhjennaLomakeMp(){

	document.form2.arr.selectedIndex = 1;
	document.form2.aikajakso.selectedIndex = 4;

	if (document.form2.vm_alk.options[0].value == 0){
		document.form2.vm_alk.selectedIndex = 0;
	}else{
		document.form2.vm_alk.selectedIndex = 2;
	}
	if (document.form2.vm_lop.options[0].value == 2100){
		document.form2.vm_lop.selectedIndex = 0;
	}else{
		document.form2.vm_lop.selectedIndex = 2;
	}
	document.form2.Merkki.options[0]=new Option('Valitse','');
	document.form2.Merkki.selectedIndex=0;

	document.form2.mallitark.value='';

	if (document.form2.ml_alk.options[0].value == 0){
		document.form2.ml_alk.selectedIndex=0;
	}else{
		document.form2.ml_alk.selectedIndex=2;
	}

	if (document.form2.ml_lop.options[0].value == 90000){
		document.form2.ml_lop.selectedIndex=0;
	}else{
		document.form2.ml_lop.selectedIndex=2;
	}



	document.form2.h_alk.value='';
	document.form2.h_lop.value='';
	document.form2.maakunta.selectedIndex=0;
	document.form2.sijaintikooste.options.length=0;

}
function avaaiso(url,id)
{
window.open(url + '?id=' + id,'','toolbar=0,menubar=0,resizable,scrollbars=1,dependent=0,status=0,width=722,height=670,left=100,top=0');
this.creator=self;
}
function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object top position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	// Return top position
	return oTop
}

function getElementHeight(Elem) {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}

		xPos = elem.offsetHeight;

		return xPos;

}

var hei = 5;



function anihakulaaja(){
	tb = document.getElementById('hakulaaja');
	tb.style.visibility='visible';
	tbhei = getElementHeight('hakulaaja');
	hakulaajamoveisox();
}

function pikahaku(){
	tb = document.getElementById('hakulaaja');

	tbhei = getElementHeight('hakulaaja');
	naytapika1();
	hakulaajamovepienex();
}

function naytalaaja(){
	var vas = getAbsoluteLeft('hakutaulu1');
	var yla = getAbsoluteTop('hakutaulu1');
	var kork = getElementHeight('hakutaulu1');

	hakurivit2 = document.getElementById('tarkat');
	hakurivit2.style.left = vas - 5 + 'px';
	hakurivit2.style.top = yla + kork - 20 + 'px';
	hakurivit2.style.visibility='visible';

	hakurivit1 = document.getElementById('alkuphakunappi');
	hakurivit1.style.visibility='hidden';
}

function naytapika1(){
	hakurivit2 = document.getElementById('tarkat');
	//hakurivit2.style.left = vas - 5 + 'px';
	//hakurivit2.style.top = yla + kork - 20 + 'px';
	hakurivit2.style.visibility='hidden';
}

function naytapika2(){
	tb = document.getElementById('hakulaaja');
	tb.style.visibility='hidden';
	hakurivit1 = document.getElementById('alkuphakunappi');
	hakurivit1.style.visibility='visible';
}


function hakulaajamoveisox(){
	tbhei = getElementHeight('hakulaaja');
	tb.style.height = tbhei + 10 + 'px';
	hei = hei + 10;
	if (hei < 240){
		setTimeout('hakulaajamoveisox()',10);
		//hakulaajamove();
	}else{
		naytalaaja();
	}
}

function hakulaajamovepienex(){
	tbhei = getElementHeight('hakulaaja');
	tb.style.height = tbhei - 10 + 'px';
	hei = hei - 10;
	if (hei > 5){
		setTimeout('hakulaajamovepienex()',10);
		//hakulaajamove();
	}else{
		naytapika2();
	}
}

function vaihda_ajoneuvo(){

window.location = './' + form1.Ajon.value;

}

function avaa(url,id)
{
window.open(url + '?id=' + id,'','toolbar=0,menubar=0,resizable,scrollbars=1,dependent=0,status=0,width=530,height=600,left=100,top=0');
this.creator=self;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

