onload=init;
function init() {
	var objDiv = document.getElementById("Page");
	//alert("before block");
	objDiv.style.display = "block";
	//alert("block");
	
	with ( document ) {
		for ( var i=0; i<images.length; i+=1 ) {
			with ( images[i] ) {
				style.width=(width*0.06251)+"em";
				style.height=(height*0.06251)+"em";
			}
		}
	}

	//Set zoom factor
	if (getCookie(zoomCookie) == "125%")
	{
		document.body.style.zoom = "125%";
	}

	// Set focus
		try
	{
		if (IdOfObjToGetFocus != null)
		{
			var s = IdOfObjToGetFocus.split(";");
			for (index = 0; index < s.length; index++)
			{
				var objToGetFocus = document.getElementById(s[index]);
				objToGetFocus.focus();
			}
		}
	}
	catch (e)
	{
	}

	//Make_corners();
	
	//FlashOn();
} // init

function setCookie(c_name, value, expiredays, path)
{
    //alert(navigator.cookieEnabled);
    if (navigator.cookieEnabled == false) {
        alert("Du skal have cookies enablet i din browser for at bruge denne funktion!");
        return(false);
    }
    // Ovenstående virker ikke i IE 7, istedet kommer en advarsel i status baren
    
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    var exdatetxt = exdate.toUTCString();
    var exdatetxt = exdatetxt.replace("UTC","GMT");
    var cookie_content = c_name+ "=" + escape(value) +
		((path) ? "; path=" + path : "") +
        ((expiredays==null) ? "" : "; expires=" + exdatetxt);

    // Ifølge MS: If you use the document.cookie property to retrieve the cookie
    // on the client side, the document.cookie property can retrieve only 4,096 bytes. 
    // This byte total can be one name-value pair of 4 KB, 
    // or it can be up to 20 name-value pairs that have a total size of 4 KB.
    // Ifølge rosettecode: JavaScript encodes strings in UTF-16, which represents each
    // character with one or two 16-bit values. The length property of string objects
    // gives the number of 16-bit values used to encode a string, so the number of bytes
    // can be determined by doubling that number.
//            alert(2*cookie_content.length);
//            alert(cookie_content);
//            var objDiv = document.getElementById("cookieContent");
//            objDiv.innerHTML = cookie_content;

    if (2*cookie_content.length > 4096)
    {
        return(false);
    }
    else
    {
        document.cookie = cookie_content;
        return(true);
    }
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        var c_start=document.cookie.indexOf(c_name + "=")
        if (c_start != -1)
        { 
            c_start=c_start + c_name.length+1;
            var c_end=document.cookie.indexOf(";",c_start);
            if (c_end == -1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}

var zoomCookie = "zoomcookie"; // konstant
var zoomExpireDays = 5;
var zoomPath = "/";

function resize()
{
//	alert(getCookie(zoomCookie));
//	document.body.style.setAttribute('zoom','125%','false');
	if (getCookie(zoomCookie) != "125%")
	{
		// cookie empty or normal
		document.body.style.zoom = "125%";
		setCookie(zoomCookie, "125%", null, zoomPath);
	}
	else
	{
		// cookie 125%
		document.body.style.zoom = "normal";
		setCookie(zoomCookie, "normal", null, zoomPath);
	}
}

function SearchFocus(obj, StandardText) {
	if(obj.value==' '+StandardText) obj.value='';
	obj.style.color="White";
} // SearchEnabled
function SearchBlur(obj, StandardText) {
	if(obj.value=='') {
		obj.value=' '+StandardText;
		obj.style.color="";
	}
} // SearchDisabled

//Nifty corners function
function Make_corners(){
	Nifty("div#CenterArea","big transparent");
}

// InsertFlashWithDetection
var FlashCanPlay;
var text="";
var text2="";
function InsertFlashWithDetection(FlashSrc, ImageSrc, Width, Height, Version, Align, BgColor, WMode, Quality, CreateDownloadLink) {
	try
	{
		//alert('insert flash started');
		FlashCanPlay=false;
		var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
		if ( plugin ) {
			var words = navigator.plugins["Shockwave Flash"].description.split(" ");
			for (var i = 0; i < words.length; ++i) {
				if (isNaN(parseInt(words[i]))) continue;
				var PluginVersion = words[i]; 
			}
			FlashCanPlay = PluginVersion >= Version;
		} else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
			/*text2 = text2 + "<script language='VBScript'> \n";
			text2 = text2 + "on error resume next \n";
			text2 = text2 + "FlashCanPlay = ( IsObject(CreateObject('ShockwaveFlash.ShockwaveFlash.'+Version+')))\n";
			text2 = text2 + "</script> \n";
			alert(text2);
			document.write(text2);*/
			
			//document.write('TESTUDSKRIFT');
			document.write('<script language=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
			//document.write('MsgBox "VBSCRIPT" \n');
			document.write('on error resume next \n');
			document.write('FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+Version+'")))\n');
			//document.write('MsgBox FlashCanPlay \n');
			document.write('</scr' + 'ipt\> \n');
			//alert('document.write');
		}

		if ( FlashCanPlay ) {
			//alert('if FlashCanPlay');
			var FlashSrcBase=FlashSrc.substr(0, FlashSrc.lastIndexOf('/'));
			text = text + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
			text = text + ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+Version+',0,0,0"';
			text = text + ' width="'+Width+'"';
			text = text + ' height="'+Height+'"';
			text = text + ' align="'+Align+'"';
			text = text + ' base="'+FlashSrcBase+'"';
			text = text + '>';
			text = text + '<param name="allowScriptAccess" value="sameDomain">';
			text = text + '<param name="menu" value="false">';
			text = text + '<param name="movie" value="'+FlashSrc+'">';
			text = text + '<param name="wmode" value="'+WMode+'">';
			text = text + '<param name="quality" value="'+Quality+'">';
			text = text + '<param name="bgcolor" value="'+BgColor+'">';
			text = text + '<embed pluginspage="http://www.macromedia.com/go/getflashplayer"';
			text = text + ' allowscriptaccess="sameDomain"';
			text = text + ' type="application/x-shockwave-flash"';
			text = text + ' menu="false"';
			text = text + ' src="'+FlashSrc+'"';
			text = text + ' base="'+FlashSrcBase+'"';
			text = text + ' width="'+Width+'"';
			text = text + ' height="'+Height+'"';
			text = text + ' align="'+Align+'"';
			text = text + ' wmode="'+WMode+'"';
			text = text + ' quality="'+Quality+'"';
			text = text + ' bgcolor="'+BgColor+'"';
			text = text + '</embed>';
			text = text + '</object>';
		} else if ( ImageSrc ) {
			//alert('Flash cannot play');
			if ( typeof(CreateDownloadLink)=='undefined' ) CreateDownloadLink=false;
			if ( CreateDownloadLink ) {
				text = text + '<a href="http://www.macromedia.com/go/getflashplayer"><img src="'+ImageSrc+'" alt="" width="'+Width+'" height="'+Height+'" border="0" align="'+Align+'"></a>';
			} else {
				text = text + '<img src="'+ImageSrc+'" alt="" width="'+Width+'" height="'+Height+'" border="0" align="'+Align+'">';
			}
		}
		//document.write(text);
		//alert(text);
		var objDiv = document.getElementById("flashinsert");
		objDiv.innerHTML = text;
		//alert('LOJ4');	
	}
	catch (e)
	{
	}

} // InsertFlashWithDetection

// Til biblioteks logon
function Browsertype() {
	this.agt = navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);  // version
	if (document.getElementById) {
		this.dom = 1;  // true for ie6, ns6
	} else {
		this.fom = 0;  
	}
	this.ns = (document.layers); //Netscape < 6
	this.ns4x = (this.ns && this.major >=4);
	this.ns6 = (this.dom && navigator.appName=="Netscape"); // Netscape >=6
	this.opera = this.agt.indexOf('opera')!=-1; // Opera
	this.ie = !this.ns6 && (document.all);   // Inernet Explorer
	if (document.all && !this.dom) {
		this.ie4 = 1;
	} else {
		this.ie4 = 0;
	}
	this.ie4x = (this.ie && this.major >= 4);
	this.ie5 = (document.all && this.dom);
}

var Browser = new Browsertype;

function handleSubmit(event, form, defaultbutton) {
	code = event.keyCode;
	target = (Browser.ie || Browser.opera) ? event.srcElement : event.target; 
	if (code == 13 && !(target.href)) {
		eval(defaultbutton+"_function(form)");
	}
}

function addKeyValue(field, key, value) {
	key = escape(key);
	value = escape(value);
	if (field.value.length > 0) {
		field.value = field.value + " " + key + "=" + value;
	} else {
		field.value = field.value + key + "=" + value;
	}			
}

function addForm(field, form) {
	if (form) {
		for (i = 0; i < form.elements.length; i++) {
			addKeyValue(field, form.elements[i].name, form.elements[i].value);
		}			
	}
}

function addData(field) { addForm(field, document.loginForm);	}
    
function AAKBLogin_function() {
	document.submitForm.data.value = "";
	addData(document.submitForm.data);
	document.submitForm.doaction.value = "patron-login";
	document.loginForm.tickno.value = "";
	document.loginForm.pin.value = "";
	document.submitForm.submit();
}


function GalleryImagePopup(ObjectId) {
	var MyWindow=false;
	try {
		var url="/gsimagepopup.aspx?ObjectId="+ObjectId;
		MyWindow=window.open(url, "GalleryImagePopup", "location=no,menubar=no,directories=no,status=no");
	} catch(ex) {
		// Do nothing about errors
	}
	return (MyWindow==false);
} // GalleryImagePopup
function LoadGalleryImage(ObjectId) {
	var isLoaded=false;
	var galleryImageContainer=$("GalleryImageContainer");
	var galleryImageLoader=$("GalleryImageLoader");
	try {
		if ( !galleryImageContainer || !galleryImageLoader ) {
			alert("Can't load gallery image.");
		} else {
			var url="/gsimagepopup.aspx?ObjectId="+ObjectId+"&Method=Gallery";
			ShowGalleryLoader();
			new Ajax.Updater(galleryImageContainer, url, {onComplete:HideGalleryLoader});
			isLoaded=true;
		}
	} catch(ex) {
		// Do nothing about errors
	}
	return (isLoaded==false);
} // LoadGalleryImage
function HideGalleryLoader() {
	var galleryImageLoader=$("GalleryImageLoader");
	var galleryImageContainer=$("GalleryImageContainer");
	galleryImageContainer.style.display="block";
	galleryImageLoader.style.display="none";
} // HideGalleryLoader
function ShowGalleryLoader() {
	var galleryImage=$("GalleryImage");
	var galleryImageLoader=$("GalleryImageLoader");
	var galleryImageContainer=$("GalleryImageContainer");
	
	// If GalleryImage exist Then loader height to the same as image. This prevents page from changing height and there for scroll.
	if ( galleryImage ) if ( galleryImage.height ) galleryImageLoader.style.height=galleryImage.height+"px";
	galleryImageLoader.style.display="block";
	galleryImageContainer.style.display="none";
} // HideGalleryLoader
