﻿/*******FUNCTIONS**************/


function fInitMenuLinks() {
var oLinks = document.getElementsByTagName("li");
var oLink, i = 0;
	while ( (oLink = oLinks[i++]) && (oLink != null)) {
		if ( oLink.className == "drop" ) {
			oLink.onmouseover = overDrop;
			oLink.onmouseout = outDrop;
		}
	}
}



/*DK*/
function lightMenu ( img ){		
	//oLink.childNodes[ 0 ].src = "2006/images/menu/"+ img + "_hover.gif"
	document.getElementById(img).src = "http://www.tivoli.dk/2006/images/menu/" + img + "_hover.gif"
}
function closeMenu ( img ){			
	document.getElementById( img ).src = "http://www.tivoli.dk/2006/images/menu/" + img + ".gif"
	for(var i = 1; i < 10; i++){
		if($("eval('topLink' + i)").className == 'topSelected'){
			$( "eval('top_' + i)").src = "http://www.tivoli.dk/2006/images/menu/" + "top_" + i + "_hover.gif";
		}
	}
}
var oPath = '/2006/images/menu/';

function setTop() {

	for(var i=1; i < 10; i++){
		if($("eval('topLink' + i)").className == 'topSelected'){
			$("eval('top_' + i)").src = oPath + 'top_' + i + '_hover.gif';
		}
	}


}

/**********************************************************************************/

/*UK*******************************************************************************/
function lightMenuUK ( img ){		
	//oLink.childNodes[ 0 ].src = "2006/images/menu/"+ img + "_hover.gif"
	document.getElementById( img ).src = "http://www.tivoli.dk/2006/images/menu/" + img + "_hover.gif"
}
function closeMenuUK ( img ){			
	document.getElementById( img ).src = "/2006/images/menu/" + img + ".gif"
	for(var i = 1; i < 10; i++){
		if($("eval('topLink' + i)").className == 'topSelected'){
			$( "eval('top_' + i)").src = "/2006/images/menu/" + "UK_top_" + i + "_hover.gif";
		}
	}
}
var oPath = '/2006/images/menu/';
	function setTopUK(){
	for(var i=1; i < 10; i++){
		if($("eval('topLink' + i)").className == 'topSelected'){
			$("eval('UK_top_' + i)").src = oPath + 'UK_top_' + i + '_hover.gif';
		}
	}

	}
/**********************************************************************************/

/***Tivoliartists***
/*UK*******************************************************************************/
function lightMenu_tam ( img ){		
	//oLink.childNodes[ 0 ].src = "2006/images/menu/"+ img + "_hover.gif"
	document.getElementById( img ).src = "/2006/images/menu/tam_" + img + "_hover.gif"
}
function closeMenu_tam ( img ){			
	document.getElementById( img ).src = "/2006/images/menu/tam_" + img + ".gif"
	for(var i = 1; i < 10; i++){
		if(document.getElementById('topLink' + i).className == 'topSelected'){
			document.getElementById( 'tam_top_' + i ).src = "/2006/images/menu/" + "tam_top_" + i + "_hover.gif";
		}
	}
}
var oPath = '/2006/images/menu/';
	function setTop_tam(){
		for(var i=1; i < 10; i++){
			if(document.getElementById('topLink' + i).className == 'topSelected'){
				document.getElementById('tam_top_' + i).src = oPath + 'tam_top_' + i + '_hover.gif';
			}
		}
	}
/**********************************************************************************/

/***Tivoliartists***
/*UK*******************************************************************************/
function lightMenu_virk ( img ){		
	//oLink.childNodes[ 0 ].src = "2006/images/menu/"+ img + "_hover.gif"
	document.getElementById( img ).src = "/2006/images/menu/virk_" + img + "_hover.gif"
}
function closeMenu_virk ( img ){			
	document.getElementById( img ).src = "/2006/images/menu/virk_" + img + ".gif"
	for(var i = 1; i < 10; i++){
		if(document.getElementById('topLink' + i).className == 'topSelected'){
			document.getElementById( 'virk_top_' + i ).src = "/2006/images/menu/" + "virk_top_" + i + "_hover.gif";
		}
	}
}
var oPath = '/2006/images/menu/';
	function setTop_virk(){
		for(var i=1; i < 10; i++){
			if(document.getElementById('topLink' + i).className == 'topSelected'){
				document.getElementById('virk_top_' + i).src = oPath + 'virk_top_' + i + '_hover.gif';
			}
		}
	}
