function printPage() {
    window.print();
}

// Val - string to be paded
// ch - padding character
// num - number of characters for padding
function padLeft(val, ch, num) {
    if (val == '') { return '' }
    var re = new RegExp(".{" + num + "}$");
    var pad = "";
    do {
        pad += ch;
    }
    while (pad.length < num)

    return re.exec(pad + val);
}

// Itemize characters to remove
function cleanString(str) {
    return str.replace(/[\(\)\.\-\s,]/g, "");
}
// Remove all non-digits
function cleanString(str) {
    return str.replace(/[^\d]/g, "");
}

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/^\s+/g, "");
}
String.prototype.rtrim = function () {
    return this.replace(/\s+$/g, "");
}

function insertNthChar(string, chr, nth) {
    var output = '';
    for (var i = 0; i < string.length; i++) {
        if (i > 0 && i % 4 == 0)
            output += chr;
        output += string.charAt(i);
    }
    return output;
}

function testCreditCard() {
    myCardNo = document.getElementById('<%= CreditcardNumberClientID %>').value;
    myCardType = '<%=CreditCardType %>';
    if (checkCreditCard(myCardNo, myCardType)) {
        alert("Credit card has a valid format")
    }
    else {
        alert(ccErrors[ccErrorNo]);
        return false; // should uncomment this for real site, commented for testing purposes
    };
}

function LaunchWindow(vAction) {
    remotewin = window.open('http://www.abc.com/index.cfm?fuseaction=' + vAction, 'remotewin', 'width=245,height=190,resizable=0,scrollbars=0,top=200,left=200');
    if (remotewin != null) {
        if (remotewin.opener == null) {
            remotewin.opener = self;
        }
    }
}

// Code for docked ajax progress
var offsetfromedge = 0      //offset from window edge when content is "docked". Change if desired.
var dockarray = new Array() //array to cache dockit instances
var dkclear = new Array()   //array to cache corresponding clearinterval pointers

function dockit(el, duration) {
    this.source = document.all ? document.all[el] : document.getElementById(el);
    this.source.height = this.source.offsetHeight;
    this.docheight = truebody().clientHeight;
    this.duration = duration;
    this.pagetop = 0;
    this.elementoffset = this.getOffsetY();
    dockarray[dockarray.length] = this;
    var pointer = eval(dockarray.length - 1);
    var dynexpress = 'dkclear[' + pointer + ']=setInterval("dockornot(dockarray[' + pointer + '])",100);';
    dynexpress = (this.duration > 0) ? dynexpress + 'setTimeout("clearInterval(dkclear[' + pointer + ']); dockarray[' + pointer + '].source.style.top=0", duration*1000)' : dynexpress;
    eval(dynexpress);
}

dockit.prototype.getOffsetY = function () {
    var totaloffset = parseInt(this.source.offsetTop);
    var parentEl = this.source.offsetParent;
    while (parentEl != null) {
        totaloffset += parentEl.offsetTop;
        parentEl = parentEl.offsetParent;
    }
    return totaloffset;
}

function dockornot(obj) {
    obj.pagetop = truebody().scrollTop;
    if (obj.pagetop > obj.elementoffset) //detect upper offset
        obj.source.style.top = obj.pagetop - obj.elementoffset + offsetfromedge + "px";
    else if (obj.pagetop + obj.docheight < obj.elementoffset + parseInt(obj.source.height)) //lower offset
        obj.source.style.top = obj.pagetop + obj.docheight - obj.source.height - obj.elementoffset - offsetfromedge + "px";
    else
        obj.source.style.top = 0;
}

function truebody() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body
}

// setting up Creuna namespaces
if (typeof Creuna == "undefined") {
    var Creuna = {};
}

if (typeof Creuna.Events == "undefined") {
    Creuna.Events = {};
}

Creuna.Events =
{
    addListener: function (obj, name, callback) {
        if (typeof obj.addEventListener != "undefined") {
            obj.addEventListener(name, callback, false);
        }
        else if (typeof window.attachEvent != "undefined") {
            obj.attachEvent("on" + name, callback);
        }
        else {
            var prop = "on" + name;
            var old = obj[prop];
            if (typeof obj[prop] != "function") {
                obj[prop] = callback;
            }
            else {
                obj[prop] = function () { old(); callback(); }
            }
        }
    }
}

if (typeof Creuna.Vacasol == "undefined") {
    Creuna.Vacasol = {};
}

