﻿
$(document).ready(function () {

    //Slide Logo
    //--------------------------------------------------------------
    $('#slider-code').tinycarousel({ display: 2, duration: 500 });

    //Tabs
    //--------------------------------------------------------------
    $('#menu').tabify();


    //Accordion Menu Prodotti SX
    //--------------------------------------------------------------
    $("#prodMenuSx-accordion p").click(function () {
        $(this).next(".panelMenuSx-accordion").slideToggle(400).siblings(".panelMenuSx-accordion").slideUp("slow");
        //$(this).siblings().css({backgroundImage:"url(images/more.png)"});
    });


    //Accordion Prodotti x MARCHIO x TIPOLOGIA
    //--------------------------------------------------------------

    //ricerca per marchio
    function initMenu() {
        $('.typeMasterProd ul').hide();
        //$('#typeMasterProd ul:first').show();
        $('.typeMasterProd li p').click(
    function () {
        var checkElement = $(this).next();
        if ((checkElement.is('ul.subCat')) && (checkElement.is(':visible'))) {
            return false;
        }
        if ((checkElement.is('ul.subCat')) && (!checkElement.is(':visible'))) {
            $('.typeMasterProd ul.subCat:visible').slideUp('normal');
            checkElement.slideDown('normal');
            return false;
        }
    });

        //codice da utilizzare per l'apertura ulteriore di una categoria legata al <li> di subCat
        $('.typeMasterProd li ul li p').click(
    function () {
        var checkElement = $(this).next();
        if ((checkElement.is('ul.subProd')) && (checkElement.is(':visible'))) {
            return false;
        }
        if ((checkElement.is('ul.subProd')) && (!checkElement.is(':visible'))) {
            $('.typeMasterProd ul.subProd:visible').slideUp('normal');
            checkElement.slideDown('normal');
            return false;
        }
    });

        //ricerca per tipologia
        $('.typeMasterProd.tipologia ul').hide();
        //$('#typeMasterProd ul:first').show();
        $('.typeMasterProd.tipologia li p').click(
    function () {
        var checkElement = $(this).next();
        if ((checkElement.is('ul.subProd')) && (checkElement.is(':visible'))) {
            return false;
        }
        if ((checkElement.is('ul.subProd')) && (!checkElement.is(':visible'))) {
            $('.typeMasterProd.tipologia ul.subProd:visible').slideUp('normal');
            checkElement.slideDown('normal');
            return false;
        }
    });
    }

    $(document).ready(function () {
        initMenu();
    });


    // MAIN MENU
    //--------------------------------------------------------------

    // Inizio drop Down Menu
    //On Hover Over x il Main Menu
    function megaHoverOver() {
        $(this).find(".showSub").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
        //(function($) {
        //Function to calculate total width of all ul's
        //jQuery.fn.calcSubWidth = function() {
        //rowWidth = 0;
        //Calculate row
        //$(this).find("ul.topMenu").each(function() { //for each ul...
        //rowWidth += $(this).width(); //Add each ul's width together
        //});
        //};
        //})(jQuery); 

        //if ( $(this).find(".row").length > 0 ) { //If row exists...

        //var biggestRow = 0;	

        //$(this).find(".row").each(function() {	//for each row...
        //$(this).calcSubWidth(); //Call function to calculate width of all ul's
        //Find biggest row
        //if(rowWidth > biggestRow) {
        //biggestRow = rowWidth;
        //}
        //});

        //$(this).find(".showSub").css({'width' :biggestRow}); //Set width
        //$(this).find(".row:last").css({'margin':'0'});  //Kill last row's margin

        //} else { //If row does not exist...

        //$(this).calcSubWidth();  //Call function to calculate width of all ul's
        //$(this).find(".showSub").css({'width' : rowWidth}); //Set Width

        //}
    }
    //On Hover Out x il Main Menu
    function megaHoverOut() {
        $(this).find(".showSub").stop().fadeTo('fast', 0, function () { //Fade to 0 opactiy
            $(this).hide();  //after fading, hide it
        });
    }
    //Set custom configurations
    var config = {
        sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)
        interval: 10, // number = milliseconds for onMouseOver polling interval
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 100, // number = milliseconds delay before onMouseOut
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)
    };

    $("ul.topMenu li .showSub").css({ 'opacity': '0' }); //Fade sub nav to 0 opacity on default
    $("ul.topMenu li").hoverIntent(config); //Trigger Hover intent with custom configurations
});

