function avaa_hakulomake() {
	window.opener.location = 'vsearch.asp?e=yes';
	window.close();
}

function openWin( windowURL, windowName, windowFeatures ) { 
		return window.open( windowURL, windowName, windowFeatures ) ; 
} 

function sulje_ikkuna() {
   window.close();
}

function CheckIsIE() { 
	if (navigator.appName.toUpperCase() == 'MICROSOFT INTERNET EXPLORER') { return true;} 
		else { return false; } 
}

function PrintThisPage() { 
	if (CheckIsIE() == true) { 
		document.googlekartta.focus(); 
		document.googlekartta.print(); 
	} 
	else { 
		window.frames['googlekartta'].focus(); 
		window.frames['googlekartta'].print(); 
	} 
} 

function zPrint(oTgt) {
	oTgt.focus();
	oTgt.print();
}

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 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 = "";
}


/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//JavaScript menu
var menu_helsinki = new Array()
menu_helsinki["0"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=1308" class="valkoinen">Herttoniemi</a><br>'
menu_helsinki["1"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=2278" class="valkoinen">Pitäjänmäki</a><br>'

var menu_tampere = new Array()
menu_tampere["0"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=1311" class="valkoinen">Lielahti</a><br>'
menu_tampere["1"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=2279" class="valkoinen">Hatanpää</a><br>'

var menu_espoo = new Array()
menu_espoo["0"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=1309" class="valkoinen">Olari</a><br>'
menu_espoo["1"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=2102" class="valkoinen">Lommila</a><br>'

var menu_vaurio = new Array()
menu_vaurio["0"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=2190" class="valkoinen">Espoo</a><br>'
menu_vaurio["1"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=2137" class="valkoinen">Helsinki</a><br>'
menu_vaurio["2"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=1313" class="valkoinen">Oulu</a><br>'
menu_vaurio["3"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=1311" class="valkoinen">Tampere</a><br>'
menu_vaurio["4"]='&nbsp;&nbsp;&nbsp;&nbsp;<a href="yhteydenotto_info_entry.asp?yid=1312" class="valkoinen">Turku</a><br>'

var menuwidth='120px' //default menu width
var menuwidth_hertto='360px' //Herttoniemessä leveämpi

//var menubgcolor='#192D7F'  //menu bgcolor
var menubgcolor='#293D8C'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu


/***********************************************
* Leijuva header-palkki
***********************************************/

function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
}

function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}

function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}	

function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}

function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

/***********************************************
* Leijuva koeajo-lomake
***********************************************/

function setVisible(){
    var myElement = document.getElementById("mini_varaakoeajo");
    if (myElement == null) {
    	var myElement = document.getElementById("mini_varaakoeajo_nayta");
    }
    myElement.style.visibility = "visible";
    document['koeajo'].src = "giffit/navi_koeajo_on.gif";
}

function hide(){
    var myElement = document.getElementById("mini_varaakoeajo");
    if (myElement == null) {
    	var myElement = document.getElementById("mini_varaakoeajo_nayta");
    }
    myElement.style.visibility = "hidden";
    document['koeajo'].src = "giffit/navi_koeajo_off.gif";
}