
var ie = document.all;
var nn6 = document.getElementById && !document.all;
var opera = window.opera;

var SJR = {
	mouse_x: 0,
	mouse_y: 0,
	mouse_moved: false,

	require: function(file) {
		document.write('<script type="text/javascript" src="/jalkimainonta-as/js/'+file+'"></script>');
	},

	load: function() {
		this.require('jquery.js');
		this.require('object.js');
		this.require('sifr.js');
		this.require('infobox.js');
		this.require('forms.js');
	},

	showText: function (id) {
		if (document.getElementById(id).style.display=='block') { document.getElementById(id).style.display = 'none'; }
		else { document.getElementById(id).style.display = 'block'; }
	},

	changeText: function (id, a, b) {
		if (document.getElementById(id).innerHTML==b) { document.getElementById(id).innerHTML = a; }
		else { document.getElementById(id).innerHTML = b; }
	},

	loadurl: function (url) {
		var jsQuery;

		try{
			jsQuery = new XMLHttpRequest();
		} catch (e){
			try{
				jsQuery = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					jsQuery = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					return false;
				}
			}
		}

		jsQuery.open("GET", url, false);
		jsQuery.send(null);
                var data = encodeURI(jsQuery.responseText);
                var data = data.replace("%EF%BB%BF", "");
                var data = decodeURI(data);
		return data;
	},

	scrollXY: function () {
		var scrOfX = 0, scrOfY = 0;

		if(typeof(window.pageYOffset) == 'number') {
			// Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;

		} else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
			// DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;

		} else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
			// IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}

		return [scrOfX, scrOfY];
	},

	viewportSize: function() {
		var myWidth = 0, myHeight = 0;

		if (typeof(window.innerWidth ) == 'number') {
			// Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;

		} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
			// IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;

		} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
			// IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}

		return [myWidth, myHeight];
	},

	sleep: function(naptime) {
		var sleeping = true;
		var now = new Date();
		var alarm;
		var startingMSeconds = now.getTime();
		while(sleeping){
			alarm = new Date();
			alarmMSeconds = alarm.getTime();
			if(alarmMSeconds - startingMSeconds > naptime){ sleeping = false; }
		}
	},

	loadForm: function(value) {
		this.require('forms.js');
		this.require('forms/'+value+'.js');
	},

	navi: function(imageName, status) {
		if (status) { document [imageName].src = "/img/" + imageName + "_" + SITE.Language + "_hover.jpg"; }
		else { document [imageName].src = "/img/" + imageName + "_" + SITE.Language + ".jpg"; }
	},

	showLogin: function(id) {
	        if (id=="Admin") { id = "loginContentAdmin"; }
	        if (id=="Webmail") { id = "loginContentWebmail"; }
	        if (id=="Email") { id = "loginContentEmail"; }
	        if (document.getElementById) {
	                document.getElementById("loginContentAdmin").style.display = 'none';
	                document.getElementById("loginContentWebmail").style.display = 'none';
	                document.getElementById("loginContentEmail").style.display = 'none';
	                document.getElementById(id).style.display = 'block';
	                return false;
	        }
	        return true;
	}
}

SJR.load();

function scrollHere(scroll_obj,page_obj){if(!scroll_obj||!page_obj){return;}
var begin_top=pageScrollY(),duration=750,start_time=(new Date()).getTime(),last_top=null;var interval=setInterval(function(){var wh=window.innerHeight?window.innerHeight:document.documentElement.clientHeight;var dh=elementY(page_obj)+page_obj.offsetHeight;var ey=elementY(scroll_obj)-100;if(dh-ey<wh){ey-=(wh+ey)-dh;}
if(dh<wh+100){clearInterval(interval);}
var time=(new Date()).getTime();var scroll=null;var current_top=pageScrollY();var p=(time-start_time)/duration;if(p>1){scroll=ey;clearInterval(interval);}else{scroll=parseInt((ey-begin_top)*animation.ease.both(p)+begin_top);}
if(last_top&&current_top!=last_top&&current_top!=0){clearInterval(interval);}else{window.scrollBy(0,scroll-current_top);last_top=scroll;}},25);}