// Fine drop Down Menu



// Cufon font replace
//--------------------------------------------------------------

Cufon.replace('#container_level2 h1')('#container_level2 h2')('#container_level2 h3')('#container_level2 h4')('#container_level2 h5')('#container_level2 h6')('.typeMasterProd li p')('.marchio-prodList h4');
Cufon.replace('#container_level3 h5:not()');

//Fine Cufon


//Slider
//--------------------------------------------------------------

$(function () {
    // Set starting slide to 1
    var startSlide = 1;
    // Get slide number if it exists
    if (window.location.hash) {
        startSlide = window.location.hash.replace('#', '');
    }
    // Initialize Slides
    $('#slidesNovita').slides({
        preload: true,
        effect: 'slide, fade',
        preloadImage: '../loader.gif',
        generatePagination: true,
        play: 3500,
        pause: 2500,
        hoverPause: true,
        // Get the starting slide
        start: startSlide,
        animationComplete: function (current) {
            // Set the slide number as a hash
            window.location.hash = '#' + current;
        }
    });
    $('#slidesLivebox').slides({
        preload: true,
        effect: 'slide, fade',
        preloadImage: '../loader.gif',
        generatePagination: true,
        play: 4000,
        pause: 2500,
        hoverPause: true,
        // Get the starting slide
        start: startSlide,
        animationComplete: function (current) {
            // Set the slide number as a hash
            window.location.hash = '#' + current;
        }
    });
    $('#slidesWebtv').slides({
        preload: true,
        effect: 'slide, fade',
        preloadImage: '../loader.gif',
        generatePagination: true,
        hoverPause: true,
        // Get the starting slide
        animationComplete: function (current) {
            // Set the slide number as a hash
            window.location.hash = '#' + current;
        }
    });
});
// Fine Sliders




//funzione CONFRONTA  - seleziona i prodotti da confrontare.
function conf(CodProd) {
    var xhr = $.ajax({
        type: 'POST',
        url: 'sisme-post.aspx',
        data: {f:'c', c: CodProd},
        success: function (data, status) {
            $('#divConfronta').html(data);
        },
        error: function (data, status) {
            $('#divConfronta').html(data);
        }
    });
} //end conf.

$('#myLink').click(function (ev) {
    //prevent the default action of the event, this will stop the href in the anchor being followed
    //before the animation has started, u can also use return false;
    ev.preventDefault();
    //store a reference to the anchor tag
    var $self = $(this);
    //get the image and animate assuming the image is a direct child of the anchor, if not use .find
    $self.children('img').animate({ height: "10px" }, function () {
        //now get the anchor href and redirect the browser
        document.location = $self.attr('href');
    });
});


// ---
// Funzione per l'autocomplete della ricerca
// ---
function selezionaElementiAutoComplete(code, page) {
    if (code == 13) {
        ridirezionaRicerca(page);
    } else {
        var xhr = $.ajax(
                {
                    type: 'POST',
                    url: 'sisme-post.aspx',
                    data: { f: 's', l: $('#Text1').val(), a: page },
                    success: function (data, status) {
                        // alert('ci sono');
                        // alert(data);
                        var availableTags = data.split(",");
                        $('#Text1').autocomplete({ source: availableTags }, { minLength: 3 });
                        },
                    error: function (data, status) {
                        //alert('ci sono 2');
                        var availableTags = data.split(",");
                        $('#Text1').autocomplete({ source: availableTags }, { minLength: 3 });
                    }
                });
    }
        }

        // ---
        // Funzione per l'autocomplete del modello sulla form RMA
        // ---
        function selezionaElementiACModello(code, page, textbox) {
         //   alert('sono dentro ACModello');
            if (code == 13) {
               //  ridirezionaRicerca(page);
            } else {
                var xhr = $.ajax(
                {
                    type: 'POST',
                    url: 'sisme-post.aspx',
                    data: { f: 's', l: $('#' + textbox).val(), a: page },
                    success: function (data, status) {
                        // alert('ci sono');
                        // alert(data);
                        var availableTags = data.split(",");
                        $('#' + textbox).autocomplete({ source: availableTags }, { minLength: 3 });
                    },
                    error: function (data, status) {
                        //alert('ci sono 2');
                        var availableTags = data.split(",");
                        $('#' + textbox).autocomplete({ source: availableTags }, { minLength: 3 });
                    }
                });
            }
        }