// defining the Stats namespace
Creuna.Vacasol.Stats =
{
    // add triggerSearchFilter function to ajax post-back event handler
    initialize: function () {
        var requestManager = Sys.WebForms.PageRequestManager.getInstance();
        requestManager.add_initializeRequest(Creuna.Vacasol.Stats.triggerSearchFilter);
        //requestManager.add_endRequest(...?);
    },

    // Sends a request to google analytics indicating what filter function was used (in post back): /filter/search/[function]-[value]
    // Note: [function] can be the name of a function, or a control GUID combinded with the html label of the control (language versioned)
    //       [value] can be the selected value, or the GUID value combined with the current browser text selected (language versioned)
    triggerSearchFilter: function (sender, args) {
        // check for globally defined Google Analytics "pageTracker" variable
        if (typeof (pageTracker) == "undefined" || !pageTracker._trackPageview) {
            return false;
        }

        // get event-triggering element
        var element = args.get_postBackElement();

        if (element.nodeName != "INPUT" && element.nodeName != "SELECT") {
            // we're only interested in handling <input type="checkbox"> and <select>-boxes
            // (not <a> post-backs for instance)
            return false;
        }

        // define a few helper functions
        var helper =
	    {
	        // return the innerHTML of the <label> element that corresponds to the element provided
	        getLabel: function (element) {
	            if (!element.id) {
	                return;
	            }

	            var labelTags = document.getElementsByTagName("LABEL");
	            for (var i = 0; i < labelTags.length; i++) {
	                var names = [];
	                for (var n in labelTags[i])
	                    names.push(n);
	                names.sort();
	                var htmlForId = (labelTags[i].htmlFor ? labelTags[i].htmlFor : labelTags[i].getAttribute("for"));
	                if (htmlForId == element.id) {
	                    return labelTags[i].innerHTML;
	                }
	            }
	        },

	        // get last (semi-unique) section of a GUID (separated by -)
	        getShortGuid: function (guid) {
	            var parts = (new String(guid)).split("-");
	            return parts[parts.length - 1];
	        },

	        // get the last part of an id (separated by _)
	        getControlId: function (dotNetId) {
	            var parts = (new String(dotNetId)).split("_");
	            return parts[parts.length - 1];
	        }
	    }

        // collect stats info:
        //     map .net user control ID (or part of it, or GUID) 
        //     to something that can be understood and not be language dependant
        var filterFunctions =
	    {
	        /*		    "ddlCountry": "country",
	        "ddlRegion": "region",
	        "ddlSubRegion": "subRegion",*/
	        "ddlDaysToStay": "daysToStay",
	        "ddlNumOfPersons": "numberOfPersons",
	        "dtArrivalDate": "arrivalDate",
	        "ddlNumPrPage": "housesPerPage",
	        "ddlSortOrder": "sortOrder",
	        "ddlSortResults": "sortCriteria"
	    }

        // collect info about the selected control and value
        var label = helper.getLabel(element);
        var guid = helper.getControlId(element.id);
        var id = helper.getShortGuid(guid);
        if (filterFunctions[id]) {
            id = filterFunctions[id];
        }
        else if (label) {
            id += "[" + label + "]";
        }

        // prepare google analytics request (url)
        var text = element.value;
        if (element.type == "checkbox") {
            text = element.checked ? "yes" : "no";
        }
        else if (element.type == "select-one") {
            text = element.options[element.selectedIndex].text;
            text = helper.getShortGuid(element.value) + "[" + text + "]";
        }

        var url = "/filter/search/" + id + "-" + text.replace(/[\/\- ]/g, " ");
        pageTracker._trackPageview(url);
        //alert(url);
    },

    // just a default error handled wrapper for google analytics page hits
    triggerPageView: function (url) {
        // check for globally defined Google Analytics "pageTracker" variable
        if (typeof (pageTracker) == "undefined" || !pageTracker._trackPageview) {
            return false;
        }

        pageTracker._trackPageview(url);
    }
}

/* used on the object details page, to show/hide longer descriptions */
var objectDetailsToggleReadMoreShowHide = 'hide';
function objectDetailsToggleReadMore() {
    var readMoreLink = document.getElementById('readMoreLink');
    var readMoreFullText = document.getElementById('readMoreFullText');
    if (objectDetailsToggleReadMoreShowHide == 'hide') {
        objectDetailsToggleReadMoreShowHide = 'show';
        readMoreLink.style.display = 'none';
        readMoreFullText.style.display = 'inline';
    }
    else {
        objectDetailsToggleReadMoreShowHide = 'hide';
        readMoreLink.style.display = 'inline';
        readMoreFullText.style.display = 'none';
    }

    return false;
}

// NOTE: onRegionRequest moved to Default_v2.aspx


function str_replace(search, replace, subject) {
    var f = search, r = replace, s = subject;
    var ra = r instanceof Array, sa = s instanceof Array, f = [].concat(f), r = [].concat(r), i = (s = [].concat(s)).length;

    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = s[i].split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f) { };
        }
    };

    return sa ? s : s[0];
}

