function avaa_hakulomake() {
	window.opener.location = 'vsearch.asp?e=yes';
	window.close();
}

function openWin( windowURL, windowName, windowFeatures ) { 
	window.open( windowURL, windowName, windowFeatures ); 
	//return false;
} 

function sulje_ikkuna() {
   window.close();
}

function checkInput(cur) {
   if ((cur.vcompany.value == '') && (cur.vmake.value == '') && (cur.vmodel.value == '') && (cur.vtype.value == '') && (cur.vfuel.value == '') && (cur.vyear_min.value == '') && (cur.vyear_max.value == '') && (cur.vmileage_min.value == '') && (cur.vmileage_max.value == '') && (cur.vprice_min.value == '') && (cur.vprice_max.value == '')) {
      alert("Valitse vähintään yksi hakuehto, kiitos.");
      return false;
   }
   return true;
}

function checkUautotInput(cur) {
   if ((cur.tmake.value == '') && (cur.tmodel.value == '') && (cur.ttype.value == '') && ((cur.tvehicle_type.value == '') || (cur.tvehicle_type.value == '5')) && (cur.tbody_type.value == '') && (cur.ttransmission_type.value == '') && (cur.tfuel.value == '') && (cur.tmotor_vol_min.value == '') && (cur.tAccessories.value == '') && (cur.tmotor_vol_max.value == '') && (cur.tprice_min.value == '') && (cur.tprice_max.value == '') && (cur.tbenefit_min.value == '') && (cur.tbenefit_max.value == '')) {
      alert("Valitse vähintään yksi hakuehto, kiitos.");
      return false;
   }
   return true;
}

function lahetaliidi() {
		window.open('', 'liidi', 'directories=no,location=no,menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,width=450,height=650');
		document.liidilomake.submit();
}

function lahetarahoitus() {
		window.open('', 'rahoitus', 'directories=no,location=no,menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,width=670,height=500');
		document.rahoituslomake.submit();
}


function submit_form(toiminto) {
	window.open('', 'Ikkuna', 'directories=no,location=no,menubar=yes,toolbar=no,resizable=yes,scrollbars=yes,width=620,height=480');
	document.auto.action.value = toiminto;
	document.auto.submit();
}

function avaa_linkki(url,foc) {
	if (!window.opener.closed) {
		opener.location.href = url;
		if (!foc == "") {
			opener.window.focus();
		}
	}
}

var ikkuna = null;
function suljePopUp() {
	if(ikkuna != null && !ikkuna.closed)
	{
		ikkuna.close();
	}
}

function Vertailuun(urli,ikkuna_nimi,leveys,korkeus,scroll) {
	LeftPosition = (screen.width) ? (screen.width-leveys)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-korkeus)/2 : 0;
	asetukset = 'height='+korkeus+',width='+leveys+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable';
	suljePopUp();
	ikkuna = window.open(urli,ikkuna_nimi,asetukset)
}

function avaa_linkit(avattava){				
	document.getElementById(avattava).style.display = "block";
}

function sulje_linkit(suljettava){
	document.getElementById(suljettava).style.display = "none";
}		

function rivivari(bcol,d_name) {
	if (document.all) {
		var thestyle = eval ('document.all.' + d_name + '.style');
		thestyle.backgroundColor = bcol;
	}
}
  
function Tarkistalahetys(cur) {
	if (confirm("Nyt asettamasi asetukset kumoavat aiemmin asettamasi Vahtipalvelu-asetukset. Jos haluat jatkaa, paina OK.")) {
		return true
	}
	else {
		return false
	}
}

function Tarkista(cur) {
	if (cur.hakusana.value == "" || cur.hakusana.value == "Syötä hakusana...") {
		alert("Kirjoita vähintään yksi hakusana!")
		cur.hakusana.focus();
		cur.hakusana.select();
		return false
	}
}

function TyhjaaLomake(cur) {
	cur.value = "";
}

// karttakoodi
    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(0, -0), 13);
        geocoder = new GClientGeocoder();
        
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
      }
    }

function fitPic() {
	if (window.innerWidth){
		iWidth = window.innerWidth-15;
		iHeight = window.innerHeight-15;
	}else{
		iWidth = document.body.clientWidth-10;
		iHeight =document.body.clientHeight-20;
	}
	//alert(iWidth + "x" + iHeight)
	iWidth = document.images[0].width - iWidth;
	iHeight = document.images[0].height - iHeight;
	window.resizeBy(iWidth, iHeight);
}