﻿//menu
$(document).ready(function () {
    $('.menu .center .item').not('.mark').not('.store').children('a').hover(function () {
        $(this).css('color', '#ffffff')
        $('.menu .center .hover .cntr').css('width', $(this).width() + 5);
        $('.menu .center .hover').css('left', $(this).parent().position().left + 5 + "px").show();
    }, function () {
        $('.menu .center .hover').hide();
        $(this).css('color', '#f78f20')
    });

    $('.menu .center .item.mark').click(function () {
        $('.menu .center .item.mark ul').slideToggle('fast');
    });
});

//teaser
$(document).ready(function () {
    $('.root .middle .teaser .manset').first().show();
    $('.root .middle .teaser .table .btns').data('last', $('.root .middle .teaser .table .btns a').first().attr('rel'));
    $('.root .middle .teaser .table .btns a').first().addClass('active');

    var iVal = 10000;
    var iId = setInterval("setNextTeaser()", iVal);
    $('.root .middle .teaser .table .btns a').click(function () {
        if ($(this).attr('rel') == $('.root .middle .teaser .table .btns').data('last')) {
            return false;
        }

        $('.root .middle .teaser .table .btns').data('last', $(this).attr('rel'));
        $('.root .middle .teaser .manset').hide();
        $('.root .middle .teaser .manset').css('left', '0px');
        $('.root .middle .teaser .table .btns a').removeClass('active');
        $('.root .middle .teaser .manset[rel=' + $(this).attr('rel') + ']').css('top', '-70px').show().animate({ top: 5 }, 'fast').animate({ top: 0 }, 'fast');
        $('.root .middle .teaser .manset[rel=' + $(this).attr('rel') + '] .highlight').css('margin-top', '0px').animate({ marginTop: 25 }, 'fast').animate({ marginTop: 15 });

        $(this).addClass('active');
        clearInterval(iId);
        iId = setInterval("setNextTeaser()", iVal);
    });
    //        $('.root .middle .teaser .table .btns a[rel=3]').click();


});


function setNextTeaser() {
    var next = parseFloat($('.root .middle .teaser .table .btns').data('last')) + 1;
    var last = parseFloat($('.root .middle .teaser .table .btns a').last().attr('rel'));
    if (next > last) { next = 1; }
    $('.root .middle .teaser .table .btns a[rel=' + next + ']').click();
}

//default-box-banner
$(document).ready(function () {


    $('.root .middle .boxes .gray .item').hide();
    $('.root .middle .boxes .gray .numbers').show();
    $('.root .middle .boxes .gray .item').first().show();
    $('.root .middle .boxes .gray .numbers a').first().css('background-image', 'url(/ui/img/dsgn/box-numHover.png)');
    $('.gray .numbers').data('last', $('.root .middle .boxes .gray .numbers a').first().attr('id'));

    var iVal = 10000;
    var iId = setInterval("setNextBanner()", iVal);

    $('.root .middle .boxes .gray .numbers a').click(function () {

        if ($(this).attr('id') == $('.gray .numbers').data('last')) {
            return false;
        }

        $('.gray .numbers').data('last', $(this).attr('id'));
        $('.root .middle .boxes .gray .item').hide();
        $('.root .middle .boxes .gray .item[id=' + $(this).attr('id') + ']').show();
        $('.root .middle .boxes .gray .numbers a').css('background-image', 'url(/ui/img/dsgn/box-num.png)');
        $(this).css('background-image', 'url(/ui/img/dsgn/box-numHover.png)');

        clearInterval(iId);
        iId = setInterval("setNextBanner()", iVal);
    });
});

function setNextBanner() {
    var next = parseFloat($('.gray .numbers').data('last')) + 1;
    var last = parseFloat($('.root .middle .boxes .gray .numbers a').last().attr('id'));
    if (next > last) { next = 0; }
    $('.root .middle .boxes .gray .numbers a[id=' + next + ']').click();
}


//content-menu-cufon-add
$(document).ready(function () {
    $('.contentMenu ul li a span').addClass('cufon');
});