// MoodalBox popup handling
/*
function preparePopupLinks()
{
// add "popup=true" for MOOdalBox links
Window.onDomReady(function()
{
$A($$('a')).each(function(el)
{
// make all target="_blank" links into modal popups
if(el.href && el.target == "_blank")
{
var url = el.href;

// if external url, then use ContentRedirect.aspx to parse contents
if (url.indexOf('http') == 0)
{
url = str_replace('http://', '', url);
url = str_replace('?', '%3F', url);
url = str_replace('/', '%2f', url);
url = "ContentRedirect.aspx?url="+ url;
}

el.href = url;
                
url += (el.href.indexOf("?") == -1 ? "?" : "&")+"popup=true"; // query string handled by standard page template (change of master page)
		  
el.href = url;
		        
el.target = ""; // remove old target; not needed
el.rel = "moodalbox"; // this attirbute is handled by moodalbox.js
}
}, this);
});
}
*/

function configureMoodalBox() {
    var width = 500;
    var height = 300;

    // override moodalbox options
    _RESIZE_DURATION = 0; 		// Duration of height and width resizing (ms)
    _INITIAL_WIDTH = width; 	// Initial width of the box (px)
    _INITIAL_HEIGHT = height; 	// Initial height of the box (px)
    _CONTENTS_WIDTH = width; 	// Actual width of the box (px)
    _CONTENTS_HEIGHT = height; 	// Actual height of the box (px)
    _DEF_CONTENTS_WIDTH = width; 	// Default width of the box (px) - used for resetting when a different setting was used
    _DEF_CONTENTS_HEIGHT = height; 	// Default height of the box (px) - used for resetting when a different setting was used
    _ANIMATE_CAPTION = false; 	// Enable/Disable caption animation
    _EVAL_SCRIPTS = false; // Option to evaluate scripts in the response text
    _EVAL_RESPONSE = false; // Option to evaluate the whole response text

    // hack: override build in opacity of popup background
    eval("MOOdalBox.open = " + MOOdalBox.open.toString().replace(/\(0\.8\)/, "(0.3)"));

    // hack: insert close event handler
    eval("MOOdalBox.close = " + MOOdalBox.close.toString().replace(/{/, "{closePopup();"));
}

// called when moodal popup closes
function closePopup() {
    // reset popup contents (remove inner asp.net form tag, primarily)
    $get("mb_contents").innerHTML = "";
}

/* checks the personal data form on step 2 of the booking flow.
returns true if everything is ok, false otherwise. */
function checkPersonalData() {
    
    var errorBox = document.getElementById("personalDataError");

    var firstName = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtFirstName");
    var lastName = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtLastName");
    var address = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtAddress");
    var zipCode = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtZipCode");
    var city = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtCity");
    var country = document.getElementById("ctl00_cphStageRegion_cphMainRegion_ddlCountry");
    var otherCountry = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtOtherCountry");
    var phone = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtPhone");
    var mobilePhone = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtCellPhone");
    var email = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtEmail");
    var acceptAgreement = document.getElementById("ctl00_cphStageRegion_cphMainRegion_chbAcceptAgreement");
    var personalDataCheckboxes = document.getElementById("personalDataCheckboxes");


    var firstNameError = document.getElementById("firstNameError");
    var lastNameError = document.getElementById("lastNameError");
    var addressError = document.getElementById("addressError");
    var zipCodeError = document.getElementById("zipCodeError");
    var cityError = document.getElementById("cityError");
    var countryError = document.getElementById("countryError");
    var emailError = document.getElementById("emailError");
    var agreementError = document.getElementById("agreementError");
    

    var errorHappened = false;

    firstNameError.style.display = "none";
    lastNameError.style.display = "none";
    addressError.style.display = "none";
    zipCodeError.style.display = "none";
    cityError.style.display = "none";
    countryError.style.display = "none";
    emailError.style.display = "none";
    agreementError.style.display = "none";

    firstName.className = "";
    lastName.className = "";
    address.className = "";
    zipCode.className = "zipCode";
    city.className = "city";
    country.className = "dropdown";
    otherCountry.className = "";
    phone.className = "";
    mobilePhone.className = "";
    email.className = "";
    acceptAgreement.className = "";

    personalDataCheckboxes.className = "personalData checkboxes";
   
    if (firstName.value == "") {
        errorHappened = true;
        firstNameError.style.display = "list-item";
        firstName.className = "error";
    }

    if (lastName.value == "") {
        errorHappened = true;
        lastNameError.style.display = "list-item";
        lastName.className = "error";
    }

    if (address.value == "") {
        errorHappened = true;
        addressError.style.display = "list-item";
        address.className = "error";
    }

    if (zipCode.value == "") {
        errorHappened = true;
        zipCodeError.style.display = "list-item";
        zipCode.className = "zipCode error";
    }

    if (city.value == "") {
        errorHappened = true;
        cityError.style.display = "list-item";
        city.className = "city error";
    }

    if (country.selectedIndex == 0 && otherCountry.value == "") {
        errorHappened = true;
        countryError.style.display = "list-item";
        country.className = "dropdown error";
    }

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email.value)) {
        errorHappened = true;
        emailError.style.display = "list-item";
        email.className = "error";
    }

    if (!acceptAgreement.checked) {
        errorHappened = true;
        agreementError.style.display = "list-item";
        personalDataCheckboxes.className = "personalData checkboxes error";
    }

    if (errorHappened) {
        errorBox.style.display = "block";
        return false;
    }

    return true;
}

