/* all-head.js start */
 /* global.js */ 
var webPath         = 'itf499';
var webGraphicsPath = '/spc/homepage.nsf/web/';
var webDbPath       = '/spc/homepage.nsf';
var webHelpPath     = '/itf499/cod/codhelp.nsf';

var maxMenu = 10;
var menuHasSubmenu = Array(maxMenu + 1);
var currentVisibleSubMenuLayer = null;

function getCookie(name)
{ 
    var cookieStr = document.cookie;
    var index = cookieStr.indexOf(name + "=");
    if (index == -1) return null;
    index = cookieStr.indexOf("=", index) + 1;
    var endstr = cookieStr.indexOf(";", index);
    if (endstr == -1) endstr = cookieStr.length; 
    return unescape(cookieStr.substring(index, endstr));
}


// POPUP
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=950,height=800');");
}
// End -->






// script for at fjerne kant ved link
function nokant()
{
   for (a in document.links) document.links[a].onfocus = document.links[a].blur;
}
document.onmousedown = nokant;

// script for link
function loadpage() {
    // Parametre: URL - eks: program.exe
    // Variabel antal parametre, der kommer i sæt af 2
    // eksempel "kundenr","123400"
    // Kaldet ville så være:
    // loadpage("program.exe","kundenr","123400")
    // Og ville medføre skift af sides URL til:
    // program.exe?kundenr=123400
    var theUrl = loadpage.arguments.shift();
    loadpage2(theUrl, loadpage.arguments);
}

function zapPrefix(theString, thePrefix)
{
    if (theString.substring(0, thePrefix.length) == thePrefix) {
	return theString.substring(thePrefix.length);
    } else {
	return theString;
    }
}


function loadpage2(theUrl, params) {
    theUrl = zapPrefix(theUrl, "http://dcsrv02.secure.dancenter.com");
    theUrl = zapPrefix(theUrl, "http://dcsrv02");
//    if (theUrl.substring(0, 5) != "http:") {
//	theUrl = "http://dcsrv02.secure.dancenter.com" + theUrl;
//    }
    if (params.length > 0) {
	theUrl += "?open";
	for (var i = 0; i < params.length; i += 2) {
	    theUrl += '&';
	    theUrl += escape(params[i]) + '=' + escape(params[i+1]);
	};
    };
// EG	alert("Jumps to: " + theUrl);
    document.location = theUrl;
}

function loadtmpl() {
    loadpage2("/servlet/EGGetTemplate", loadtmpl.arguments);
}

function openWindow(URL, height, width)
{
  var pos = URL.length;
  if (URL.substring(pos-5, 5) != '.html' && URL.substring(0, 5) == '/html') {
   URL += '.html';
  }

    var win = window.open(URL, "",
	'width=' + width + ',height=' + height + ','
	+ 'directories=no,status=no,scrollbars=yes,'
	+ 'resizable=no,menubar=no,toolbar=no');
}


function visMulti(hus,width,height) {     
	 urlstr = "http://jjj.dancenter.com/pubweb/printhousepictures?title=Danland&houseid="; 
	 var husstr = ("");
	 husstr = hus;

	multiWindow = openDanWindow( urlstr+husstr, 'dancenter', 'width='+width+',height='+height+',toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1' ); 
	multiWindow.focus();}
	 
	 
function openHelp(doc)
{
    var helpWin = window.open(webHelpPath+'/webpages/'+doc,'HelpWin','toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=1,scrollbars=1,left=1,top=1');
    helpWin.resizeTo(600,400);
}

function showHouse(URL) {
	openWindow(URL, 500, 650);
}

function showHousepic2(URL) {
	openWindow(URL, 230, 380);
}

function dcClickMenu(clickIndex)
{
    dcMouseOverMenu(null, clickIndex);
}

function dcMouseOverMenu(theEvent, clickIndex)
{
    //alert("dcMouseOverMenu(" + document.layers + ": " + theEvent + ", " + clickIndex + ")");
    if (!document.all) {
	//alert("layer: " + theEvent + ", " + document.dcSubMenuLayer2.name);
	if (theEvent && document.dcSubMenuLayer2) {
	    showSubMenuLayer(theEvent, clickIndex);
	} else {
	    hideCurrentSubmenuLayer();
	}
	return;
    }
    var i;
    for (i = 1; i <= maxMenu; i++) {
	if (menuHasSubmenu[i]) {
	    var name = "dcMenuItems" + i;
	    var value = (i == clickIndex) ? "inline" : "none";
	    document.all[name].style.display = value;
	}
    }
}

function hideCurrentSubmenuLayer()
{
    if (currentVisibleSubMenuLayer != null) {
	currentVisibleSubMenuLayer.hidden = true;
	currentVisibleSubMenuLayer = null;
    }
}

function showSubMenuLayer(theEvent, clickIndex)
{
    if (!menuHasSubmenu[clickIndex]) {
	hideCurrentSubmenuLayer();
	return;
    }
    var name = "dcSubMenuLayer" + clickIndex;
    var theLayer = document[name];
    if (theLayer == null) {
	hideCurrentSubmenuLayer();
	return;
    }
    if (theLayer == currentVisibleSubMenuLayer) {
	return; // keep it.
    }
    hideCurrentSubmenuLayer();
    currentVisibleSubMenuLayer = theLayer;
    //alert("showSubMenuLayer(" + name + ")");
    theLayer.bgColor = "#FFFFCC";
    theLayer.pageX = 60; //120;
    theLayer.pageY = theEvent.pageY + 8;
    theLayer.zIndex = 50;
    theLayer.hidden = false;
}

