var yScroll, iframedivtop, psize;
var browser = (navigator.userAgent.search(/MSIE/)>0) ? 1 : 0;

function gebi(id)
{
	var obj = null;

	if(document.getElementById) obj = document.getElementById(id);
	else if(document.all) obj = document.all[id];

	return obj;
}

function set(element, code, temp, su, ps)
{
	gebi('grad').innerHTML = element.innerHTML;
	gebi('slika').src = '/px/weather/32/'+code+'.png';
	gebi('temp').innerHTML = temp+'°C';
	gebi('fc0').innerHTML = su;
	gebi('fc1').innerHTML = ps;

	gebi(city).className = 'off';
	gebi(element.id).className = 'on';
	city = element.id;
}

function fixSize()
{
	var xScroll;
	
	if (window.innerHeight && window.scrollMaxY) { xScroll = document.body.scrollWidth; yScroll = window.innerHeight + window.scrollMaxY; }
	else if (document.body.scrollHeight > document.body.offsetHeight) { xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; }
	else { xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; }
	
	var windowWidth, windowHeight;

	if (self.innerHeight) { windowWidth = self.innerWidth-16; windowHeight = self.innerHeight; }
	else if (document.documentElement && document.documentElement.clientHeight) { windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; }
	else if (document.body) { windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; }	
	
	pageHeight = (yScroll<windowHeight) ? windowHeight : yScroll;
	pageWidth = (xScroll < windowWidth) ? windowWidth : xScroll;

	fader.style.width = pageWidth;
	fader.style.height = pageHeight;

	psize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	iframediv.style.width = Math.round(pageWidth*0.94);
	iframediv.style.height = Math.round(windowHeight*0.90);
	iframediv.style.left = Math.round(pageWidth*0.03);
	iframediv.style.top = iframedivtop = Math.round(windowHeight*0.05);

	return psize;
}

function pause(numberMillis)
{
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) { now = new Date(); if (now.getTime() > exitTime) return; }
}

function fade(id, step)
{
	if (browser) gebi(id).style.filter = 'alpha(opacity='+s+')';
	else gebi(id).style.opacity = s/10;
	s+=step;
	if ((s>100 && step>0) || (s<0 && step<0)) clearInterval(process);
}

function fadeout()
{
	process=setInterval('fade("iframe",-10)',5);
}

function show(url)
{
	if (url=='') return;

	if (self.pageYOffset) yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop;
	else if (document.body) yScroll = document.body.scrollTop;

	gebi('fader').style.display = '';
	gebi('iframediv').style.display = '';
	gebi('iframe').src = url;
}

function move()
{
	if (self.pageYOffset) yScroll = self.pageYOffset;
	else if (document.documentElement && document.documentElement.scrollTop) yScroll = document.documentElement.scrollTop;
	else if (document.body) yScroll = document.body.scrollTop;
	iframediv.style.top = yScroll+((iframedivtop) ? iframedivtop : 0);
}