//content-title-textsizer
$(document).ready(function () {
    $('#textBigger').click(function () {

        $('.contentBody *').css({
            fontSize: function () { return parseInt($(this).css('font-size')) + 1; },
            lineHeight: '3ex'
        });

    });
    $('#textSmaller').click(function () {
        $('.contentBody *').css({
            fontSize: function () { return parseInt($(this).css('font-size')) - 1; },
            lineHeight: '2.5ex'
        });
    });
});
//
function Format(nesne) {
                        nesne = nesne.replace('/\,/g', '');
                        yyy = "";
                        kalan = (nesne.length - 1) % 3 + 1;
                        if (nesne.length > 3) {
                            yyy = nesne.substring(0, kalan);
                            for (kkk = 0; kkk < Math.floor((nesne.length - 1) / 3); kkk++) {
                                yyy = yyy + "." + nesne.substring(kalan + 3 * kkk, kalan + 3 * kkk + 3);
                            }
                            nesne = yyy;
                        }
                        return nesne;
                    }

//ui-dialog
function uiMesaj(Baslik, Url, Yonlen, width, height, mesaj) {
    if (Url != '')
        $('<div>').appendTo('body').html("<iframe src='" + Url + "' width='100%' height='100%' frameborder='0' marginheight='0' marginwidth='0'></iframe>").dialog({ title: Baslik, resizable: false, closeText: 'Kapat', width: width, height: height, beforeClose: function () { (Yonlen == '' ? null : $(location).attr('href', Yonlen)); }, modal: true, buttons: { 'Tamam': function () { (Yonlen == '' ? $(this).dialog('close') : $(location).attr('href', Yonlen)) } } });
    else
        $('<div>').appendTo('body').html(mesaj).dialog({ title: Baslik, resizable: false, modal: true, width: width , closeText: 'Kapat', buttons: { 'Elma Arama Devam Et': function () { (Yonlen == '' ? $(this).dialog('close') : $(location).attr('href', Yonlen)); } } });
}

function uiMesajSaat(Baslik, Url, Yonlen, width, height, mesaj) {
    if (Url != '')
        $('<div>').appendTo('body').html("<iframe src='" + Url + "' width='100%' height='100%' frameborder='0' marginheight='0' marginwidth='0'></iframe>").dialog({ title: Baslik, resizable: false, closeText: 'Kapat', width: width, height: height, beforeClose: function () { (Yonlen == '' ? null : $(location).attr('href', Yonlen)); }, modal: true, buttons: { 'Tamam': function () { (Yonlen == '' ? $(this).dialog('close') : $(location).attr('href', Yonlen)) } } });
    else
        $('<div>').appendTo('body').html(mesaj).dialog({ title: Baslik, resizable: false, modal: true, width: width , closeText: 'Kapat', buttons: { 'Ana Sayfaya Git.!' : function () { (Yonlen == '' ? $(this).dialog('close') : $(location).attr('href', Yonlen)); } } });
}

function facebookLike(Baslik, mesaj) {
    $('<div id="LikeModal">').appendTo('body').html("<div>"+mesaj+"</div>").dialog({  title:Baslik, resizable: false, modal: true, width : 350 , buttons : { 'Tamam' : function() { $(this).dialog('close') } } });  
}

function Close()
{
   
}
//menu-hover-cufon
$(document).ready(function () {
    $('.menu .center .item').not('.mark').not('.store').children('a.cufon').hover(function () {
        Cufon.replace(this, { color: '#ffffff', fontFamily: $(this).css('font-family') });
    }, function () {
        Cufon.replace(this, { color: '#f78f20', fontFamily: $(this).css('font-family') });
    });


});



//cufon
$(document).ready(function () {
    $('.cufon').each(function () {
        Cufon.replace(this, {
            fontStyle: $(this).css('font-style'),
            fontFamily: $(this).css('font-family'),
            fontSize: $(this).css('font-size'),
            letterSpacing: $(this).css('letter-spacing'),
            color: $(this).css('color'),
            
        });
    });
});



