﻿$(window).load(function () {
    $(".ad-image-wrapper").css('visibility', 'visible');
    $('.ad-gallery').adGallery();
    $(".fancy").fancybox();
    $("a.iframe").fancybox({ 'width': 400, 'height': 300, 'scrolling': 'no' });
    $(".youtube").click(function () {
	    $.fancybox({
		    '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': { 'allowfullscreen': 'true' }
	    });
	    return false;
    });
    dropdown('nav', 'hover', 10);
    if ($('#header-image').length > 0) {
	    $('#header-image').cycle('fade');
    }
    $("#header-image").css('visibility', 'visible');
        
    var ticker = $("#ticker");
    ticker.children().filter("dt").each(function() {	
        var dt = $(this),
        container = $("<div>");	
        dt.next().appendTo(container);
        dt.prependTo(container);	
        container.appendTo(ticker);
    });
    ticker.css("overflow", "hidden");
        
    function animator(currentItem) {
        var distance = currentItem.height();
        duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.02;
        currentItem.animate({ marginTop: -distance }, duration, "linear", function() {
            currentItem.appendTo(currentItem.parent()).css("marginTop", 0);
            animator(currentItem.parent().children(":first"));      
        });
    };

    animator(ticker.children(":first"));
    ticker.mouseenter(function() {	        
        ticker.children().stop();
    });

    ticker.mouseleave(function() {
        animator(ticker.children(":first"));	
    });    
    $("#extrabox-content").show();
});

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-15608457-1']);
_gaq.push(['_trackPageview']);

(function () {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
