var ie6 = null;

(function($) {
    ArchiveDates = function() {
        this.visibleitems = 5;
        this.archivelist = $('#archivelist li');
        this.buttonOlder = $("#pagBack");
        this.buttonNewer = $("#pagFwd");
        this.currentPage = 1;

        var archiveDate = this;
        this.buttonOlder.click(function() {
            archiveDate.gotoPage(archiveDate.currentPage + 1);
            return false;
        });

        this.buttonNewer.click(function() {
            archiveDate.gotoPage(archiveDate.currentPage - 1);
            return false;
        });

        this.gotoPage(this.getPageIndexFromURL());
    }

    ArchiveDates.prototype.size = function() {
        return this.archivelist.length;
    }

    ArchiveDates.prototype.totalPages = function() {
        return Math.ceil(this.size() / this.visibleitems);
    }

    ArchiveDates.prototype.pageIndex = function(index) {
        var newPageIndex = Math.ceil(index / this.visibleitems);

        if (newPageIndex <= 0) {
            newPageIndex = 1;
        } else if (newPageIndex > this.totalPages()) {
            newPageIndex = this.totalPages();
        }

        return newPageIndex;
    }

    ArchiveDates.prototype.gotoPage = function(page) {
        this.currentPage = this.pageIndex(page * this.visibleitems);

        this.buttonNewer.show();
        this.buttonOlder.show();

        if (this.currentPage <= 1) {
            this.buttonNewer.hide();
        }
        if (this.currentPage >= this.totalPages()) {
            this.buttonOlder.hide();
        }

        var archiveDate = this;
        this.archivelist.each(function(position, object) {
            if (archiveDate.pageIndex(position + 1) == archiveDate.currentPage) {
                $(object).removeClass("archiveDateOff");
            }
            else {
                $(object).addClass("archiveDateOff");
            }
        });
    }

    ArchiveDates.prototype.getPageIndexFromURL = function() {
        var startsWith = function(input, matches) {
           return input.match("^" + matches) == matches;
        }

        var self = this;
        var path = $.url.attr("path");

        var pageIndex = 1;
        this.archivelist.each(function(index, value) {
            var anchor = $(this).find("a:first");
            if (startsWith(path, anchor.attr("href"))) {
                pageIndex = self.pageIndex(index + 1);
            }
        });

        return pageIndex;
    }

    $.extend({
        isAppleMobile: function() {
           var pattern = /(iPad|iPod|iPhone)/i;

           return navigator && navigator.userAgent && pattern.test(navigator.userAgent);
        },

        buildVideoFromUrl: function(url) {
            if ((null == url) || ("" == url)) return "";

            var video = { videoId: "", type: "" };

            var ytbPatternUriV = /^http:\/\/www\.youtube\.com\/v\/([^&]+)(&.*)?$/;

            if (ytbPatternUriV.test(url)) {
               video = { videoId : url.replace(ytbPatternUriV, "$1"), type : "ytbvideo" };
            }

            var ytbPatternQueryV = /^http:\/\/www\.youtube\.com\/watch\?v=([^&]+)(&.*)?$/;
            if (ytbPatternQueryV.test(url)) {
               video = { videoId: url.replace(ytbPatternQueryV, "$1"), type : "ytbvideo" };
            }

            var vmoPatternUriV = /^http:\/\/www\.vimeo\.com\/([^&]+)(&.*)?$/;
            if (vmoPatternUriV.test(url)) {
               video = { videoId: url.replace(vmoPatternUriV, "$1"), type: "vmovideo" };
            }

            var vmoPatternQueryV = /^http:\/\/vimeo\.com\/moogaloop\.swf\?clip_id=([^&]+)(&.*)?$/;
            if (vmoPatternQueryV.test(url)) {
               video = { videoId: url.replace(vmoPatternQueryV, "$1"), type : "vmovideo" };
            }

            return video;
        },

        replaceVideoWithIFrameEmbed: function(parentObject, height, width, video) {
            if (video.type == "ytbvideo") {
                return $.replaceObjectWithIFrameEmbed(parentObject, height, width, "http://www.youtube.com/embed/", video.videoId);
            }

            if (video.type == "vmovideo") {
                return $.replaceObjectWithIFrameEmbed(parentObject, height, width, "http://player.vimeo.com/video/", video.videoId);
            }

            return false;
        },

        replaceObjectWithIFrameEmbed: function(parentObject, height, width, videoProvider, videoId) {
            if ((null == videoProvider) || ("" == videoProvider) || (null == videoId) || ("" == videoId)) return false;

            var iframe = $("<iframe></iframe>");
            iframe.attr("height", height);
            iframe.attr("width", width);
            iframe.attr("src", videoProvider + videoId);
            iframe.attr("frameborder", "0");

            parentObject.replaceWith(iframe);

            return true;
        },
        
        decorateVideoForAppleMobile: function() {
            if (!$.isAppleMobile()) return;

            $("param[name=movie]").each(function() {
               var objectTag = $(this).parents("object");

               if (!objectTag.is("object")) return;

               var width  = objectTag.attr("width");
               var height = objectTag.attr("height");
               var movie  = $(this).attr("value");
               var video = $.buildVideoFromUrl(movie);

               $.replaceVideoWithIFrameEmbed(objectTag, height, width, video);
            });
        }
    });

    $(function() {
        $.decorateVideoForAppleMobile();
    });
})(jQuery);

var archive = {};

