// JavaScript Document

$(document).ready(function(){
	$('body').addClass('hasJS');

    $(function()
		{
			// Call stylesheet init so that all stylesheet changing functions
			// will work.
			$.stylesheetInit();

			// When one of the styleswitch links is clicked then switch the stylesheet to
			// the one matching the value of that links rel attribute.
			$('.styleswitch').bind(
				'click',
				function(e)
				{
					$.stylesheetSwitch(this.getAttribute('rel'));
					return false;
				}
			);
		}
	);

     $(".signin").click(function(e) {
                e.preventDefault();
                $("fieldset#signin_menu").toggle();
                $(".signin").toggleClass("menu-open");
            });

            $("fieldset#signin_menu").mouseup(function() {
                return false
            });
            $(document).mouseup(function(e) {
                if($(e.target).parent("a.signin").length==0) {
                    $(".signin").removeClass("menu-open");
                    $("fieldset#signin_menu").hide();
                }
            });

    /* HOVER INTENT */
    function megaHoverOver() {
        $(this).find(".sub, .sub#last").stop().show();
    }

    function megaHoverOut() {
        $(this).find(".sub").stop().hide();
    }


    //
    $(function() {
	    $("#carousel").jCarouselLite({
	        btnNext: "#next",
	        btnPrev: "#prev",
            auto: 10000,
            speed: 2000,
            scroll: 3
	    });
	});

    $(function () {
        $('#sonhaber').ticker({
            speed: 0.2,
            pauseOnItems: 4000,
            htmlFeed: false,
            ajaxFeed: true,
            feedUrl: '/haber/son',
            feedType: 'xml',
            fadeInSpeed: 600,
            titleText: 'Son haberler'
        });
    });

    $("#sectionBranding").cycle({
        fx: 'fade',
        sync: 0,
        delay: -1000,
        pager: '#RotatorPager',
        slideExpr: '.bannerRotateImage',
        speed: 2500,
        timeout: 6500,
        pagerAnchorBuilder: function(idx, slide) { return '<a href="#">' + (idx + 1) + '</a>'; }
    });

    var config = {
        sensitivity: 5, // number = sensitivity threshold (must be 1 or higher)
        interval: 0, // number = milliseconds for onMouseOver polling interval
        over: megaHoverOver, // function = onMouseOver callback (REQUIRED)
        timeout: 0, // number = milliseconds delay before onMouseOut
        out: megaHoverOut // function = onMouseOut callback (REQUIRED)
    };

    //$("ul#topnav li .sub").css({'opacity':'0'});
    $("ul#topnav li").hoverIntent(config);



}); //END OF DOCUMENT.READY