function dcAddSubmenu(nr)
{
    menuHasSubmenu[nr] = 1;
}

function postLoadUpdateMenu(nr)
{
    if (!document.all) {
	return;
    }
    dcMouseOverMenu(null, nr);
    var suffix = (nr == 2) ? "2" : "";
    var name = "dcMenuAktiv" + nr;
    var url = "";
    url += "http://" + document.domain;
    url += "/SPC/Imageres.nsf/.ImagesByKeyAndLanguage/";
    url += "menu_aktiv" + suffix;
    url += "DK/$FILE/menu-aktiv" + suffix + ".gif";
    if (document.all[name] == null) {
	//alert("Mangler <img id=" + name + ">");
    } else {
	document.all[name].src = url;
    }
}

function nytVindue3()
{
    nytVindueKalender();
}

function nytVindueKalender()
{
///alert("nytVindueKalender.0");
    var url = "";
    //url += "http://jjj.dancenter.com/mainweb/calendar";
    url += "/servlet/EGGetTemplate?open&ID=kalender_";
    var lang = getCookie("EGLanguageCookie");
///alert("nytVindueKalender.1: " + lang);
    if (lang == null || lang.length != 2) {
	lang = "DE";
    }
    url += lang.toLowerCase();
    url += "&a=" + (new Date()).getTime();
///alert("prev pop: " + url);
    var si = document.searchForm.HWFRDT.selectedIndex;
///alert("post pop: " + si + " for " + document.searchForm.HWFRDT.selectedIndex);
    if (si > 0) {
	url += "#";
	var dd = document.searchForm.HWFRDT.options[si].value;
	url += "20" + dd.substr(6, 2) + "_" + dd.substr(3, 2);
///alert("with selected date: " + url);
    }
    var w = window.open(url, '', 'toolbar=0,menubar=1,location=0,directories=0,status=1,resizable=1,scrollbars=1,left=1,top=1,width=280,height=400');
    w.myPop = document.searchForm.HWFRDT;
}


function nytVindue4()
{
    nytVindueKalendernumber();
}

function nytVindueKalendernumber()
{
    var url = "";
    //url += "http://jjj.dancenter.com/mainweb/calendar";
    url += "/servlet/EGGetTemplate?open&ID=kalender_";
    var lang = getCookie("EGLanguageCookie");
    if (lang == null || lang.length != 2) {
	lang = "DE";
    }
    url += lang.toLowerCase();
    url += "&a=" + (new Date()).getTime();
    var si = document.searchForm.HWFRDT.selectedIndex;
    if (si > 0) {
	url += "#";
	var dd = document.searchForm.HWFRDT.options[si].value;
	url += "20" + dd.substr(6, 2) + "_" + dd.substr(3, 2);
    }
    var w = window.open(url, '', 'toolbar=0,menubar=1,location=0,directories=0,status=1,resizable=1,scrollbars=1,left=1,top=1,width=280,height=400');
    w.myPop = document.searchForm.HWFRDT;
}

function popChooseDate(cYear, cMonth, cDay)
{
    if (cMonth.length < 2) {
	cMonth = "0" + cMonth;
    }
    if (cDay.length < 2) {
	cDay = "0" + cDay;
    }
    var sic = cDay + "." + cMonth + "." + cYear.substr(2, 2);
    var myPop = window.myPop;
    //alert("Tries to find " + sic);
    if (myPop == null && window.opener) {
	if (window.opener.searchForm) {
	    myPop = window.opener.searchForm.HWFRDT;
	} else if (window.opener.searchForm) {
	    myPop = window.opener.searchForm.HWFRDT;
	}
    }
    if (myPop == null) {
	alert("Sorry, is missing reference to select box");
	return;
    }
    var opts = myPop.options;
    var i;
    for (i = 1; i < opts.length; i++) {
	var v = opts[i].value;
	if (v.length < 8) {
	    continue;
	}
	if (v == sic) {
	    opts[i].selected = true;
	    window.close();
	    return;
	}
    }
    alert("Kan ikke justere tidspunkt menuen - du må vælge direkte fra den.");
}

function wwsog8ra(dummy, isUnload)
{
}


function makeHousecubeIFrame(language, extras) {
	var url = "http://housecube.dancenter.com/housecube/searchHouse.kodefabrikken";
	url += "?language=" + language ;
	var m = document.URL.match(/\?(.+)/);
	if (m) {
		var args = m[1].split("&");
		for (var i = 0; i < args.length; i++) {
			m = args[i].match(/^hc-(.+)/i) || args[i].match(/^((ag|agnet|sr)=.+)$/);
			if (m) {
				url += "&" + m[1];
				extras = "";
			}
		}
	}
	url += extras || "";
	var f = '<iframe src="' + url + '" name="booking" id="booking" ' +
		'width="974" height="580"  align="left" ' +
		'scrolling="no" frameborder="0"></iframe>';
	document.write(f);
}

 /* popupvindue.js */ 

/* all-head.js end */
