//slider global variables
var overflowHeight;
var overflowHeightHalf;
var firstImg;
var firstImgHalf;
var sliderTop;
var myCurrentSlideTop;
var currSlideIndex ;
var slideLength ;
var canAnimate = true;
var nextSlideInd ;
var myCurrentSlideInd; //preserve the current slide
var firstTime = true; //bool for resizing width
var sliderMovementTimer = 2000; // slider time to move to another slide
var currentClicked = 1;

function welcomeMsgHide(event) {
//		if ($('.form_container').length != 0 && !$(event.target).closest('.form_container').length) {
//		hideStep1();
//		hideStep2();
//		hideStep3();
//		hideStep4();
//		$('body').unbind('click');
//		}
	}

	$(document).ready(function () {

	    $(document).keyup(function (event) {
	        if (event.which == 27 && $("body").attr("id") != 'home') {
	            hideStep1();
	            hideForm();
	            hideSharing();
	            hideJoin();
	            hideSitemap();
	        }
	    });

	    fillVariables();
	    if ($('#home').length != 0) {
	        $('.sliderBoard > div').css('opacity', .4);



	        (function ($) {
	            $.fn.valign = function (options) {

	                var defaults = {
	                    wraps: false,
	                    wrapper: "",
	                    halign: false
	                };

	                var T = this;

	                options = $.extend(defaults, options);

	                if (options.wrapper.length > 0) {
	                    //custom wrapper is specified
	                    T.wrapAll(options.wrapper);
	                } else if ((options.wraps == true) || T.parent().is("body")) {
	                    //no wrapper defined, use default
	                    T.wrapAll("<div></div>");
	                    console.log(options.wraps == true);
	                }
	                //shift focus of this to wrapper
	                T = this.parent();

	                TP = T.parent();

	                if (TP.is("body")) {
	                    //if the parent is the BODY then make the body & HTML 100% height
	                    TP.css("height", "100%");
	                    $("html").attr("style", "height:100%");
	                }

	                if (TP.css("position") != "absolute") TP.css("position", "relative");
	                T.css({
	                    "position": "absolute",
	                    "height": T.height(),
	                    "top": "50%",
	                    "left": "0px",
	                    "margin-top": 0 - (T.height() / 2)
	                })
	                if (options.halign) {
	                    T.css({
	                        "width": T.width(),
	                        "left": "50%",
	                        "margin-left": 0 - (T.width() / 2)
	                    })
	                }




	            } 
	        })(jQuery);

	        // Handler for .ready() called.


	        $('.linksWrap').valign();


	    }


	    $(window).resize(adjustImg);
	});

//mySlider
function sliderRight(){
	if( canAnimate ){
		myCurrentSlideInd = currSlideIndex;
		//  nextSlideInd = currSlideIndex == slideLength - 1 ? 0  : currSlideIndex + 1; //for rotating to first
		if(currSlideIndex != slideLength - 1 )
		{ 
			nextSlideInd =  currSlideIndex + 1;
			$($('.sliderBoard > div')[currSlideIndex]).removeClass('myCurrentSlide');
			$($('.sliderBoard > div')[nextSlideInd]).addClass('myCurrentSlide');
			firstTime = true;
			adjustImg();
		}
	}
}

function slideLeft(){
	if( canAnimate ){
	    myCurrentSlideInd = currSlideIndex;
	  //  nextSlideInd = currSlideIndex == 0 ? slideLength - 1 : currSlideIndex-1; //for rotating to last

   if(currSlideIndex > 0 )
	   { 
	   nextSlideInd = currSlideIndex-1;
		$($('.sliderBoard > div')[currSlideIndex]).removeClass('myCurrentSlide');
		$($('.sliderBoard > div')[nextSlideInd]).addClass('myCurrentSlide');
		firstTime = true;
		adjustImg();
	   }
	}
}

