$(document).ready(function() {
    $('#slide').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 3000,
        pause: 1,
        pauseOnPagerHover: 1,
        prev: '#prev',
        next: '#next',
        pager: '#nav',
        before: onAfter
    });

    $('.slide').cycle({
        fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 3000,
        pause: 1,
        pauseOnPagerHover: 1,
        prev: '#prev',
        next: '#next',
        pager: '#nav'
    });

    $('#brandslide').cycle({
        fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 0,
        prev: '#brandsprev',
        next: '#brandsnext'
    });

    $('#bestsellers').cycle({
        fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 10000,
        pause: 1,
        prev: '#bestsprev',
        next: '#bestsnext'
    });

    $('#festivalslide').cycle({
        fx: 'scrollHorz', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 10000,
        pause: 1,
        prev: '#festprev',
        next: '#festnext'
    });

    function onAfter() {
        $('#imagetitle').html('<a href="' + this.href + '">' + $(this).children("img:first").prop("alt") + '</a>');
    }
    $('.jshide').css('visibility','visible');
    $('.pauseonhover').hover(function(){$('#slide').cycle('pause');}, function() {$('#slide').cycle('resume');});
    $('.bestpauseonhover').hover(function(){$('#bestsellers').cycle('pause');}, function() {$('#bestsellers').cycle('resume');});
    $('.festpauseonhover').hover(function(){$('#festivalslide').cycle('pause');}, function() {$('#festivalslide').cycle('resume');});

    $(".rollover").hover(function() {
        var pathParts = $(this).prop("src").split(".");
        pathParts[pathParts.length-2] += "_ro";
        $(this).prop("src", pathParts.join("."));
    }, function() {
        $(this).prop("src", $(this).prop("src").replace("_ro.","."));
    });

//menutop
    $("#menu2").removeClass("cssonly");
    $("#menu2 li a.rootNav").hover(function(){
        $(this).addClass("bgcol");

        $(this).parent().find("ul.subnav").fadeIn(0);
        $(this).parent().hover(function() {
        }, function() {
            $(this).parent().find("ul.subnav").fadeOut(0);
            $("#menu2 li a.rootNav").removeClass("bgcol");

        })
    });

//jScrollPane
    $('#pane1').jScrollPane();
    $('#fpnews').jScrollPane();
    $('#fpnews2').jScrollPane();
    $('.festival_box_text').jScrollPane();
    $('.scroll-pane').jScrollPane();


//tabs
    $("ul.tabs").tabs("div.panes > div.test");
    $("ul.fptabs").tabs("div.fppanes > div.fptest");

    $("#productcarousel").CloudCarousel(
    {
        xPos: 304,
        yPos: 50,
        xRadius: 264,
        yRadius: 25,
        buttonLeft: $("#carouselleft"),
        buttonRight: $("#carouselright"),
        altBox: $("#alt-text"),
        mouseWheel: true,
        titleBox: $("#title-text"),
        updateOnHover: false
    });

    $('.truncate').truncate({
        max_length: 1000,
        more: 'more'
    });

    $('.tickets_truncate').truncate({
        max_length: 200,
        more: 'more'
    });

    var stickyPanelOptions = {
                    topPadding: 0,
                    afterDetachCSSClass: "stickyMenu",
                    savePanelSpace: true
                };

    $("#menu_container").stickyPanel(stickyPanelOptions);

});

function openWindow(page, name, params)
{
    if (! window.focus)return true;
    window.open(page, name, params);
    return false;
}

function checkSizeDropDown(field,message){
	if(field.value == ""){
		alert(message);
		return false;
	} else {
		return true;
	}
}