$(document).ready(function() {     
    archive = new ArchiveDates();

    ((document.all) && (navigator.appVersion.indexOf("MSIE 6.") != -1)) ? (ie6 = true) : (ie6 = false);

    if ($('#cont_txtbottom').is('div')) {
        var c_offset = $('#cont_txtbottom').position();
        var fader_ctx = "<div id=\"fader_ctx\">&nbsp;</div>";
        $('#cont_txtbottom').before(fader_ctx);
        $('#fader_ctx').css('left', c_offset.left);
        $('#fader_ctx').css('top', c_offset.top);
        $('#fader_ctx').css('height', $('#cont_txtbottom').height());
    }

    if ($('#date').is('div')) {
        var date = new Date();
        var today = dateFormat(date, "fullDate");
        var arr_date = today.split(',')
        var giorno = "<span style=\"font-weight:bold;\">" + arr_date[0] + "</span>";
        var mese_anno = "<span>" + arr_date[1]+ ","+ arr_date[2] + "</span>";
        $('#today').html(giorno + mese_anno);
    }

    if ($('#fan').is('div')) {
        hover_sn();
    }

    if($('#imgGallery').is('div')){
        setribbon_coldx();
    }

    if($('.hp_section').is('div')){
        setribbon_hpsection();
    }

    if($('.hp_subsection').is('div')){
        setribbon_hpsubsection();
    }

    if($('.search_page').is('div')){
        setribbon_searchsection();
    }

    if($('#swide_radio').is('div')){
        $('#swide_radio a').click(function(){
            window.open('http://webradio.kiver.com/swide/','Swide Radio','width=470,height=240');
        });
    }
    
    if($('#subscribe_nwl').is('div')){
        subscribe_nwl.init();
    }

    //adattamento larghezza title MainPage
    if ($('.title').width() > $('.hpHeadCnt').width()) {
	    $('.hpHeadCnt').width($('.title').width() + 20);
    }

    //adattamento larghezza txtLayer
    if ($('.title').width() > $('#txtContainer').width()) {
        $('#txtContainer').width($('p.title').width() + 20);
        $('#txtLayer').width($('#txtContainer').outerWidth());
    }

    $('li#lang>a, #lang>ul').bind('mouseover', function() {
        $('#lang ul').show();
    });
    $('#lang ul').bind('mouseout', function() {
        $(this).hide();
    });

    $('ul.level1>li>a').hover(function() {
        $('#menu div').not($('#menu li.on div')).hide();
        $('ul.level1>li>a.active').removeClass('active');
        $(this).addClass('active').next().show();
        inMenu = true;
    }, function() {
        inMenu = false;
        window.setTimeout("closeMenu()", 500);
    });

    $('ul.level1 li>div').hover(function() {
        inMenu = true;
    }, function() {
        inMenu = false;
        window.setTimeout("closeMenu()", 500);
    });

    $('#banners a img').css({opacity:0.6});

    $('#banners a').hover(function() {
        $(this).find('img').css({opacity:1});
    }, function() {
        $(this).find('img').css({opacity:0.6});
    });

    $("#newSearch").click(function() {
        $("#searchForm").submit();
        return false;
    });

    $("#newRefineSearch").click(function() {
        $("#refineSearchForm").submit();
        return false;
    });

    $("#refineSearchForm").submit(function() {
        setFormAction("#refineSearchForm", 1);
    });

    $("#searchForm").submit(function() {
        setFormAction("#searchForm", 1);
    });
    
    $('#searchForm input').focus(function() {
        if ($(this).val() == searchString) {
            $(this).val('');
        }
    });

    $('#searchForm input').blur(function() {
        if ($(this).val() == '') {
            $(this).val(searchString);
        }
    });

    if ($("#searchResults").is("div")) {
        setPaginationLinks();
    }

    if ($("#archiveResults").is("div")) {
       setArchiveLinks();
    }

    function setArchiveLinks() {
       var currentPage = new Number($("#currentPage").text());

        var path = $.url.attr("path").replace(/\/+$/, "");
        var pageRegExp = new RegExp("/page/" + currentPage + "$");

        var renderPageURL = function(newPageNumber) {
            if (pageRegExp.test(path)) {
                return path.replace("/page/" + currentPage, "/page/" + newPageNumber);
            }

            return path + "/page/" + newPageNumber;
        };

        $("#archiveResults a.pageSelector").each(function() {
            var pageSelector = $(this);
            var page = $(this).find("span:eq(0)").text();
            pageSelector.attr("href", renderPageURL(page));
        });
    }

    if ($('#imgGallery').is('div')) {
        gallery.init();
		$('#layout').addClass('article_detail');
    }

    if($('#imgCounter li').length>0){
        slide_gall.init();
    }
    
    // Media per tutti i video FLV
    if ($('.flvvideo').is('div')) {
        $('#videoContainer').find('.flvvideo').each(function() {
            var videoUrl = $(this).attr('url');
            var vw = $(this).attr('w');
            var vh = $(this).attr('h');
            $(this).media({
                width:     460,
                height:    370,
                autoplay:  true,
                params:    {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true'},
                attrs:     {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true', id: 'video_flv'},
                src:       $("#videoPlayerUrl").text(),
                flashvars:  {file: videoUrl, image: flvstarterimage, height : 370, width :460,frontcolor :"ffffff",backcolor : "000000",lightcolor : "FFFFFF",overstretch : false,bufferlength : 5,usefullscreen : true, id: 'video_flv'},
                caption:   false
            });
            var $videoTitle = $('#videoTitle');
            var pdHor = parseInt($videoTitle.css('paddingLeft')) + parseInt($videoTitle.css('paddingRight'));
            var pdVer = parseInt($videoTitle.css('paddingTop')) + parseInt($videoTitle.css('paddingBottom'));
            $videoTitle.css({width:parseInt(710 - vw - pdHor), height:parseInt(vh - pdVer)});
        });
    }
    if ($('.ytbvideo').is('div')) {
        $('#videoContainer').find('.ytbvideo').each(function() {
            var videoUrl = $(this).attr('url');
            var vw = $(this).attr('w');
            var vh = $(this).attr('h');

            var buildMedia = true;
            if ($.isAppleMobile()) {
                buildMedia = !$.replaceVideoWithIFrameEmbed($(this), vh, vw, $.buildVideoFromUrl(videoUrl));
            }

            if (buildMedia) {
                $(this).media({
                    width:     vw,
                    height:    vh,
                    autoplay:  true,
                    params:    {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true'},
                    attrs:     {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true', id: 'video_youtube'},
                    src:       $("#videoPlayerUrl").text(),
                    flashvars:  {file: videoUrl, image: flvstarterimage, height : 370, width :460,frontcolor :"ffffff",backcolor : "000000",lightcolor : "FFFFFF",overstretch : false,bufferlength : 5,usefullscreen : true, id: 'video_youtube'},
                    caption:   false
                });
            }
            
            var $videoTitle = $('#videoTitle');
            var pdHor = parseInt($videoTitle.css('paddingLeft')) + parseInt($videoTitle.css('paddingRight'));
            var pdVer = parseInt($videoTitle.css('paddingTop')) + parseInt($videoTitle.css('paddingBottom'));
            $videoTitle.css({width:parseInt(710 - vw - pdHor), height:parseInt(vh - pdVer)});
        });
    }
    if ($('.vmovideo').is('div')) {
        $('#videoContainer').find('.vmovideo').each(function() {
            var videoUrl = $(this).attr('url');
            var vw = $(this).attr('w');
            var vh = $(this).attr('h');

            var buildMedia = true;
            if ($.isAppleMobile()) {
                buildMedia = !$.replaceVideoWithIFrameEmbed($(this), vh, vw, $.buildVideoFromUrl(videoUrl));
            }

            if (buildMedia) {
                $(this).media({
                    width:     vw,
                    height:    vh,
                    autoplay:  true,
                    params:    {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true'},
                    attrs:     {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true', id: 'video_vimeo'},
                    src:       $("#videoPlayerUrl").text(),
                    flashvars:  {file: videoUrl, image: flvstarterimage, height : 370, width :460,frontcolor :"ffffff",backcolor : "000000",lightcolor : "FFFFFF",overstretch : false,bufferlength : 5,usefullscreen : true, id: 'video_vimeo', type: $("#vimeoPlayerUrl").text()},
                    caption:   false
                });
            }

            var $videoTitle = $('#videoTitle');
            var pdHor = parseInt($videoTitle.css('paddingLeft')) + parseInt($videoTitle.css('paddingRight'));
            var pdVer = parseInt($videoTitle.css('paddingTop')) + parseInt($videoTitle.css('paddingBottom'));
            $videoTitle.css({width:parseInt(710 - vw - pdHor), height:parseInt(vh - pdVer)});
        });
    }
    if ($('.strvideo').is('div')) {
        $('#videoContainer').find('.strvideo').each(function() {
            var videoUrl = $(this).attr('url');
            var width = $(this).attr('w');
            var height = $(this).attr('h');
            var vw = $(this).attr('w');
            var vh = $(this).attr('h');

            var sFile = videoUrl.split("$")[0];
            var sStreamer = videoUrl.split("$")[1];
            $(this).media({
                width:     vw,
                height:    vh,
                autoplay:  true,
                params:    {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true'},
                attrs:     {bgcolor : '#000000',scale:'noscale', allowfullscreen:'true', id: 'video_streaming'},
                src:       $("#videoPlayerUrl").text(),
                flashvars:  {file: sFile, streamer: sStreamer, image: flvstarterimage, height : 370, width :460,frontcolor :"ffffff",backcolor : "000000",lightcolor : "FFFFFF",overstretch : false,bufferlength : 5,usefullscreen : true, id: 'video_streaming'},
                caption:   false
            });

            var $videoTitle = $('#videoTitle');
            var pdHor = parseInt($videoTitle.css('paddingLeft')) + parseInt($videoTitle.css('paddingRight'));
            var pdVer = parseInt($videoTitle.css('paddingTop')) + parseInt($videoTitle.css('paddingBottom'));
            $videoTitle.css({width:parseInt(710 - vw - pdHor), height:parseInt(vh - pdVer)});
        });
    }

    handleAminatedGallery();
});

function handleAminatedGallery() {
    var animGalleries = $("div.animGallery");

    animGalleries.each(function() {
        $(this).data("gallery", {next: 0, pics: $(this).find("img")});
    });

    function spinGalleries() {
        $.each(animGalleries, function(index, value) {
            var gallery = $.data(value, "gallery")
            gallery.pics.eq(gallery.next).hide();
            gallery.next = (gallery.next + 1) % gallery.pics.length;
            gallery.pics.eq(gallery.next).show();
        });
    }

    setInterval(spinGalleries,100);
}

var subscribe_nwl={
    init : function(){
        $('#subscribe_nwl>a').click(function(){
            subscribe_nwl.showform();
            return false;
        });
    },
    showform :  function(){
        var offset_btn=$('#subscribe_nwl').offset();
        var page_h=$(document).height();
        var fdr='<div id="fdr_nwl">&nbsp;</div>';
        var box_nwl='<div id="box_nwl"><img src="' + $("#closeRadioButtonUrl").text() + '" id="close_nwl" /><iframe src="http://fe-mn1.mag-news.it/nl/dolcegabbanasito_page157.mn" width="390" height="190" scrolling="auto" frameborder="0"></iframe></div>';
        $('body').append(fdr);
        $('#fdr_nwl').height(page_h);
        $('body').append(box_nwl);
        $('#box_nwl').css('left',offset_btn.left-210)
        $('#box_nwl').css('top',offset_btn.top);
        $('#close_nwl').click(function(){
            subscribe_nwl.closeform()
        })
    },
    closeform : function(){
        $('#box_nwl').hide();
        $('#fdr_nwl').hide();
        $('#box_nwl').remove();
        $('#fdr_nwl').remove();
    }
}

function setribbon_coldx(){
    $('#imgGallery').append('<img src="' + $("#spacerUrl").text() + '" id="filetto" />');
}

function setribbon_hpsection(){
    $('.wideClmn').append('<img src="' + $("#spacerUrl").text() + '" id="filetto_hpsection" />');
    $('.narrowClmn').append('<img src="' + $("#spacerUrl").text() + '" id="filetto_hpsection_coldx" />');
}

function setribbon_hpsubsection(){
    $('.wideClmn').append('<img src="' + $("#spacerUrl").text() + '" id="filetto_hpsubsection" />');
    $('.narrowClmn').append('<img src="' + $("#spacerUrl").text() + '" id="filetto_hpsection_coldx" />');
}

function setribbon_searchsection(){
    $('#breadcrumbs').append('<img src="' + $("#searchSpacerUrl").text() + '" id="filetto_searchsection" />');
}
		
function setPageLink(selector, page) {
    var pageLink = $(selector);
    
    if (pageLink.is("a")) {
        pageLink.attr("href", searchUri + "/" + page + "/" + getSearchUri());
    }
}

function setPaginationLinks() {
    $("#searchResults a.pageSelector").each(function() {
        var pageSelector = $(this);
        var page = $(this).find("span:eq(0)").text();
        pageSelector.attr("href", searchUri + "/" + page + "/" + getSearchUri());
    });
}

function setFormAction(selector, page) {
    var form = $(selector);
    if (form.is("form")) {
        form.attr("action", searchUri + "/" + page + "/" + getSearchUri());
    }
}

function hover_sn() {
    $('#fan a').hover(
            function () {
                $(this).find('.on').fadeIn('fast');
            },
            function () {
                $(this).find('.on').fadeOut('fast');
            }
            );
}

function closeMenu() {
    if (inMenu == false) {
        $('ul.level1 li>a.active').not($('li.on>a')).removeClass('active').next().hide();
    }
}

var slide_gall={
    pics : [],
    currrent_slide : 0,
    init : function(){
        $('#imgGallery').append('<div id="slider_gall">&nbsp;</div>');
        var default_img=$('#imgGallery>img').eq(0).attr('src');
        $('#slider_gall').append('<p id="c_defaultimg" round="first"><img src="'+default_img+'" id="default_img" /></p>');
        $('#imgCounter li>a').each(function(){
            slide_gall.pics.push($(this).attr('href'));
        });
        slide_gall.preload();
    },
    preload : function(){
        $.preload(slide_gall.pics, {onFinish:function(data){
            slide_gall.createImgs();
        }});
    },
    createImgs : function(){
        $(slide_gall.pics).each(function(i){
            $('#slider_gall').append('<img src="'+$(slide_gall.pics)[i]+'" id="el_slide_'+i+'" class="els_slider" />');
        });
        $('#imgGallery img').click(function(){
            gallery.open();
            return false;
        });
        window.setTimeout("slide_gall.slider()",2000);
    },
    slider : function(){
        $('#slider_gall').cycle({
            fx:   'fade',
            speed:  1500,
            startingSlide: 1,
            after:  function (curr,next,opts) {
                slide_gall.currrent_slide=opts.currSlide;
            }

        });

        if(!$.browser.msie){
            $('#imgGallery>img').eq(0).fadeTo(1000,0);
            $('#slider_gall').fadeTo(1500,1);
        }
        else{
            $('#imgGallery>img').eq(0).hide();
            $('#slider_gall').show();
        }
    }
}

var gallery = {
    currItem : 0,
    init: function() {
        images = $('#imgCounter ul a');
        caption = $('#txtContainer .title').text();
        $('#startSS').click(function(e) {
            e.preventDefault();
            gallery.open();
        });
    },
    open: function() {
        cw_h = $('#contentWrapper').height();
        backgroundDiv = '<div class="layerOverlay"></div>';
        if ((images.length) > 1) {
            galleryHolder = '<div class="galleryHolder"><div class="top"><h1></h1><a href="#" class="close">Close</a></div><div class="imgHolder"></div><div class="bottom"><p class="nav"><a class="prev" href="#">Prev</a> | <a class="next" href="#">Next</a></p><p class="desc">&nbsp;</p></div></div>';
        } else {
            galleryHolder = '<div class="galleryHolder"><div class="top"><h1></h1><a href="#" class="close">Close</a></div><div class="imgHolder"></div><div class="bottom"><p class="desc">&nbsp;</p></div></div>';
        }
        $('#contentWrapper').append(backgroundDiv);
        $('#contentWrapper').append(galleryHolder);
        $('.galleryHolder .top h1').text(caption);
        $('#imgCounter ul').clone().insertBefore('.bottom a.prev');
        $('.galleryHolder').css({opacity:0})
        $('.layerOverlay').css({opacity:0}).fadeTo('fast', 0.7, function() {
            $('.galleryHolder').fadeTo('fast', 1);
        });
        gallery.browse();
        gallery.openImg(slide_gall.currrent_slide-1);
		$('#slider_gall').cycle('pause'); 
    },
    openImg : function(n) {
        gallery.currItem = (n < 0) ? (images.length - 1) : (n == images.length) ? 0 : n;
        $('.galleryHolder .bottom ul a').removeClass('active');
        var pic = new Image();
        picSrc = images.eq(gallery.currItem).attr('href');
        $(pic).load(function() {
            $('.imgHolder')
                    .find('img')
                    .remove()
                    .end()
                    .append((pic));
            $('.galleryHolder .bottom p.desc').text(images.eq(gallery.currItem).attr('title'));
            $('.galleryHolder .bottom ul a').eq(gallery.currItem).addClass('active');
            if (cw_h < $('.galleryHolder').height()) {
                $('#contentWrapper').height($('.galleryHolder').height());
            }
            else {
                $('#contentWrapper').height(cw_h);
            }
        });

        $(pic).attr({src:picSrc});
    },
    browse : function() {
        $('.bottom a.prev').
                bind('click', function(e) {
            e.preventDefault();
            gallery.openImg(gallery.currItem - 1);
        });

        $('.bottom a.next').
                bind('click', function(e) {
            e.preventDefault();
            gallery.openImg(gallery.currItem + 1);
        });
        $('.top a.close').
                bind('click', function(e) {
            e.preventDefault();
            gallery.close();
        });
        $('.bottom ul a').
                bind('click', function(e) {
            e.preventDefault();
            gallery.openImg(parseInt($(this).text() - 1));
        });
    },
    close : function() {
        $('div.galleryHolder').fadeTo('fast', 0, function() {
            $('div.layerOverlay').fadeTo('fast', 0, function() {
                $('div.galleryHolder').remove();
                $('div.layerOverlay').remove();
            });
        });
        $('#slider_gall').cycle(gallery.currItem+1);
		$('#slider_gall').cycle('resume');
    }
}


function getSearchUri() {
    var search = "";
    var categories = "";
    var types = "";

    var SearchOption = function(key, text) {
        this.checkbox = $("#refineSearch #" + key);
        this.text = text;
    }

    var arrayOfAreaIds = [new SearchOption("style", "Style-"), new SearchOption("faces", "Faces-"), new SearchOption("life", "Life-"), new SearchOption("history", "History-")];

    $.each(arrayOfAreaIds, function(indexInArray, valueOfElement) {
        var valueChecked = valueOfElement.checkbox.attr("checked")
        if (valueChecked == true) {
           categories += valueOfElement.text;
        }
    });

    var arrayOfTypeIds = [new SearchOption("articles", "1-"), new SearchOption("videos", "3-"), new SearchOption("images", "2-")];

    $.each(arrayOfTypeIds, function(indexInArray, valueOfElement) {
        var valueChecked = valueOfElement.checkbox.attr("checked")
        if (valueChecked == true) {
           types += valueOfElement.text;
        }
    });

    if (categories == "") {
        categories = 'NONE';
    }

    if (types == "") {
        types = 'NONE';
    }

    search +=  categories + "/" + types + "/";

    var searchWords = escape($('#searchwords').val());
    if (searchWords != "") {
       search += searchWords + "/"; 
    }

    return search;
}

$(window).load(function() {
    //hack per ie6 - corregge l'altezza del blocco bianco negli elementi selezionati
    if (ie6) {
        $('.hpHeadCnt, .txtRght .txtWrapper, #imgGallery #txtLayer').setHeight();
    }
});

$.fn.setHeight = function() {
    return this.each(function() {
        var parentH = $(this).parent().find('img').height();
        $(this).height(parentH).parent().find('#imgCounter').css({top: (parentH - 35) + 'px'});
    });
}

var inMenu = false;
var searchString = "Swide Search";

function getCalendarDateEn(idlang, idMonth)
{
    var months = new Array(13);

    months[0] = "January";
    months[1] = "February";
    months[2] = "March";
    months[3] = "April";
    months[4] = "May";
    months[5] = "June";
    months[6] = "July";
    months[7] = "August";
    months[8] = "September";
    months[9] = "October";
    months[10] = "November";
    months[11] = "December";

    if (idlang == 'it') {
        months[0] = "Gennaio";
        months[1] = "Febbraio";
        months[2] = "Marzo";
        months[3] = "Aprile";
        months[4] = "Maggio";
        months[5] = "Giugno";
        months[6] = "Luglio";
        months[7] = "Agosto";
        months[8] = "Settembre";
        months[9] = "Ottobre";
        months[10] = "Novembre";
        months[11] = "Dicembre";
    }

    return months[idMonth];
} // function getCalendarDate()

/*
 * Date Format 1.2.2
 * (c) 2007-2008 Steven Levithan <stevenlevithan.com>
 * MIT license
 * Includes enhancements by Scott Trenda <scott.trenda.net> and Kris Kowal <cixar.com/~kris.kowal/>
 *
 * Accepts a date, a mask, or a date and a mask.
 * Returns a formatted version of the given date.
 * The date defaults to the current date/time.
 * The mask defaults to dateFormat.masks.default.
 */
var dateFormat = function () {
    var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
            timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
            timezoneClip = /[^-+\dA-Z]/g,
            pad = function (val, len) {
                val = String(val);
                len = len || 2;
                while (val.length < len) val = "0" + val;
                return val;
            };

    // Regexes and supporting functions are cached through closure
    return function (date, mask, utc) {
        var dF = dateFormat;

        // You can't provide utc if you skip other args (use the "UTC:" mask prefix)
        if (arguments.length == 1 && (typeof date == "string" || date instanceof String) && !/\d/.test(date)) {
            mask = date;
            date = undefined;
        }

        // Passing date through Date applies Date.parse, if necessary
        date = date ? new Date(date) : new Date();
        if (isNaN(date)) throw new SyntaxError("invalid date");

        mask = String(dF.masks[mask] || mask || dF.masks["default"]);

        // Allow setting the utc argument via the mask
        if (mask.slice(0, 4) == "UTC:") {
            mask = mask.slice(4);
            utc = true;
        }

        var _ = utc ? "getUTC" : "get",
                d = date[_ + "Date"](),
                D = date[_ + "Day"](),
                m = date[_ + "Month"](),
                y = date[_ + "FullYear"](),
                H = date[_ + "Hours"](),
                M = date[_ + "Minutes"](),
                s = date[_ + "Seconds"](),
                L = date[_ + "Milliseconds"](),
                o = utc ? 0 : date.getTimezoneOffset(),
                flags = {
                    d:    d,
                    dd:   pad(d),
                    ddd:  dF.i18n.dayNames[D],
                    dddd: dF.i18n.dayNames[D + 7],
                    m:    m + 1,
                    mm:   pad(m + 1),
                    mmm:  dF.i18n.monthNames[m],
                    mmmm: dF.i18n.monthNames[m + 12],
                    yy:   String(y).slice(2),
                    yyyy: y,
                    h:    H % 12 || 12,
                    hh:   pad(H % 12 || 12),
                    H:    H,
                    HH:   pad(H),
                    M:    M,
                    MM:   pad(M),
                    s:    s,
                    ss:   pad(s),
                    l:    pad(L, 3),
                    L:    pad(L > 99 ? Math.round(L / 10) : L),
                    t:    H < 12 ? "a" : "p",
                    tt:   H < 12 ? "am" : "pm",
                    T:    H < 12 ? "A" : "P",
                    TT:   H < 12 ? "AM" : "PM",
                    Z:    utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
                    o:    (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
                    S:    ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
                };

        return mask.replace(token, function ($0) {
            return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
        });
    };
}();

// Some common format strings
dateFormat.masks = {
    "default":      "ddd mmm dd yyyy HH:MM:ss",
    shortDate:      "m/d/yy",
    mediumDate:     "mmm d, yyyy",
    longDate:       "mmmm d, yyyy",
    fullDate:       "dddd, mmmm d, yyyy",
    shortTime:      "h:MM TT",
    mediumTime:     "h:MM:ss TT",
    longTime:       "h:MM:ss TT Z",
    isoDate:        "yyyy-mm-dd",
    isoTime:        "HH:MM:ss",
    isoDateTime:    "yyyy-mm-dd'T'HH:MM:ss",
    isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};

// Internationalization strings
dateFormat.i18n = {
    dayNames: [
        "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
        "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
    ],
    monthNames: [
        "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
        "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
    ]
};

// For convenience...
Date.prototype.format = function (mask, utc) {
    return dateFormat(this, mask, utc);
};

/* ===========================================================================
 *
 * JQuery URL Parser
 * Version 1.0
 * Parses URLs and provides easy access to information within them.
 *
 * Author: Mark Perkins
 * Author email: mark@allmarkedup.com
 *
 * For full documentation and more go to http://projects.allmarkedup.com/jquery_url_parser/
 */
jQuery.url=function(){var segments={};var parsed={};var options={url:window.location,strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var parseUri=function(){str=decodeURI(options.url);var m=options.parser[options.strictMode?"strict":"loose"].exec(str);var uri={};var i=14;while(i--){uri[options.key[i]]=m[i]||""}uri[options.q.name]={};uri[options.key[12]].replace(options.q.parser,function($0,$1,$2){if($1){uri[options.q.name][$1]=$2}});return uri};var key=function(key){if(!parsed.length){setUp()}if(key=="base"){if(parsed.port!==null&&parsed.port!==""){return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/"}else{return parsed.protocol+"://"+parsed.host+"/"}}return(parsed[key]==="")?null:parsed[key]};var param=function(item){if(!parsed.length){setUp()}return(parsed.queryKey[item]===null)?null:parsed.queryKey[item]};var setUp=function(){parsed=parseUri();getSegments()};var getSegments=function(){var p=parsed.path;segments=[];segments=parsed.path.length==1?{}:(p.charAt(p.length-1)=="/"?p.substring(1,p.length-1):path=p.substring(1)).split("/")};return{setMode:function(mode){strictMode=mode=="strict"?true:false;return this},setUrl:function(newUri){options.url=newUri===undefined?window.location:newUri;setUp();return this},segment:function(pos){if(!parsed.length){setUp()}if(pos===undefined){return segments.length}return(segments[pos]===""||segments[pos]===undefined)?null:segments[pos]},attr:key,param:param}}();

//media
eval(function(p, a, c, k, e, r) {e = function(c) {return(c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))}; if (!''.replace(/^/, String)) {while (c--)r[e(c)] = k[c] || e(c); k = [function(e) { return r[e] }]; e = function() { return'\\w+' }; c = 1 }; while (c--)if (k[c])p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }(';(6($){$.3.4=6(d,e,f){s S.1p(6(){5(15 d==\'6\'){f=e;e=d;d={}}2 o=1E(S,d);5(15 e==\'6\')e(S,o);2 r=22();2 m=r.3D(o.8)||[\'\'];o.K?m[0]=o.K:m.37();y(2 i=0;i<m.14;i++){3=m[i].2c();5(1b(3[0]))3=\'3\'+3;5(!$.3.4[3])2v;2 a=$.3.4[3+\'1z\'];5(!o.t)o.t={};5(a){2 b=a.1f==\'1y\';o.t[a.1f||\'11\']=b?(o.11?1:0):o.11?1c:1X}2 c=$.3.4[3](S,o);c.1U(\'1S\',o.F).u(o.u);5(15 f==\'6\')f(S,c[0],o,a.G);36}})};$.3.4.2Z=6(a,b){5(!a||!b||!$.3.4.v.H[b])s;a=a.2c();5(1b(a[0]))a=\'3\'+a;$.3.4[a]=$.3.4[b];$.3.4[a+\'1z\']=$.3.4.v.H[b]};$.3.4.v={u:1K,A:1K,11:0,F:\'#2L\',t:{2I:\'2G\'},M:{},C:{},1d:\'7\',12:10,21:\'23.U\',2a:\'23.U\',B:{1B:\'1c\',1A:\'1c\',1C:\'24\',1e:\'0.9\',1u:10,1t:10,1r:10,1q:10}};$.3.4.v.H={T:{G:\'T\',I:\'1Y,1h,U\',Q:{1a:\'18:3o-3l-1R-3h-3f\',K:\'Y/x-1P\',1O:\'R://33.2Y.P/2W/1M/2U/T/2S.1V#1e=\'+$.3.4.v.1d},O:{K:\'Y/x-1M-T\',17:\'R://W.2K.P/2J/2H\'}},1l:{G:\'1l\',I:\'2F,2D,2C,2A,2z,2y,2x,2w,2u,2t,2s,2q,2p,2n,2m,2k,2j,2g,2f,2d,4o,4l,4g,4d\',Q:{1a:\'18:4b-4a-48-46-45\',1O:\'R://W.28.P/3U/3T.1V\'},O:{17:\'R://W.28.P/1l/3S/\'}},3R:{G:\'20\',I:\'3N,3M,3L,3J,3I,3H,3G\',1f:\'1y\',Q:{1a:\'18:3F-3E-1R-3C-3B\'},O:{K:\'3A/x-3z-3x-3w\',17:\'R://W.20.P/3u/\'}},1G:{G:\'1G\',I:\'3t,3s,3r,3q\',1f:\'1y\',1T:\'3p\',Q:{1a:\'18:3n-3m-3k-3j-3i\',K:\'Y/x-1P\'},O:{K:$.1n.3g&&1Q()?\'Y/x-3e-3d\':\'Y/x-3c\',17:\'R://W.3b.P/3a/39/\'}},X:{G:\'X\',I:\'V,38\'},B:{G:\'B\',I:\'16\'}};6 1Q(){2 a=35.34;y(i=0;i<a.14;i++){2 b=a[i];5(b[\'31\']==\'30-2X.32\')s 1c}s 1X}2 l=1;y(2 n D $.3.4.v.H){2 q=$.3.4.v.H[n].I;$.1p(q.2V(\',\'),6(i,o){5(1b(o[0]))o=\'3\'+o;$.3.4[o]=$.3.4[n]=1N(n);$.3.4[o+\'1z\']=$.3.4.v.H[n]})};6 22(){2 a=\'\';y(2 b D $.3.4.v.H){5(a.14)a+=\',\';a+=$.3.4.v.H[b].I};s 1L 2T(\'\\\\.(\'+a.2R(/,/g,\'|\')+\')\\\\b\')};6 1N(c){s 6(a,b){s 1m(a,b,c)}};6 1b(c){s\'2Q\'.2P(c)>-1};6 1E(d,e){e=e||{};2 f=$(d);2 g=d.2O||\'\';2 j=$.1J?f.1J():$.2N?f.2M():{};j=j||{};2 w=j.u||1I(((g.1H(/w:(\\d+)/)||[])[1]||0));2 h=j.A||1I(((g.1H(/h:(\\d+)/)||[])[1]||0));5(w)j.u=w;5(h)j.A=h;5(g)j.L=g;2 a=$.3.4.v;2 b=e;2 c=j;2 p={t:{F:e.F||$.3.4.v.F}};2 k=$.1o({},a,b,c);$.1p([\'M\',\'t\',\'C\',\'B\'],6(i,o){k[o]=$.1o({},p[o]||{},a[o]||{},b[o]||{},c[o]||{})});5(15 k.J==\'2E\')k.J=f.3v();k.8=k.8||f.1w(\'2B\')||f.1w(\'8\')||\'3y\';s k};$.3.4.U=6(b,c){5(!Z.1W&&!Z.1k){5(c.C){2 a=[];y(2 f D c.C)a.E(f+\'=\'+c.C[f]);5(!c.t)c.t={};c.t.C=a.1j(\'&\')}s 1m(b,c,\'T\')}2 d=b.z?(\' z="\'+b.z+\'"\'):\'\';2 e=c.L?(\' 1i="\'+c.L+\'"\'):\'\';2 g=$(\'<N\'+d+e+\'>\');5(Z.1k){$(b).19(g).13(g);5(!b.z)b.z=\'1Z\'+l++;1k.3K(c.8,b.z,c.u,c.A,c.1d,c.12,c.C,c.t,c.M)}1s{$(b).19(g).1v();2 h=1L 1W(c.8,\'1Z\'+l++,c.u,c.A,c.1d,c.F);5(c.12)h.2r(c.12);y(2 p D c.t)5(p!=\'F\')h.3O(p,c.t[p]);y(2 f D c.C)h.3P(f,c.C[f]);h.3Q(g[0])}5(c.J)$(\'<N>\').13(g).V(c.J);s g};$.3.4.1Y=$.3.4.1h=6(a,b){2 c=b.8;2 d=/\\.1h\\b/i.2o(c)?$.3.4.v.2a:$.3.4.v.21;b.8=d;b.8=b.8+\'?1F=\'+c;b.C=$.1o({},{1F:c},b.C);s $.3.4.U(a,b)};$.3.4.16=6(a,b){5(!Z.1x||!Z.1x.1g){5($.3.4.16.1D)s;$.3.4.16.1D=1;2l(\'3V 3W 2i 2h 1g.3Z 40.\');s}2 c={u:b.u,A:b.A,2e:b.F,1B:b.B.1B,1A:b.B.1A,1C:b.B.1C,1e:b.B.1e};2 d={1u:b.B.1u,1t:b.B.1t};2 e=a.z?(\' z="\'+a.z+\'"\'):\'\';2 f=b.z||\'42\'+l++;2 g=b.L?(\' 1i="\'+b.L+\'"\'):\'\';2 h=$(\'<N\'+e+g+\'>\');$(a).19(h).1v();1x.1g.43({44:b.8,1r:b.B.1r,1q:b.B.1q,z:f,4n:h[0],4m:c,4h:d});5(b.J)$(\'<N>\').13(h).V(b.J);s h};6 1m(b,c,d){2 e=$(b);2 o=$.3.4.v.H[d];5(d==\'X\'){2 o=$(\'<X\'+\' u="\'+c.u+\'" A="\'+c.A+\'" >\');o.1w(\'8\',c.8);o.1U(\'1S\',o.F)}1s 5($.1n.29){2 a=[\'<4f u="\'+c.u+\'" A="\'+c.A+\'" \'];y(2 f D c.M)a.E(f+\'="\'+c.M[f]+\'" \');y(2 f D o.Q||{})a.E(f+\'="\'+o.Q[f]+\'" \');a.E(\'></4e\'+\'4c\'+\'>\');2 p=[\'<27 G="\'+(o.1T||\'8\')+\'" 26="\'+c.8+\'">\'];y(2 f D c.t)p.E(\'<27 G="\'+f+\'" 26="\'+c.t[f]+\'">\');2 o=25.2b(a.1j(\'\'));y(2 i=0;i<p.14;i++)o.49(25.2b(p[i]))}1s{2 a=[\'<47 u="\'+c.u+\'" A="\'+c.A+\'" 4i="4j:4k"\'];5(c.8)a.E(\' 8="\'+c.8+\'" \');y(2 f D c.M)a.E(f+\'="\'+c.M[f]+\'" \');y(2 f D o.O||{})a.E(f+\'="\'+o.O[f]+\'" \');y(2 f D c.t)a.E(f+\'="\'+c.t[f]+\'" \');a.E(\'></41\'+\'3Y\'+\'>\')}2 g=b.z?(\' z="\'+b.z+\'"\'):\'\';2 h=c.L?(\' 1i="\'+c.L+\'"\'):\'\';2 j=$(\'<N\'+g+h+\'>\');e.19(j).1v();($.1n.29||d==\'X\')?j.3X(o):j.V(a.1j(\'\'));5(c.J)$(\'<N>\').13(j).V(c.J);s j}})(4p);', 62, 274, '||var|fn|media|if|function||src||||||||||||||||||||return|params|width|defaults|||for|id|height|silverlight|flashvars|in|push|bgColor|name|players|types|caption|type|cls|attrs|div|eAttrs|com|oAttrs|http|this|flash|swf|html|www|iframe|application|window|null|autoplay|expressInstaller|appendTo|length|typeof|xaml|pluginspage|clsid|after|classid|isDigit|true|flashVersion|version|autoplayAttr|Silverlight|mp3|class|join|swfobject|quicktime|generate|browser|extend|each|userContext|initParams|else|onLoad|onError|remove|attr|Sys|autostart|_player|isWindowless|inplaceInstallPrompt|framerate|warning|getSettings|file|winmedia|match|parseInt|metadata|400|new|shockwave|getGenerator|codebase|oleobject|isFirefoxWMPPluginInstalled|11cf|backgroundColor|oUrl|css|cab|SWFObject|false|flv|movie_player_|real|flvPlayer|getTypesRegExp|mediaplayer||document|value|param|apple|msie|mp3Player|createElement|toLowerCase|tif|background|snd|qti|the|include|qif|qtif|alert|qt|psd|test|m4a|mp4|useExpressInstall|mpeg|mpg|midi|continue|mid|mov|gsm|bmp|au|href|aac|aiff|undefined|aif|transparent|getflashplayer|wmode|go|adobe|ffffff|data|meta|className|indexOf|0123456789|replace|swflash|RegExp|cabs|split|pub|mswmp|macromedia|mapFormat|np|filename|dll|fpdownload|plugins|navigator|break|shift|pdf|MediaPlayer|Windows|microsoft|mplayer2|wmp|ms|444553540000|mozilla|96b8|00C04F79FAA6|B153|11d3|ae6d|394A|6BF52A52|d27cdb6e|url|wmv|wma|avi|asf|player|text|plugin|realaudio|unknown|pn|audio|0020AFBBCCFA|B84B|exec|8BE4|CFCDAA03|smil|smi|rv|rpm|embedSWF|rm|ram|ra|addParam|addVariable|write|realplayer|download|qtplugin|qtactivex|You|must|append|bed|js|script|em|AG|createObjectEx|source|D3488ABDDC6B|BC80|embed|4B23|appendChild|8C17|02BF25D5|ject|3gp|ob|object|3g2|events|style|display|block|wav|properties|parentElement|tiff|jQuery'.split('|'), 0, {}));

(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);

/*
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version: 2.86 (05-APR-2010)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.6 or later
 */
(function($){var ver="2.86";if($.support==undefined){$.support={opacity:!($.browser.msie)};}function debug(s){if($.fn.cycle.debug){log(s);}}function log(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "));}}$.fn.cycle=function(options,arg2){var o={s:this.selector,c:this.context};if(this.length===0&&options!="stop"){if(!$.isReady&&o.s){log("DOM not ready, queuing slideshow");$(function(){$(o.s,o.c).cycle(options,arg2);});return this;}log("terminating; zero elements found by selector"+($.isReady?"":" (DOM not ready)"));return this;}return this.each(function(){var opts=handleArguments(this,options,arg2);if(opts===false){return;}opts.updateActivePagerLink=opts.updateActivePagerLink||$.fn.cycle.updateActivePagerLink;if(this.cycleTimeout){clearTimeout(this.cycleTimeout);}this.cycleTimeout=this.cyclePause=0;var $cont=$(this);var $slides=opts.slideExpr?$(opts.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){log("terminating; too few slides: "+els.length);return;}var opts2=buildOptions($cont,$slides,els,opts,o);if(opts2===false){return;}var startTime=opts2.continuous?10:getTimeout(opts2.currSlide,opts2.nextSlide,opts2,!opts2.rev);if(startTime){startTime+=(opts2.delay||0);if(startTime<10){startTime=10;}debug("first timeout: "+startTime);this.cycleTimeout=setTimeout(function(){go(els,opts2,0,!opts2.rev);},startTime);}});};function handleArguments(cont,options,arg2){if(cont.cycleStop==undefined){cont.cycleStop=0;}if(options===undefined||options===null){options={};}if(options.constructor==String){switch(options){case"destroy":case"stop":var opts=$(cont).data("cycle.opts");if(!opts){return false;}cont.cycleStop++;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);}cont.cycleTimeout=0;$(cont).removeData("cycle.opts");if(options=="destroy"){destroy(opts);}return false;case"toggle":cont.cyclePause=(cont.cyclePause===1)?0:1;checkInstantResume(cont.cyclePause,arg2,cont);return false;case"pause":cont.cyclePause=1;return false;case"resume":cont.cyclePause=0;checkInstantResume(false,arg2,cont);return false;case"prev":case"next":var opts=$(cont).data("cycle.opts");if(!opts){log('options not found, "prev/next" ignored');return false;}$.fn.cycle[options](opts);return false;default:options={fx:options};}return options;}else{if(options.constructor==Number){var num=options;options=$(cont).data("cycle.opts");if(!options){log("options not found, can not advance slide");return false;}if(num<0||num>=options.elements.length){log("invalid slide index: "+num);return false;}options.nextSlide=num;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}if(typeof arg2=="string"){options.oneTimeFx=arg2;}go(options.elements,options,1,num>=options.currSlide);return false;}}return options;function checkInstantResume(isPaused,arg2,cont){if(!isPaused&&arg2===true){var options=$(cont).data("cycle.opts");if(!options){log("options not found, can not resume");return false;}if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}go(options.elements,options,1,1);}}}function removeFilter(el,opts){if(!$.support.opacity&&opts.cleartype&&el.style.filter){try{el.style.removeAttribute("filter");}catch(smother){}}}function destroy(opts){if(opts.next){$(opts.next).unbind(opts.prevNextEvent);}if(opts.prev){$(opts.prev).unbind(opts.prevNextEvent);}if(opts.pager||opts.pagerAnchorBuilder){$.each(opts.pagerAnchors||[],function(){this.unbind().remove();});}opts.pagerAnchors=null;if(opts.destroy){opts.destroy(opts);}}function buildOptions($cont,$slides,els,options,o){var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});if(opts.autostop){opts.countdown=opts.autostopCount||els.length;}var cont=$cont[0];$cont.data("cycle.opts",opts);opts.$cont=$cont;opts.stopCount=cont.cycleStop;opts.elements=els;opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});if(!$.support.opacity&&opts.cleartype){opts.after.push(function(){removeFilter(this,opts);});}if(opts.continuous){opts.after.push(function(){go(els,opts,0,!opts.rev);});}saveOriginalOpts(opts);if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($slides);}if($cont.css("position")=="static"){$cont.css("position","relative");}if(opts.width){$cont.width(opts.width);}if(opts.height&&opts.height!="auto"){$cont.height(opts.height);}if(opts.startingSlide){opts.startingSlide=parseInt(opts.startingSlide);}if(opts.random){opts.randomMap=[];for(var i=0;i<els.length;i++){opts.randomMap.push(i);}opts.randomMap.sort(function(a,b){return Math.random()-0.5;});opts.randomIndex=1;opts.startingSlide=opts.randomMap[1];}else{if(opts.startingSlide>=els.length){opts.startingSlide=0;}}opts.currSlide=opts.startingSlide||0;var first=opts.startingSlide;$slides.css({position:"absolute",top:0,left:0}).hide().each(function(i){var z=first?i>=first?els.length-(i-first):first-i:els.length-i;$(this).css("z-index",z);});$(els[first]).css("opacity",1).show();removeFilter(els[first],opts);if(opts.fit&&opts.width){$slides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}var reshape=opts.containerResize&&!$cont.innerHeight();if(reshape){var maxw=0,maxh=0;for(var j=0;j<els.length;j++){var $e=$(els[j]),e=$e[0],w=$e.outerWidth(),h=$e.outerHeight();if(!w){w=e.offsetWidth||e.width||$e.attr("width");}if(!h){h=e.offsetHeight||e.height||$e.attr("height");}maxw=w>maxw?w:maxw;maxh=h>maxh?h:maxh;}if(maxw>0&&maxh>0){$cont.css({width:maxw+"px",height:maxh+"px"});}}if(opts.pause){$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});}if(supportMultiTransitions(opts)===false){return false;}var requeue=false;options.requeueAttempts=options.requeueAttempts||0;$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:($el.height()||this.offsetHeight||this.height||$el.attr("height")||0);this.cycleW=(opts.fit&&opts.width)?opts.width:($el.width()||this.offsetWidth||this.width||$el.attr("width")||0);if($el.is("img")){var loadingIE=($.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var loadingFF=($.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete);var loadingOp=($.browser.opera&&((this.cycleW==42&&this.cycleH==19)||(this.cycleW==37&&this.cycleH==17))&&!this.complete);var loadingOther=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(loadingIE||loadingFF||loadingOp||loadingOther){if(o.s&&opts.requeueOnImageNotLoaded&&++options.requeueAttempts<100){log(options.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){$(o.s,o.c).cycle(options);},opts.requeueTimeout);requeue=true;return false;}else{log("could not determine size of image: "+this.src,this.cycleW,this.cycleH);}}}return true;});if(requeue){return false;}opts.cssBefore=opts.cssBefore||{};opts.animIn=opts.animIn||{};opts.animOut=opts.animOut||{};$slides.not(":eq("+first+")").css(opts.cssBefore);if(opts.cssFirst){$($slides[first]).css(opts.cssFirst);}if(opts.timeout){opts.timeout=parseInt(opts.timeout);if(opts.speed.constructor==String){opts.speed=$.fx.speeds[opts.speed]||parseInt(opts.speed);}if(!opts.sync){opts.speed=opts.speed/2;}var buffer=opts.fx=="shuffle"?500:250;while((opts.timeout-opts.speed)<buffer){opts.timeout+=opts.speed;}}if(opts.easing){opts.easeIn=opts.easeOut=opts.easing;}if(!opts.speedIn){opts.speedIn=opts.speed;}if(!opts.speedOut){opts.speedOut=opts.speed;}opts.slideCount=els.length;opts.currSlide=opts.lastSlide=first;if(opts.random){if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.startingSlide>=(els.length-1)?0:opts.startingSlide+1;}if(!opts.multiFx){var init=$.fn.cycle.transitions[opts.fx];if($.isFunction(init)){init($cont,$slides,opts);}else{if(opts.fx!="custom"&&!opts.multiFx){log("unknown transition: "+opts.fx,"; slideshow terminating");return false;}}}var e0=$slides[first];if(opts.before.length){opts.before[0].apply(e0,[e0,e0,opts,true]);}if(opts.after.length>1){opts.after[1].apply(e0,[e0,e0,opts,true]);}if(opts.next){$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1);});}if(opts.prev){$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1);});}if(opts.pager||opts.pagerAnchorBuilder){buildPager(els,opts);}exposeAddSlide(opts,els);return opts;}function saveOriginalOpts(opts){opts.original={before:[],after:[]};opts.original.cssBefore=$.extend({},opts.cssBefore);opts.original.cssAfter=$.extend({},opts.cssAfter);opts.original.animIn=$.extend({},opts.animIn);opts.original.animOut=$.extend({},opts.animOut);$.each(opts.before,function(){opts.original.before.push(this);});$.each(opts.after,function(){opts.original.after.push(this);});}function supportMultiTransitions(opts){var i,tx,txs=$.fn.cycle.transitions;if(opts.fx.indexOf(",")>0){opts.multiFx=true;opts.fxs=opts.fx.replace(/\s*/g,"").split(",");for(i=0;i<opts.fxs.length;i++){var fx=opts.fxs[i];tx=txs[fx];if(!tx||!txs.hasOwnProperty(fx)||!$.isFunction(tx)){log("discarding unknown transition: ",fx);opts.fxs.splice(i,1);i--;}}if(!opts.fxs.length){log("No valid transitions named; slideshow terminating.");return false;}}else{if(opts.fx=="all"){opts.multiFx=true;opts.fxs=[];for(p in txs){tx=txs[p];if(txs.hasOwnProperty(p)&&$.isFunction(tx)){opts.fxs.push(p);}}}}if(opts.multiFx&&opts.randomizeEffects){var r1=Math.floor(Math.random()*20)+30;for(i=0;i<r1;i++){var r2=Math.floor(Math.random()*opts.fxs.length);opts.fxs.push(opts.fxs.splice(r2,1)[0]);}debug("randomized fx sequence: ",opts.fxs);}return true;}function exposeAddSlide(opts,els){opts.addSlide=function(newSlide,prepend){var $s=$(newSlide),s=$s[0];if(!opts.autostopCount){opts.countdown++;}els[prepend?"unshift":"push"](s);if(opts.els){opts.els[prepend?"unshift":"push"](s);}opts.slideCount=els.length;$s.css("position","absolute");$s[prepend?"prependTo":"appendTo"](opts.$cont);if(prepend){opts.currSlide++;opts.nextSlide++;}if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($s);}if(opts.fit&&opts.width){$s.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}s.cycleH=(opts.fit&&opts.height)?opts.height:$s.height();s.cycleW=(opts.fit&&opts.width)?opts.width:$s.width();$s.css(opts.cssBefore);if(opts.pager||opts.pagerAnchorBuilder){$.fn.cycle.createPagerAnchor(els.length-1,s,$(opts.pager),els,opts);}if($.isFunction(opts.onAddSlide)){opts.onAddSlide($s);}else{$s.hide();}};}$.fn.cycle.resetState=function(opts,fx){fx=fx||opts.fx;opts.before=[];opts.after=[];opts.cssBefore=$.extend({},opts.original.cssBefore);opts.cssAfter=$.extend({},opts.original.cssAfter);opts.animIn=$.extend({},opts.original.animIn);opts.animOut=$.extend({},opts.original.animOut);opts.fxFn=null;$.each(opts.original.before,function(){opts.before.push(this);});$.each(opts.original.after,function(){opts.after.push(this);});var init=$.fn.cycle.transitions[fx];if($.isFunction(init)){init(opts.$cont,$(opts.elements),opts);}};function go(els,opts,manual,fwd){if(manual&&opts.busy&&opts.manualTrump){debug("manualTrump in go(), stopping active transition");$(els).stop(true,true);opts.busy=false;}if(opts.busy){debug("transition active, ignoring new tx request");return;}var p=opts.$cont[0],curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleStop!=opts.stopCount||p.cycleTimeout===0&&!manual){return;}if(!manual&&!p.cyclePause&&((opts.autostop&&(--opts.countdown<=0))||(opts.nowrap&&!opts.random&&opts.nextSlide<opts.currSlide))){if(opts.end){opts.end(opts);}return;}var changed=false;if((manual||!p.cyclePause)&&(opts.nextSlide!=opts.currSlide)){changed=true;var fx=opts.fx;curr.cycleH=curr.cycleH||$(curr).height();curr.cycleW=curr.cycleW||$(curr).width();next.cycleH=next.cycleH||$(next).height();next.cycleW=next.cycleW||$(next).width();if(opts.multiFx){if(opts.lastFx==undefined||++opts.lastFx>=opts.fxs.length){opts.lastFx=0;}fx=opts.fxs[opts.lastFx];opts.currFx=fx;}if(opts.oneTimeFx){fx=opts.oneTimeFx;opts.oneTimeFx=null;}$.fn.cycle.resetState(opts,fx);if(opts.before.length){$.each(opts.before,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});}var after=function(){$.each(opts.after,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});};debug("tx firing; currSlide: "+opts.currSlide+"; nextSlide: "+opts.nextSlide);opts.busy=1;if(opts.fxFn){opts.fxFn(curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}else{if($.isFunction($.fn.cycle[opts.fx])){$.fn.cycle[opts.fx](curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}else{$.fn.cycle.custom(curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}}}if(changed||opts.nextSlide==opts.currSlide){opts.lastSlide=opts.currSlide;if(opts.random){opts.currSlide=opts.nextSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];if(opts.nextSlide==opts.currSlide){opts.nextSlide=(opts.currSlide==opts.slideCount-1)?0:opts.currSlide+1;}}else{var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}}if(changed&&opts.pager){opts.updateActivePagerLink(opts.pager,opts.currSlide,opts.activePagerClass);}var ms=0;if(opts.timeout&&!opts.continuous){ms=getTimeout(curr,next,opts,fwd);}else{if(opts.continuous&&p.cyclePause){ms=10;}}if(ms>0){p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev);},ms);}}$.fn.cycle.updateActivePagerLink=function(pager,currSlide,clsName){$(pager).each(function(){$(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);});};function getTimeout(curr,next,opts,fwd){if(opts.timeoutFn){var t=opts.timeoutFn(curr,next,opts,fwd);while((t-opts.speed)<250){t+=opts.speed;}debug("calculated timeout: "+t+"; speed: "+opts.speed);if(t!==false){return t;}}return opts.timeout;}$.fn.cycle.next=function(opts){advance(opts,opts.rev?-1:1);};$.fn.cycle.prev=function(opts){advance(opts,opts.rev?1:-1);};function advance(opts,val){var els=opts.elements;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if(opts.random&&val<0){opts.randomIndex--;if(--opts.randomIndex==-2){opts.randomIndex=els.length-2;}else{if(opts.randomIndex==-1){opts.randomIndex=els.length-1;}}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{if(opts.random){opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){if(opts.nowrap){return false;}opts.nextSlide=els.length-1;}else{if(opts.nextSlide>=els.length){if(opts.nowrap){return false;}opts.nextSlide=0;}}}}var cb=opts.onPrevNextEvent||opts.prevNextClick;if($.isFunction(cb)){cb(val>0,opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,val>=0);return false;}function buildPager(els,opts){var $p=$(opts.pager);$.each(els,function(i,o){$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);});opts.updateActivePagerLink(opts.pager,opts.startingSlide,opts.activePagerClass);}$.fn.cycle.createPagerAnchor=function(i,el,$p,els,opts){var a;if($.isFunction(opts.pagerAnchorBuilder)){a=opts.pagerAnchorBuilder(i,el);debug("pagerAnchorBuilder("+i+", el) returned: "+a);}else{a='<a href="#">'+(i+1)+"</a>";}if(!a){return;}var $a=$(a);if($a.parents("body").length===0){var arr=[];if($p.length>1){$p.each(function(){var $clone=$a.clone(true);$(this).append($clone);arr.push($clone[0]);});$a=$(arr);}else{$a.appendTo($p);}}opts.pagerAnchors=opts.pagerAnchors||[];opts.pagerAnchors.push($a);$a.bind(opts.pagerEvent,function(e){e.preventDefault();opts.nextSlide=i;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}var cb=opts.onPagerEvent||opts.pagerClick;if($.isFunction(cb)){cb(opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,opts.currSlide<i);});if(!/^click/.test(opts.pagerEvent)&&!opts.allowPagerClickBubble){$a.bind("click.cycle",function(){return false;});}if(opts.pauseOnPagerHover){$a.hover(function(){opts.$cont[0].cyclePause++;},function(){opts.$cont[0].cyclePause--;});}};$.fn.cycle.hopsFromLast=function(opts,fwd){var hops,l=opts.lastSlide,c=opts.currSlide;if(fwd){hops=c>l?c-l:opts.slideCount-l;}else{hops=c<l?l-c:l+opts.slideCount-c;}return hops;};function clearTypeFix($slides){debug("applying clearType background-color hack");function hex(s){s=parseInt(s).toString(16);return s.length<2?"0"+s:s;}function getBg(e){for(;e&&e.nodeName.toLowerCase()!="html";e=e.parentNode){var v=$.css(e,"background-color");if(v.indexOf("rgb")>=0){var rgb=v.match(/\d+/g);return"#"+hex(rgb[0])+hex(rgb[1])+hex(rgb[2]);}if(v&&v!="transparent"){return v;}}return"#ffffff";}$slides.each(function(){$(this).css("background-color",getBg(this));});}$.fn.cycle.commonReset=function(curr,next,opts,w,h,rev){$(opts.elements).not(curr).hide();opts.cssBefore.opacity=1;opts.cssBefore.display="block";if(w!==false&&next.cycleW>0){opts.cssBefore.width=next.cycleW;}if(h!==false&&next.cycleH>0){opts.cssBefore.height=next.cycleH;}opts.cssAfter=opts.cssAfter||{};opts.cssAfter.display="none";$(curr).css("zIndex",opts.slideCount+(rev===true?1:0));$(next).css("zIndex",opts.slideCount+(rev===true?0:1));};$.fn.cycle.custom=function(curr,next,opts,cb,fwd,speedOverride){var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut;$n.css(opts.cssBefore);if(speedOverride){if(typeof speedOverride=="number"){speedIn=speedOut=speedOverride;}else{speedIn=speedOut=1;}easeIn=easeOut=null;}var fn=function(){$n.animate(opts.animIn,speedIn,easeIn,cb);};$l.animate(opts.animOut,speedOut,easeOut,function(){if(opts.cssAfter){$l.css(opts.cssAfter);}if(!opts.sync){fn();}});if(opts.sync){fn();}};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(":eq("+opts.currSlide+")").css("opacity",0);opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.opacity=0;});opts.animIn={opacity:1};opts.animOut={opacity:0};opts.cssBefore={top:0,left:0};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,onPrevNextEvent:null,prevNextEvent:"click.cycle",pager:null,onPagerEvent:null,pagerEvent:"click.cycle",allowPagerClickBubble:false,pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250,activePagerClass:"activeSlide",updateActivePagerLink:null};})(jQuery);
/*
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2008 M. Alsup
 * Version:	 2.72
 * 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.cycle.transitions.none=function($cont,$slides,opts){opts.fxFn=function(curr,next,opts,after){$(next).show();$(curr).hide();after();};};$.fn.cycle.transitions.scrollUp=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssBefore={top:h,left:0};opts.cssFirst={top:0};opts.animIn={top:0};opts.animOut={top:-h};};$.fn.cycle.transitions.scrollDown=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var h=$cont.height();opts.cssFirst={top:0};opts.cssBefore={top:-h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.scrollLeft=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:0-w};};$.fn.cycle.transitions.scrollRight=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push($.fn.cycle.commonReset);var w=$cont.width();opts.cssFirst={left:0};opts.cssBefore={left:-w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.scrollHorz=function($cont,$slides,opts){$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.left=fwd?(next.cycleW-1):(1-next.cycleW);opts.animOut.left=fwd?-curr.cycleW:curr.cycleW;});opts.cssFirst={left:0};opts.cssBefore={top:0};opts.animIn={left:0};opts.animOut={top:0};};$.fn.cycle.transitions.scrollVert=function($cont,$slides,opts){$cont.css("overflow","hidden");opts.before.push(function(curr,next,opts,fwd){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.top=fwd?(1-next.cycleH):(next.cycleH-1);opts.animOut.top=fwd?curr.cycleH:-curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0};opts.animIn={top:0};opts.animOut={left:0};};$.fn.cycle.transitions.slideX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;});opts.cssBefore={left:0,top:0,width:0};opts.animIn={width:"show"};opts.animOut={width:0};};$.fn.cycle.transitions.slideY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$(opts.elements).not(curr).hide();$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;});opts.cssBefore={left:0,top:0,height:0};opts.animIn={height:"show"};opts.animOut={height:0};};$.fn.cycle.transitions.shuffle=function($cont,$slides,opts){var i,w=$cont.css("overflow","visible").width();$slides.css({left:0,top:0});opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);});if(!opts.speedAdjusted){opts.speed=opts.speed/2;opts.speedAdjusted=true;}opts.random=0;opts.shuffle=opts.shuffle||{left:-w,top:15};opts.els=[];for(i=0;i<$slides.length;i++){opts.els.push($slides[i]);}for(i=0;i<opts.currSlide;i++){opts.els.push(opts.els.shift());}opts.fxFn=function(curr,next,opts,cb,fwd){var $el=fwd?$(curr):$(next);$(next).css(opts.cssBefore);var count=opts.slideCount;$el.animate(opts.shuffle,opts.speedIn,opts.easeIn,function(){var hops=$.fn.cycle.hopsFromLast(opts,fwd);for(var k=0;k<hops;k++){fwd?opts.els.push(opts.els.shift()):opts.els.unshift(opts.els.pop());}if(fwd){for(var i=0,len=opts.els.length;i<len;i++){$(opts.els[i]).css("z-index",len-i+count);}}else{var z=$(curr).css("z-index");$el.css("z-index",parseInt(z)+1+count);}$el.animate({left:0,top:0},opts.speedOut,opts.easeOut,function(){$(fwd?this:curr).hide();if(cb){cb();}});});};opts.cssBefore={display:"block",opacity:1,top:0,left:0};};$.fn.cycle.transitions.turnUp=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=next.cycleH;opts.animIn.height=next.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,height:0};opts.animIn={top:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnDown=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssFirst={top:0};opts.cssBefore={left:0,top:0,height:0};opts.animOut={height:0};};$.fn.cycle.transitions.turnLeft=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=next.cycleW;opts.animIn.width=next.cycleW;});opts.cssBefore={top:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.turnRight=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={top:0,left:0,width:0};opts.animIn={left:0};opts.animOut={width:0};};$.fn.cycle.transitions.zoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false,true);opts.cssBefore.top=next.cycleH/2;opts.cssBefore.left=next.cycleW/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};opts.animOut={width:0,height:0,top:curr.cycleH/2,left:curr.cycleW/2};});opts.cssFirst={top:0,left:0};opts.cssBefore={width:0,height:0};};$.fn.cycle.transitions.fadeZoom=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,false);opts.cssBefore.left=next.cycleW/2;opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,left:0,width:next.cycleW,height:next.cycleH};});opts.cssBefore={width:0,height:0};opts.animOut={opacity:0};};$.fn.cycle.transitions.blindX=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.width=next.cycleW;opts.animOut.left=curr.cycleW;});opts.cssBefore={left:w,top:0};opts.animIn={left:0};opts.animOut={left:w};};$.fn.cycle.transitions.blindY=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:0};opts.animIn={top:0};opts.animOut={top:h};};$.fn.cycle.transitions.blindZ=function($cont,$slides,opts){var h=$cont.css("overflow","hidden").height();var w=$cont.width();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.animIn.height=next.cycleH;opts.animOut.top=curr.cycleH;});opts.cssBefore={top:h,left:w};opts.animIn={top:0,left:0};opts.animOut={top:h,left:w};};$.fn.cycle.transitions.growX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true);opts.cssBefore.left=this.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:0};});opts.cssBefore={width:0,top:0};};$.fn.cycle.transitions.growY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false);opts.cssBefore.top=this.cycleH/2;opts.animIn={top:0,height:this.cycleH};opts.animOut={top:0};});opts.cssBefore={height:0,left:0};};$.fn.cycle.transitions.curtainX=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,false,true,true);opts.cssBefore.left=next.cycleW/2;opts.animIn={left:0,width:this.cycleW};opts.animOut={left:curr.cycleW/2,width:0};});opts.cssBefore={top:0,width:0};};$.fn.cycle.transitions.curtainY=function($cont,$slides,opts){opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,false,true);opts.cssBefore.top=next.cycleH/2;opts.animIn={top:0,height:next.cycleH};opts.animOut={top:curr.cycleH/2,height:0};});opts.cssBefore={left:0,height:0};};$.fn.cycle.transitions.cover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);if(d=="right"){opts.cssBefore.left=-w;}else{if(d=="up"){opts.cssBefore.top=h;}else{if(d=="down"){opts.cssBefore.top=-h;}else{opts.cssBefore.left=w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.uncover=function($cont,$slides,opts){var d=opts.direction||"left";var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(d=="right"){opts.animOut.left=w;}else{if(d=="up"){opts.animOut.top=-h;}else{if(d=="down"){opts.animOut.top=h;}else{opts.animOut.left=-w;}}}});opts.animIn={left:0,top:0};opts.animOut={opacity:1};opts.cssBefore={top:0,left:0};};$.fn.cycle.transitions.toss=function($cont,$slides,opts){var w=$cont.css("overflow","visible").width();var h=$cont.height();opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts,true,true,true);if(!opts.animOut.left&&!opts.animOut.top){opts.animOut={left:w*2,top:-h/2,opacity:0};}else{opts.animOut.opacity=0;}});opts.cssBefore={left:0,top:0};opts.animIn={left:0};};$.fn.cycle.transitions.wipe=function($cont,$slides,opts){var w=$cont.css("overflow","hidden").width();var h=$cont.height();opts.cssBefore=opts.cssBefore||{};var clip;if(opts.clip){if(/l2r/.test(opts.clip)){clip="rect(0px 0px "+h+"px 0px)";}else{if(/r2l/.test(opts.clip)){clip="rect(0px "+w+"px "+h+"px "+w+"px)";}else{if(/t2b/.test(opts.clip)){clip="rect(0px "+w+"px 0px 0px)";}else{if(/b2t/.test(opts.clip)){clip="rect("+h+"px "+w+"px "+h+"px 0px)";}else{if(/zoom/.test(opts.clip)){var top=parseInt(h/2);var left=parseInt(w/2);clip="rect("+top+"px "+left+"px "+top+"px "+left+"px)";}}}}}}opts.cssBefore.clip=opts.cssBefore.clip||clip||"rect(0px 0px 0px 0px)";var d=opts.cssBefore.clip.match(/(\d+)/g);var t=parseInt(d[0]),r=parseInt(d[1]),b=parseInt(d[2]),l=parseInt(d[3]);opts.before.push(function(curr,next,opts){if(curr==next){return;}var $curr=$(curr),$next=$(next);$.fn.cycle.commonReset(curr,next,opts,true,true,false);opts.cssAfter.display="block";var step=1,count=parseInt((opts.speedIn/13))-1;(function f(){var tt=t?t-parseInt(step*(t/count)):0;var ll=l?l-parseInt(step*(l/count)):0;var bb=b<h?b+parseInt(step*((h-b)/count||1)):h;var rr=r<w?r+parseInt(step*((w-r)/count||1)):w;$next.css({clip:"rect("+tt+"px "+rr+"px "+bb+"px "+ll+"px)"});(step++<=count)?setTimeout(f,13):$curr.css("display","none");})();});opts.cssBefore={display:"block",opacity:1,top:0,left:0};opts.animIn={left:0};opts.animOut={left:0};};})(jQuery);