function adjustImg(){
	//re adjust the variables
	fillVariables();
	var toTop = 0;

	toTop = $('.myCurrentSlide').index() == 122 ? 0 :
	overflowHeightHalf - ( myCurrentSlideTop +  firstImgHalf  );

	if( $('.myCurrentSlide').index() == $('.sliderBoard > div').length -1){
		toTop = $('.myCurrentSlide').index() == 0 ? 0 : overflowHeightHalf - ( myCurrentSlideTop +  firstImgHalf  ) ;
	}
  
	if(sliderTop  < overflowHeightHalf && canAnimate){
	    canAnimate = false;
	    $('.sliderBoard').stop().animate({ top: toTop }, 1000, function () {
	        canAnimate = true;
	        $($('.sliderBoard  > div')[currSlideIndex]).siblings().stop().animate({ opacity: 0.6 }, 300, function () { });
	        $($('.sliderBoard > div')[currSlideIndex]).stop().animate({ opacity: 1 }, 300, function () {
	            timesClicked = $('#myHiddenField').val();
	            if (leftMenuCount != 0) {
	                var routeUrl = document.getElementById("routeURL").value;
	                if (leftMenuCount == 1)
	                    navToSlide(this, routeUrl + 'Hotel/thestandard1');
	                if (leftMenuCount == 2)
	                    navToSlide(this, routeUrl + 'Hotel/thestandard2');
	                if (leftMenuCount == 3)
	                    navToSlide(this, routeUrl + 'Hotel/theliving');
	                if (leftMenuCount == 4)
	                    navToSlide(this, routeUrl + 'Hotel/themodern');
	                if (leftMenuCount == 5)
	                    navToSlide(this, routeUrl + 'Hotel/thegroup');
	            }
	        });
	        if (firstTime) {
	            firstTime = false;
	        }
	    });
	}
	
	if($('.myCurrentSlide').index() == $('.sliderBoard > img').length-1 ){
	}
	
	if(getmyCurrentSlideInd() == 0 ){
	    $('.prevNavSlide').stop().animate({ opacity: .4 }, 500, function () { });
		}
	else {
	    $('.prevNavSlide').stop().animate({ opacity: 1 }, 500, function () { });
		}
		
	if(getmyCurrentSlideInd() == $('.sliderBoard > div').length-1 ){
	    $('.nextNavSlide').stop().animate({ opacity: .4 }, 500, function () { });
		}
	else {
	    $('.nextNavSlide').stop().animate({ opacity: 1 }, 500, function () { });
		}
}
function fillVariables(){
	//get the slide length
	slideLength = $('.sliderBoard > div').length;
	
    //get the  indexe of the current images
    currSlideIndex = $('.myCurrentSlide').index();

	//get the overflow container width and the width/2
	overflowHeight = $('.slideShowOf').height();
	overflowHeightHalf = overflowHeight / 2 ;
	
	//get the image width and the width/2
	firstImg  = $('.myCurrentSlide').height();
	firstImgHalf = firstImg/2;
	
	//get the slider left position
	sliderTop = getSliderTop();
	
	//get the curernt image left position
	
	 myCurrentSlideTop = getmyCurrentSlideTop();
	
}
function getSliderTop(){
	if($('.sliderBoard').position() != null) // If element exists
		return $('.sliderBoard').position().top;
}
function getmyCurrentSlideTop(){
	if($('.myCurrentSlide').position() != null)
		return $('.myCurrentSlide').position().top;
}
function getmyCurrentSlideInd(){
	if($('.myCurrentSlide').position() != null)
	  return $('.myCurrentSlide').index();
}



$(document).ready(function () {
    $(document).click(function (event) {
        if (event.target.id == "js_reservation_1" || event.target.id == "js_reservation_2" || event.target.id == "js_reservation_3" || event.target.id == "js_reservation_4") {
            hideStep1();
        }

    });
});


function  navigateToSlide(elm,websiteUrl){
	
	$('.sliderBoard > div').removeClass('myCurrentSlide');
	$($('.sliderBoard > div')[$(elm).index()]).addClass('myCurrentSlide');
	//$('.sliderBoard > div:not(.myCurrentSlide)').unbind('click');
	//$('.myCurrentSlide').siblings().unbind('click');
	var vThisIndex = $('.myCurrentSlide').index();
	//$('.myCurrentSlide').bind('click');

	//if ((timesClicked-1) == vThisIndex)
	//{
		window.location = websiteUrl; 
	//}
	// Me
    
 	currentClicked = vThisIndex;
	$('.linksWrap > div').removeClass('selected');
	$($('.linksWrap > div')[vThisIndex]).addClass('selected');
	// End Me
	/*	$(".myCurrentSlide").click(
		function()
		{
			window.location = websiteUrl;
		});*/
	
	adjustImg();
}

function navToSlide(elm,websiteUrl){
	$('.sliderBoard > div').removeClass('myCurrentSlide');
	$($('.sliderBoard > div')[$(elm).index()]).addClass('myCurrentSlide');
	//$('.sliderBoard > div:not(.myCurrentSlide)').unbind('click');
	//$('.myCurrentSlide').bind('click', function() {  });
	$($('.linksWrap > div')[$(elm).index()]).addClass('selected');
	$($('.linksWrap > div')[$(elm).index()]).siblings().removeClass('selected');
    currentClicked = $(elm).index();
    adjustImg();
}
//end mySlider
function showSohie()
{
	 document.getElementById("sophie").style.display='block';
}
function hideSophie()
{
	document.getElementById("sophie").style.display='none';
}
function showBtmLink(elm){
}
function openForm(id) {
    //$("[name=getMe]"
    if (document.getElementsByTagName('body')[0].getAttribute('id') == 'thestd2photosgal') {
        $('#imagesGoHere').css({ top: (-533) * parseInt(id) });
        if ($('#imagesGoHere').position().top == 0) {
            $('.prev').addClass('selected');
        }
        document.getElementById("js_viewphotos").style.display = 'block';
        $('#blankCover').css({ display: 'block', zIndex: '1' });
    }
}
function fillInImages(arrayOfPictures) {
    if (document.getElementsByTagName('body')[0].getAttribute('id') == 'thestd2photosgal') {
        for (var i = 0; i < arrayOfPictures.length; i++) {
            $('#imagesGoHere').html($('#imagesGoHere').html() + '<img width="702px" height="528px" id="sliderimage' + i + '" src="/content/uploads/HotelAlbum/' + arrayOfPictures[i] + '" />');
            //$('#imagesGoHere').html($('#imagesGoHere').html()+'<img id="sliderimage'+ i +'" src="/Utils/ResizeImage?imageName=' + "/content/uploads/HotelAlbum/" + arrayOfPictures[i] + '&width=703&height=468&isresize=1">');
        }
    }
}
var slideshowDone = 0;
function nextSlideshowImage(numOfImages) {
    if (slideshowDone == 0) {
        slideshowDone = 1;
        if ($('#imagesGoHere').position().top != ((-533) * parseInt(numOfImages - 1))) {
            $('.prev').removeClass('selected');
            $('#imagesGoHere > img').animate({ opacity: '0' }, 700, function () {
            });
            if ($('#imagesGoHere').position().top == ((-533) * parseInt(numOfImages - 2)))
                $('.next').addClass('selected');
            setTimeout("$('#imagesGoHere').css({ top: $('#imagesGoHere').position().top - 533 })", 800);
            setTimeout("$('#imagesGoHere > img').animate({ opacity: '1' }, 700, function(){slideshowDone = 0;})", 800);
        }
        else {
            slideshowDone = 0;
        }
    }
}
function previousSlideshowImage() {
    if (slideshowDone == 0) {
        slideshowDone = 1;
        if ($('#imagesGoHere').position().top != 0) {
            $('.next').removeClass('selected');
            $('#imagesGoHere > img').animate({ opacity: '0' }, 700, function () {
            });
            if ($('#imagesGoHere').position().top == -533)
                $('.prev').addClass('selected');
            setTimeout("$('#imagesGoHere').css({ top: $('#imagesGoHere').position().top + 533 })", 800);
            setTimeout("$('#imagesGoHere > img').animate({ opacity: '1' }, 700, function(){slideshowDone = 0;})", 800);
        }
        else {
            slideshowDone = 0;
        }
    }
}
function hideForm()
{
    if (document.getElementsByTagName('body')[0].getAttribute('id') == 'thestd2photosgal') {
        document.getElementById("js_viewphotos").style.display = 'none';
        $('#blankCover').css({ display: 'none', zIndex: 'none' });
    }
}
function openSharing() {
    $("#blankCover").css({ display: 'block' });
	document.getElementById("js_sharethoughts").style.display='block';
}

