﻿function rawurlencode (str) {
    // URL-encodes string  
    // 
    // version: 1003.2411
    // discuss at: http://phpjs.org/functions/rawurlencode    // +   original by: Brett Zamir (http://brett-zamir.me)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Michael Grier    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
    // +      input by: Ratheous
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Joris
    // +      reimplemented by: Brett Zamir (http://brett-zamir.me)    // %          note 1: This reflects PHP 5.3/6.0+ behavior
    // %        note 2: Please be aware that this function expects to encode into UTF-8 encoded strings, as found on
    // %        note 2: pages served as UTF-8
    // *     example 1: rawurlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin%20van%20Zonneveld%21'    // *     example 2: rawurlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: rawurlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
    str = (str+'').toString(); 
    // Tilde should be allowed unescaped in future versions of PHP (as reflected below), but if you want to reflect current
    // PHP behavior, you would need to add ".replace(/~/g, '%7E');" to the following.
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A');
}

if (typeof(STHL) == "undefined"){ STHL={}; }

STHL.PageFeatures = {
  recommendToFriendPopup:function(url) {
    url = rawurlencode(url); 
    window.open('/Admin/Public/SendToFriend.aspx?M=SendFriend&url='+url+'&amp;lid=3', 'sendfriend', 'width=322,height=250');
  }
};

STHL.OnlineBooking = {
  loadAccountLoginWindow:function(baseURL, areaID, lang) {
    topids = new Array();

    // da-DK
    topids[181] = '55896'; // Grønhøj
    topids[184] = '56019'; // Kattegat
    topids[174] = '56142'; // SeaWest
    topids[187] = '55773'; // Øer
    topids[190] = '55035'; // Marina Fiskenæs
    topids[193] = '54543'; // Rønbjerg
    topids[198] = '54666'; // Rømø
    // en-GB
    topids[76] = '55896'; // Grønhøj
    topids[82] = '56019'; // Kattegat
    topids[100] = '56142'; // SeaWest
    topids[146] = '55773'; // Øer
    topids[167] = '55035'; // Marina Fiskenæs
    topids[169] = '54543'; // Rønbjerg
    topids[199] = '54666'; // Rømø
    // de-DE
    topids[75] = '55896'; // Grønhøj
    topids[81] = '56019'; // Kattegat
    topids[99] = '56142'; // SeaWest
    topids[147] = '55773'; // Øer
    topids[166] = '55035'; // Marina Fiskenæs
    topids[195] = '54543'; // Rønbjerg
    topids[200] = '54666'; // Rømø

    var url = "http://booking.dayz.dk/OwnerLogin/OwnerLoginStart.aspx";

    if (lang == 'en-GB') {
      url += '?lang=en';
    }
    else if (lang == 'de-DE') {
      url += '?lang=de';
    }
    else {
      url += '?lang=da';
    }

    if (topids[areaID] != undefined && topids[areaID] != '') {
      url += '&hotelid='+topids[areaID];
    }

    document.location = url;
    return;
  },

  
  loadBookingWindow:function(baseURL, frm, areaID, lang) {
    topids = new Array();

    // da-DK
    topids[181] = '55896'; // Grønhøj
    topids[184] = '56019'; // Kattegat
    topids[174] = '56142'; // SeaWest
    topids[187] = '55773'; // Øer
    topids[190] = '55035'; // Marina Fiskenæs
    topids[193] = '54543'; // Rønbjerg
    topids[198] = '54666'; // Rømø
    // en-GB
    topids[76] = '55896'; // Grønhøj
    topids[82] = '56019'; // Kattegat
    topids[100] = '56142'; // SeaWest
    topids[146] = '55773'; // Øer
    topids[167] = '55035'; // Marina Fiskenæs
    topids[169] = '54543'; // Rønbjerg
    topids[199] = '54666'; // Rømø
    // de-DE
    topids[75] = '55896'; // Grønhøj
    topids[81] = '56019'; // Kattegat
    topids[99] = '56142'; // SeaWest
    topids[147] = '55773'; // Øer
    topids[166] = '55035'; // Marina Fiskenæs
    topids[195] = '54543'; // Rønbjerg
    topids[200] = '54666'; // Rømø

    var url = "http://booking.dayz.dk/domino.aspx" ;

    if (lang == 'en-GB') {
      url += '?lang=en';
    }
    else if (lang == 'de-DE') {
      url += '?lang=de';
    }
    else {
      url += '?lang=da';
    }
    
    url += '&hotelid=56142';

    var arrival = new Date(parseInt(frm.year.value), (parseInt(frm.month.value)-1), parseInt(frm.day.value));
    
    var departure = new Date(parseInt(frm.year.value), (parseInt(frm.month.value)-1), (parseInt(frm.day.value)+parseInt(frm.nights.value)));

    var arrivalYear = frm.year.value;
    var arrivalMonth = (frm.month.value.length == 1) ? '0'+frm.month.value : frm.month.value;
    var arrivalDay = (frm.day.value.length == 1) ? '0'+frm.day.value : frm.day.value;
    
    var departureYear = departure.getFullYear()+'';
    var departureMonth = (departure.getMonth()+1)+'';
    var departureDay = departure.getDate()+'';
    
    var departureMonth = (departureMonth.length == 1) ? '0'+departureMonth : departureMonth;
    var departureDay = (departureDay.length == 1) ? '0'+departureDay : departureDay;
    
    url += '&p_pax='+frm.adults.value+"_"+frm.children.value+"_"+frm.babies.value;
    url += '&p_arr='+arrivalYear+arrivalMonth+arrivalDay+'_0000';
    url += '&p_dep='+departureYear+departureMonth+departureDay+'_0000';

    if (topids[areaID] != undefined && topids[areaID] != '') {
      url += '&p_hotel='+topids[areaID];
    }
    else
    {
      url += '&p_hotel=0';
    }
    
    url += "&p_domino=157";

    document.location = url;
    return;
  },
  
  setValidDate:function() {
    var years = new Array();
  
    years['2012'] = 0;
    years['2013'] = 1;
    years['2014'] = 2;
    years['2015'] = 3;
  
    var now = new Date();
    
    var tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate()+1);
  
    var month = tomorrow.getMonth();
    var date  = tomorrow.getDate()-1;
    var year  = tomorrow.getFullYear();

    year = years[year];
  
    document.getElementById("booking:month").options[month].selected = true;
    document.getElementById("booking:date").options[date].selected   = true;
    document.getElementById("booking:year").options[year].selected   = true;
  }
};