// funzione che reindirizza nella pagina di ricerca
function ridirezionaRicerca(page) {
    // alert('ci sono');
    if (page == '2') {
        location.href = 'sisme-search.aspx?p=' + $('#Text1').val().replace(/\+/g,'%2b');
    }
    else {
        location.href = 'sisme-search.aspx?p=' + $('#Text1').val().replace(/\+/g, '%2b') + '&s1=' + $('#s1').val() + '&s2=' + $('#s2').val();
    }

}

// funzione per il retrieve della Cat2 delle Faq a seguito della selezione della Cat1
function faq(AreaIdExclude) {
    // alert('ci sono:' + $("#ctl00_page_content_dd_Cat1").val() );
    var xhr = $.ajax(
                {
                    type: 'POST',
                    url: 'sisme-post.aspx',
                    data: { f: 'fs', a: AreaIdExclude, l: $("#ctl00_page_content_dd_Cat1").val() },
                    success: function (data, status) {
                        //var availableTags = data.split("#");
                        $('#contenitore_select').html(data);
                        $('#contenuto_faq').html("");
                        // cambiaFAQ()
                    },
                    error: function (data, status) {
                        // $('#cat1').html(data);
                        $('#contenitore_select').html(data);
                        $('#contenuto_faq').html("");
                        // cambiaFAQ()
                    }
                });
}

// funzione per il retrieve delle FAQ relative ad un dato argomento
function cambiaFAQ() {
    // alert('ci sono:' + $("#Select1").val());
    if ($("#Cat2").val() != "--- SELEZIONA UNA CATEGORIA ---") {
        OpenLoading('1');
        var xhr = $.ajax(
                {
                    type: 'POST',
                    url: 'sisme-post.aspx',
                    data: { f: 'fr', l: $("#Cat2").val() },
                    success: function (data, status) {
                        // alert(data);
                        $('#contenuto_faq').html(data);
                        OpenLoading(0);
                    },
                    error: function (data, status) {
                        $('#contenuto_faq').html(data);
                        OpenLoading(0);
                    }
                });
        }
        }




    function caricaRivenditori(r, idg) {
        if (r != "") {
            //OpenLoading('1');
            var xhr = $.ajax(
                {
                    type: 'POST',
                    url: 'sisme-post.aspx',
                    data: { f: 'cr', r: r, idg: idg },
                    success: function (data, status) {
                        //alert(data);
                        $('#RivenditoriResult').html(data);
                        
                    },
                    error: function (data, status) {
                        $('#RivenditoriResult').html(data);
                        
                    }
                });
        }
    }

function OpenLoading(IsToOpen) {
            if (IsToOpen=='1')
                $('#div_loading').show();
            else
                $('#div_loading').hide('fast');
        }

