
Cufon.replace('h1, h2, #mainMenu a, #languages a, #capCycle p, #thumbs ul li, .roomDescr, .intror', { hover: true })

$(document).ready(function () {
    resize();
    rooms();
    map();
    hoverFadeLight();
    startSlideShow();
});
$(window).bind('resize', function () {
    resize();
    rooms();
    map();
});


function map() {
    var r = $('#right').width();
    $('#locCanvas').width(r);
}


function rooms() {

    $('#roomsCanvas li img').hover(function () {
        $(this).stop().fadeTo('fast', 1)
    }, function () {
        $(this).stop().fadeTo('fast', 0.7)
    });


    var r = $('#right').width();
    var wli = (r / 3) - 1;
    $('#roomsCanvas li').width(wli);
    $('#roomsCanvas li.last').width(wli + 1);

    $('#roomsCanvas a').hover(function () {
        //alert('in');
        var ulName = $(this).parent().parent().attr('id');
        var idx = $('#' + ulName + ' li').index($(this).parent())
        var lan = $('body').attr('lan');
        $('#' + ulName + 'Ul' + lan).removeClass('hide');
        $('#' + ulName + 'Ul' + lan +' li').eq(idx).removeClass('hide').addClass('show');
    }, function () {
        var ulName = $(this).parent().parent().attr('id');
        var idx = $('#' + ulName + ' li').index($(this).parent())
        var lan = $('body').attr('lan');
        $('#' + ulName + 'Ul' + lan).addClass('hide');
        $('#' + ulName + 'Ul' + lan + ' li').eq(idx).removeClass('show').addClass('hide');
    });


}

function resize() {
    var h = $(window).height();
    var c = $('#container').height();
    if (c < h) {
        $('#footer').css('padding-top', (h-c));
    }
}

function slideshow() {
    $('#cycle').cycle({
        fx: 'fade',
        speed: 750,
        timeout: 5000,
        before: onBefore,
        pager: '#thumbs',
        pagerAnchorBuilder: function (idx, slide) {
            return '#thumbs li:eq(' + idx + ') a';
        }
    });
    //single image
    if ($('#cycle img.sigleImg').length > 0) {
        $('#cycle img.sigleImg').show()
        if ($('#img1Cap').length > 0) {
            $('#capCycle').show().css('opacity', '0.80')
            $('#capCycle p').html($('#img1Cap').html());
        }
    }
    stopSlideShow()
}

function onBefore(curr, next, opts) {
    $('#capCycle p').hide().empty()
    $('#' + curr.id + 'Thumb a img').fadeTo(200, '0.6')
    $('#' + next.id + 'Thumb a img').fadeTo(200, '1')
    if ($('#' + this.id + 'Cap').length > 0) {
        $('#capCycle p').html($('#' + this.id + 'Cap').html()).show();
        Cufon.replace('#capCycle p', { hover: true })

    }
}

function stopSlideShow() {
    $('#thumbs li a').click(function () {
        $('#cycle').cycle('pause');
    })
}

function hoverFadeLight() {
    $('#thumbs li a img').hover(function () {
        $(this).stop().fadeTo(200, '1')
    }, function () {
        $(this).stop().fadeTo(200, '0.6')
    })
}


function startSlideShow() {
    $('#pckgSlideshow').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });
}
