﻿var bid = 0;
var bid_keeper = true;
var inti;
var bannerialt = 2;

function getPageSize(){
	
				var xScroll, yScroll;
	
					if (window.innerHeight && window.scrollMaxY) {	
						xScroll = document.body.scrollWidth;
						yScroll = window.innerHeight + window.scrollMaxY;
					} else if (document.body.scrollHeight > document.body.offsetHeight){ // alle undtagen Explorer Mac
						xScroll = document.body.scrollWidth;
						yScroll = document.body.scrollHeight;
					} else { // Explorer Mac...virker også i Explorer 6, Mozilla og Safari
						xScroll = document.body.offsetWidth;
						yScroll = document.body.offsetHeight;
					}
	
				var windowWidth, windowHeight;
					if (self.innerHeight) {	// alle undtagen Explorer
						windowWidth = self.innerWidth;
						windowHeight = self.innerHeight;
					} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6
						windowWidth = document.documentElement.clientWidth;
						windowHeight = document.documentElement.clientHeight;
					} else if (document.body) { // Andre Explorers
						windowWidth = document.body.clientWidth;
						windowHeight = document.body.clientHeight;
			}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

window.onload = function() {
	if(document.getElementById('bund')) {
		var dd = getPageSize();
		var dd3 = parseInt(dd[1]) - 37;
		document.getElementById('bund').style.top = dd3+'px';
		document.getElementById('bund').style.display = 'block';
		//alert(dd3); 		
	}
	//if(document.getElementById('pic1')) {
	//	setTimeout("skift_pic()", 4500);
	//}
	if(document.getElementById('banner2'))
		bannerialt = banner.length;	
  if(document.getElementById('banner')) {
	document.getElementById('banner').src = banner[0];
	document.getElementById('banner2').src = banner[1];
	document.getElementById('banner').style.visibility = 'visible';
	inti = setInterval("loop_banner()",5000);
  }
  
  if(serie==true) {
 	bannerialt = bb.length;	
    document.getElementById('ba').src = bb[0];
	document.getElementById('ba2').src = bb[1];
	document.getElementById('ba').style.visibility = 'visible';
	inti = setInterval("loop_banner2()",4000);
  }
  
}

			var idnow = 1;
   			var doit = true;
			function skift_pic() {
					Effect.Fade('pic'+idnow, { duration: 3.0 });
					idnow++;
					if(idnow>2)
						idnow=1;
					Effect.Appear('pic'+idnow, { duration: 3.0 });
					doit = false;
					setTimeout("skift_pic()", 7000);
			}
			




function set_banner(bannertal) {
	clearInterval(inti);
	if(bannertal==bannerialt) 
		bannertal = 0;
	
	if(bid_keeper) {
		document.getElementById('banner2').src = banner[bannertal];
		
		setTimeout("Effect.Fade('banner', { duration: 3.0 })", 100);
		setTimeout("Effect.Appear('banner2', { duration: 3.0 })", 100);
		bid_keeper = false;
	} else {
		document.getElementById('banner').src = banner[bannertal];
		
		setTimeout("Effect.Fade('banner2', { duration: 3.0 })", 100);
		setTimeout("Effect.Appear('banner', { duration: 3.0 })", 100);
		bid_keeper = true;
	}
	bid = bannertal;
	inti = setInterval("loop_banner()",8000);
}

function set_banner2(bannertal) {
	clearInterval(inti);
	if(bannertal==bannerialt) 
		bannertal = 0;
	
	if(bid_keeper) {
		document.getElementById('ba2').src = bb[bannertal];
		
		setTimeout("Effect.Fade('ba', { duration: 3.0 })", 100);
		setTimeout("Effect.Appear('ba2', { duration: 3.0 })", 100);
		bid_keeper = false;
	} else {
		document.getElementById('ba').src = bb[bannertal];
		
		setTimeout("Effect.Fade('ba2', { duration: 3.0 })", 100);
		setTimeout("Effect.Appear('ba', { duration: 3.0 })", 100);
		bid_keeper = true;
	}
	bid = bannertal;
	inti = setInterval("loop_banner2()",4000);
}

function loop_banner() {
	set_banner(bid+1);
}

function loop_banner2() {
	set_banner2(bid+1);
}


function popUp(URL) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open('player.php?file="+URL+"', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=220,height=30');");
}

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=719,height=350,scrollbars=no');
return false;
}