function confronta(idProd) {            
            if (idProd == '') return false;
            //Loading(1);
            var xhr = $.ajax({
                type: 'POST',
                url: 'sisme-post.aspx',
                data: { f: 'conf', id: idProd },
                success: function (data, status) {                    
                    $('#jshide').html(data);
                    //Loading(0);
                    $('#showConfronta').show()
                },
                error: function (data, status) {
                    alert(data);
                    //Loading(0);
                }
            });
        }




        /* //END ChkForm - Form Field Control */
        /*!
        * EIDOS PopUpBox JavaScript Library
        * http://lab.gruppoeidos.it/
        *
        * Copyright 2010, EIDOS Srl
        * http://www.gruppoeidos.it
        *
        * v1.0.1 Date: 2010-11-13
        */

        $(document).ready(function () {

            /* Hide div popup on click and/or keypress */

            $('.ui-widget-overlay').live('click', function () { $('#popupbox').dialog('close'); });

            /* Change click on dialog "popupboxclose" class object */
            $('.popupboxclose').click(function (e) {
                e.preventDefault();
                parent.top.$("#popupbox").dialog("close");
            });

            /* Change click on a class "popupbox" */
            $('.popupbox').click(function (e) {
                e.preventDefault();
                var iframeSource = $(this).attr("href");
                setPopUp(iframeSource, $(this).attr("rel"));
            });


        });

        // Read a page's GET URL variables and return them as an associative array.
        function getUrlVars(myURL) {
            var vars = [], hash;
            var hashes = myURL.slice(myURL.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }

        function popupbox(iframeSource) {
            setPopUp(iframeSource);
        }

        function setPopUp(iframeSource, frameTitle) {
            var wdim = 50;
            var hdim = 60;
            var UrlVarS = getUrlVars(iframeSource);

            var popw = UrlVarS['popw'];
            if (popw == 'max') popw = $(window).width() - 100;
            if (isNaN(popw)) popw = 810;

            var poph = UrlVarS['poph'];
            if (poph == 'max') poph = $(window).height() - 100;
            if (isNaN(poph)) poph = 550;

            var w = Number(popw);
            var h = Number(poph);

            $('#popupbox').append('<div id="popupboxwait" style="display:none; margin-top:100px;"><img alt="loading..." src="images/popup_loading.gif"/></div>'
        + '<iframe id="popupboxfrm" frameborder="0" style="display:none; border:none;"></iframe>');

            //var pophpad = Math.Floor(poph / 2)
            //$('#popupboxwait').attr('margin-top', pophpad);
            $('#popupboxwait').show();

            $('#popupboxfrm').hide();
            $('#popupboxfrm').attr('src', iframeSource).width(w - wdim).height(h - hdim);

            $('#popupboxfrm').load(function () {
                $('#popupboxfrm').show();
                $('#popupboxwait').hide();
            });
            if ($('#popupboxfrm').complete) $('#popupboxfrm').trigger("load");

            $('#popupbox').css('display', 'none');
            $('#popupbox').dialog({
                width: w,
                height: h,
                resizable: false,
                modal: true,
                title: frameTitle
                //resizeStop: function (event, ui) {
                //    $('#popupbox iframe').width($('#popupbox').width() - wdim)
                //    .height($('#popupbox').width() - hdim);
                //}
            });
        }


/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY; }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]); } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]); }; var handleHover = function (e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode; } catch (e) { p = this; } } if (p == this) { return false; } var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } if (e.type == "mouseover") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob); }, cfg.interval); } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob); }, cfg.timeout); } } }; return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery);




