// JavaScript Document
$(function () {
    $('.bubbleInfo2').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 500;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.trigger', this);
        var info = $('.popup', this).css('opacity', 0);


        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    top: -210,
                    left: -5,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });
});
$(function () {
    $('.bubbleInfo').each(function () {
        var distance = 10;
        var time = 250;
        var hideDelay = 500;

        var hideDelayTimer = null;

        var beingShown = false;
        var shown = false;
        var trigger = $('.trigger', this);
        var info = $('.popup', this).css('opacity', 0);


        $([trigger.get(0), info.get(0)]).mouseover(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            if (beingShown || shown) {
                // don't trigger the animation again
                return;
            } else {
                // reset position of info box
                beingShown = true;

                info.css({
                    top: -60,
                    left: -5,
                    display: 'block'
                }).animate({
                    top: '-=' + distance + 'px',
                    opacity: 1
                }, time, 'swing', function() {
                    beingShown = false;
                    shown = true;
                });
            }

            return false;
        }).mouseout(function () {
            if (hideDelayTimer) clearTimeout(hideDelayTimer);
            hideDelayTimer = setTimeout(function () {
                hideDelayTimer = null;
                info.animate({
                    top: '-=' + distance + 'px',
                    opacity: 0
                }, time, 'swing', function () {
                    shown = false;
                    info.css('display', 'none');
                });

            }, hideDelay);

            return false;
        });
    });
});


(function($){                                    
    $.fn.extend({
        suslider1:  function(options){

           var defaults = {  
                    wrap: '.theme-day-wrap', 
                    items: '.theme-day', 
                    item: '.try', //theme-day-col', 
                    speed: 300
            };
            var options = $.extend(defaults, options);                                            
            var slider = this
            var items = $(options.items, this)
            if ($(options.item,items).size()<4)
                return false;                                           

            var itemswrap = $(options.wrap, this)
            var itemwidth = $(options.item+':eq(0)',items).width()
                var arrows = $("<div class='slider_arrows'><a href='#' class='prev' /><a href='#' class='next' /></div>")
                arrows.css({
                    'position': 'absolute',
                    'top' : 10,
                    'right' : 11
                })
                slider.css({
                        'position' : 'relative'
                    })
                    .prepend(arrows)

                itemswrap.css({
                    'height': items.height(),
                    'width' : '100%',
                    'position' : 'relative',
                    'overflow' : 'hidden'                                                    
                })
                items
                    .data('animated',false)
                    .css({                                                    
                        'position': 'absolute',
                        'left' : 0
                    })
                function check(){
                    if ($(options.item+':last',items).position()['left']+items.position()['left']<=itemswrap.width()){
                        $('a.next',arrows).addClass('nonext')
                    }else{
                        $('a.next',arrows).removeClass('nonext')
                    }
                    if (items.position()['left']>=0){
                        $('a.prev',arrows).addClass('noprev')
                    }else{
                        $('a.prev',arrows).removeClass('noprev')
                    }
                }

                check()

                $('a',arrows).click(function(){
                    return false;
                })
                $('a.next',arrows).click(function(){
                    if ($(this).hasClass('nonext')||items.data('animated'))
                        return false;

                    items.data('animated',true)
                        .animate({
                            'left': '-='+(itemwidth+11)
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })

                })
                $('a.prev',arrows).click(function(){
                    if ($(this).hasClass('noprev')||items.data('animated'))
                        return false; 

                    items.data('animated',true)
                        .animate({
                            'left': '+='+(itemwidth+11)
                        },options.speed,function(){
                            check()
                            items.data('animated',false)
                        })

                })
            }
    })
});
