﻿/// <reference path="jquery-1.3.2-vsdoc.js" />
 
var clientListScroll;
var worksListScroll;
var ebulettinScroll;

var isTabEffectInProgress = false;
var isFirstTabInProgess = false;
var firstTabOpenerIsNotLogo = false;

$(document).ready(function () {

    // Load Flash Objects
    var flashvars = {};
    var params = { wmode: "transparent" };
    var attributes = {};
    //    swfobject.embedSWF("swf/1.swf", "Video1", "70", "70", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
    //    swfobject.embedSWF("swf/2.swf", "Video2", "70", "70", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
    //    swfobject.embedSWF("swf/3.swf", "Video3", "70", "70", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
    //    swfobject.embedSWF("swf/4.swf", "Video4", "70", "70", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
    //    swfobject.embedSWF("swf/5.swf", "Video5", "70", "70", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);

    //    // sIFR Sux, Cufon Rulez!....
    //    Cufon.set("fontFamily", "Auto2").replace('.headerText'); // Main Navigation
    //    Cufon.replace('.firstTabNav', { hover: 'color:#c20075' }); // Sub Navigation
    //    Cufon.replace('.WeDoSubLink', { hover: { color: '#c20075'} });
    //    Cufon.replace('.ClientsSubLink', { hover: { color: '#c20075'} });
    //    Cufon.replace('.WorksSubLink', { hover: { color: '#c20075'} });
    //    Cufon.replace('.ClientsSubSubLink', { hover: { color: '#c20075'} });
    //    Cufon.replace('.CustomFont'); // For Custom Font Container
    //    Cufon.replace(".headerText");
    //    Cufon.replace(".WorkName");

    //    Cufon.replace(".ClientListNumber", { fontFamily: 'Auto2Numbers' });
    //    Cufon.replace(".headerTextNumber", { fontFamily: 'Auto2Numbers' });
    //    Cufon.replace(".ClientNumber", { fontFamily: 'Auto2Numbers' });
    //    Cufon.replace(".CustomFontNumber", { fontFamily: 'Auto2Numbers' });


    //    Cufon.replace(".AwardNumber", { fontFamily: 'Auto2Numbers' });

    // eBulletin Item Hover Events

    $(".EbulletinlistitemContainer").mouseover(function () { $(this).toggleClass("EbulletinlistitemContainerHover"); });
    $(".EbulletinlistitemContainer").mouseout(function () { $(this).toggleClass("EbulletinlistitemContainerHover"); });

    // WaterMark Subscribe TextBox
    $("#txtEmailSubscribe").blur(function () {
        if ($(this).val().length == 0) $(this).val("E-posta adresinizi yazın");
    });

    $("#txtEmailSubscribe").click(function () {
        if (!validateEmail($(this).val())) $(this).val("");
    });

    //horizontal Tabs

    var minWidthlogo = 181;
    var maxWidthlogo = 476;
    var maxWidth = 382;
    var minWidth = 87;
    var zeroWidth = 0;
    var speed = 400;
    var slow = 700;
    var lastBlock = document.getElementById("logo");


    $(".headerText").click(function () {


        //Scrollable div Top Scroll = 0;
        document.getElementById("divWeAreHeadContentHolder").scrollTop = 0;
        document.getElementById("divWeDoHeadContentHolder").scrollTop = 0;

        var thisHeaderTest = this;
        if ($(thisHeaderTest).attr("id") == "headertextWeDo") {

            $("#divweDoContent").html(weDoContentSpotContent[1]);
            $("#divweDoTitle").html(weDoContentSpotContent[0]);
            $(".WeDoSubLinkSelected").removeClass("WeDoSubLinkSelected");
            //
            //window.setTimeout("Cufon.refresh();", 100);
        }
        else if ($(thisHeaderTest).attr("id") == "headertextWeAre") {
            $("#divweAreContent").html(weAreContentSpotContent[1]);
            $("#divweAreTitle").html(weAreContentSpotContent[0]);
            $(".WeAreSubLinkSelected").removeClass("WeAreSubLinkSelected");
            //window.setTimeout("Cufon.refresh();", 100);
        }
        else if ($(thisHeaderTest).attr("id") == "headertextClients") {
            $(".ClientsSubLink:eq(0)").click();
        }
        else if ($(thisHeaderTest).attr("id") == "headertextWorks") {
            $(".WorksSubLink:eq(0)").click();
        }

        // Eğer herhangi bir açılma işlemi sürüyorsa yenisine izin verme. Çünkü önce yapılacak olan iş yarıda kalıyor.
        // ya da Ebulletin Detay getirilmiyorsa.
        if (!isTabEffectInProgress && lastBlock.id != this.id && !eBulletinDetailIsInProgress) {

            isTabEffectInProgress = true;
            
            var thisTab = $($(this).parent());

            //$($(lastBlock).parent()).find(".headerTextNumber").removeClass("headerTextSelected");
            $(".headerTextSelected").removeClass("headerTextSelected");
            thisTab.find(".headerText").addClass("headerTextSelected");
            $(this).addClass("headerTextSelected");

            if (thisHeaderTest.id != "logo" || thisHeaderTest.id != "notlogo") {
                //FirstTabContentManager(lastOpenFirstTabContainerObjID);
                $("#HomeSubLogos").css("display", "block");
            }
            else {
                //initGoogleMap();
                $("#HomeSubLogos").css("display", "none");
            }

            $(".firstInnerContent").hide();

            if (thisHeaderTest.id != "logo") {
                $("div#divEBulletinSectionContainer").fadeOut(200);
            }




            if (true) {


                $($(lastBlock).parent()).animate({ width: (($(lastBlock).attr("id") == "logo" || $(lastBlock).attr("id") == "notlogo") ? minWidthlogo : minWidth) + "px" },
                {
                    duration: speed,
                    queue: false,
                    complete: function () {

                        // li büyüt


                        $(this).find(".MiniVideoContainer").css("display", "block");

                        thisTab.find(".MiniVideoContainer").css("display", "none");
                        //Tabların açılma efekti burda.
                        thisTab.animate({ width: (thisTab.attr("id") == "liLogo" ? maxWidthlogo : maxWidth) + "px" },
                        {

                            duration: slow, queue: false,
                            complete: function () {
                                isTabEffectInProgress = false;

                                //Cufon.refresh(".headerText");
                                //Cufon.refresh(".headerTextNumber");
                                //alert(thisTab.find(".headerTextNumber").attr("class"));


                            }
                        });
                        // content büyüt

                        thisTab.find(".sliderContext:first").animate({ width: (thisTab.attr("id") == "liLogo" ? maxWidthlogo : maxWidth) + "px" },
                        {
                            duration: slow, queue: false,
                            complete: function () {
                                tabActi = true;
                                if (thisHeaderTest.id == "logo" || thisHeaderTest.id == "notlogo") {
                                    if (thisHeaderTest.id == "logo") {
                                        FirstTabContentManager("divEBulletinContainer");
                                    }
                                    else if (thisHeaderTest.id == "notlogo")
                                        FirstTabContentManager(lastOpenFirstTabContainerObjID);
                                }

                                if (thisHeaderTest.id == "notlogo") {
                                    
                                    $(".firstInnerContent").show();
                                }
                                else {
                                    $(".firstTabNavSelected").toggleClass("firstTabNavSelected");
                                    $(".firstInnerContent").hide();
                                }
                            }



                        });

                        thisTab.addClass("selectedTabLi");

                    }
                });
            }



            //            //$($(lastBlock).parent()).find(".headerTextNumber").removeClass("headerTextSelected");
            //            $(".headerTextSelected").removeClass("headerTextSelected");
            //            thisTab.find(".headerTextNumber").addClass("headerTextSelected");
            //            $(this).addClass("headerTextSelected");

            $($(lastBlock).parent()).find(".sliderContext").animate({ width: zeroWidth }, { duration: speed, queue: false, complete: function () { } });
            $($(lastBlock).parent()).removeClass("selectedTabLi");


            // Chrome da internet explorerdaki gibi içerdeki eleman parent i iteleyemiyor.
            // Bu yuzden ben li yi de büyük min yerine max ları kullandım sorun chromeda çözüldü.
            // Saat 5:50
            // Bu arada ClientWorkDetail.aspx e de bir bak :)
            // $($(this).parent()).animate({ width: ($(this).attr("id") == "logo" ? maxWidthlogo : maxWidth) + "px" }, { duration: 100000, queue: false, complete: function() { } });

            lastBlock = thisHeaderTest.id == "notlogo" ? thisHeaderTest : this;

            // Ebulletin Ve Harita Gibi uzatmalı geniş div kapatma


            //HandleOverSizeAbsoluteContent();

        }

    });
    // End Of Horizontal Tabs

    // Ebulletin List item click Event ataması
    $(".EbulletinlistitemContainer").bind("click",
                                        function (e) {
                                            //ID , Index
                                            getEbulletinDetails(parseInt(this.id.split("_")[1]), parseInt(this.id.split("_")[2]));
                                        });



    //Start Yeri.


    //$(".headerText:eq(" + startTabIndex + ")").click();

    //$(".WeDoSubLink:first").toggleClass("WeDoSubLinkSelected");


    doClientListScrollable();
    doWorkListScrollable();
    doEBulletinListScrollable();

    //$(".EbulletinlistitemContainer:first").click();
    FirstTabContentManager("divEBulletinContainer"); //, document.getElementById("aEbulletinNav"));
    //EOF Start Yeri.

});