function checkPersonalDatav3() {

    var errorBox = document.getElementById("personalDataError");

    var firstName = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtFirstName");
    var lastName = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtLastName");
    var address = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtAddress");
    var zipCode = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtZipCode");
    var city = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtCity");
    var country = document.getElementById("ctl00_cphStageRegion_cphMainRegion_ddlCountry");
    var otherCountry = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtOtherCountry");
    var phone = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtPhone");
    var mobilePhone = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtCellPhone");
    var email = document.getElementById("ctl00_cphStageRegion_cphMainRegion_txtEmail");
    var acceptAgreement = document.getElementById("ctl00_cphStageRegion_cphMainRegion_chbAcceptAgreement");
    var personalDataCheckboxes = document.getElementById("personalDataCheckboxes");

    //    var paymentType = document.getElementById("ctl00_cphStageRegion_cphMainRegion_ddlPaymentType");


    var firstNameError = document.getElementById("firstNameError");
    var lastNameError = document.getElementById("lastNameError");
    var addressError = document.getElementById("addressError");
    var zipCodeError = document.getElementById("zipCodeError");
    var cityError = document.getElementById("cityError");
    var countryError = document.getElementById("countryError");
    var emailError = document.getElementById("emailError");
    var phoneError = document.getElementById("phoneError");
    var agreementError = document.getElementById("agreementError");
    var paymentTypeError = document.getElementById("paymentTypeError");
    var paymentType = document.getElementById("paymenttableerror");


    var errorHappened = false;

    firstNameError.style.display = "none";
    lastNameError.style.display = "none";
    addressError.style.display = "none";
    zipCodeError.style.display = "none";
    cityError.style.display = "none";
    countryError.style.display = "none";
    phoneError.style.display = "none";
    emailError.style.display = "none";
    agreementError.style.display = "none";
    paymentTypeError.style.display = "none";

    firstName.className = "";
    lastName.className = "";
    address.className = "";
    zipCode.className = "zipCode";
    city.className = "city";
    country.className = "dropdown";
    otherCountry.className = "";
    phone.className = "";
    mobilePhone.className = "";
    email.className = "";
    acceptAgreement.className = "";
    //    paymentType.className = "";

    personalDataCheckboxes.className = "personalData checkboxes";
    if (firstName.value == "") {
        errorHappened = true;
        firstNameError.style.display = "list-item";
        firstName.className = "error";
    }

    if (lastName.value == "") {
        errorHappened = true;
        lastNameError.style.display = "list-item";
        lastName.className = "error";
    }

    if (phone.value == "") {
        errorHappened = true;
        phoneError.style.display = "list-item";
        phone.className = "error";
    }

    if (address.value == "") {
        errorHappened = true;
        addressError.style.display = "list-item";
        address.className = "error";
    }

    if (zipCode.value == "") {
        errorHappened = true;
        zipCodeError.style.display = "list-item";
        zipCode.className = "zipCode error";
    }

    if (city.value == "") {
        errorHappened = true;
        cityError.style.display = "list-item";
        city.className = "city error";
    }

    if (country.selectedIndex == 0 && otherCountry.value == "") {
        errorHappened = true;
        countryError.style.display = "list-item";
        country.className = "dropdown error";
    }

    if (paymentType.selectedIndex == 0) {
        errorHappened = true;
        paymentTypeError.style.display = "list-item";
        paymentType.className = "error";
    }
    var valid = false;
    for (i = 0; i < paymentIdList.length; i++) {

        var checkbox = document.getElementById(paymentIdList[i]);
        if (checkbox != null) {
            if (checkbox.checked == true) {
                valid = true;
                break;
            }
        }

    }
    if (!valid) {
        errorHappened = true;
        paymentTypeError.style.display = "list-item";
        paymentType.className = "errorborder";
    }

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email.value)) {
        errorHappened = true;
        emailError.style.display = "list-item";
        email.className = "error";
    }

    if (!acceptAgreement.checked) {
        errorHappened = true;
        agreementError.style.display = "list-item";
        personalDataCheckboxes.className = "personalData checkboxes error";
    }

    if (errorHappened) {
        errorBox.style.display = "block";
        return false;
    }

    return true;
}

function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}
function firefoxDefaultButtonFix() {
    aList = document.getElementsByTagName("a");

    for (var i = 0; i < aList.length; i++) {
        try {
            var anchor = aList[i];
            if (anchor && anchor.id && anchor.id == "")
                continue;

            // define a click function for firefox
            if (typeof (anchor.click) == "undefined") {
                anchor.click = function () {
                    try {
                        this.onclick();
                    }
                    catch (ex) { };
                    eval(this.href.replace("javascript:", ""));

                }
            }
        }
        catch (ex) { }
    }
}

