function old_popitup(url,name,muut) {
	var popup=window.open(url,name,muut);
	if (window.focus) {
        popup.focus();
    }
	return false;
}

function old_popUp(URL,muut,text) {
    day = new Date();
    id = day.getTime();
    var newwin="page" + id;
    eval("page" + id + " = window.open(URL, '" + id + "', muut);");
    if (window.focus) {
        id.focus();
        
    }
}

function popitup(URL,muut,text) {
    day = new Date();
    id = day.getTime();
    var header='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
    header+='<html xmlns="http://www.w3.org/1999/xhtml">\n';
    header+='<head>\n';
    header+='<meta http-equiv="Content-Language" content="fi" />\n';
    header+='<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />\n';
    header+='<title>Valoasunnot </title>\n';
    header+='<link rel="stylesheet" type="text/css" href="/style/waloasunnot.css">\n</head>\n';
    var body='<body>\n';
    body+='<table width="100%" border="0">\n';
    body+='<tr>\n<td>\n';
    body+='<p>'+text+'</p>\n';
    body+='</td>\n<td align="rigth">\n';
    body+='<p><a href="javascript:self.close()">sulje</a></p>\n';
    body+='</td>\n</tr>\n</table>\n';
    body+='<p><img src="'+URL+'" border="0"></p>\n';
    body+='</body>\n</html>\n';
    eval("newwin = window.open('', '" + id + "', muut);");
	var tmp = newwin.document;
	tmp.write(header + body);
	tmp.close();
}




function Avaa(tiedosto, ikkuna, muut)
{ 
	// Pop-up -ikkuna funktio, attribuutit:
	// tiedosto = tiedoston nimi ja mahd. polku
	// ikkuna = ikkunan nimi
	// muut :
	// toolbar = no tai yes (työkalupalkki)
	// location = no tai yes (Tiedoston nimi)
	// directories = no tai yes (hakemistot)
	// menubar = no tai yes (menuvalikko)
	// scrollbars = no, yes tai auto (vierityspalkit)
	// status = no tai yes (tilarivi)
	// resizable = 1 tai 0, (koko muutettavissa)
	// width = leveys pixeleinä tai prosentteina näytön koosta
	// height = korkeus pixeleinä tai prosentteina näytön koosta,
	// top = sijainti pixeleinä yläreunasta,	
	// left = sijainti pixeleinä vasemmasta reunasta
	//
	// eli kutsu esim (rivitetty lukemisen helpoittamiseksi). 
	// <a href="#" onClick="Avaa('test3.htm', 'ikkuna3', 'toolbar=yes,
	//			location=yes,directories=yes,menubar=yes,
	//			scrollbars=auto,status=yes,resizable=0,
	//			width=340,height=200,top=0,left=0')">test2</a> 
	//
	// Copyright Esa Hietala
	// Saa lainata jos siltä tuntuu.
	//
	popup = window.open(tiedosto, ikkuna, muut);  
	// popup.creator=top;
	// if ( popup.document.close() ) {
	// 	popup.document.close();
	// }
}


function testdisableEnterKey(e){
    var key = (window.event)? event.keyCode: e.which;
    return (key != 13);
}
function disableEnterKey(e)
{
    var key;
    if(window.event){
        key = window.event.keyCode;     //IE
    }
    else{
        key = e.which;     //firefox
    }
    if((key == 13)||(key==10)||(key==12)){
        return false;
    } 
    else{
        return true;
    }
}




// kuvan linkin vaihto -funktiot 
function findLinkByHref(href) {
    for (var i=0; i<document.links.length; i++) {
        if (document.links[i].href.indexOf(href)!=-1){
            return i; 
        }
    }
    return -1;
}
function changeLinkHref(id,newHref,oldHref) {
    if (document.links.length > 0) {
        if (document.getElementById) {
            document.getElementById(id).href = newHref;
        }
        else if (document.all) {
            document.all[id].href = newHref;
        }
        else {
            var index = findLinkByHref(oldHref);
            if (index > -1){
                document.links[index].href = newHref;
            }
        }
    }
}