function makeWorksClientsListItemLink(cssClassSelector,byMusteri) {

    $("." + (cssClassSelector == null ? "ClientListitemContainer" : cssClassSelector)).bind("click",
                                        function(e) {
                                            var bilgiler = new Object();
                                            var bilgiArray = this.id.split("_");
                                            bilgiler = { "iceriktipi": bilgiArray[1],
                                                "kategori": bilgiArray[2],
                                                "isid": bilgiArray[3]
                                            }; // this.id.split("_");
                                            if (bilgiArray.length > 4) {
                                                if (bilgiArray[4] == "0") {
                                                    return false;
                                                }
                                            }
                                            window.location.href = "ClientWorksdetail.aspx?cType=" + bilgiler.iceriktipi + (byMusteri ? "" : "&catID=" + bilgiler.kategori) + (byMusteri ? "&musID=" : "&cID=") + bilgiler.isid;

                                        });
}



// We are..


//function weAreContentManager(Where) {
//    if ((weAreActiveIndex + Where) >= 0) {
//        weAreActiveIndex += Where;
//        $("#divweAreContentHolder").fadeOut(300);
//        _Default.GetAjaxWeAreContent(weAreIDArray[(weAreActiveIndex % weAreIDArray.length)], _callBackWeAre);
//    }
//}