//boxes-digilifecoach
function digiLife() {
    $(document).ready(function () {
        $('.blueYellow .container').data('imgPath', '/ui/img/digilife/');
        iconsPanel();
        //questionPanel(0);
        //answerPanel(0, 0);
    });
}

function setDigiAnims() {
    $('.blueYellow .iconCont a').hover(function () {
        $(this).animate({ 'width': '120px', 'height': '120px', 'margin-top': '-40px' },
    { queue: false,
        duration: 200,
        complete: function () { $(this).children('span').css('display', 'block') }
    });

        var ml = '-40px';
        if ($(this).index() == 0) { ml = '0px' }
        if ($(this).index() == $('.blueYellow .iconCont a').length - 1) { ml = '-60px' }
        $('.blueYellow .iconCont').animate({ 'margin-left': ml }, { queue: false, duration: 200 });


    }, function () {
        $(this).animate({ 'width': '40px', 'height': '40px', 'margin-top': '0px' },
    { queue: false,
        duration: 200,
        step: function () { $(this).children('span').css('display', 'none') }
    });

        $('.blueYellow .iconCont').animate({ 'margin-left': '0px' }, { queue: false, duration: 200 });
    });
}

function iconsPanel() {
    $('.blueYellow .boxTitle').show();
    var cont = $('.blueYellow .container');
    cont.html('');
    $('.blueYellow .backtoicons').remove();
    var iconCont = '<div class="iconCont"></div>';
    cont.append($('<div>').attr('class', 'capsule').append($(iconCont)));
    $('.blueYellow .container').css('overflow', 'visible');
    $('.blueYellow .btnSlider').remove();

    $(digiJson).each(function (i, current) {
        $('.iconCont').append(
            $('<a>').attr({ 'href': 'javascript:questionPanel(' + i + ')', 'rel': '' + i + '', 'title': '' }).append(
                $('<img>').attr('src', cont.data('imgPath') + current.img),
                $('<span>').append(current.title)
            )
        );
    })
    setDigiAnims();
}

function questionPanel(indis) {
    $('.blueYellow .boxTitle').hide();
    var cont = $('.blueYellow .container');
    cont.html('');
    $(cont).append($('<a>').attr({ 'class': 'backtoicons', 'href': 'javascript:iconsPanel()', 'title': 'Başa dön' }))
    var qCont = '<div class="qCont"></div>';
    $(qCont).appendTo(cont);
    $('.qCont').append(
                $('<span>').attr('class', 'title').append(digiJson[indis].title),
                $('<img>').attr('src', cont.data('imgPath') + digiJson[indis].img),
                $('<div>').append($('<strong>').append(digiJson[indis].question.title))
                );

    $(digiJson[indis].question.answers).each(function (i, current) {
        $('.qCont div').append(
            $('<a>').attr({ 'href': 'javascript:answerPanel(' + indis + ',' + i + ')', 'rel': '' + i + '', 'title': '' + current.answer.title + '' }).append(
                $('<span>').attr('class', 'left'),
                $('<span>').attr('class', 'center').append(current.answer.title),
                $('<span>').attr('class', 'right')
            )
        );
    })
}

