$(document).ready(function () {
	
	

    /*Navigation altındaki Boxes için Class eklemek*/
    var navCounter = 1;
    $(" div.headerTopMenu").find(">ul>li").each(function () {
        if (navCounter < 7) {
            $(this).addClass("topMenu" + navCounter);
        } else {

            //Ana menudeki 6 baslik haricindekileri kaldiriyoruz. -> Chrome Bug
            $(this).remove();
        }
        navCounter++;
    });

    /*Navigation altındaki Boxes için Class eklemek*/
    var navCounter = 1;
    $("#navigation").find(">li").each(function () {
        if (navCounter < 7) {
            $(this).addClass("nav" + navCounter);
        } else {

            //Ana menudeki 6 baslik haricindekileri kaldiriyoruz. -> Chrome Bug
            $(this).remove();
        }
        navCounter++;
    });


    $("ul#navigation>li:last, div.bottomContent div.BottomBoxes:last, div.footerTopInner ul li:last, div.sideBar ul li:last, div.hizliErisimBoxes ul:last, div.subNavigation ul li:last-child").addClass("last");
    $("ul#navigation>li.nav6 a").removeClass("menulu");



    $("div.detailInner ul  li:odd ").addClass("current");


    /*SubNavın Açılması İçin*/
    $("#navigation > li").hover(function () {

        $(this).addClass("active");
        $(this).find("div.subNavigation").show();
        Cufon.refresh();

    }, function () {

        $(this).removeClass("active");
        $(this).find("div.subNavigation").hide();
        Cufon.refresh();
    })

	

            //$("div.pager b").addClass("selected");
//			$("div.pager span:nth-child(3n)").addClass("buttonwrap");
//            $("div.pager span:nth-child(3n) a").addClass("button");
//            $("div.pager div > span:first").addClass("prev");
//            $("div.pager div > span:last").addClass("next")
    
	$("table tr:odd td").addClass("eventr");
		
    /*Hızlı Erişim*/
    $("div.headerTopMenu li.topMenu2").hover(function () {

        $(this).addClass("selected");
        $(this).find("div.subHizliErisim").show();
        Cufon.refresh();

    }, function () {

        $(this).removeClass("selected");
        $(this).find("div.subHizliErisim").hide();
        Cufon.refresh();
    })


    jQuery('#mycarousel').jcarousel({
        auto: 2,
        scroll: 1,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });


    $("ul#mycarousel>li>a").hover(function () { //On hover...

        var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'

        //Set a background image(thumbOver) on the <a> tag - Set position to bottom
        $(this).css({ 'background': 'url(' + thumbOver + ') no-repeat center bottom' });

        //Animate the image to 0 opacity (fade it out)
        $(this).find("span").stop().fadeTo('fast', 0, function () {
            $(this).hide() //Hide the image after fade
        });
    }, function () { //on hover out...
        //Fade the image to full opacity 
        $(this).find("span").stop().fadeTo('fast', 1).show();
    });



    Cufon.replace('ul#navigation>li>a, div.leftContent div.detailInner h3, div.leftContent div.detailInner h2, div.leftContent div.detailInner h5, div.sideBar h3', { fontFamily: 'DINPro-Bold', hover: true });
    Cufon.replace('div.BottomBoxes h2, div.detailInner ul.currentList li a', { fontFamily: 'DINPro-Medium', hover: true });



    getData(1);

});

function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function () {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function () {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });



};


function fbs_click() { u = location.href; t = document.title; window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436'); }

function twt_click() {
    u = location.href; t = document.title; window.open('http://twitter.com/home?status=' + encodeURIComponent(u) + ' ' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=800,height=600');
}



function getData(pageNumber) {
    defaultParameters = "{pageNumber:" + pageNumber + "}";

    $(".loadingText").ajaxStart(function () {
        $(this).show();
    });

    $.ajax({
        type: "POST",
        url: "ajaxpage/indexhomesliderContentJSON.aspx",
        data: defaultParameters,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: (
			function (data) {

			    var dataLength = data.NewList.length;
			    var pageTotal = dataLength / 4;

			    if (pageTotal > parseInt(pageTotal)) { pageTotal = parseInt(pageTotal) + 1 }

			    $('#dataHomeSliderContent').setTemplateURL('ajaxpage/indexhomesliderContentTemplate.html', null, { filter_data: false });
			    $("#dataHomeSliderContent").setParam('pageNumber', pageNumber);
			    $("#dataHomeSliderContent").setParam('ItemQueue', (pageNumber - 1) * 4);
			    $("#dataHomeSliderContent").setParam('pageTotal', pageTotal);
			    $('#dataHomeSliderContent').processTemplate(data).fadeIn();
			}
		)
    })

    $(".loadingText").ajaxStop(function () {
        $(this).hide();
    });
}