var mouseIsInsideShareThoughts      = 0;
var mouseIsInsideCloseShareThoughts = 0;
$(document).ready(function () {
    $("#shareThoughtsForm").mouseenter(function () {
        mouseIsInsideShareThoughts = 1;
    }).mouseleave(function () {
        mouseIsInsideShareThoughts = 0;
    });

    $(".closeshare, .cancel").mouseenter(function () {
        mouseIsInsideCloseShareThoughts = 1;
    }).mouseleave(function () {
        mouseIsInsideCloseShareThoughts = 0;
    }); ;
});

function hideSharing() {
    if (mouseIsInsideShareThoughts == 0 || mouseIsInsideCloseShareThoughts == 1) {
        clearAll();
        $('#titleShare').val("");
        $('#MessageShare').val("");
        $("#myRateBab").css({ color: '#333333' });
        document.getElementById("js_sharethoughts").style.display = 'none';
        $("#blankCover").css({ display: 'none' });
    }
}

var siteMapOpened = 0;
function hideSitemap()
{
    $('.sitemap').animate({ height: '0px' }, 600, function () {
        document.getElementById("js_sitemap").style.display = 'none';
        $('#blankCover').css({ display: 'none' });
        siteMapOpened = 0;
    });
}
function openSitemap() {
    document.getElementById("js_sitemap").style.display = 'block';
    $('.sitemap').animate({ height: '250px' }, 600, function () {
        $('#blankCover').css({ display: 'block' });
        siteMapOpened = 1;
    });
}

function newsOpening() {
    hideSitemap();
    setTimeout("openJoin()", 700);
}

var mouse_is_inside_sitemap = false;
$(document).ready(function () {
    $('.sitemap_form').hover(function () {
        mouse_is_inside_sitemap = true;
    }, function () {
        mouse_is_inside_sitemap = false;
    });

    $("body").mouseup(function () {
        if (mouse_is_inside_sitemap == false) { if (siteMapOpened == 1) hideSitemap(); };
    });
});

var reserveFormIsDone = 0;
function showRes() {
    if (reserveFormIsDone == 0) {
        document.getElementById("js_reservation_1").style.display = 'block';
        document.getElementById("js_reservation_2").style.display = 'none';
        document.getElementById("js_reservation_3").style.display = 'none';
        $(".reserve_stay").css({ zIndex: '1' });
        $("#blankCover").css({ display: 'block' });

        $('.reserv_form_1').animate({ width: '653px' }, 1000, function () {
            reserveFormIsDone = 1;
        });
    }
}

function showStep1() {
    $('#reserv_inner1').css({ right: '-640px' });
    $('.right_info').css({ display: 'none' });
    document.getElementById("js_reservation_1").style.display = 'block';
    document.getElementById("js_reservation_3").style.display = 'none';
    $('#reserv_inner2').animate({ right: '-640px' }, 1000, function () {
        $('#js_reservation_2').css({ zIndex: '2' });
        $('#js_reservation_2').css({ display: 'none' });
        $('.right_info').css({ display: 'block' });
        $('#reserv_inner1').animate({ right: '0px' }, 1000, function () {

        });
    });
}

function showStep2() {
    $('#numOfAd').html($('#adultsNumber').val());
    $('#numOfRo').html($('#roomNumber').val());
    $('.from_date').html($('#dateArrival').val());
    $('.till_date').html($('#datedeparture').val());
    $('#reserv_inner2').css({ right: '-640px' });
    $('.right_info').css({ display:'none' });
    document.getElementById("js_reservation_2").style.display = 'block';
    document.getElementById("js_reservation_3").style.display = 'none';

    $('#reserv_inner1').animate({ right: '-640px' }, 1000, function () {
        $('.right_info').css({ display: 'block' });
        $('#js_reservation_2').css({ zIndex:'4' });
        $('#reserv_inner2').animate({ right: '0px' }, 1000, function () {
           
        });
    });
}