function answerPanel(indis, answerIndis) {
    $('.blueYellow .boxTitle').hide();
    var cont = $('.blueYellow .container');
    cont.html('').css('overflow', 'hidden');

    $(cont).parent().append($('<a>').css('top', '11px').attr({ 'class': 'backtoicons', 'href': 'javascript:iconsPanel()', 'title': 'Başa dön' }));
    var aCont = '<div class="aCont"></div>';
    cont.append($('<div>').attr('class', 'capsule').css({ 'overflow-x': 'scroll', 'height': '205px' }).append($(aCont)));

    var contLength = $(digiJson[indis].question.answers[answerIndis].answer.items).length;
    var contWidth = contLength * 150;
    $('.aCont').width(contWidth).css('margin', '0px auto');

    if (contLength > 3) {
        $('<a>').attr({ 'href': 'javascript:', 'class': 'btnSlider moveLeft', 'title': 'Geri' }).click(function () {
            $('.blueYellow .container .capsule').animate({ scrollLeft: $('.blueYellow .container .capsule').scrollLeft() - 150 }, 'slow');
        }).appendTo('.blueYellow');

        $('<a>').attr({ 'href': 'javascript:', 'class': 'btnSlider moveRight', 'title': 'İleri' }).click(function () {
            $('.blueYellow .container .capsule').animate({ scrollLeft: $('.blueYellow .container .capsule').scrollLeft() + 150 }, 'slow');
        }).appendTo('.blueYellow');
    }
    $(digiJson[indis].question.answers[answerIndis].answer.items).each(function (i, current) {

        $('.aCont').append(
            $('<a>').attr({ 'href': '' + current.link + '', 'rel': '' + i + '' }).append(
                $('<img>').attr('src', cont.data('imgPath') + current.img),
                $('<h2>').append(current.title)
            )
        );
        if (current.textarea != null) {
            $('.aCont a[rel=' + i + ']').append(
                $('<div>').attr('class', 'tooltip').append(
                    $('<strong>').append(current.textarea.title),
                    $('<span>').append(current.textarea.text)
                )
            );
        }

    });

    $('.blueYellow .container .aCont a').mouseover(function () {
        $('.tooltip', this).clone().appendTo('.blueYellow').show().css({ 'left': $(this).position().left + 150 + "px", 'top': '50px' });
    }).mouseout(function () {
        $('.blueYellow > .tooltip').remove();
    });
}


//product main page category product spot
$(document).ready(function () {
    $('.spotContainer .item:last').show();
    $('.spotBtnContainer div.item:last').css('background-image', 'url(/ui/img/dsgn/product-icon-back-hover.png)');
    Cufon.replace($(".spotBtnContainer div.item span:last"), { color: '#FFFFFF', fontFamily: $(".spotBtnContainer div.item span:first").css('font-family') });


    setTimeout("fitProductItem()", 700);


    $('.spotBtnContainer div.item').click(function () {
        Cufon.replace($(".spotBtnContainer div.item span"), { color: '#000000', fontFamily: $(".spotBtnContainer div.item span").css('font-family') });
        $('.spotContainer .item').hide();
        $('.spotBtnContainer div.item').css('background-image', 'url(/ui/img/dsgn/product-icon-back.png)');

        Cufon.replace($(this).children('span'), { color: '#FFFFFF', fontFamily: $(this).children('span').css('font-family') });
        $(this).css('background-image', 'url(/ui/img/dsgn/product-icon-back-hover.png)');
        $('.spotContainer .item[rel=' + $(this).attr('rel') + ']').show();
    });
});

function fitProductItem() {
    $('.spotBtnContainer div.item img').each(function () {
        var fark = $(this).height() - $('.spotBtnContainer div.item').height();
        $(this).css('margin-top', "-" + fark / 2 + "px");
    });
}




//product detail page link big
$(document).ready(function () {
    $('.productDetailLinkBig .item a:odd').addClass('aOddJ');
    $('.productDetailLinkBig .item:odd').addClass('itemOddJ');
});

//listeleme tr odd
$(document).ready(function () {
    $('.listContent tr:odd').addClass('odd');
});


//content accordion
$(document).ready(function () {
    $('.accContent .txt .item').click(function () {
        $('.accContent .txt .item .content').hide();
        $('.accContent .txt .item .sup').show();
        $('.accContent .txt .item').css('background-color', '#ffffff');
        $('.sup', this).hide();
        $('.content', this).show('fast');
        $(this).css('background-color', '#ffffcb');
    });
});