var weAreActiveIndex = 0;
var lastWeAreNav = $(".WeAreSubLink:first");
function weAreContentManager(Where, isID, navLinkItem) {
    // Link indexlerinden mi geliyor. Yoksa ileri/geri ilemi geliyor?
    if (!isID) {
        weAreActiveIndex = (weAreActiveIndex + Where) >= 0 ? (weAreActiveIndex + Where) % weAreIDArray.length : 0;
    }
    //
    $("#divweAreContentHolder").fadeOut(300);
    _Default.GetAjaxWeAreContent((isID ? Where : weAreIDArray[weAreActiveIndex]), false, _callBackWeAre);

    // Select Nav Style
    $(".WeAreSubLinkSelected").removeClass("WeAreSubLinkSelected");
    if (isID) {
        $(navLinkItem).toggleClass("WeAreSubLinkSelected");
    }
    else {
        $($(".WeAreSubLink")[weAreActiveIndex]).toggleClass("WeAreSubLinkSelected");
    }
}
  

function _callBackWeAre(res) {
    if (res.error == null) {
        $("#divweAreContent").html(res.value[1]);
        document.getElementById("divweAreContent").scrollTop = 0; 
        $("#divweAreTitle").html(res.value[0]);
        $("#divweAreContentHolder").fadeIn(200);
        //Cufon.refresh();
    }
}
// EOF We Are..