/*
* Slides, A Slideshow Plugin for jQuery
* Intructions: http://slidesjs.com
* By: Nathan Searles, http://nathansearles.com
* Version: 1.1.3
* Updated: February 21th, 2011
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function ($) {
    $.fn.slides = function (option) {
        option = $.extend({}, $.fn.slides.option, option); return this.each(function () {
            $('.' + option.container, $(this)).children().wrapAll('<div class="slides_control"/>'); var elem = $(this), control = $('.slides_control', elem), total = control.children().size(), width = control.children().outerWidth(), height = control.children().outerHeight(), start = option.start - 1, effect = option.effect.indexOf(',') < 0 ? option.effect : option.effect.replace(' ', '').split(',')[0], paginationEffect = option.effect.indexOf(',') < 0 ? effect : option.effect.replace(' ', '').split(',')[1], next = 0, prev = 0, number = 0, current = 0, loaded, active, clicked, position, direction, imageParent, pauseTimeout, playInterval; function animate(direction, effect, clicked) {
                if (!active && loaded) {
                    active = true; switch (direction) {
                        case 'next': prev = current; next = current + 1; next = total === next ? 0 : next; position = width * 2; direction = -width * 2; current = next; break; case 'prev': prev = current; next = current - 1; next = next === -1 ? total - 1 : next; position = 0; direction = 0; current = next; break; case 'pagination': next = parseInt(clicked, 10); prev = $('.' + option.paginationClass + ' li.current a', elem).attr('href').match('[^#/]+$'); if (next > prev) { position = width * 2; direction = -width * 2; } else { position = 0; direction = 0; }
                            current = next; break;
                    }
                    if (effect === 'fade') {
                        option.animationStart(); if (option.crossfade) { control.children(':eq(' + next + ')', elem).css({ zIndex: 10 }).fadeIn(option.fadeSpeed, option.fadeEasing, function () { if (option.autoHeight) { control.animate({ height: control.children(':eq(' + next + ')', elem).outerHeight() }, option.autoHeightSpeed, function () { control.children(':eq(' + prev + ')', elem).css({ display: 'none', zIndex: 0 }); control.children(':eq(' + next + ')', elem).css({ zIndex: 0 }); option.animationComplete(next + 1); active = false; }); } else { control.children(':eq(' + prev + ')', elem).css({ display: 'none', zIndex: 0 }); control.children(':eq(' + next + ')', elem).css({ zIndex: 0 }); option.animationComplete(next + 1); active = false; } }); } else {
                            option.animationStart(); control.children(':eq(' + prev + ')', elem).fadeOut(option.fadeSpeed, option.fadeEasing, function () {
                                if (option.autoHeight) { control.animate({ height: control.children(':eq(' + next + ')', elem).outerHeight() }, option.autoHeightSpeed, function () { control.children(':eq(' + next + ')', elem).fadeIn(option.fadeSpeed, option.fadeEasing); }); } else { control.children(':eq(' + next + ')', elem).fadeIn(option.fadeSpeed, option.fadeEasing, function () { if ($.browser.msie) { $(this).get(0).style.removeAttribute('filter'); } }); }
                                option.animationComplete(next + 1); active = false;
                            });
                        } 
                    } else { control.children(':eq(' + next + ')').css({ left: position, display: 'block' }); if (option.autoHeight) { option.animationStart(); control.animate({ left: direction, height: control.children(':eq(' + next + ')').outerHeight() }, option.slideSpeed, option.slideEasing, function () { control.css({ left: -width }); control.children(':eq(' + next + ')').css({ left: width, zIndex: 5 }); control.children(':eq(' + prev + ')').css({ left: width, display: 'none', zIndex: 0 }); option.animationComplete(next + 1); active = false; }); } else { option.animationStart(); control.animate({ left: direction }, option.slideSpeed, option.slideEasing, function () { control.css({ left: -width }); control.children(':eq(' + next + ')').css({ left: width, zIndex: 5 }); control.children(':eq(' + prev + ')').css({ left: width, display: 'none', zIndex: 0 }); option.animationComplete(next + 1); active = false; }); } }
                    if (option.pagination) { $('.' + option.paginationClass + ' li.current', elem).removeClass('current'); $('.' + option.paginationClass + ' li:eq(' + next + ')', elem).addClass('current'); } 
                } 
            }
            function stop() { clearInterval(elem.data('interval')); }
            function pause() { if (option.pause) { clearTimeout(elem.data('pause')); clearInterval(elem.data('interval')); pauseTimeout = setTimeout(function () { clearTimeout(elem.data('pause')); playInterval = setInterval(function () { animate("next", effect); }, option.play); elem.data('interval', playInterval); }, option.pause); elem.data('pause', pauseTimeout); } else { stop(); } }
            if (total < 2) { return; }
            if (start < 0) { start = 0; }
            if (start > total) { start = total - 1; }
            if (option.start) { current = start; }
            if (option.randomize) { control.randomize(); }
            $('.' + option.container, elem).css({ overflow: 'hidden', position: 'relative' }); control.children().css({ position: 'absolute', top: 0, left: control.children().outerWidth(), zIndex: 0, display: 'none' }); control.css({ position: 'relative', width: (width * 3), height: height, left: -width }); $('.' + option.container, elem).css({ display: 'block' }); if (option.autoHeight) { control.children().css({ height: 'auto' }); control.animate({ height: control.children(':eq(' + start + ')').outerHeight() }, option.autoHeightSpeed); }
            if (option.preload && control.find('img').length) {
                $('.' + option.container, elem).css({ background: 'url(' + option.preloadImage + ') no-repeat 50% 50%' }); var img = control.find('img:eq(' + start + ')').attr('src') + '?' + (new Date()).getTime(); if ($('img', elem).parent().attr('class') != 'slides_control') { imageParent = control.children(':eq(0)')[0].tagName.toLowerCase(); } else { imageParent = control.find('img:eq(' + start + ')'); }
                control.find('img:eq(' + start + ')').attr('src', img).load(function () { control.find(imageParent + ':eq(' + start + ')').fadeIn(option.fadeSpeed, option.fadeEasing, function () { $(this).css({ zIndex: 5 }); elem.css({ background: '' }); loaded = true; }); });
            } else { control.children(':eq(' + start + ')').fadeIn(option.fadeSpeed, option.fadeEasing, function () { loaded = true; }); }
            if (option.bigTarget) { control.children().css({ cursor: 'pointer' }); control.children().click(function () { animate('next', effect); return false; }); }
            if (option.hoverPause && option.play) { control.bind('mouseover', function () { stop(); }); control.bind('mouseleave', function () { pause(); }); }
            if (option.generateNextPrev) { $('.' + option.container, elem).after('<a href="#" class="' + option.prev + '">Prev</a>'); $('.' + option.prev, elem).after('<a href="#" class="' + option.next + '">Next</a>'); }
            $('.' + option.next, elem).click(function (e) {
                e.preventDefault(); if (option.play) { pause(); }
                animate('next', effect);
            }); $('.' + option.prev, elem).click(function (e) {
                e.preventDefault(); if (option.play) { pause(); }
                animate('prev', effect);
            }); if (option.generatePagination) { elem.append('<ul class=' + option.paginationClass + '></ul>'); control.children().each(function () { $('.' + option.paginationClass, elem).append('<li><a href="#' + number + '">' + (number + 1) + '</a></li>'); number++; }); } else { $('.' + option.paginationClass + ' li a', elem).each(function () { $(this).attr('href', '#' + number); number++; }); }
            $('.' + option.paginationClass + ' li:eq(' + start + ')', elem).addClass('current'); $('.' + option.paginationClass + ' li a', elem).click(function () {
                if (option.play) { pause(); }
                clicked = $(this).attr('href').match('[^#/]+$'); if (current != clicked) { animate('pagination', paginationEffect, clicked); }
                return false;
            }); $('a.link', elem).click(function () {
                if (option.play) { pause(); }
                clicked = $(this).attr('href').match('[^#/]+$') - 1; if (current != clicked) { animate('pagination', paginationEffect, clicked); }
                return false;
            }); if (option.play) { playInterval = setInterval(function () { animate('next', effect); }, option.play); elem.data('interval', playInterval); } 
        });
    }; $.fn.slides.option = { preload: false, preloadImage: '/img/loading.gif', container: 'slides_container', generateNextPrev: false, next: 'next', prev: 'prev', pagination: true, generatePagination: true, paginationClass: 'pagination', fadeSpeed: 350, fadeEasing: '', slideSpeed: 350, slideEasing: '', start: 1, effect: 'slide', crossfade: false, randomize: false, play: 0, pause: 0, hoverPause: false, autoHeight: false, autoHeightSpeed: 350, bigTarget: false, animationStart: function () { }, animationComplete: function () { } }; $.fn.randomize = function (callback) {
        function randomizeOrder() { return (Math.round(Math.random()) - 0.5); }
        return ($(this).each(function () {
            var $this = $(this); var $children = $this.children(); var childCount = $children.length; if (childCount > 1) {
                $children.hide(); var indices = []; for (i = 0; i < childCount; i++) { indices[indices.length] = i; }
                indices = indices.sort(randomizeOrder); $.each(indices, function (j, k) {
                    var $child = $children.eq(k); var $clone = $child.clone(true); $clone.show().appendTo($this); if (callback !== undefined) { callback($child, $clone); }
                    $child.remove();
                });
            } 
        }));
    };
})(jQuery);



/* jquery.tabify.js" */
(function(a){a.fn.extend({tabify:function(e){function c(b){hash=a(b).find("a").attr("href");return hash=hash.substring(0,hash.length-4)}function f(b){a(b).addClass("active");a(c(b)).show();a(b).siblings("li").each(function(){a(this).removeClass("active");a(c(this)).hide()})}return this.each(function(){function b(){location.hash&&a(d).find("a[href="+location.hash+"]").length>0&&f(a(d).find("a[href="+location.hash+"]").parent())}var d=this,g={ul:a(d)};a(this).find("li a").each(function(){a(this).attr("href", a(this).attr("href")+"-tab")});location.hash&&b();setInterval(b,100);a(this).find("li").each(function(){a(this).hasClass("active")?a(c(this)).show():a(c(this)).hide()});e&&e(g)})}})})(jQuery);