//karşılaştırma sliderları hizalı
$(document).ready(function () {
    $('.contentArea .compareCols .colContainer').width($('.contentArea .compareCols .colContainer .row:first .col').length * 222);
    setTimeout("$('.contentArea .compareCont').height($('.contentArea .compareCols').height() - 17)", 1);


    $('.contentArea .compareCols .colContainer .row').each(function () {
        $(this).children().first().css("border-left", "none");
        $(this).children().height($(this).height());
    });

    $('.contentArea .compareCont .compareCols .colContainer .rowGr:odd').css("background-color", "#f5f5f5");

    $('.larrow').click(function () {
        getSlideMoveComp(-222);
    });

    $('.rarrow').click(function () {
        getSlideMoveComp(222);
    });


    var lastPageX;
    $('.contentArea .compareCont .compareCols').data("isReady", true);
    $('.contentArea .compareCont .compareCols').data("direction", "center");
    $('.contentArea .compareCont .compareCols .colContainer').mousedown(function (e) {

        var inner = $(this);
        lastPageX = e.pageX;

        $(inner).mousemove(function (e) {
            $('.contentArea .compareCont .compareCols').stop(true, false);
            $('.contentArea .compareCont .compareCols').data("isReady", true);
            var diff = lastPageX - e.pageX;
            if (diff > 0)
                $('.contentArea .compareCont .compareCols').data("direction", "right");
            else if (diff < 0)
                $('.contentArea .compareCont .compareCols').data("direction", "left");

            $('.contentArea .compareCont .compareCols').scrollLeft($('.contentArea .compareCont .compareCols').scrollLeft() + diff);
            lastPageX = e.pageX;
        }).mouseup(function (e) {
            $(inner).unbind("mousemove");
            setTimeout(getSlideDiffComp(lastPageX, e), 1000);
        });

        $(window).mouseup(function (e) {
            $(inner).unbind("mousemove");
        });
        return false;
    });
});

function getSlideMoveComp(direction) {
    var setPos = $('.contentArea .compareCont .compareCols').scrollLeft() + direction;
    $('.contentArea .compareCont .compareCols').animate({ scrollLeft: setPos }, 'slow', function () {
        $('.contentArea .compareCont .compareCols').data("isReady", true);
        $('.contentArea .compareCont .compareCols').data("direction", "center")
    });
}

function getSlideDiffComp(lastPageX, e) {
    var diff = lastPageX - e.pageX;
    var colW = 222;
    if ($('.contentArea .compareCont .compareCols').data("isReady") && $('.contentArea .compareCont .compareCols').data("direction") != "center") {

        $('.contentArea .compareCont .compareCols').data("isReady", false);

        var direction = 0;
        if ($('.contentArea .compareCont .compareCols').data("direction") == "left") {
            direction = 0 - colW;
        }
        else if ($('.contentArea .compareCont .compareCols').data("direction") == "right") {
            direction = colW;
        }


        var lastPos = $('.contentArea .compareCont .compareCols').scrollLeft() + direction;
        var col = Math.round(lastPos / colW);
        var setPos = col * colW;


        $('.contentArea .compareCont .compareCols').animate({ scrollLeft: setPos }, 'slow', function () {
            $('.contentArea .compareCont .compareCols').data("isReady", true);
            $('.contentArea .compareCont .compareCols').data("direction", "center")
        });
    }
}


//hakkimizda-page
$(document).ready(function () {
    $('.hakkimizda .tabMenu .item').first().css('background', 'url(/Files/img/hakkimizda-tab-back.jpg) no-repeat');
    $('.hakkimizda .tabContent .content').first().show();
    $('.hakkimizda .tabMenu .item').click(function () {
        $('.hakkimizda .tabMenu .item').css('background', '');
        $(this).css('background', 'url(/Files/img/hakkimizda-tab-back.jpg) no-repeat');
        $('.hakkimizda .tabContent .content').hide();
        $('.hakkimizda .tabContent .content[rel=' + $(this).attr('rel') + ']').slideDown('fast');
    });
});