/**********************************************************************************/




/*DROPDOWN MENU*/	
oDiv = null
timer = null
delayTime = 500

function show(menuDiv) {

	objRef(menuDiv).style.display = "block"
	
	if(timer) clearTimeout(timer)
	if(menuDiv != oDiv) {
		if(oDiv){objRef(oDiv).style.display = "none"}
		 oDiv = menuDiv
	}
}

function hide(navn) {
	n_navn = navn
	timer = setTimeout('objRef(n_navn).style.display = "none"',delayTime)
}

function objRef(mitid) {
	if(document.getElementById)	return document.getElementById(mitid)
	else if(document.all) return document.all[mitid]
}
	

/*NYHEDSBREV FORM*/
function validateMail() {
	var a =''
	var email = document.forms['gb_form'].email.value

	if (email.indexOf("@") == -1 || email.indexOf(".") == -1 || email == "Email") a = 'Email feltet er ikke udfyldt korrekt';
	if ( a != '' ){ 
		alert ( a );
		return false;
	}else{ 
		document.forms['gb_form'].submit();
	}
}
function clearName(){
	oForm = document.forms['gb_form'] 
	if(oForm.navn.value == 'Navn'){
		oForm.navn.value = ""
	}
}
function clearEmail(){
	oForm = document.forms['gb_form'] 
	if(oForm.email.value == 'Email'){
		oForm.email.value = ""
	}
}
	
/*MOUSEOVER P� FLAG*/	
var imgPath = "/2006/images/basic/"	
function lightFlag( flagId ){
	document.getElementById( flagId ).src = imgPath + "flag_" + flagId + "_on.gif"
}

function closeFlag( flagId ){
	document.getElementById( flagId ).src = imgPath + "flag_" + flagId + "_off.gif"
}

//KALENDER
			
function ViewCrossReference (selSelectObject){
	if (selSelectObject.options[selSelectObject.selectedIndex].value != ""){ 
		location.href=selSelectObject.options[selSelectObject.selectedIndex].value
	}
}

//Extranet check
			
function getArgs(){	
	var args = new Object(); 
	var query = location.search.substring(1); 
	var pairs = query.split("&"); 
	for (i=0;i<pairs.length;i++){ 
		var pos = pairs[i].indexOf('='); 
		if (pos == -1) continue; 
		var argname = pairs[i].substring(0,pos); 
		var value = pairs[i].substring(pos+1); 
		args[argname] = unescape(value); 
	} 
	return args;	
} 




function showMore(oDiv){
 		var o =  document.getElementById( oDiv )
 		var oControl =  document.getElementById( 'advancedLink' )
		if ( o.style.display == 'none' || o.style.display == '' ) { 
		  o.style.display = 'block'
		  oControl.style.background = 'url(images/basic/minus.gif) transparent no-repeat 0 2px;'
		 //oControl.className = 'selected'
		}else{ 
		  o.style.display = 'none'
		  oControl.style.background = 'url(images/basic/plus.gif) transparent no-repeat 0 2px;' 
		 }
		}
		

function testScroll(){
	if(window.screen.width == 800){
		document.getElementById('bodyContainer').style.width = 770 + 'px'
	}
}

	
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// UTF8 functions
// http://ecmanaut.blogspot.com/2006/07/encoding-decoding-utf8-in-javascript.html
function encode_utf8( s )
{
  return unescape( encodeURIComponent( s ) );
}

function decode_utf8( s )
{
  return decodeURIComponent( escape( s ) );
}

function replaceSpecialChars(s) {
	
	return s;
}


