var ie=document.all;
// false, kui tegemist pole DOM standardit toetava brauseriga brauseriga.
var dom=document.getElementById;
// false, kui tegemist pole Netscape4.X brauseriga.
var ns4=document.layers;
document.write('
');
// This is a fix for one of the CSS warnings (2007-02-13)
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
var myimages = new Array();
var oldsrc = null;
function preloadImgs(){
for (i=0;i< document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}
// Find the element's offsetTop and offsetLeft relative to the BODY tag.
objLeft = obj.offsetLeft;
objTop = obj.offsetTop;
objParent = obj.offsetParent;
while( objParent.tagName.toUpperCase() != "BODY" )
{
objLeft += objParent.offsetLeft;
objTop += objParent.offsetTop;
objParent = objParent.offsetParent;
if (objParent.tagName == "HTML") break;
}
objHeight = obj.offsetHeight;
objWidth = obj.offsetWidth;
if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
else if( overDiv.offsetTop >= ( objTop + objHeight ));
else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
else
{
obj.style.visibility = "hidden";
}
}
}
}
/*
* unhides and objects (for IE only)
*/
function showElement( elmID )
{
if( document.all )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}
obj.style.visibility = "";
}
}
}
function showTooltip(ref,txt,type){
document.getElementById("tooltipInner").innerHTML = txt;
document.getElementById("tooltip").style.display = 'block';
var tooltipWidth = document.getElementById("tooltip").offsetWidth;
var tooltipHeight = document.getElementById("tooltip").offsetHeight;
var leftpos = 0;
var toppos = 0;
aTag = ref;
do
{
aTag = aTag.offsetParent;
if (aTag.tagName == "HTML") break;
leftpos += aTag.offsetLeft;
toppos += aTag.offsetTop;
}
while(aTag.tagName!="BODY");
var tooltipTop = ref.offsetTop + toppos;
var tooltipBottom = tooltipTop + tooltipHeight;
var tooltipLeft = ref.offsetLeft + ref.offsetWidth + leftpos + 10;
var tooltipRight = tooltipLeft + tooltipWidth;
var x,y;
if (self.pageYOffset || self.pageXOffset) // all except Explorer
{
x = self.pageXOffset;
y = self.pageYOffset;
}
else if (document.documentElement) // Explorer 6 Strict
{
x = document.documentElement.scrollLeft;
y = document.documentElement.scrollTop;
}
else if (document.body) // all other Explorers
{
x = document.body.scrollLeft;
y = document.body.scrollTop;
}
var scrollLeft = x;
var scrollTop = y;
if (self.innerHeight || self.innerWidth) // all except Explorer
{
x = self.innerWidth;
y = self.innerHeight;
}
else if (document.documentElement) // Explorer 6 Strict Mode
{
x = document.documentElement.clientWidth;
y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
x = document.body.clientWidth;
y = document.body.clientHeight;
}
var clientWidth = x;
var clientHeight = y;
var bottom = scrollTop + clientHeight;
var right = scrollLeft + clientWidth;
if (tooltipBottom > bottom)
{
tooltipTop = bottom - tooltipHeight - 10;
}
if (tooltipRight > right)
{
tooltipLeft = right - tooltipWidth - 10;
}
toppos = tooltipTop;
leftpos = tooltipLeft;
if(type=='error'){
document.getElementById("tooltipInner").className = 'tooltip-error';
} else {
document.getElementById("tooltipInner").className = 'tooltip-normal';
}
document.getElementById("tooltip").style.left = leftpos+'px';
document.getElementById("tooltip").style.top = toppos+'px';
hideElement( 'SELECT', document.getElementById("tooltip") );
hideElement( 'APPLET', document.getElementById("tooltip") );
}
function hideTooltip(){
document.getElementById("tooltip").style.display = 'none';
showElement( 'SELECT', document.getElementById("tooltip") );
showElement( 'APPLET', document.getElementById("tooltip") );
}
function getSearchParam() {
el = document.getElementById('sisend');
param = el.value;
target = document.getElementById('searchButton');
target.setAttribute("arn-evntpar", param);
}
function doSearch($char, $mozChar) {
if($mozChar != null) { // Look for a Mozilla-compatible browser
if($mozChar == 13) {
getSearchParam();
document.getElementById('searchButton').click();
}
} else { // Must be an IE-compatible Browser
if($char == 13){
getSearchParam();
document.getElementById('searchButton').click();
}
}
}
/* for list checkboxes */
function toggleCheckboxes(arrFormElems, prefix) {
var checked = null;
for (var i = 0; i < arrFormElems.length; i++) {
var elem = arrFormElems[i];
if (elem.getAttribute('type')=='checkbox' && hasCorrectPrefix(elem, prefix)) {
if (checked == null) {
checked = elem.checked;
} else {
elem.checked=checked;
}
}
}
return true;
}
function hasCorrectPrefix(elem, prefix) {
if (prefix == null || elem.id == null) {
return true;
} else if (elem.id.indexOf(prefix) == 0) {
return true;
} else {
return false;
}
}
//Cookies management util functions
function writeCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i=0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
//Version checker - reloads cache if version has updated
function writeScriptsVersionCookie(version) {
writeCookie("kkrFullVersion", version, 365);
}
function checkScriptsVersion(scriptsVersionServerSide) {
var browserScriptsVersion = readCookie("kkrFullVersion");
// alert("browserScriptsVersion: " + browserScriptsVersion + "
// scriptsVersionServerSide: " + scriptsVersionServerSide);
if (browserScriptsVersion != scriptsVersionServerSide) {
writeScriptsVersionCookie(scriptsVersionServerSide);
// A little hack to prevent Aranea's StateExpirationException
// (we have to be sure that GET method will be used)
writeCookie('JSESSIONID', '', 0);
window.location.reload();
}
}
function prepareFileDownload() {
Object.extend(Aranea.Popups, {
openPopup2: Aranea.Popups.openPopup,
openPopup: function(popupId) {
var url = this.popupProperties[popupId].url;
$(document.body).insert(new Element("iframe", {"id": popupId, "src": url} ));
$(popupId).hide();
Object.extend(Aranea.Popups, {openPopup: this.openPopup2});
}
});
return true;
}
function callback(transport) {
transport.responseText.evalScripts();
}
/**
* Fotode tabis foto kuvamise script
*/
function display_img(url,portraitHeight,landscapeHeight){
var maxHeight;
var newImg = new Image();
newImg.src = url;
var height = newImg.height;
var width = newImg.width;
if (height > width) {
maxHeight = portraitHeight;
} else {
maxHeight = landscapeHeight;
}
var image1 = ' ';
document.write(image1);
}
function getScrollTop() {
if (document.documentElement && document.documentElement.scrollTop) {
// IE 6
return document.documentElement.scrollTop;
} else if (document.body) {
// IE 5
return document.body.scrollTop;
} else {
// Netscape, Mozilla, Firefox etc
return window.pageYOffset;
}
}
function getPageHeight() {
if (window.innerHeight && window.scrollMaxY) {// Firefox
return yWithScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
return yWithScroll = document.body.scrollHeight;
} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
return yWithScroll = document.body.offsetHeight;
}
}
function getWindowHeight() {
var myHeight = 200;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myHeight = document.body.clientHeight;
}
return myHeight;
}
/**
* Timer for wait overlay (aranea ajax loading)
*/
function getElemById(elmID) {
var elem = null;
if (dom) {
elem = document.getElementById(elmID);
} else if (ie) {
elem = document.all[elmID];
} else if (ns4) {
elem = document.layers[elmID];
}
return elem;
}
//lehe uuendamisel ootamise teate taimeri algus.
var timerStart;
// taimeri s??ndmuse ID.
var timerID;
function showWaitTimer(boolShow) {
var elem = getElemById('wait');
if (elem == null) {
return true;
}
if (boolShow) {
elem.style.top = "0 px";
elem.style.height=getPageHeight() + "px";
elem.style.visibility = "";
elem = getElemById('middle');
elem.style.top=(getScrollTop()+getWindowHeight()/2)+"px"
timerID = setInterval(updateWaitTimer, 1000);
timerStart = undefined;
updateWaitTimer();
window.onunload = function() {
showWaitTimer(false);
};
} else {
elem.style.visibility = "hidden";
timerStart = undefined;
if (!isNaN(timerID)) {
clearInterval(timerID);
timerID = undefined;
}
}
return true;
}
function updateWaitTimer() {
if (timerStart == undefined) {
timerStart = new Date();
}
var now = new Date();
var diff = now - timerStart;
now = new Date(diff);
var lblMin = " minutit, ";
var lblSec = " sekundit.";
if (now.getMinutes() == 1) {
lblMin = ' minut, ';
}
if (now.getSeconds() == 1) {
lblSec = ' sekund.';
}
var elem = getElemById('waitTimer');
if (elem != null) {
elem.innerHTML = now.getMinutes()
+ lblMin + now.getSeconds() + lblSec;
}
return true;
}
/**
* listen print button click
*/
function documentPrint()
{
/*
* call frame function to generate printable content
*/
try {
var gisFrame = document.getElementById("mapFrame");
if (gisFrame != null && gisFrame != undefined) {
gisFrame.contentWindow.preparePrint();
}
}
catch (err) {
// handle errors here
}
window.print();
}