/* http: //www.baijs.nl/tinycarousel/  */
(function($){$.fn.tinycarousel=function(options){var defaults={start:1,display:1,axis:'x',controls:true,pager:false,interval:false,intervaltime:3000,rewind:false,animation:true,duration:1000,callback:null};var options=$.extend(defaults,options);var oSlider=$(this);var oViewport=$('.viewport:first',oSlider);var oContent=$('.overview:first',oSlider);var oPages=oContent.children();var oBtnNext=$('.next:first',oSlider);var oBtnPrev=$('.prev:first',oSlider);var oPager=$('.pager:first',oSlider);var iPageSize,iSteps,iCurrent,oTimer,bPause,bForward=true,bAxis=options.axis=='x';return this.each(function(){initialize();});function initialize(){iPageSize=bAxis?$(oPages[0]).outerWidth(true):$(oPages[0]).outerHeight(true);var iLeftover=Math.ceil(((bAxis?oViewport.outerWidth():oViewport.outerHeight())/(iPageSize*options.display))-1);iSteps=Math.max(1,Math.ceil(oPages.length/options.display)-iLeftover);iCurrent=Math.min(iSteps,Math.max(1,options.start))-2;oContent.css(bAxis?'width':'height',(iPageSize*oPages.length));move(1);setEvents();}
function setEvents(){if(options.controls&&oBtnPrev.length>0&&oBtnNext.length>0){oBtnPrev.click(function(){move(-1);return false;});oBtnNext.click(function(){move(1);return false;});}if(options.interval){oSlider.hover(function(){clearTimeout(oTimer);bPause=true},function(){bPause=false;setTimer();});}if(options.pager&&oPager.length>0){$('a',oPager).click(setPager);}}
function setButtons(){if(options.controls){oBtnPrev.toggleClass('disable',!(iCurrent>0));oBtnNext.toggleClass('disable',!(iCurrent+1<iSteps));}if(options.pager){var oNumbers=$('.pagenum',oPager);oNumbers.removeClass('active');$(oNumbers[iCurrent]).addClass('active');}}
function setPager(oEvent){if($(this).hasClass('pagenum')){iCurrent=parseInt(this.rel)-1;move(1);}return false;}
function setTimer(){if(options.interval&&!bPause){clearTimeout(oTimer);oTimer=setTimeout(function(){iCurrent=!options.rewind&&(iCurrent+1==iSteps)?-1:iCurrent;bForward=iCurrent+1==iSteps?false:iCurrent==0?true:bForward;move((options.rewind?(bForward?1:-1):1));},options.intervaltime);}}
function move(iDirection){if(iCurrent+iDirection>-1&&iCurrent+iDirection<iSteps){iCurrent+=iDirection;var oPosition={};oPosition[bAxis?'left':'top']=-(iCurrent*(iPageSize*options.display));oContent.animate(oPosition,{queue:false,duration:options.animation?options.duration:0,complete:function(){if(typeof options.callback=='function')options.callback.call(this,oPages[iCurrent],iCurrent);}});setButtons();setTimer();}}};})(jQuery);