function showStep3() {
    //alert(checkIfReserverPasses());
    if (checkIfReserverPasses() == true) {
        //alert(checkIfReserverPasses());
        $('#numOfAd').html($('#adultsNumber').val());
        $('#numOfRo').html($('#roomNumber').val());
        $('.from_date').html($('#dateArrival').val());
        $('.till_date').html($('#datedeparture').val());
        $('#reserv_inner3').css({ right: '-640px' });
        document.getElementById("js_reservation_3").style.display = 'block';
        document.getElementById("js_reservation_1").style.display = 'none';

        $('#reserv_inner2').animate({ right: '-640px' }, 1000, function () {
            $('#js_reservation_3').css({ zIndex: '4' });
            $('#reserv_inner3').animate({ right: '0px' }, 1000, function () {

            });
        });
    }
}

function showStep4() {
    $('#numOfAd').html($('#adultsNumber').val());
    $('#numOfRo').html($('#roomNumber').val());
    $('.from_date').html($('#dateArrival').val());
    $('.till_date').html($('#datedeparture').val());
    $('#reserv_inner4').css({ right: '-640px' });
    document.getElementById("js_reservation_3").style.display = 'block';
    document.getElementById("js_reservation_4").style.display = 'block';
    document.getElementById("js_reservation_1").style.display = 'none';

    $('#reserv_inner3').animate({ right: '-640px' }, 1000, function () {
        $('#js_reservation_4').css({ zIndex: '4' });
        $('#reserv_inner4').animate({ right: '0px' }, 1000, function () {
            setTimeout("document.makeYourReservation.reset(); hideStep1()", 6000);
        });
    });
}
function hideStep1() {
    if (reserveFormIsDone == 1) {
        $('.reserv_form_1').animate({ width: '0px' }, 1000, function () {
            document.getElementById("js_reservation_1").style.display = 'none';
            $('#reserv_inner1').css({ right: '0px' });
            $('#reserv_inner2').css({ right: '-640px' });
            $('#reserv_inner3').css({ right: '-640px' });
            $('#reserv_inner4').css({ right: '-640px' });
            document.getElementById("js_reservation_1").style.display = 'none';
            document.getElementById("js_reservation_2").style.display = 'none';
            document.getElementById("js_reservation_3").style.display = 'none';
            document.getElementById("js_reservation_4").style.display = 'none';
            $('#js_reservation_3').css({ zIndex: '2' });
            $('#js_reservation_2').css({ zIndex: '3' });
            $('#js_reservation_1').css({ zIndex: '4' });
            $('#js_reservation_4').css({ zIndex: '1' });
            $(".reserve_stay").css({ zIndex: '0' });
            $("#blankCover").css({ display: 'none' });
            reserveFormIsDone = 0;
        });
    }
}
function hideStep2() {
    if (reserveFormIsDone == 1) {
        $('.right_info').css({ display: 'none' });
        $('.reserv_form_1').animate({ width: '0px' }, 1000, function () {
            document.getElementById("js_reservation_2").style.display = 'none';
            $('.right_info').css({ display: 'block' });
            $('#reserv_inner1').css({ right: '0px' });
            $('#reserv_inner2').css({ right: '-640px' });
            $('#reserv_inner3').css({ right: '-640px' });
            $('#reserv_inner4').css({ right: '-640px' });
            document.getElementById("js_reservation_1").style.display = 'none';
            document.getElementById("js_reservation_2").style.display = 'none';
            document.getElementById("js_reservation_3").style.display = 'none';
            document.getElementById("js_reservation_4").style.display = 'none';
            $('#js_reservation_3').css({ zIndex: '2' });
            $('#js_reservation_2').css({ zIndex: '3' });
            $('#js_reservation_1').css({ zIndex: '4' });
            $('#js_reservation_4').css({ zIndex: '1' });
            reserveFormIsDone = 0;
        });
    }
}
function hideStep3()
{
    
        $('.reserv_form_1').animate({ width: '0px' }, 1000, function () {
            document.getElementById("js_reservation_3").style.display = 'none';
            $('#reserv_inner1').css({ right: '0px' });
            $('#reserv_inner2').css({ right: '-640px' });
            $('#reserv_inner3').css({ right: '-640px' });
            $('#reserv_inner4').css({ right: '-640px' });
            $('#js_reservation_3').css({ zIndex: '2' });
            $('#js_reservation_2').css({ zIndex: '3' });
            $('#js_reservation_1').css({ zIndex: '4' });
            $('#js_reservation_4').css({ zIndex: '1' });
            document.getElementById("js_reservation_1").style.display = 'none';
            document.getElementById("js_reservation_2").style.display = 'none';
            document.getElementById("js_reservation_3").style.display = 'none';
            document.getElementById("js_reservation_4").style.display = 'none';
            reserveFormIsDone = 0;
        });
    
}
function hideStep4()
{
    
        $('.reserv_form_1').animate({ width: '0px' }, 1000, function () {
            document.getElementById("js_reservation_4").style.display = 'none';
            $('#reserv_inner1').css({ right: '0px' });
            $('#reserv_inner2').css({ right: '-640px' });
            $('#reserv_inner3').css({ right: '-640px' });
            $('#reserv_inner4').css({ right: '-640px' });
            document.getElementById("js_reservation_1").style.display = 'none';
            document.getElementById("js_reservation_2").style.display = 'none';
            document.getElementById("js_reservation_3").style.display = 'none';
            document.getElementById("js_reservation_4").style.display = 'none';
            $('#js_reservation_3').css({ zIndex: '2' });
            $('#js_reservation_2').css({ zIndex: '3' });
            $('#js_reservation_1').css({ zIndex: '4' });
            $('#js_reservation_4').css({ zIndex: '1' });
            reserveFormIsDone4 = 0;
        });
    
}