jQuery(function () {

    var readMore = 'Read more';
    var hide = 'Hide';


    // Grab all the excerpt class
    jQuery('.excerpt').each(function () {

        if (typeof (readMoreText) != 'undefined')
            readMore = readMoreText;
        if (typeof (hideText) != 'undefined')
            hide = hideText;

        // Run formatWord function and specify the length of words display to viewer
        jQuery(this).html(formatWords(jQuery(this).html(), 100, readMore));

        // Hide the extra words
        jQuery(this).children('span').hide();
        var more_link_text = jQuery(this).children('span.more_link_text');
        more_link_text.show();
        // Apply click event to read more link
    }).click(function () {

        // Grab the hidden span and anchor
        var more_text = jQuery(this).children('span.more_text');
        var more_link_text = jQuery(this).children('span.more_link_text');
        var more_link = jQuery(this).children('a.more_link');

        // Toggle visibility using hasClass
        // I know you can use is(':visible') but it doesn't work in IE8 somehow...
        if (more_text.hasClass('hide')) {
            more_text.show();
            more_link.html(hide);
            more_link_text.hide();
            more_text.removeClass('hide');
        } else {
            more_text.hide();
            more_link_text.show();
            more_link.html(readMore);
            more_text.addClass('hide');
        }

        return false;

    });
});

// Accept a paragraph and return a formatted paragraph with additional html tags
function formatWords(sentence, show, readMore) {

    // split all the words and store it in an array
    var words = sentence.split(' ');
    var new_sentence = '';

    // loop through each word
    for (i = 0; i < words.length; i++) {

        // process words that will visible to viewer
        if (i <= show) {
            new_sentence += words[i] + ' ';

            // process the rest of the words
        } else {

            // add a span at start
            if (i == (show + 1)) new_sentence += '<span class="more_link_text">... </span><span class="more_text hide">';

            new_sentence += words[i] + ' ';

            // close the span tag and add read more link in the very end
            if (words[i + 1] == null) new_sentence += '</span><a href="#" class="more_link">' + readMore + '</a>';
        }
    }

    return new_sentence;

}



/**
* Feedback Floating Badge
*
* Display a floating Feedback Badge on page
*
* @author Dumitru Glavan
* @link http://dumitruglavan.com
* @version 1.0
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://dumitruglavan.com/jquery-feedback-badge/
* Official jQuery plugin page: http://plugins.jquery.com/project/feedback-badge
* Find source on GitHub: https://github.com/doomhz/jQuery-Feedback-Badge
*
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
*
*/
; (function ($) {
    $.fn.feedbackBadge = function (options) {
        this.config = { css: { 'position': 'absolute', 'float': 'left', 'display': 'none', 'zIndex': '999' }, 'animate': false, 'css3Safe': false, 'float': 'left' }; $.extend(this.config, options); this.config.css.float = this.config.float; this.window = $(window); var self = this; if (this.config.css3Safe) {
            this.badgeHeight = this.height(); this.windowHeight = self.window.height(); this.topDistance = ~ ~(+(this.windowHeight - this.badgeHeight) / 2); this.config.css.position = 'absolute'; if (typeof (this.config.css.marginTop) == 'undefined') { this.config.css.marginTop = this.getTopMiddleDistance(true); }
            if (this.config.animate) { self.window.scroll(function () { self.stop().animate({ 'margin-top': self.getTopMiddleDistance(true) }, 1000); }); } else { self.window.scroll(function () { self.css('margin-top', self.getTopMiddleDistance(true)); }); }
            self.window.resize(function () { self.badgeHeight = self.height(); self.windowHeight = self.window.height(); self.topDistance = ~ ~(+(self.windowHeight - self.badgeHeight) / 2); self.css('margin-top', self.getTopMiddleDistance(true)); });
        } else { this.config.css.position = 'fixed'; if (typeof (this.config.css.top) == 'undefined') { this.config.css.top = this.getTopMiddleDistance(); } }
        if (typeof (this.config.onClick) == 'function') { $(this).bind('click', this.config.onClick); }
        $(this).css(this.config.css).prependTo('body').show(); return this;
    }, $.fn.getTopMiddleDistance = function (inPixels) { if (inPixels) { return (this.topDistance + this.window.scrollTop() + 'px'); } else { var badgeHeightPerc = $(this).height() * 100 / this.window.height(); return ~ ~(+(100 - badgeHeightPerc) / 2) + '%'; } } 
})(jQuery);
/*
 * SimpleModal 1.4.1 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * Copyright (c) 2010 Eric Martin (http://twitter.com/ericmmartin)
 * Dual licensed under the MIT and GPL licenses
 * Revision: $Id: jquery.simplemodal.js 261 2010-11-05 21:16:20Z emartin24 $
 */
