var styleTargetObject = null; var styleDivShim = getStyleObject('DivShim'); var PeriodStart = "12-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, controlId, clickObjId, calendarId, secControlId) { if(!styleTargetObject) styleTargetObject = getStyleObject(targetObjectId); if(eventObj && styleTargetObject && styleDivShim) { //!!TTO: append calendarstring, seasonstartdate, calendartype og secControlId. if(document.getElementById(calendarId + '_vacant') != null && document.getElementById(calendarId + '_startdate') != null) {sCalendar = "&cs=" + document.getElementById(calendarId + '_startdate').innerHTML + "&cv=" + document.getElementById(calendarId + '_vacant').innerHTML;} else{sCalendar ="";} if(document.getElementById(calendarId + '_calendartype') != null){sCalendar += "&ct=" + document.getElementById(calendarId + '_calendartype').innerHTML;} if(document.getElementById(secControlId).value != ""){sCalendar += "&csoc=" + document.getElementById(secControlId).value;} //overskrivning startdate TB_startdate = document.getElementById(controlId); if( TB_startdate.value == "" ) { if( document.getElementById(secControlId).value != "" ) { TB_startdate.value = document.getElementById(secControlId).value; } } LastStartDate = TB_startdate.value; doCal('show'); // Asyn eventObj.cancelBubble = true;// stop event from bubbling up any farther var newXCoordinate = findPosX(document.getElementById(clickObjId)); var newYCoordinate = findPosY(document.getElementById(clickObjId)); 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) { if (document.getElementById) { // Netscape 6, Explorer 5 var x = document.getElementById(id); x.innerHTML = ''; x.innerHTML = text; } else if (document.all) { // IE4 DOM x = document.all[id]; x.innerHTML = text; } } function doCal(func, parms) { var httpRequest; var targetObjectId = "docCal"; 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,targetObjectId,httpRequest); }; httpRequest.open("GET", "/temasite/HouseCalendar.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, targetObjectId, httpRequest) { if (httpRequest.readyState == 4) { if (httpRequest.status == 200) { var Data = eval('(' + httpRequest.responseText + ')'); LastStartDate = Data.calendar[0].startdate; writeit(Data.calendar[0].html,targetObjectId); // 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); } } } //********************** indflytning / afrejse *************************************************** function validateCalenderDate(pStartdate, pEnddate, pCanceldate) { // parameter datatype - valid dato format skal være yyyy/MM/dd // pStartdate (string) // pEnddate (string) // pCanceldate (string) // statuskoder // 0 = alt OK // 1 = startdate tom // 2 = enddate tom // 3 = enddate = startdate // 4 = enddate > startdate // 5 = periode kortere en 2 dage // 6 = periode længere end 28 dage // 7 = startdate større end canceldate // 8 = enddate større end canceldate var status = 0; var numofdays = null; if(pStartdate == "") { status = 1; } else if(pEnddate == "") { status = 2; } else { var dtStartdate = new Date(convertDateString(pStartdate)); var dtEnddate = new Date(convertDateString(pEnddate)); numofdays = calculateDateDiff(dtStartdate, dtEnddate); if(numofdays == 0) { status = 3; } else if(numofdays < 0) { status = 4; } else if(numofdays < 2) { status = 5; } else if(numofdays > 28) { status = 6; } else if(pCanceldate != "") { var dtCanceldate = new Date(convertDateString(pCanceldate)); if(dtStartdate > dtCanceldate ) { status = 7; } else if(dtEnddate > dtCanceldate) { status = 8; } } } return status; } function convertDateString(date) { // konverterer dato fra dd-MM-yyyy til yyyy/MM/dd var sSplit = date.split("-"); var sResult = sSplit[2] + "/" + sSplit[1] + "/" + sSplit[0]; return sResult; } function calculateDateDiff(pStartdate, pEnddate) { //returnerer antallet af dage // parametre skal være date objekter. diff = new Date(); diff.setTime(Math.abs(pStartdate.getTime() - pEnddate.getTime())); days = Math.floor(diff.getTime() / (1000 * 60 * 60 * 24)); if(pEnddate < pStartdate) { days = days * -1; } return days; } function translateErrMsg(errorcode, language) { //status beskeder hentes fra control.config. Language parameter bruges ikke. var sResult = ""; if(errorcode == 1) {sResult = "Kies van 2 tot 28 overnachtingen";} else if(errorcode == 2) {sResult = "Kies van 2 tot 28 overnachtingen";} else if(errorcode == 3) {sResult = "Kies van 2 tot 28 overnachtingen";} else if(errorcode == 4) {sResult = "Kies van 2 tot 28 overnachtingen";} else if(errorcode == 5) {sResult = "Kies van 2 tot 28 overnachtingen";} else if(errorcode == 6) {sResult = "Kies van 2 tot 28 overnachtingen";} else if(errorcode == 7) {sResult = "Vakantiewonig kan niet geboekt worden in de gekozen periode. Kies een nieuwe periode.";} else if(errorcode == 8) {sResult = "Vakantiewonig kan niet geboekt worden in de gekozen periode. Kies een nieuwe periode.";} return sResult; } //*********************** indflytning / afrejse ******************************************