
//---- Biletoppgåver ------------------------------------------
function Oppdater(kjelde)	{
	theDate = new Date();
	bilete = new Image();
	bilete.src = "http://vikjavev.no/webcam/bilete.php?kjelde="+ kjelde +"&dummy=" + theDate.getTime().toString(10);
	bilete.onLoad = document.getElementById("webcam").src = bilete.src;
    if (kjelde != "timeout") OppdaterVertabell();
}


function OppdaterVertabell() {
	if (document.getElementById("callback")) { // callback iframe is already created
		callback = document.getElementById("callback");
	} else { // create callback iframe
		var callback = document.createElement("iframe");
		callback.id = "callback";
		callback.style.display = "none";
		document.body.appendChild(callback);
	} 
	// load content
	var src = "../ver/verIframe.php";
	callback.src = src;
	
}


var queryString = window.top.location.search.substring(1);

function getParameter ( parameterName ) {
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
		// Find the beginning of the string
		begin = queryString.indexOf ( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
			// Return the string
			return unescape ( queryString.substring ( begin, end ) );
		}
		// Return "null" if no parameter has been found
		return "null";
	}
} 

// Autooppdatering
var solopp, solned, servertid; // tileigna i index.php
var oppdatIntervall = 3 * 60000; // 3 minutt
var oppdatHoldILive = 120 * 60000;
//var oppdatIntervall = 1000; // 3 minutt
//var oppdatHoldILive = 1000;
var autooppdaterTeljar = 0;


setTimeout("Autooppdater()", oppdatIntervall);

function Autooppdater()	{
	autooppdaterTeljar++;
	
	// oppdater servertid
	servertid += 2;
	if (servertid % 100 >= 60) servertid += 40;
	if (servertid >= 2400) servertid -= 2400;
	
	if (autooppdaterTeljar < oppdatHoldILive / oppdatIntervall)	{
		kjelde = (servertid > solopp && servertid < solned) ? "nytt" : "dagens";
		Oppdater(kjelde);
		setTimeout("Autooppdater()", oppdatIntervall);
	
    } else { // tidi er gått ut
        document.getElementById("vertabell").innerHTML = 
        "<div style='width: 520px; padding: 10px 0; text-align: center'>Trykk Oppdater-knappen i nettlesaren</div>";
        Oppdater("timeout");
        
    }
}

function videopopup(dato) {
	URL = "/webcam/videopopup.php?dato=" + dato;
	eval("fotovindauga = window.open(URL, 'Storesvingen', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,resizable=1,width=100,height=100,left =100,top =40');");
}

// =====================================
// Do not edit anything below this line!
// =====================================

var tss = new Array();
var jss = new Array();
var pss = new Array();


var serie;
var picture_array;

function StartSlideShow(serien)	{
	if (serien == serie) runSlideShow(); // fortset etter stopp
	else	{
		serie = serien;
		if (serie == "igaar") picture_array = Picture_igaar;
		if (serie == "idag") picture_array = Picture_idag;
		if (serie == "mnd") picture_array = Picture_mnd;
		jss[serie] = 1;
		pss[serie] = picture_array.length-1;
		runSlideShow();
		}
	}

function runSlideShow(){
	StoppAlle();
	if (isIE)	{
		wc.style.filter="blendTrans(duration=2)";
		wc.style.filter="blendTrans(duration=CrossFadeDuration)";
		wc.filters.blendTrans.Apply();
		}
	p1 = document.getElementById("preloader1");
	p1.innerHTML = "<img src='" + picture_array[jss[serie]] + "' width=1 height=1 "
		+ "onLoad=\"BytBilete();\">";
	}
		
function BytBilete()	{
	wc.src = picture_array[jss[serie]];
	if (isIE) wc.filters.blendTrans.Play();
	jss[serie] = jss[serie] + 1;
	if (jss[serie] > pss[serie]) jss[serie] = 1;
	else tss[serie] = setTimeout("runSlideShow()", SlideShowSpeed);
	
	p2 = document.getElementById("preloader2");
	p2.innerHTML = "<img src='" + picture_array[jss[serie]] + "' width=1 height=1>";
	}

function StoppAlle()	{
	clearTimeout(tss[serie]);
	}
	
document.write("<div id=preloader1 style='position:absolute; top:200px; left:200px;'><\/div>");
document.write("<div id=preloader2 style='position:absolute; top:201px; left:201px;'><\/div>");
// Slutt animasjon
function Vis(kjelde)	{
	bilete = new Image();
	bilete.src = "../webcam/bilete.php?kjelde=" + kjelde;
	bilete.onLoad = Oppdater2();
	}
	
function VentLitt()	{
	document.getElementById("webcamdiv").style.filter = "alpha(opacity=50)"
	}
    
//-- Highslide updater --------------------------------------------

hs.showCredits = false;
hs.graphicsDir = "/highslide/highslide/graphics/";
hs.numberOfImagesToPreload = 0;

var vgInterval = 2 * 60 * 1000; 
var vgTimeToLive = 60 * 60 * 1000; // 60 minutes

// Event handler to start the cycling of pictures. The cycling
// doesn't start if the href doesn't contain /nocache/
hs.Expander.prototype.onAfterExpand = function() {
    if (/nocache/.test(this.a.href)) {
        this.vgStarted = (new Date).getTime();
        var exp = this;
        this.vgTimer = setTimeout(function() {
            vgLoad(exp);
        }, vgInterval);
    }
};
// Stop the cycling after close. Also, the anchor's href is changed
// to force the browser to reload a new image on subsequent open.
hs.Expander.prototype.onAfterClose = function() {
    if (this.vgTimer) clearTimeout(this.vgTimer);
    this.a.href = this.a.href.replace(/nocache=[0-9]*$/, "nocache="+ (new Date).getTime());
};
// Prevent preloading of next image
hs.Expander.prototype.preloadNext = function() {};

// Start loading a new image. If the time has run out, close the expander.
function vgLoad(exp) {
    if ((new Date).getTime() > exp.vgStarted + vgTimeToLive) {
        exp.close();
        return;
    }
    var img = new Image;
    var src = exp.a.href.replace(/nocache=[0-9]*$/, "nocache="+ (new Date).getTime());
    img.onload = function () {
        vgShow(exp, src);
    }
    img.src = src;
};
// Show the new, preloaded image and start a new timeout for the next one.
function vgShow(exp, src) {
    exp.content.src = src;
    exp.vgTimer = setTimeout(function() {
        vgLoad(exp);
    }, vgInterval);
};
	
