var styleTargetObject = null; var styleDivShim = getStyleObject('DivShim'); var PeriodStart = "11-03-2010"; var PeriodEnd = "08-01-2011"; var sCalendar = null; var LastStartDate = TB_startdate.value; var IsIE = false; var aMatches = window.navigator.userAgent.match( /MSIE ([\d]+\.[\d]+)/ ); if( aMatches != null ) if( parseFloat( aMatches[ 1 ] ) >= 5 ) IsIE = true; function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } function addUnLoadEvent(func) { var oldonload = window.onunload; if (typeof window.onunload != 'function') { window.onunload = func; } else { window.onunload = function() { if (oldonload) { oldonload(); } func(); } } } // initialize hacks whenever the page loads //window.onload = initializeHacks; addLoadEvent(initializeHacks); addUnLoadEvent(initializeHacks); // setup an event handler to hide popups for generic clicks on the document document.onclick = hidePopup; function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; } function getStyleObject(objectId) { if(document.getElementById && document.getElementById(objectId)) { // W3C DOM return document.getElementById(objectId).style; } else if (document.all && document.all(objectId)) { // MSIE 4 DOM return document.all(objectId).style; } else if (document.layers && document.layers[objectId]) { // NN 4 DOM.. note: this won't find nested layers return document.layers[objectId]; } else { return false; } } function showPopup (targetObjectId, eventObj) { if(!styleTargetObject) styleTargetObject = getStyleObject(targetObjectId); if(eventObj && styleTargetObject && styleDivShim) { //!!TTO: append calendarstring og seasonstartdate. if(document.getElementById(targetObjectId + '_vacant') != null && document.getElementById(targetObjectId + '_startdate') != null) {sCalendar = "&cs=" + document.getElementById(targetObjectId + '_startdate').innerHTML + "&cv=" + document.getElementById(targetObjectId + '_vacant').innerHTML;} else{sCalendar ="";} doCal('show'); // Asyn eventObj.cancelBubble = true;// stop event from bubbling up any farther var newXCoordinate = findPosX(document.getElementById('Image_startdate')); var newYCoordinate = findPosY(document.getElementById('Image_startdate')); styleTargetObject.left = newXCoordinate +"px"; styleTargetObject.top = newYCoordinate +"px"; styleTargetObject.position = 'absolute'; if(IsIE) { // IE5 Placer Iframe bagved layer styleTargetObject styleTargetObject.width = 200; // Ugenumre så størrelse er 200 styleDivShim.position = styleTargetObject.position; styleDivShim.width = styleTargetObject.width; styleDivShim.left = newXCoordinate +"px"; styleDivShim.top = newYCoordinate +"px"; styleDivShim.zIndex = styleTargetObject.zIndex-1; styleDivShim.display = styleTargetObject.display; } } else { return false; } } function hidePopup() { if(styleTargetObject) { styleTargetObject.display='none'; if(IsIE) styleDivShim.display = styleTargetObject.display; } } function initializeHacks() { // this ugly little hack resizes a blank div to make sure you can click // anywhere in the window for Mac MSIE 5 if ((navigator.appVersion.indexOf('MSIE 5') != -1) && (navigator.platform.indexOf('Mac') != -1) && getStyleObject('blankDiv')) { window.onresize = explorerMacResizeFix; } resizeBlankDiv(); // this next function creates a placeholder object for older browsers if (!window.event) window.event = false; } function resizeBlankDiv() { // resize blank placeholder div so IE 5 on mac will get all clicks in window if ((navigator.appVersion.indexOf('MSIE 5') != -1) && (navigator.platform.indexOf('Mac') != -1) && getStyleObject('blankDiv')) { getStyleObject('blankDiv').width = document.body.clientWidth - 20; getStyleObject('blankDiv').height = document.body.clientHeight - 20; } } function explorerMacResizeFix () { location.reload(false); } function writeit(text,id) { var x = null; if (document.getElementById) { // Netscape 6, Explorer 5 x = document.getElementById(id); if(x) { x.innerHTML = ''; x.innerHTML = text; } } else if (document.all) { // IE4 DOM x = document.all[id]; if(x) x.innerHTML = text; } } function doCal(func, parms) { var httpRequest; if (window.XMLHttpRequest) { // Mozilla, Safari, ... httpRequest = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!httpRequest) { return false; } httpRequest.onreadystatechange = function() { responseCal(func,httpRequest); }; httpRequest.open("GET", "/temasite/Calendar.aspx?f="+ func +"&p="+ LastStartDate +":"+ parms +"&sd=" + TB_startdate.value +"&ps=" + PeriodStart +"&pe=" + PeriodEnd + sCalendar, true); httpRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); httpRequest.send(null); } function responseCal(func,httpRequest) { if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { var Data = eval('(' + httpRequest.responseText + ')'); LastStartDate = Data.calendar[0].startdate; writeit(Data.calendar[0].html,"docCal"); // JSON styleTargetObject.display = 'block'; if(IsIE) styleDivShim.display = styleTargetObject.display; if(func=='day') { TB_startdate.value = Data.calendar[0].startdate; if(TB_startdate.onchange) TB_startdate.onchange(); hidePopup(); } } else { alert('Fejl:'+ httpRequest.status); } } }