//teknik-ozellikler-page
$(document).ready(function () {
    $('.teknikozellikler .tablo tr:even').addClass('evenJ');
    $('.teknikozellikler .tablo tr:odd').addClass('oddJ');
    $('.teknikozellikler .col').first().css('border-left', 'none')

    $('.teknikozellikler .tabMenu .item').first().css('background', 'url(/Files/img/tab-small.jpg) no-repeat');
    $('.teknikozellikler .tabContent .content').first().show();
    $('.teknikozellikler .tabMenu .item').click(function () {
        $('.teknikozellikler .tabMenu .item').css('background', '');
        $(this).css('background', 'url(/Files/img/tab-small.jpg) no-repeat');
        $('.teknikozellikler .tabContent .content').hide();
        $('.teknikozellikler .tabContent .content[rel=' + $(this).attr('rel') + ']').show('fast');
    });
});


//tab contents for all
$(document).ready(function () {

    $('.tabContainer .tabMenu .item').first().children().addClass('hover');
    $('.tabContainer .tabContent .content[rel=' + $('.tabContainer .tabMenu .item').first().attr('rel') + ']').first().show();
    $('.tabContainer .tabMenu .item').click(function () {
        if ($(this).children('.hover').length > 0) { return; }
        $('.tabContainer .tabMenu .item').children().removeClass('hover');
        $(this).children().addClass('hover');
        $('.tabContainer .tabContent .content').hide();
        $('.tabContainer .tabContent .content[rel=' + $(this).attr('rel') + ']').show('fast');
    });

});

$(document).ready(function () {

    $('.tabContainer .tabMenuTek .item').first().children().addClass('hover');
    $('.tabContainer .tabContent .content[rel=' + $('.tabContainer .tabMenuTek .item').first().attr('rel') + ']').first().show();
    $('.tabContainer .tabMenuTek .item').click(function () {
        if ($(this).children('.hover').length > 0) { return; }
        $('.tabContainer .tabMenuTek .item').children().removeClass('hover');
        $(this).children().addClass('hover');
        $('.tabContainer .tabContent .content').hide();
        $('.tabContainer .tabContent .content[rel=' + $(this).attr('rel') + ']').show('fast');
    });

});


//lightbox
$(function () {
    $('a.lightbox').lightBox();
});



//neden-mac-page
$(document).ready(function () {
    setTimeout("$('.nedenmac .boxes .box .middle').each(function () {$(this).data('maxH', $(this).height());}); $('.nedenmac .boxes .box .middle').height('80px'); $('.nedenmac .boxes .box .middle .cont').height('80px'); $('.nedenmac .boxes .box .middle .cont').css('background-position', 'left center');", 1);

    $('.nedenmac .boxes .box .middle').click(function () {
        if ($(this).height() > 80) {
            $('.cont', this).animate({ height: '80px' });
            $(this).animate({ height: '80px' });
        }
        else {
            $('.cont', this).animate({ height: $(this).data('maxH') });
            $(this).animate({ height: $(this).data('maxH') });
        }
    });
});

//support detail-info menu
$(document).ready(function () {

    //    $('.infoMenu img').click(function () {

    //        if ($(this).css('opacity') == '1') { return; }

    //        $('.infoMenu a').hide();

    //        $('.infoMenu img').fadeTo('fast', 0.3, function () { });

    //        $(this).fadeTo('fast', 1, function () { }).next('a').animate({ width: 'toggle' }, 'fast', function () { });

    //    });

});


