
(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);


$(document).ready(function() {

    var loc = location.pathname.substring(0, 9);
    jQuery("#menu a, #main-left-menu a").each(function() {
        if(loc.indexOf(jQuery(this).attr('href').substring(0, 9)) > -1) {
            jQuery(this).addClass('active');
        }
    });

    $('.top-dropdown').each(function () {
        $(this).parent().eq(0).hoverIntent({
            timeout: 100,
            over: function () {
                var current = $('.top-dropdown:eq(0)', this);
                current.slideDown(100);
            },
            out: function () {
                var current = $('.top-dropdown:eq(0)', this);
                current.fadeOut(100);
            }
        });
		$(this).css("left", $(this).parent().eq(0).position().left + 10);
    });
    
    $('.top-dropdown a').hover(function () {
		$(this).stop(true).animate({paddingLeft: '5px'}, 60);
	}, function () {
		$(this).stop(true).animate({paddingLeft: '0'}, 60);
	});

    $(".dropopen").toggle(
        function() { 
           $(".dropdown").slideToggle('slow', function(){
                $(".dropopen").css({"background" : "url('/pic/arrow_up.png') no-repeat 15px 30px"});
            });
            $(".dropopen a").animate({marginBottom: '10px'}, 100, function() {});
            
        },
        function() { 
			 $(".dropdown").slideToggle('slow', function(){
                $(".dropopen").css({"background":"url('/pic/arrow.png') no-repeat 15px 30px"});
            });
            $(".dropopen a").animate({marginBottom: '5px'}, 500, function() {});
        }
        );   
        
    $(".lightview").fancybox({
        titleShow: true,
        overlayOpacity		:	0.7,
        overlayColor		:	'#000'
    });
    
    $(".show_video").click(function() {
        $.fancybox({
            'overlayColor'	: '#000',
            'overlayOpacity': 0.9,
            'padding'		: 0,
            'autoScale'		: false,
            'transitionIn'	: 'none',
            'transitionOut'	: 'none',
            'title'			: this.title,
            'width'		: 680,
            'height'		: 495,
            'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type'			: 'swf',
            'swf'			: {

                'wmode'		: 'transparent',
                'allowfullscreen'	: 'true'
            }
        });
        return false;
    });
    
});