// We Do...
var weDoActiveIndex = 0;
var lastWeDoNav = $(".WeDoSubLink:first");
function weDoContentManager(Where, isID, navLinkItem) {
    // Link indexlerinden mi geliyor. Yoksa ileri/geri ilemi geliyor?
    if (!isID) {
        weDoActiveIndex = (weDoActiveIndex + Where) >= 0 ? (weDoActiveIndex + Where) % weDoIDArray.length : 0;
    }
    $("#divweDoContentHolder").fadeOut(300);
    _Default.GetAjaxWeDoContent((isID ? Where : weDoIDArray[weDoActiveIndex]), false, _callBackWeDo);

    // Select Nav Style
    $(".WeDoSubLinkSelected").removeClass("WeDoSubLinkSelected");
    if (isID) {
        $(navLinkItem).toggleClass("WeDoSubLinkSelected");
    }
    else {
        $($(".WeDoSubLink")[weDoActiveIndex]).toggleClass("WeDoSubLinkSelected");
    }
}

function _callBackWeDo(res) {
    if (res.error == null) {
        $("#divweDoContent").html(res.value[1]);
        resetScroll("divweDoContent");
        $("#divweDoTitle").html(res.value[0]);
        $("#divweDoContentHolder").fadeIn(200);
        //Cufon.refresh();
    }
}
// EOF We Do...

// Clients
var clientWorksActiveIndex = 0;
var lastClientCatNav = $("#divClientsCatContainer > .ClientsSubLink:first");

function clientWorksContentManager(Where) {
    // Link indexlerinden mi geliyor. Yoksa ileri/geri ilemi geliyor?
    clientWorksActiveIndex = (clientWorksActiveIndex + Where) > 0 ? (clientWorksActiveIndex + Where) % clientsWorkArr.length : 0;

    $("#divclientsWorkHolder").fadeOut(300);
    _Default.GetAjaxClientWork(clientsWorkArr[clientWorksActiveIndex], _callBackclientWorks);
}

var LastClientWorksContentKatID = 0;
var LastClientWorksContentID = 0;
function _callBackclientWorks(res) {
    if (res.error == null) {

        //divclientWorkTitle
        //var dr = res.value.Rows[0];
        //ID
        //$("#clientWorkID").html(clientsWorkArr[clientWorksActiveIndex]);
        $("#clientWorkID").html((clientsWorkArr.length - clientWorksActiveIndex));
        $("#spnClientName").html(res.value.Rows[0]["musteri"]);
        $("#spnClientTitle").html(res.value.Rows[0]["baslik"]);
        $("#divclientWorkContent").html(res.value.Rows[0]["icerik"]);
        resetScroll("divclientWorkContent");
        $("#divclientWorkContent").append("<a href=\"ClientWorksdetail.aspx?cType=0&catID=" + res.value.Rows[0]["muskat_ID"] + "&cID=" + res.value.Rows[0]["ID"] + "\"></a>");
        LastClientWorksContentID = res.value.Rows[0]["ID"];
        LastClientWorksContentKatID = res.value.Rows[0]["muskat_ID"];

        $("#imgclientWorksImage").attr("src", "uploads/galleryimages/" + res.value["resimadi"]);
        $("#divclientsWorkHolder").fadeIn(200);

        $.each($("#divclientWorkTitle").children(), function() {
            $(this).click(function() { ClientWorkDetailOpen(0, LastClientWorksContentKatID, LastClientWorksContentID); });
        });
              
        $("#clientWorkID").click(function() {
            ClientWorkDetailOpen(0, LastClientWorksContentKatID, LastClientWorksContentID);
        });
        
        //Cufon Refresh
        //Cufon.refresh();
    }
}