(function(d){var k=d.browser.msie&&parseInt(d.browser.version)===6&&typeof window.XMLHttpRequest!=="object",m=d.browser.msie&&parseInt(d.browser.version)===7,l=null,f=[];d.modal=function(a,b){return d.modal.impl.init(a,b)};d.modal.close=function(){d.modal.impl.close()};d.modal.focus=function(a){d.modal.impl.focus(a)};d.modal.setContainerDimensions=function(){d.modal.impl.setContainerDimensions()};d.modal.setPosition=function(){d.modal.impl.setPosition()};d.modal.update=function(a,b){d.modal.impl.update(a,
b)};d.fn.modal=function(a){return d.modal.impl.init(this,a)};d.modal.defaults={appendTo:"body",focus:true,opacity:50,overlayId:"simplemodal-overlay",overlayCss:{},containerId:"simplemodal-container",containerCss:{},dataId:"simplemodal-data",dataCss:{},minHeight:null,minWidth:null,maxHeight:null,maxWidth:null,autoResize:false,autoPosition:true,zIndex:1E3,close:true,closeHTML:'<a class="modalCloseImg" title="Close"></a>',closeClass:"simplemodal-close",escClose:true,overlayClose:false,position:null,
persist:false,modal:true,onOpen:null,onShow:null,onClose:null};d.modal.impl={d:{},init:function(a,b){var c=this;if(c.d.data)return false;l=d.browser.msie&&!d.boxModel;c.o=d.extend({},d.modal.defaults,b);c.zIndex=c.o.zIndex;c.occb=false;if(typeof a==="object"){a=a instanceof jQuery?a:d(a);c.d.placeholder=false;if(a.parent().parent().size()>0){a.before(d("<span></span>").attr("id","simplemodal-placeholder").css({display:"none"}));c.d.placeholder=true;c.display=a.css("display");if(!c.o.persist)c.d.orig=
a.clone(true)}}else if(typeof a==="string"||typeof a==="number")a=d("<div></div>").html(a);else{alert("SimpleModal Error: Unsupported data type: "+typeof a);return c}c.create(a);c.open();d.isFunction(c.o.onShow)&&c.o.onShow.apply(c,[c.d]);return c},create:function(a){var b=this;f=b.getDimensions();if(b.o.modal&&k)b.d.iframe=d('<iframe src="javascript:false;"></iframe>').css(d.extend(b.o.iframeCss,{display:"none",opacity:0,position:"fixed",height:f[0],width:f[1],zIndex:b.o.zIndex,top:0,left:0})).appendTo(b.o.appendTo);
b.d.overlay=d("<div></div>").attr("id",b.o.overlayId).addClass("simplemodal-overlay").css(d.extend(b.o.overlayCss,{display:"none",opacity:b.o.opacity/100,height:b.o.modal?f[0]:0,width:b.o.modal?f[1]:0,position:"fixed",left:0,top:0,zIndex:b.o.zIndex+1})).appendTo(b.o.appendTo);b.d.container=d("<div></div>").attr("id",b.o.containerId).addClass("simplemodal-container").css(d.extend(b.o.containerCss,{display:"none",position:"fixed",zIndex:b.o.zIndex+2})).append(b.o.close&&b.o.closeHTML?d(b.o.closeHTML).addClass(b.o.closeClass):
"").appendTo(b.o.appendTo);b.d.wrap=d("<div></div>").attr("tabIndex",-1).addClass("simplemodal-wrap").css({height:"100%",outline:0,width:"100%"}).appendTo(b.d.container);b.d.data=a.attr("id",a.attr("id")||b.o.dataId).addClass("simplemodal-data").css(d.extend(b.o.dataCss,{display:"none"})).appendTo("body");b.setContainerDimensions();b.d.data.appendTo(b.d.wrap);if(k||l)b.fixIE()},bindEvents:function(){var a=this;d("."+a.o.closeClass).bind("click.simplemodal",function(b){b.preventDefault();a.close()});
a.o.modal&&a.o.close&&a.o.overlayClose&&a.d.overlay.bind("click.simplemodal",function(b){b.preventDefault();a.close()});d(document).bind("keydown.simplemodal",function(b){if(a.o.modal&&b.keyCode===9)a.watchTab(b);else if(a.o.close&&a.o.escClose&&b.keyCode===27){b.preventDefault();a.close()}});d(window).bind("resize.simplemodal",function(){f=a.getDimensions();a.o.autoResize?a.setContainerDimensions():a.o.autoPosition&&a.setPosition();if(k||l)a.fixIE();else if(a.o.modal){a.d.iframe&&a.d.iframe.css({height:f[0],
width:f[1]});a.d.overlay.css({height:f[0],width:f[1]})}})},unbindEvents:function(){d("."+this.o.closeClass).unbind("click.simplemodal");d(document).unbind("keydown.simplemodal");d(window).unbind("resize.simplemodal");this.d.overlay.unbind("click.simplemodal")},fixIE:function(){var a=this,b=a.o.position;d.each([a.d.iframe||null,!a.o.modal?null:a.d.overlay,a.d.container],function(c,h){if(h){var g=h[0].style;g.position="absolute";if(c<2){g.removeExpression("height");g.removeExpression("width");g.setExpression("height",
'document.body.scrollHeight > document.body.clientHeight ? document.body.scrollHeight : document.body.clientHeight + "px"');g.setExpression("width",'document.body.scrollWidth > document.body.clientWidth ? document.body.scrollWidth : document.body.clientWidth + "px"')}else{var e;if(b&&b.constructor===Array){c=b[0]?typeof b[0]==="number"?b[0].toString():b[0].replace(/px/,""):h.css("top").replace(/px/,"");c=c.indexOf("%")===-1?c+' + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"':
parseInt(c.replace(/%/,""))+' * ((document.documentElement.clientHeight || document.body.clientHeight) / 100) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';if(b[1]){e=typeof b[1]==="number"?b[1].toString():b[1].replace(/px/,"");e=e.indexOf("%")===-1?e+' + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"':parseInt(e.replace(/%/,""))+' * ((document.documentElement.clientWidth || document.body.clientWidth) / 100) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}}else{c=
'(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (t = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"';e='(document.documentElement.clientWidth || document.body.clientWidth) / 2 - (this.offsetWidth / 2) + (t = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + "px"'}g.removeExpression("top");g.removeExpression("left");g.setExpression("top",
c);g.setExpression("left",e)}}})},focus:function(a){var b=this;a=a&&d.inArray(a,["first","last"])!==-1?a:"first";var c=d(":input:enabled:visible:"+a,b.d.wrap);setTimeout(function(){c.length>0?c.focus():b.d.wrap.focus()},10)},getDimensions:function(){var a=d(window);return[d.browser.opera&&d.browser.version>"9.5"&&d.fn.jquery<"1.3"||d.browser.opera&&d.browser.version<"9.5"&&d.fn.jquery>"1.2.6"?a[0].innerHeight:a.height(),a.width()]},getVal:function(a,b){return a?typeof a==="number"?a:a==="auto"?0:
a.indexOf("%")>0?parseInt(a.replace(/%/,""))/100*(b==="h"?f[0]:f[1]):parseInt(a.replace(/px/,"")):null},update:function(a,b){var c=this;if(!c.d.data)return false;c.d.origHeight=c.getVal(a,"h");c.d.origWidth=c.getVal(b,"w");c.d.data.hide();a&&c.d.container.css("height",a);b&&c.d.container.css("width",b);c.setContainerDimensions();c.d.data.show();c.o.focus&&c.focus();c.unbindEvents();c.bindEvents()},setContainerDimensions:function(){var a=this,b=k||m,c=a.d.origHeight?a.d.origHeight:d.browser.opera?
a.d.container.height():a.getVal(b?a.d.container[0].currentStyle.height:a.d.container.css("height"),"h");b=a.d.origWidth?a.d.origWidth:d.browser.opera?a.d.container.width():a.getVal(b?a.d.container[0].currentStyle.width:a.d.container.css("width"),"w");var h=a.d.data.outerHeight(true),g=a.d.data.outerWidth(true);a.d.origHeight=a.d.origHeight||c;a.d.origWidth=a.d.origWidth||b;var e=a.o.maxHeight?a.getVal(a.o.maxHeight,"h"):null,i=a.o.maxWidth?a.getVal(a.o.maxWidth,"w"):null;e=e&&e<f[0]?e:f[0];i=i&&i<
f[1]?i:f[1];var j=a.o.minHeight?a.getVal(a.o.minHeight,"h"):"auto";c=c?a.o.autoResize&&c>e?e:c<j?j:c:h?h>e?e:a.o.minHeight&&j!=="auto"&&h<j?j:h:j;e=a.o.minWidth?a.getVal(a.o.minWidth,"w"):"auto";b=b?a.o.autoResize&&b>i?i:b<e?e:b:g?g>i?i:a.o.minWidth&&e!=="auto"&&g<e?e:g:e;a.d.container.css({height:c,width:b});a.d.wrap.css({overflow:h>c||g>b?"auto":"visible"});a.o.autoPosition&&a.setPosition()},setPosition:function(){var a=this,b,c;b=f[0]/2-a.d.container.outerHeight(true)/2;c=f[1]/2-a.d.container.outerWidth(true)/
2;if(a.o.position&&Object.prototype.toString.call(a.o.position)==="[object Array]"){b=a.o.position[0]||b;c=a.o.position[1]||c}else{b=b;c=c}a.d.container.css({left:c,top:b})},watchTab:function(a){var b=this;if(d(a.target).parents(".simplemodal-container").length>0){b.inputs=d(":input:enabled:visible:first, :input:enabled:visible:last",b.d.data[0]);if(!a.shiftKey&&a.target===b.inputs[b.inputs.length-1]||a.shiftKey&&a.target===b.inputs[0]||b.inputs.length===0){a.preventDefault();b.focus(a.shiftKey?"last":
"first")}}else{a.preventDefault();b.focus()}},open:function(){var a=this;a.d.iframe&&a.d.iframe.show();if(d.isFunction(a.o.onOpen))a.o.onOpen.apply(a,[a.d]);else{a.d.overlay.show();a.d.container.show();a.d.data.show()}a.o.focus&&a.focus();a.bindEvents()},close:function(){var a=this;if(!a.d.data)return false;a.unbindEvents();if(d.isFunction(a.o.onClose)&&!a.occb){a.occb=true;a.o.onClose.apply(a,[a.d])}else{if(a.d.placeholder){var b=d("#simplemodal-placeholder");if(a.o.persist)b.replaceWith(a.d.data.removeClass("simplemodal-data").css("display",
a.display));else{a.d.data.hide().remove();b.replaceWith(a.d.orig)}}else a.d.data.hide().remove();a.d.container.hide().remove();a.d.overlay.hide();a.d.iframe&&a.d.iframe.hide().remove();setTimeout(function(){a.d.overlay.remove();a.d={}},10)}}}})(jQuery);




jQuery(document).ready(function () {
    var isVacasolWebsite = false;

    var loweredUrl = location.href.toLowerCase();
    if (loweredUrl.indexOf("://www.vacasol") != -1
    || loweredUrl.indexOf("://vacasol") != -1
    || loweredUrl.indexOf("://secure.vacasol") != -1
    || loweredUrl.indexOf("://test.vacasol") != -1
    || loweredUrl.indexOf("://testsecure.vacasol") != -1
    || loweredUrl.indexOf("localhost") != -1
    || loweredUrl.indexOf("vnhantest01") != -1)
        isVacasolWebsite = true;

    if (typeof noFeedback != "undefined" || false == isVacasolWebsite) {
        return;
    }

    jQuery('body').append('<a href="#" id="FEEDBAck-badge-right"  onclick="_gaq.push([\'_trackEvent\', \'Kontakt\', \'feedback\', \'clickfeed\']); rel="FEEDBAckForm"><span>Feedback</span></a>')

    jQuery('#FEEDBAck-badge-right').feedbackBadge({
        css3Safe: jQuery.browser.safari ? true : false,
        float: 'right',
        onClick: function () {
            try {
                if (jQuery("#FEEDBAckForm").length <= 0) {

                    var language = "";
                    var url = location.href.toLowerCase();

                    if (url.indexOf("/da") != -1 || url.indexOf("epslanguage=da") != -1) {
                        language = "da";
                    }
                    else if (url.indexOf("/en") != -1 || url.indexOf("epslanguage=en") != -1) {
                        language = "en";
                    }
                    else if (url.indexOf("/de") != -1 || url.indexOf("epslanguage=de") != -1) {
                        language = "de";
                    }
                    else if (url.indexOf("/nl") != -1 || url.indexOf("epslanguage=nl") != -1) {
                        language = "nl";
                    }
                    else if (url.indexOf("/no") != -1 || url.indexOf("epslanguage=no") != -1) {
                        language = "no";
                    }
                    else if (url.indexOf("/sv") != -1 || url.indexOf("epslanguage=sv") != -1) {
                        language = "sv";
                    }
                    else if (url.indexOf("/fr") != -1 || url.indexOf("epslanguage=fr") != -1) {
                        language = "fr";
                    }

                    var root = location.protocol + '//' + location.host;


                    root += "/Templates/Pages/SendFeedback.aspx";

                    if (language != "") {
                        root += "?epslanguage=" + language;
                    }

                    jQuery('body').append('<div id="FEEDBAckForm"><iframe scrolling="no" frameborder="0" src="' + root + '" class="feedbackFrame"></iframe></div>');
                    _gaq.push(['_trackEvent', 'Kontakt', 'feedback', 'clickfeed']);
                }

                jQuery('#FEEDBAckForm').modal({ overlayClose: true, onClose: function (dialog) {
                    dialog.data.fadeOut('fast', function () {
                        dialog.container.fadeOut('fast', function () {
                            dialog.overlay.fadeOut('fast', function () {
                                jQuery.modal.close();
                                jQuery('embed').show();
                            });
                        });
                    });
                }
                });
                return false;
            } catch (err) { }
        }
    });

});
//Infobox mouseover tracking function
jQuery(document).ready(function () {
    jQuery(".imageinfo").live('mouseover', function () {
        var infoBoxId = jQuery(this).attr('id').toString();
        infoBoxId = infoBoxId.slice(infoBoxId.search(/imginfo/i));
        var optLabel = "infobox" + infoBoxId.slice(7);
        _gaq.push(['_trackEvent', 'infobox', optLabel]);
    });
});


