// Alustetaan muuttujat.
var FooterHeightOsoite = ''
var FooterHeightLinkit = ''
var isNS4
var isIE4
var isIE5
var isNS6

// Tarkistetaan selain.
isNS4 = (document.layers) ? true : false;
isNS6 = (!document.all && document.getElementById) ? true : false;
isIE4 = (document.all && !document.getElementById) ? true : false;
isIE5 = (document.all && document.getElementById) ? true : false;

function initialize(){
// Etsitään <span> -tagit; StaticFooterLinkit ja StaticFooterOsoite.
// Tarkistetaan niiden korkeus ja selainikkunan korkeus ja aktivoidaan oikea staticit_** -funktio.

	if (isIE4 || isIE5){
		FooterHeightLinkit = StaticFooterLinkit.offsetHeight
		FooterHeightOsoite = StaticFooterOsoite.offsetHeight

		setInterval("staticit_ie()",10)
		StaticFooterLinkit.style.visibility = "visible"
		StaticFooterOsoite.style.visibility = "visible"

	}
	else if (isNS4){
		FooterHeightLinkit = document.StaticFooterLinkit.document.height
		FooterHeightOsoite = document.StaticFooterOsoite.document.height
		
		setInterval("staticit_ns()",10)
		document.StaticFooterLinkit.visibility = "show"
		document.StaticFooterOsoite.visibility = "show"

	}
	else if (isNS6){		
		FooterHeightLinkit = document.getElementById("StaticFooterLinkit").offsetHeight;
		FooterHeightOsoite = document.getElementById("StaticFooterOsoite").offsetHeight;

		setInterval("staticit_ns6()",10)
		document.getElementById("StaticFooterLinkit").style.visibility = "visible"
		document.getElementById("StaticFooterOsoite").style.visibility = "visible"

	}
}

function staticit_ie(){
	StaticFooterLinkit.style.pixelTop = document.body.scrollTop + document.body.clientHeight - FooterHeightLinkit;
	StaticFooterOsoite.style.pixelTop = document.body.scrollTop + document.body.clientHeight - FooterHeightLinkit - FooterHeightOsoite;
}

function staticit_ns(){
	document.StaticFooterLinkit.top = pageYOffset + window.innerHeight - FooterHeightLinkit
	document.StaticFooterOsoite.top = pageYOffset + window.innerHeight - FooterHeightLinkit - FooterHeightOsoite
}

function staticit_ns6(){
	document.getElementById("StaticFooterLinkit").style.top = pageYOffset + window.innerHeight - FooterHeightLinkit
	document.getElementById("StaticFooterOsoite").style.top = pageYOffset + window.innerHeight - FooterHeightLinkit - FooterHeightOsoite
}

//--------------------------------------------
function replace( sString, sStr1, sStr2 ) {
// Tarkistaa lomakkeen tyhjät kentät, myös välilynnit.
//--------------------------------------------
	var arrTemp = sString.split( sStr1 );
	return arrTemp.join( sStr2 );
}

//--------------------------------------------
function SubmitSendPage(strMessage1, strMessage2) {
//Sivun lähetys ja tarkistus että kentissä on kirjoitusta.
//--------------------------------------------
	if( replace(document.frmSendPage.email.value," ", "").length < 1 ) {alert(strMessage1);document.frmSendPage.email.focus();return false;}

	if( replace(document.frmSendPage.name.value," ", "").length < 1 )  {alert(strMessage2);document.frmSendPage.name.focus();return false;}

}


//--------------------------------------------
function SubmitEditPage(){
//Lomakkeen lähetys ja tarkistus että pakollisissa kentissä on kirjoitusta.
//--------------------------------------------
	var alertMsg = "";
	var bDataChanged = false;

	if(document.forms["PageEdit"]){
		objEl = document.forms["PageEdit"].elements;
		for(var i=0; i < objEl.length; i++ ){
			if(objEl[i].getAttribute("IsOptional") == "False" && objEl[i].value == ""){
				alertMsg = alertMsg + objEl[i].name + " puuttuu. \n"
			}
			else if(objEl[i].getAttribute("IsOptional") == "False" && objEl[i].value != ""){
			}
		}
		if(alertMsg.length < 1){
			return true;
			document.forms[0].submit();
		}
		else{
			alert(alertMsg);
			return false;
		}
	}
}


//--------------------------------------------
function OpenParent(theURL) {
// Avaa parent-ikkunaan parametrinä tulleen urlin ja sulkee lähettävän ikkunan.
//--------------------------------------------
	window.opener.location = theURL;
	this.window.close();
}

//--------------------------------------------
function popup(theURL,winName,features) {
// Avaa uuden selainikkunan näytön keskelle.
//--------------------------------------------
	var winleft = (screen.width - 500) / 2;
	var wintop  = (screen.height - 300) / 2;
	features = features + ',left='+winleft + ',top='+wintop
	msgWindow = window.open(theURL,winName,features);
	msgWindow.focus();
}