function ClientWorkDetailInit(Type, CatID, ID) {

    $.each($("#" + (Type == 0 ? "divclientWorkTitle" : "divWorkTitle")).children(), function() {
        $(this).click(function() {
            ClientWorkDetailOpen(Type, CatID, ID);
        });
    });

    $("#" + (Type == 0 ? "clientWorkID" : "workID")).click(function() {
        ClientWorkDetailOpen(Type, CatID, ID);
    });
}

function ClientWorkDetailOpen(Type, CatID, ID) {
    window.location.href = "ClientWorksdetail.aspx?cType=" + Type + "&catID=" + CatID + "&cID=" + ID;
}

var LastSelectPKatID = 0;
function clientListOfCats(CatID, obj) {
    // Eski Mantık.
    //_Default.GetClientsOrWorkList(CatID, 0, _callBackclientListOfCats);
    LastSelectPKatID = CatID;
    $("#clientsSubKatsList").css("display", "none");
    $("#divclientContentHolderList > .items").html("");
    
    _Default.GetSubKats(CatID, _callBackclientsSubKat);
    $("#divClientsCatContainer > .ClientsSubLinkSelected").removeClass("ClientsSubLinkSelected");
    $(".ClientsSubLinkSelected").removeClass("ClientsSubLinkSelected");
    $(obj).toggleClass("ClientsSubLinkSelected");
}

//Güçümüz için alt ktegorileri listesi getiriyoruz.
function _callBackclientsSubKat(res) {
    if (res.error == null) {
        $("#clientsSubKatsList").html("");
        var dt = res.value;
        //Still Ayarlamaları
        //Finansal Kurumlar
        if (LastSelectPKatID == 25) {
            $("#clientsSubKatsList").css("height", "80px");
            $("#divclientContentHolderListContainer .scrollable").css("height", "360px");
            $(".ClientListNextPage").css("top", "365px");
        }
        else if (LastSelectPKatID == 24) {
            $("#clientsSubKatsList").css("height", "130px");
            $("#divclientContentHolderListContainer .scrollable").css("height", "310px");
            $(".ClientListNextPage").css("top", "315px");
        }
        else {
            $("#clientsSubKatsList").css("display", "none");
            $("#divclientContentHolderListContainer .scrollable").css("height", "451px");
            $(".ClientListNextPage").css("top", "450px");
        }        
        
        //Alt Kategorisi var ise...
        if (dt.Rows.length > 0) {
            $("#clientsSubKatsList").css("display", "block");
            for (var i = 0; i < dt.Rows.length; i++) {
                $("#clientsSubKatsList").append("<li class=\"ClientsSubSubMenuLI\"><a class=\"ClientsSubSubLink CustomFont\" onclick=\"getClientListOfSubKats(this," + dt.Rows[i]["ID"] + ",true);\">" + dt.Rows[i]["kategori"] + "</a></li>");
            }

            $("#clientsSubKatsList a.ClientsSubSubLink:eq(0)").click();
            //Cufon.refresh(".ClientsSubLink");
            //Cufon.refresh(".ClientsSubSubLink");         
            
        }
        else {
            //Alt Kategori Listesini Gizle.
            $("#clientsSubKatsList").css("display", "none");
            // Alt Kategorisi Yok ise Seçili PKATID den içerik Al
            _Default.GetClientsOrWorkListNew(LastSelectPKatID, false, 0, _callBackclientListOfCats);
        }       
        
    }
    else
        alert(res.error.Message);
}

//Tıklanan alt kategori için İş Listesi
function getClientListOfSubKats(sender, SubCatID, isSubKat) {

    _Default.GetClientsOrWorkListNew(SubCatID, isSubKat, 0, _callBackclientListOfCats);
    //$("#clientsSubKatsList > .ClientsSubSubLinkSelected").removeClass("ClientsSubSubLinkSelected");
    $(".ClientsSubSubLinkSelected").removeClass("ClientsSubSubLinkSelected");
    $(sender).toggleClass("ClientsSubSubLinkSelected");
    //Cufon.refresh(".ClientsSubSubLinkSelected");
}