//aksesuar-slider
$(document).ready(function () {
    jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
        return -c * ((t = t / d - 1) * t * t * t - 1) + b;
    };

    jQuery(function ($) {
        $('#slider-content').serialScroll({
            items: 'li',
            prev: '.slideBox .left-ear a',
            next: '.slideBox .right-ear a',
            offset: -180, //when scrolling to photo, stop 230 before reaching it (from the left)
            start: 1, //as we are centering it, start at the 2nd
            duration: 1200,
            force: true,
            stop: true,
            lock: false,
            cycle: false, //don't pull back once you reach the end
            easing: 'easeOutQuart', //use this easing equation for a funny effect
            jump: false //click on the images to scroll to them
        });
    });

    $('#toggle1').click(function () {
        $('.toggle1').slideToggle('fast');
    });
    $('#toggle2').click(function () {
        $('.toggle2').slideToggle('fast');
    });
    $('#toggle3').click(function () {
        $('.toggle3').slideToggle('fast');
    });
});
//social network url maker
//$(document).ready(function () {
function makeURL(nod) {
    var title = encodeURI(document.title);
    var url = URLRewriteReplace(decodeURI(document.URL));
    var options = "height=700,width=800,titlebar=no,status=no,toolbar=no,menubar=no,location=no,resizable=no,scrollbars=1";
    var mURL = '';
    var siteDescriptionTagText = document.getElementsByName('description')[0].content;

    if (nod == 1) { mURL = "http://www.facebook.com/sharer.php?u=" + url + "&amp;t=" + title; }
    if (nod == 2) { mURL = "http://twitter.com/intent/tweet?text=" + siteDescriptionTagText + "&url=" + url };
    if (nod == 3) { mURL = "http://friendfeed.com/share/bookmarklet/frame#title=" + siteDescriptionTagText + "&amp;url=" + url; }

    window.open(mURL.replace(/amp;/gi, ''), '_blank', options);
}
function URLRewriteReplace(str) {
    str = str.replace(/Ü/g, "U"); str = str.replace(/Ç/g, "C");
    str = str.replace(/Ö/g, "O"); str = str.replace(/Ş/g, "S");
    str = str.replace(/Ğ/g, "G"); str = str.replace(/İ/g, "I");
    str = str.replace(/ü/g, "u"); str = str.replace(/ö/g, "o");
    str = str.replace(/ç/g, "c"); str = str.replace(/ş/g, "s");
    str = str.replace(/ı/g, "i"); str = str.replace(/ğ/g, "g");
    return str;
}
//});

function BilgiCagi() {
    var items = new Array();
    $.getJSON('/GetBilgiCagiRss', function (data) {
        $.each(data, function (key, val) {
            items.push(val);
        });
        $('.root .middle .bilgicagi .right a.upbtn').attr('rel', 0);
        $('.root .middle .bilgicagi .right a.downbtn').attr('rel', 0);
        FillBilgiCagi(0);
    });

    $('.root .middle .bilgicagi .right a.upbtn').click(function () {
        window.clearInterval(ind);
        ind = self.setInterval("MoveSlider()", 5000);
        var index = parseInt($(this).attr('rel'));
        if (index - 1 < 0) {
            FillBilgiCagi(items.length - 1);
            index = items.length;
        }
        else {
            FillBilgiCagi(index - 1);
        }

        $(this).attr('rel', index - 1);
        $('.root .middle .bilgicagi .right a.downbtn').attr('rel', index - 1);

        return false;
    });

    $('.root .middle .bilgicagi .right a.downbtn').click(function () {
        window.clearInterval(ind);
        ind = self.setInterval("MoveSlider()", 5000);
        var index = parseInt($(this).attr('rel'));
        var elMiddle = $('.root .middle .bilgicagi .center .middleside');
        var elShare = $('.root .middle .bilgicagi .center .shareside');
        elMiddle.html('');
        elShare.html('');
        if (index + 1 >= items.length) {
            FillBilgiCagi(0);
            index = -1;
        }
        else {
            FillBilgiCagi(index + 1);
        }
        $(this).attr('rel', index + 1);
        $('.root .middle .bilgicagi .right a.upbtn').attr('rel', index + 1);
        return false;
    });

    var FillBilgiCagi = function (index) {
        var elMiddle = $('.root .middle .bilgicagi .center .middleside');
        var elShare = $('.root .middle .bilgicagi .center .shareside');
        elMiddle.html('');
        elShare.html('');
        elMiddle.append(items[index].Description);
        elMiddle.append($('<h1>').html(items[index].Title));
        elMiddle.append($('<a>').addClass('title').attr('href','#').html(elMiddle.children('h1')));
        elMiddle.append($('<div>').addClass('imgback').html($('.root .middle .bilgicagi .center .middleside img').css('width', '73px').css('height', '80px')));
        elShare.append($("<iframe src='http://www.facebook.com/plugins/like.php?app_id=271673746178596&amp;href=" + items[index].Link + "&amp;send=false&amp;layout=box_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=90' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:65px; height:61px;' allowTransparency='true'></iframe>"));
        elShare.append($("<a href='http://twitter.com/share' class='twitter-share-button' data-url='" + items[index].Link + "' data-count='vertical'></a><script type='text/javascript' src='http://platform.twitter.com/widgets.js'></script>"));
        Cufon.replace('.root .middle .bilgicagi .center .middleside h1');
        $('.root .middle .bilgicagi .center .middleside a.title').click(function () {
            window.open(items[index].Link);
        });
    }
    var ind = self.setInterval("MoveSlider()", 6000);


}

