﻿var winW = 630, winH = 460;
$.fx.speeds._default = 1200;
$(function () {
    $("#dialogBugun").dialog({
        show: "blind",
        hide: "slide",
        //  position: [0, 0],
        width: 162,
        closeText: "Kapat",
        buttons: "close"
    });
    $("#dialogBugun").dialog("option", "title", 'Bugün Eklenen Oyunlar');

    if (document.body && document.body.offsetWidth) {
        winW = document.body.offsetWidth;
        winH = document.body.offsetHeight;
    }
    if (document.compatMode == 'CSS1Compat' && document.documentElement && document.documentElement.offsetWidth) {
        winW = document.documentElement.offsetWidth;
        winH = document.documentElement.offsetHeight;
    }
    if (window.innerWidth && window.innerHeight) {
        winW = window.innerWidth;
        winH = window.innerHeight;
    }
    //var xxx = $("#adhoodReklam").position();
    // $("#dialog:ui-dialog").dialog("destroy");
    //var sas = $("#dialogBugun").height();
    // sas = parseInt(sas) + parseInt("50");
    //  $("#dialogReklam").dialog({
    //    width: 330,
    //  position: [xxx.left, xxx.top],
    //  modal: false
    // });
    // $("#dialogReklam").position(xxx.left, xxx.top);
    //    $("#dialogHepsiBurada").dialog({
    //        minWidth: 125,
    //        position: [winW - 130, winH - 125],
    //        width: 140
    //    });
    $("#dialogSeninki").dialog({

        show: "blind",
        hide: "slide",
        //position: [winW - 105, 0],
        width: 162,
        closeText: "Kapat",
        buttons: "close"
    });
    $("#dialogSeninki").dialog("option", "title", 'Son Oynadığın Oyun');
});
function changeColor2(id, color) {
    document.getElementById(id).style.backgroundColor = color;
}

function getNewGamesCount() {
    $.post('veri_isle.aspx', '17,',
       function (deger) {
           if (deger != "0") {
               var li = $("#newGamesLi");
               li.append("<div class='notifyIcon'>" + deger + "</div>");
           } //if
       });    //post
}

function loadMost() { // tab 1 contents
    var z = "<div align='center' style='width: 600px; height: auto;'> <img src='images/yukleniyor.gif' /> </div>";
    $("#yukleniyorGif_1").html(z);
    $("#gamesPart1_1").html("");
    $("#gamesPart2_1").html("");
    $.post('veri_isle.aspx', '9,9',
         function (deger) {
             if (deger != "") {
                 $("#gamesPart1_1").html(deger);
                 $('#gamesPart1_1 .game_box').poshytip({
                     className: 'tip-darkgray',
                     showTimeout: 1,
                     followCursor: true,
                     alignTo: 'target',
                     alignX: 'center',
                     offsetY: -8,
                     offsetX: 0,
                     slide: false,
                     fade: true,
                     hideAniDuration: 0,
                     allowTipHover: false
                 });
                 $("#yukleniyorGif_1").html("");
             } //if
         }); //post
}
function loadNew() { // tab 2 contents
    var z = "<div align='center' style='width: 600px; height: auto;'> <img src='images/yukleniyor.gif' /> </div>";
    $("#yukleniyorGif_2").html(z);
    $("#gamesPart1_2").html("");
    $("#gamesPart2_2").html("");
    $.post('veri_isle.aspx', '10,9',
         function (deger) {
             if (deger != "") {
                 $("#gamesPart1_2").html(deger);
                 $('#gamesPart1_2 .game_box').poshytip({
                     className: 'tip-darkgray',
                     showTimeout: 1,
                     followCursor: true,
                     alignTo: 'target',
                     alignX: 'center',
                     offsetY: -8,
                     offsetX: 0,
                     slide: false,
                     fade: true,
                     hideAniDuration: 0,
                     allowTipHover: false
                 });
                 $("#yukleniyorGif_2").html("");
             } //if
         }); //post
}
function loadRecent() { // tab 3 contents
    var z = "<div align='center' style='width: 600px; height: auto;'> <img src='images/yukleniyor.gif' /> </div>";
    $("#yukleniyorGif_3").html(z);
    $("#gamesPart1_3").html("");
    $("#gamesPart2_3").html("");
    $.post('veri_isle.aspx', '8,9',
         function (deger) {
             if (deger != "") {
                 $("#gamesPart1_3").html(deger);
                 $('#gamesPart1_3 .game_box').poshytip({
                     className: 'tip-darkgray',
                     showTimeout: 1,
                     followCursor: true,
                     alignTo: 'target',
                     alignX: 'center',
                     offsetY: -2,
                     offsetX: 0,
                     slide: false,
                     fade: true,
                     hideAniDuration: 0,
                     allowTipHover: false
                 });
                 $("#yukleniyorGif_3").html("");
             } //if
         }); //post

}
function loadRecentComments() { // tab 3 contents
    var z = "<div align='center' style='width: 600px; height: auto;'> <img src='images/yukleniyor.gif' /> </div>";
    $("#yukleniyorGif_4").html(z);
    $("#recentGameComments").html("");
    //         $("#gamesPart1_3").html("");
    //         $("#gamesPart2_3").html("");
    $.post('veri_isle.aspx', '16,-1',
         function (deger) {
             if (deger != "") {
                 $("#recentGameComments").html(deger);
                 $("#yukleniyorGif_4").html("");
             } //if
         }); //post

}

$(document).ready(function () {
    //    var selected = $("#tabse").tabs("option", "selected");
    //    alert(selected);
    //    $("#tabse").tabs("option", "selected", 2);
    //    var selected = $("#tabse").tabs("option", "selected");
    //    alert(selected);
    $("#tabse").tabs();

    loadRecent();

    getNewGamesCount();

    $('#slider-code1').tinycarousel({ pager: true, interval: true });
    $('#slider-code1 .tip').poshytip({
        className: 'tip-darkgray',
        showTimeout: 1,
        followCursor: true,
        alignTo: 'target',
        alignX: 'center',
        offsetY: -8,
        offsetX: 0,
        slide: false,
        fade: true,
        hideAniDuration: 0,
        allowTipHover: false
    });

    $('#slider-code2').tinycarousel({ pager: true, interval: true });
    $('#slider-code2 .tip').poshytip({
        className: 'tip-darkgray',
        showTimeout: 1,
        followCursor: true,
        alignTo: 'target',
        alignX: 'center',
        offsetY: -8,
        offsetX: 0,
        slide: false,
        fade: true,
        hideAniDuration: 0,
        allowTipHover: false
    });

    $('#slider-code1Container,#slider-code2Container').click(function () {
        var id = $(this).attr("id");
        var x = id.split("Container")[0];
        if ($("#" + id + " span").hasClass("ui-icon ui-icon-circle-triangle-s"))
            $("#" + id + " span").attr("class", "ui-icon ui-icon-circle-triangle-n")
        else if ($("#" + id + " span").hasClass("ui-icon ui-icon-circle-triangle-n"))
            $("#" + id + " span").attr("class", "ui-icon ui-icon-circle-triangle-s")

        $('#' + x).slideToggle('400', function () {
            // Animation complete.
        });
    });


});