function _callBackclientListOfCats(res) {
    if (res.error == null) {

        $("#divclientContentHolderDetail").css("display", "none");
        $("#divclientContentHolderListContainer").css("display", "block");
        $("#divclientContentHolderList > .items").html(res.value);

        var options = clientListScroll.getConf();

        if (LastSelectPKatID == 25) {
            options.size = 22;
        }
        else if (LastSelectPKatID == 24) {
            options.size = 20
        }
        else {
            options.size = 30;
        }  
        
        clientListScroll.reload();
        clientListScroll.begin();
        

        // List itemlara tıklanınca atanacak methodlar.
        makeWorksClientsListItemLink("ClientListitemContainer2", true);
        $("#divclientContentHolderList").mousewheel();
        
        $(".ClientListitemInnerContainer2").mouseover(function() { $(this).toggleClass("EbulletinlistitemContainerHover"); });
        $(".ClientListitemInnerContainer2").mouseout(function() { $(this).toggleClass("EbulletinlistitemContainerHover"); });
        //Cufon.refresh();
//        Cufon.refresh(".ClientsSubLink");
//        Cufon.refresh(".ClientListDesc");
//        Cufon.refresh(".ClientListNumber");        
    }
    else {
        alert(res.error.Message);
    }
}

function doClientListScrollable() {
    clientListScroll = $("#divclientContentHolderList").scrollable({
        size: 
        30,
        vertical: "true",
        api: "true",
        clickable: "true",
        activeClass: "activeClientCatsItem",
        onSeek: function() {
            // alert("current page is " + this.getClickIndex());
        }
    });
}
// EOF Clients

// Works

var worksActiveIndex = 0;
var lastWorkCatNav = $("#divWorksCatContainer > .ClientsSubLink:first");

function worksContentManager(Where) {
    // Link indexlerinden mi geliyor. Yoksa ileri/geri ilemi geliyor?
    worksActiveIndex = (worksActiveIndex + Where) > 0 ? (worksActiveIndex + Where) % worksArr.length : 0;

    $("#divworksHolder").fadeOut(300);
    _Default.GetAjaxClientWork(worksArr[worksActiveIndex], _callBackWorks);
}

var LastWorksContentKatID = 0;
var LastWorksContentID = 0;
function _callBackWorks(res) {
    if (res.error == null) {
        //ID
        //$("#workID").html(worksArr[worksActiveIndex]);
        $("#workID").html((worksArr.length - worksActiveIndex));
        $("#spnWorkName").html(res.value.Rows[0]["musteri"]);
        $("#spnWorkTitle").html(res.value.Rows[0]["baslik"]);
        $("#divWorkContent").html(res.value.Rows[0]["icerik"]);
        resetScroll("divWorkContent");
        $("#divWorkContent").append("<a class=\"DetayLink\" href=\"ClientWorksdetail.aspx?cType=1&catID=" + res.value.Rows[0]["muskat_ID"] + "&cID=" + res.value.Rows[0]["ID"] + "\"></a>");
        $("#divworksHolder").fadeIn(200, function() { });
        $("#imgWorksImage").attr("src", "./uploads/galleryimages/" + res.value.Rows[0]["resimadi"]);
        
        LastWorksContentID = res.value.Rows[0]["ID"];
        LastWorksContentKatID = res.value.Rows[0]["muskat_ID"];

        $.each($("#divWorkTitle").children(), function() {
            $(this).click(function() { ClientWorkDetailOpen(1, LastWorksContentKatID, LastWorksContentID); });
        });

        $("#workID").click(function() {
            ClientWorkDetailOpen(1, LastWorksContentKatID, LastWorksContentID);
        });

        //Cufon.refresh();


    }
}

function workListOfCats(CatID, obj) {
    _Default.GetClientsOrWorkList(CatID, 1, _callBackworksListOfCats);
    $(".WorksSubLinkSelected").removeClass("WorksSubLinkSelected");
    $(obj).toggleClass("WorksSubLinkSelected");
    //Cufon.refresh();
}

