﻿

function selectThumbnail(largepicid, largepicsrc, thumnailid, thumbnailStart, thumbnailCount) {
    document.getElementById(largepicid).src = largepicsrc;
    for (var i = 0; i < thumbnailCount; i++) {
        document.getElementById(thumbnailStart + i).setAttribute('class', '');
        document.getElementById(thumbnailStart + i).className = '';
    }
    document.getElementById(thumnailid).setAttribute('class', 'selected');
    document.getElementById(thumnailid).className = 'selected';
}

// fix for firefox
if (typeof HTMLElement != 'undefined') {
    HTMLElement.prototype.click = function() {
        var evt = this.ownerDocument.createEvent('MouseEvents');
        evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
        this.dispatchEvent(evt);
    }
}

function imageLoadErrorHotel(image)
{
    image.src = "/Content/Images/Global/nohotel.jpg"; 
    return true;
}

function swapImageIn(control)
{
     document.getElementById(control).src = "/Content/Images/Global/Navigation/menu-arrow-down-white.png";
}

function swapImageInWhite(control)
{
     document.getElementById(control).src = "/Content/Images/Global/Navigation/menu-arrow-right-white.png";
}

function swapImageOut(control)
{
     document.getElementById(control).src = "/Content/Images/Global/Navigation/menu-arrow-right-red.png";
}

function moveLeft(amount, flyClass) {

	var style = $('.' + flyClass).attr('style');
	$('.' + flyClass).attr('style', 'left:' + amount + 'px;' + style);


}

function moveRight(amount, flyClass) {
    var style = $('.' + flyClass).attr('style');
    var width = $('.' + flyClass).width();
    $('.' + flyClass).attr('style', 'left:' + (-(width + 11)) + 'px;' + style);
   }

   function daysInMonth(iMonth, iYear) {
   	return 32 - new Date(iYear, iMonth, 32).getDate();
   }

   setUrlEncodedKey = function(key, value, query) {

   	query = query || window.location.search;
   	var q = query + "&";
   	var re = new RegExp("[?|&]" + key + "=.*?&");
   	if (!re.test(q))
   		q += key + "=" + encodeURI(value);
   	else
   		q = q.replace(re, "&" + key + "=" + encodeURIComponent(value) + "&");
   	q = q.trimStart("&").trimEnd("&");
   	return q[0] == "?" ? q : q = "?" + q;


   }

   String.prototype.trimEnd = function(c) {
   	if (c)
   		return this.replace(new RegExp(c.escapeRegExp() + "*$"), '');
   	return this.replace(/\s+$/, '');
   }
   String.prototype.trimStart = function(c) {
   	if (c)
   		return this.replace(new RegExp("^" + c.escapeRegExp() + "*"), '');
   	return this.replace(/^\s+/, '');
   }

   String.prototype.escapeRegExp = function() {
   	return this.replace(/[.*+?^${}()|[\]\/\\]/g, "\\$0");
   };
  