function PreloadImage(imgSrc, callback){

  var objImagePreloader = new Image();


  objImagePreloader.src = imgSrc;

  if(objImagePreloader.complete){

	callback();

	objImagePreloader.onload=function(){};

  }

  else{

	objImagePreloader.onload = function() {

	  callback();

	  //    clear onLoad, IE behaves irratically with animated gifs otherwise

	  objImagePreloader.onload=function(){};

	}

  }

}


/////////////////////////////////sahih///////////////////////////////////////
function slideSwitch() {
    var $active = $('.slideshow div.active');

    if ( $active.length == 0 ) $active = $('.slideshow div:last');

    var $next =  $active.next().length ? $active.next() : $('.slideshow div:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
    }

    $(document).ready(function () {
        var numberOfSliderImages = $('.show').length;
        var isDone = 0;
        var imagesNames = new Array();
        $('.prev').css({ opacity: 0.5 });

        for (var i = 1; i < numberOfSliderImages; i++) {
            imagesNames[i - 1] = $("#" + i).css('background-image').substring(38, $("#" + i).css('background-image').length);
            if (i < numberOfSliderImages-1) {
                PreloadImage(imagesNames[i-1]);
            }
            else {
                isDone = 1;
            }
        }

        if (document.getElementById("2") !== null)
            if(isDone == 1)
                setInterval('slideSwitch()', 5000);
    })

    var slidingDone     = 0;
    var myCurrentPos    = 0;
    function previousUp() {
        if (slidingDone == 0) {
            slidingDone = 1;
            $('#prev').css({ opacity: 1 });
            var numberOfWhatsUpImages = $(".WhatsInItem").length;
            if (myCurrentPos < numberOfWhatsUpImages - 1) {
                var leftPosition = $("#WhatsInSlider").position().left;
                $("#WhatsInSlider").animate({ left: leftPosition - 200 }, 300, function () {
                    myCurrentPos++;
                    slidingDone = 0;
                });
            }
            else {
                setTimeout("slidingDone = 0", 300);
            }
            if (myCurrentPos == numberOfWhatsUpImages - 2) {
                setTimeout("slidingDone = 0", 300);
                $('#next').css({ opacity: 0.5 });
            }
        }
    }

    function nextUp() {
        if (slidingDone == 0) {
            $('#next').css({ opacity: 1 });
            slidingDone = 1;
            var numberOfWhatsUpImages = $(".WhatsInItem").length;
            if (myCurrentPos > 0) {
                var leftPosition = $("#WhatsInSlider").position().left;
                $("#WhatsInSlider").animate({ left: leftPosition + 200 }, 300, function () {
                    myCurrentPos--;
                    slidingDone = 0;
                });
            }
            else {
                setTimeout("slidingDone = 0", 300);
            }
            if (myCurrentPos == 1) {
                setTimeout("slidingDone = 0", 300);
                $('#prev').css({ opacity: 0.5 });
            }
        }
    }

    var slidingDone2 = 0;
    function nextUp2() {
        //alert(slidingDone2);
        if (slidingDone2 == 0) {
            $('#next2').css({ opacity: 1 });
            slidingDone2 = 1;
            var numberOfWhatsUpImages = $(".GuestInItem").length;
            if (myCurrentPos > 0) {
                var leftPosition = $("#GuestSlider").position().left;
                $("#GuestSlider").animate({ left: leftPosition + 200 }, 300, function () {
                    myCurrentPos--;
                    slidingDone2 = 0;
                });
            }
            else {
                setTimeout("slidingDone2 = 0", 300);
            }
            if (myCurrentPos == 1) {
                setTimeout("slidingDone2 = 0", 300);
                $('#prev2').css({ opacity: 0.5 });
            }
        }
    }

    function previousUp2() {
        if (slidingDone2 == 0) {
            $('#prev2').css({ opacity: 1 });
            slidingDone2 = 1;
            var numberOfWhatsUpImages = $(".GuestInItem").length;
            if (myCurrentPos < numberOfWhatsUpImages - 1) {
                var leftPosition = $("#GuestSlider").position().left;
                $("#GuestSlider").animate({ left: leftPosition - 200 }, 300, function () {
                    myCurrentPos++;
                    setTimeout("slidingDone2 = 0", 300);
                });
            }
            else {
                slidingDone2 = 0;
            }
            if (myCurrentPos == numberOfWhatsUpImages - 2) {
                setTimeout("slidingDone2 = 0", 300);
                $('#next2').css({ opacity: 0.5 });
            }
        }
    }

    function clickOnStar(obj, event) {
        var moi = event.layerX + "x" + event.layerY;

        if (event.layerX > 2 && event.layerX < 10) {
            $('#formStars').css({ width: '20%' });
            $('#formStars').val(1);
        }
        else if (event.layerX > 17 && event.layerX < 27) {
            $('#formStars').css({ width: '40%' });
            $('#formStars').val(2);
        }
        else if (event.layerX > 32 && event.layerX < 40) {
            $('#formStars').css({ width: '60%' });
            $('#formStars').val(3);
        }
        else if (event.layerX > 46 && event.layerX < 54) {
            $('#formStars').css({ width: '80%' });
            $('#formStars').val(4);
        }
        else if (event.layerX > 59 && event.layerX < 67) {
            $('#formStars').css({ width: '100%' });
            $('#formStars').val(5);
        }
    }


    ////////////////function for Ajax + send Mail//////////////////
    function clearAll() {
        $('#titleShare').css({ border: 'none' });
        $('#MessageShare').css({ border: 'none' });
        $('#chkcomfort').removeAttr('checked');
        $('#chkcleanliness').removeAttr('checked');
        $('#chkfastservice').removeAttr('checked');
        $('#chklocation').removeAttr('checked');
        $('#chkservice').removeAttr('checked');
        $('#formStars').css({ width: '0%' });
        $('#formStars').val(0);
        $('#missingGuestFields').css({ display: 'none' });
        $('#shareThoughtsLoader').css({ display: 'none' });
        $('#guestbookSent').css({ display: 'none' });
    }

    var shareThoughtsIsOpened = 0;
    function submitThoughtsForm() {
        if (shareThoughtsIsOpened == 0) {
            shareThoughtsIsOpened = 1;
            var i = 0;
            var routeURL = $('#routeURL').val();
            var titleShare = "", MessageShare = "";

            if (jQuery.trim($('#titleShare').val()) == "") {
                i = 1;
                $('#titleShare').css({ border: '1px solid #CB157E' });
            }
            else {
                $('#titleShare').css({ border: 'none' });
                titleShare = $('#titleShare').val();
            }
            if (jQuery.trim($('#MessageShare').val()) == "") {
                i = 1;
                $('#MessageShare').css({ border: '1px solid #CB157E' });
            }
            else {
                $('#MessageShare').css({ border: 'none' });
                MessageShare = $('#MessageShare').val();
            }
            if (jQuery.trim($('#formStars').val()) == "") {
                $("#myRateBab").css({ color: '#CB157E' });
                rate = 0;
            }
            else {
                $("#myRateBab").css({ color: '#333333' });
                rate = $('#formStars').val();
            }
            iscomfort       = $('#iscomfort').attr('checked');
            isCleanliness   = $('#isCleanliness').attr('checked');
            isFastService   = $('#isFastService').attr('checked');
            isGoodLocation  = $('#isGoodLocation').attr('checked');
            isRoomService   = $('#isRoomService').attr('checked');
            hotelSentFrom   = $('#hotelSentFrom').val();

            if (i == 1) {
                $('#missingGuestFields').css({ display: 'block' });
                shareThoughtsIsOpened = 0;
            }
            else if (i == 0) {
                $('#missingGuestFields').css({ display: 'none' });
                $('#shareThoughtsLoader').css({ display: 'block' });
                poststr = "titleShare=" + titleShare + "&MessageShare=" + MessageShare + "&rate=" + rate + "&iscomfort=" + iscomfort + "&isCleanliness=" + isCleanliness + "&isFastService=" + isFastService + "&isGoodLocation=" + isGoodLocation + "&isRoomService=" + isRoomService + "&hotelSentFrom=" + hotelSentFrom;
                $.ajax({
                    url: routeURL + 'Hotel/SendThoughts',
                    type: 'POST',
                    data: '' + poststr,
                    success: function (data) {
                        $('#shareThoughtsLoader').css({ display: 'none' });
                        $('#guestbookSent').css({ display: 'block' });
                        setTimeout("hideSharing()", 3000);
                        setTimeout("shareThoughtsIsOpened = 0", 3000);
                        clearAll();
                    }
                });
            }
        }
    }
    ////////////////function for Ajax + send Mail//////////////////

    var joinIsOpened = 0;
    function hideJoin() {
        $('#missingNewsLetterFields').css({ display: 'none' });
        $('#newsLetterSent').css({ display: 'none' });
        $('.joinournewsletter_form').animate({ height: '0px' }, 500, function () {
            document.getElementById("js_blank").style.display = 'none';
            document.getElementById("js_joinournewsletter").style.display = 'none';
            document.joinournewsletter_form.reset();
            clearAllNewsLetter();
            joinIsOpened = 0;
        });
    }
    function openJoin() {
        $('#fullName').css({ height: '16px' });
        $('#phone').css({ height: '16px' });
        $('#country').css({ height: '16px' });
        $('#email').css({ height: '16px' });
        document.getElementById("js_joinournewsletter").style.display = 'block';
        $('.joinournewsletter_form').animate({ height: '216px' }, 500, function () {
            document.getElementById("js_blank").style.display = 'block';
            joinIsOpened = 1;
        });
    }

    var mouse_is_inside_joinNewsLetter = false;

    $(document).ready(function () {
        $('#js_joinournewsletter').hover(function () {
            mouse_is_inside_joinNewsLetter = true;
        }, function () {
            mouse_is_inside_joinNewsLetter = false;
        });

        $("body").mouseup(function () {
            if (mouse_is_inside_joinNewsLetter == false && joinIsOpened == 1) { hideJoin();};
        });
    });

    function clearAllNewsLetter() {
        $('#fullName').css({ border: 'none' });
        $('#phone').css({ border: 'none' });
        $('#country').css({ border: 'none' });
        $('#email').css({ border: 'none' });
        $('#missingNewsLetterFields').css({ display: 'none' });
        $('#newsLetterLoader').css({ display: 'none' });
        $('#newsLetterSent').css({ display: 'none' });
    }

    var newsLetterIsOpened = 0;
    function sendJoin(color) {
        if (newsLetterIsOpened == 0) {
            newsLetterIsOpened = 1;
            clearAllNewsLetter();
            var i = 0;
            var routeURL = $('#routeURL').val();
            var fullName = "", phone = "", country = "";
            var email = $('#email').val();
            var AtPos = email.indexOf("@");
            var StopPos = email.lastIndexOf(".");

            if (jQuery.trim($('#fullName').val()) == "") {
                i = 1;
                $('#fullName').css({ border: '1px solid ' + color , height : '14px' });
            }
            else {
                fullName = $('#fullName').val();
                $('#fullName').css({ height: '16px' });
            }
            if (jQuery.trim($('#phone').val()) == "") {
                i = 1;
                $('#phone').css({ border: '1px solid ' + color, height: '14px' });
            }
            else {
                phone = $('#phone').val();
                $('#phone').css({ height: '16px' });
            }
            if (jQuery.trim($('#country').val()) == "") {
                i = 1;
                $('#country').css({ border: '1px solid ' + color, height: '14px' });
            }
            else {
                country = $('#country').val();
                $('#country').css({ height: '16px' });
            }
            if (jQuery.trim($('#email').val()) == "" || (AtPos == -1 || StopPos == -1)) {
                i = 1;
                $('#email').css({ border: '1px solid ' + color, height: '14px' });
            }
            else {
                email = $('#email').val();
                $('#email').css({ height: '16px' });
            }

            if (i == 1) {
                $('#missingNewsLetterFields').css({ display: 'block' });
                newsLetterIsOpened = 0;
            }
            else if (i == 0) {
                $('#missingNewsLetterFields').css({ display: 'none' });
                $('#newsLetterLoader').css({ display: 'block' });
                poststr = "fullName=" + fullName + "&phone=" + phone + "&country=" + country + "&email=" + email;
                $.ajax({
                    url: routeURL + 'Hotel/JoinNewsLetter',
                    type: 'POST',
                    data: '' + poststr,
                    success: function (data) {
                        $('#newsLetterLoader').css({ display: 'none' });
                        $('#newsLetterSent').css({ display: 'block' });
                        setTimeout("hideJoin()", 3000);
                        setTimeout("newsLetterIsOpened = 0", 3000);
                    }
                });
            }
        }
    }


    function clearAllContactUs() {
        $('#cname').css({ border: 'none' });
        $('#cphone').css({ border: 'none' });
        $('#ccountry').css({ border: 'none' });
        $('#cemail').css({ border: 'none' });
        $('#cmessage').css({ border: 'none' });
        $('#missingContactUsFields').css({ display: 'none' });
        $('#ContactUsLoader').css({ display: 'none' });
        $('#ContactUsSent').css({ display: 'none' });
    }

    var ContactUsIsOpened = 0;
    function sendContactUs(color) {
        if (ContactUsIsOpened == 0) {
            ContactUsIsOpened = 1;
            clearAllContactUs();
            var i = 0;
            var routeURL = $('#routeURL').val();
            var fullName = "", phone = "", country = "";
            var cemail = $('#cemail').val();
            var AtPos = cemail.indexOf("@");
            var StopPos = cemail.lastIndexOf(".");

            if (jQuery.trim($('#cname').val()) == "") {
                i = 1;
                $('#cname').css({ border: '1px solid ' + color, height: '15px' });
            }
            else {
                fullName = $('#cname').val();
                $('#cname').css({ height: '16px' });
            }
            if (jQuery.trim($('#cphone').val()) == "") {
                i = 1;
                $('#cphone').css({ border: '1px solid ' + color, height: '15px' });
            }
            else {
                phone = $('#cphone').val();
                $('#cphone').css({ height: '16px' });
            }
            if (jQuery.trim($('#ccountry').val()) == "") {
                i = 1;
                $('#ccountry').css({ border: '1px solid ' + color, height: '15px' });
            }
            else {
                country = $('#ccountry').val();
                $('#ccountry').css({ height: '16px' });
            }
            if (jQuery.trim($('#cmessage').val()) == "") {
                i = 1;
                $('#cmessage').css({ border: '1px solid ' + color, height: '57px' });
            }
            else {
                cmessage = $('#cmessage').val();
                $('#cmessage').css({ height: '58px' });
            }
            if (jQuery.trim($('#cemail').val()) == "" || (AtPos == -1 || StopPos == -1)) {
                i = 1;
                $('#cemail').css({ border: '1px solid ' + color, height: '15px' });
            }
            else {
                email = $('#cemail').val();
                $('#cemail').css({ height: '16px' });
            }

            if (i == 1) {
                $('#missingContactUsFields').css({ display: 'block' });
                ContactUsIsOpened = 0;
            }
            else if (i == 0) {
                $('#missingContactUsFields').css({ display: 'none' });
                $('#ContactUsLoader').css({ display: 'block' });
                poststr = "fullName=" + fullName + "&phone=" + phone + "&country=" + country + "&email=" + email + "&message=" + $('#cmessage').val();
                $.ajax({
                    url: routeURL + 'Hotel/JoinContactUs',
                    type: 'POST',
                    data: '' + poststr,
                    success: function (data) {
                        $('#ContactUsLoader').css({ display: 'none' });
                        $('#ContactUsSent').css({ display: 'block' });
                        setTimeout("ContactUsIsOpened = 0; $('#ContactUsSent').css({ display: 'none' }); document.ContactUsForm.reset();", 3000);
                    }
                });
            }
        }
    }








    function clearAllReservation() {
        if (($('#reremail').val() != "" && $('#reremail').val() != "Required")) 
            $('#reremail').css({ color: '#333333' });
        if (($('#rfullName').val() != "" && $('#rfullName').val() != "Required"))
            $('#rfullName').css({ color: '#333333' });
        if (($('#rphone').val() != "" && $('#rphone').val() != "Required"))
            $('#rphone').css({ color: '#333333' });
        if (($('#rcountry').val() != "" && $('#rcountry').val() != "Required")) 
        $('#rcountry').css({ color: '#333333' });
    }

    var fullName = "", phone = "", country = "", address = "";
    function checkIfReserverPasses() {
        var i = 0;
        var AtPos = $('#reremail').val().indexOf("@");
        var StopPos = $('#reremail').val().lastIndexOf(".");
        
        if (jQuery.trim($('#rfullName').val()) == "" || jQuery.trim($('#rfullName').val()) == "Required") {
            i = 1;
            $('#rfullName').css({ color: 'red' });
            $('#rfullName').val('Required');
        }
        else {
            fullName = $('#rfullName').val();
        }
        if (jQuery.trim($('#rphone').val()) == "" || jQuery.trim($('#rphone').val()) == "Required") {
            i = 1;
            $('#rphone').css({ color: 'red' });
            $('#rphone').val('Required');
        }
        else {
            phone = $('#rphone').val();
            $('#rphone').css({ height: '16px' });
        }
        if (jQuery.trim($('#rcountry').val()) == "" || jQuery.trim($('#rcountry').val()) == "Required") {
            i = 1;
            $('#rcountry').css({ color: 'red' });
            $('#rcountry').val('Required');
        }
        else {
            country = $('#rcountry').val();
            $('#rcountry').css({ height: '16px' });
        }
        if (jQuery.trim($('#reremail').val()) == "" || (AtPos == -1 || StopPos == -1) || jQuery.trim($('#reremail').val()) == "Required") {
            i = 1;
            $('#reremail').css({ color: 'red' });
            if (jQuery.trim($('#reremail').val()) == "")
                $('#reremail').val('Required');
        }
        else {
            ademail = $('#reremail').val();
        }
        if (i == 1) {
            $('.lbreq').css({ visibility: 'visible' });
            ContactUsIsOpened = 0;
            return false;
        }
        else {
            return true;
        }
    }

    function sendReserve() {
                var routeURL = $('#routeURL').val();
                $('.lbreq').css({ visibility: 'hidden' });
                $('#ReserveLoader').css({ display: 'block' });
                poststr = "fullName=" + fullName + "&phone=" + phone + "&country=" + country + "&email=" + $('#reremail').val() + "&address=" + $('#raddress').val() + "&arrivalDate=" + $('#dateArrival').val() + "&departureDate=" + $('#datedeparture').val() + "&roomNumber=" + $('#roomNumber').val() + "&adultsNumber=" + $('#adultsNumber').val() + "&childNumber=" + $('#childNumber').val() + "&hotelSentFrom=" + $('#hotelSentFrom').val() + "&numbOfRooms=" + $('#numbOfRooms').val();
                $.ajax({
                    url: routeURL + 'Hotel/JoinReserve',
                    type: 'POST',
                    data: '' + poststr,
                    success: function (data) {
                        $('#ReserveLoader').css({ display: 'none' });
                        $('#ReserveSent').css({ display: 'block' });
                        showStep4();
                    }
                });
    }



    function GWT_entryPoint() {
        
        if (document.getElementById("arrivalDate") != null) {
            var Editndate = "";
            calendarPath = document.getElementById('CalendarPath').value;
            showCalendar('' + calendarPath + '', 'arrivalDate', 'dateArrival', true, false, '', 'MM/dd/yyyy', Editndate);
        }

        if (document.getElementById("departureDate") != null) {
            var Editndate = "";
            calendarPath = document.getElementById('CalendarPath').value;
            showCalendar('' + calendarPath + '', 'departureDate', 'datedeparture', true, false, '', 'MM/dd/yyyy', Editndate);
        }
    }


    function upArrow(id) {
        $('#' + id).val(parseFloat(parseFloat($('#' + id).val()) + 1));
        if ($('#' + id).val() < 10) 
        $('#' + id).val("0" + parseFloat($('#' + id).val()));
    }

    function downArrow(id) {
        if ($('#' + id).val() > 1) {
            $('#' + id).val(parseFloat(parseFloat($('#' + id).val()) - 1));
            if ($('#' + id).val() < 10)
                $('#' + id).val("0" + parseFloat($('#' + id).val()));
        }
    }

    // this shows the coming soon of themodern for some seconds
    function showComingSoon() {
        $("#comingSoon2012").show();
        setTimeout(function () {
            $("#comingSoon2012").hide();
        }, 4000);
    }
        /////////////////////////////////sahih///////////////////////////////////////