function _callBackworksListOfCats(res) {
    if (res.error == null) {

        $("#divworkContentHolderDetail").css("display", "none");
        $("#divworkContentHolderListContainer").css("display", "block");
        $("#divworkContentHolderList > .items").html(res.value);
        worksListScroll.reload();
        worksListScroll.begin();

        // List itemlara tıklanınca atanacak methodlar.
        makeWorksClientsListItemLink();

        $("#divworkContentHolderList").mousewheel();
        $(".ClientListitemInnerContainer").hover(
        function() { $(this).toggleClass("EbulletinlistitemContainerHover"); },
        function() { $(this).toggleClass("EbulletinlistitemContainerHover"); }
        );
        //Cufon.refresh();

    }
}

function doWorkListScrollable() {
    worksListScroll = $("#divworkContentHolderList").scrollable({
        size: 6,
        vertical: "true",
        api: "true",
        clickable: "true",
        activeClass: "activeClientCatsItem",
        onSeek: function() {
            // alert("current page is " + this.getClickIndex());
        }
    });
}

// EOF Works

// Awards
var awardsActiveIndex = 0;
function awardsContentManager(Where) {
    // Link indexlerinden mi geliyor. Yoksa ileri/geri ilemi geliyor?
    awardsActiveIndex = (awardsActiveIndex + Where) > 0 ? (awardsActiveIndex + Where) % awardsIDArr.length : 0;

    $("#divAwardsContent").fadeOut(300);
    _Default.GetAjaxAwardContent(awardsIDArr[awardsActiveIndex], _callBackAwards);
}

function _callBackAwards(res) {
    if (res.error == null) {
        //$("#divAwardsID").html(awardsIDArr[awardsActiveIndex]);
        $("#divAwardsID").html(awardsIDArr.length - awardsActiveIndex);
        
        var awardDetailLink = $("#aAwardsTitle").attr("href");
        awardDetailLink = awardDetailLink.split('=')[0] + "=" + awardsIDArr[awardsActiveIndex];
        $("#aAwardsTitle").attr({ href: awardDetailLink });
        $("#aAwardsTitle").html(res.value[0]);
        $("#divAwardsContent").html(res.value[1]);
        $("#divAwardsContent").append("<a class=\"DetayLink\" href=\"AwardsDetail.aspx?aID=" + awardsIDArr[awardsActiveIndex] + "\">&nbsp;  </a>");
        $("#imgAwardsImage").attr("src", "./uploads/galleryimages/" + res.value[2]);
        resetScroll("divAwardsContent");
        //Cufon.refresh();
        $("#divAwardsContent").fadeIn(200);
    }
}

// EOF Awards


// Ebulletin

function doEBulletinListScrollable() {
    ebulettinScroll = $("#divEbulletinList").scrollable({
        size: 5,
        vertical: "true",
        api: "true",
        clickable: "true",
        activeClass: "EbulletinlistitemContainerActive",
        hover: "EbulletinlistitemContainerActive",
        hoverables: true,
        onSeek: function() {
            // alert("current page is " + this.getClickIndex());
        }
    });


    $("#divEbulletinList").mousewheel();
}

var eBulletinDetailIsInProgress = false;
function getEbulletinDetails(EBulletID, EBulletIndex) {
    //    alert($.browser.mozilla);
    //    if ($.browser.mozilla)
    //        _callbackgetEbulletinDetails(_Default.GetAjaxEbulletinDetails(EBulletID));
    //    else
    eBulletinDetailIsInProgress = true;
    $("#divEbulletinDetailContainer").fadeOut(100, function () {
        _Default.GetAjaxEbulletinDetails(EBulletID, EBulletIndex, _callbackgetEbulletinDetails);
    });
   

}

function _callbackgetEbulletinDetails(res) {
    if (res.error == null) {
//        $("#divEBulletinID").html(res.value.Rows[0].Index);
        $("#divEBulletinDetailImage").attr("src", "uploads/ebulletin/" + res.value.Rows[0].resimadi);

//        $("#divEBulletinTitle").html(res.value.Rows[0].baslik);
        $("#divEBulletinContent").html(res.value.Rows[0].icerik);
        resetScroll("divEBulletinContent");
        $("#divEbulletinDetailContainer").fadeIn(300, function() { /*window.setTimeout("Cufon.refresh();", 100);*/ });
        
    }
    else
        alert(res.error.Message);
    eBulletinDetailIsInProgress = false;
}