function MoveSlider() {
    $('.root .middle .bilgicagi .right a.downbtn').trigger('click');
}


function DipNot() {
    var items = new Array();
    $.getJSON('/GetDipNotRss', function (data) {
        $.each(data, function (key, val) {
            items.push(val);
        });
        $('.root .middle .dipNot .right a.upbtn').attr('rel', 0);
        $('.root .middle .dipNot .right a.downbtn').attr('rel', 0);
        FilldipNot(0);
    });

    $('.root .middle .dipNot .right a.upbtn').click(function () {
        window.clearInterval(ind);
        ind = self.setInterval("MoveSlider2()", 5000);
        var index = parseInt($(this).attr('rel'));
        if (index - 1 < 0) {
            FilldipNot(items.length - 1);
            index = items.length;
        }
        else {
            FilldipNot(index - 1);
        }

        $(this).attr('rel', index - 1);
        $('.root .middle .dipNot .right a.downbtn').attr('rel', index - 1);

        return false;
    });

    $('.root .middle .dipNot .right a.downbtn').click(function () {
        window.clearInterval(ind);
        ind = self.setInterval("MoveSlider2()", 5000);
        var index = parseInt($(this).attr('rel'));
        var elMiddle = $('.root .middle .dipNot .center .middleside');
        var elShare = $('.root .middle .dipNot .center .shareside');
        elMiddle.html('');
        elShare.html('');
        if (index + 1 >= items.length) {
            FilldipNot(0);
            index = -1;
        }
        else {
            FilldipNot(index + 1);
        }
        $(this).attr('rel', index + 1);
        $('.root .middle .dipNot .right a.upbtn').attr('rel', index + 1);
        return false;
    });

    var FilldipNot = function (index) {
        var elMiddle = $('.root .middle .dipNot .center .middleside');
        var elShare = $('.root .middle .dipNot .center .shareside');
        elMiddle.html('');
        elShare.html('');
        elMiddle.append(items[index].Description);
        elMiddle.append($('<h1>').html(items[index].Title));
        elMiddle.append($('<a>').addClass('title').attr('href','#').html(elMiddle.children('h1')));
        elMiddle.append($('<div>').addClass('imgback').html($('.root .middle .dipNot .center .middleside img').css('width', '73px').css('height', '80px')));
        elShare.append($("<iframe src='http://www.facebook.com/plugins/like.php?href=" + items[index].Link + "&amp;send=false&amp;layout=box_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=90' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:65px; height:61px;' allowTransparency='true'></iframe>"));
        elShare.append($("<a href='http://twitter.com/share' class='twitter-share-button' data-url='" + items[index].Link + "' data-count='vertical'></a><script type='text/javascript' src='http://platform.twitter.com/widgets.js'></script>"));


        Cufon.replace('.root .middle .dipNot .center .middleside h1');
        $('.root .middle .dipNot .center .middleside a.title').click(function () {
            window.open(items[index].Link);
        });
    }
    var ind = self.setInterval("MoveSlider2()", 6000);


}

function MoveSlider2() {
    $('.root .middle .dipNot .right a.downbtn').trigger('click');
}


$(document).ready(function () {
        var height = $('.middle').css("height").replace('px', '');
        var width = $('.middle').css("width").replace('px', '');       
});


function ImgError(source){
$('.middle').css("position", "inherit");
        $(source).hide();
        return true;

}