var lastOpenFirstTabContainerObjID = ""; // "divContactUsContainer";
var tabActi = false;
function FirstTabContentManager(openContainerID, obj) {
    if (lastOpenFirstTabContainerObjID != openContainerID) {
        lastOpenFirstTabContainerObjID = openContainerID;

        firstTabOpenerIsNotLogo = true;
        // Sağda açılan sub divleri kapatmak lazım.
        HandleOverSizeAbsoluteContent();

        $(".FirstTabChildSection").css("display", "none");
        $("#" + openContainerID).show();
        if (openContainerID == "divEBulletinContainer") {
            $(".EbulletinlistitemContainer:first").click();
            $("div#divEBulletinSectionContainer").show();
            $("a#logo").click();
        }
        else
            $("a#notlogo").click();
        

    } else if (openContainerID == "none") {
        $(".FirstTabChildSection").css("display", "none");
        lastOpenFirstTabContainerObjID = "";
    }


    if (obj != null) {
        $(".firstTabNavSelected").removeClass("firstTabNavSelected");
        $(obj).addClass("firstTabNavSelected");
        $("a#notlogo").click();
    }

    if (lastOpenFirstTabContainerObjID == "divEBulletinContainer") {
        $("div#divEBulletinSectionContainer").fadeIn(200);
    }
//    else if (!tabActi)
//        $(".firstTabNav:first").addClass("firstTabNavSelected");


    tabActi = false;

    
    //Cufon.refresh();
    return false;
}


var mapObj;
function initGoogleMap() {
    var mapObj = new GMap2(document.getElementById("googleMapContainer"), { size: new GSize(180, 283) });
    var marker = new GMarker(new GLatLng(41.04739,28.997249));
    mapObj.addOverlay(marker)
    mapObj.setCenter(new GLatLng(41.04739,28.997249), 13);
    mapObj.setUIToDefault();
    GEvent.addListener(mapObj, "click", function() {

        var mapTemp = new GMap2(document.getElementById("divLargeGoogleMap"), { size: new GSize(672, 385) });
        mapTemp.addOverlay(new GMarker(new GLatLng(41.04739,28.997249)))
        mapTemp.setCenter(new GLatLng(41.04739,28.997249), 17);
        mapTemp.setUIToDefault();

        $("#divLargeGoogleMapContainer").fadeIn(300);
        $("#googleMapContainer").fadeOut(300);
    });
}


// EOF Ebulletin

function HandleOverSizeAbsoluteContent() {
    $(".divUzatmaDiv").fadeOut(200, function() {
        if ($("#divContactUsContainer").css("display") == "block")
            $("#googleMapContainer").fadeIn(300);
    });
}

//Ebülten Kaydı
function SaveEmail() {
    var email = $("#txtEmailSubscribe").val();
    if (email.length > 0) {
        if (validateEmail(email)) {
            //O.K.
            _Default.SaveAjaxEMail(email, _callbackSaveEmail);
        }
        else {
            alert("Lütfen E-Posta adresinizi kontrol ediniz.");
        }
    }
    else
        alert("Lüften E-Posta adresinizi giriniz.");
        
    return false;
}

function validateEmail(data) {
    var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return data.match(emailRegEx);
}

function _callbackSaveEmail(res) {
    if (res.error == null) {
        if (res.value) {
            alert("Listemize katıldığınız için teşekkürler.");
            $("#txtEmailSubscribe").val("");
        }
        else {
            alert("Bu E-Posta adresi zaten sistemimize kayıtlıdır.");
        }
    }
    else
        alert(res.error.Message);
}

function resetScroll(ContentContainerID) {
    document.getElementById(ContentContainerID).scrollTop = 0;
}
