﻿var cacheTime = new Date().getTime();
var hs = 0;
var hw = 0;
var hn = 0;
var wid = 0;
var nid = 0;
var hsayisi = 0;
var hslides = 0;

$(document).ready(function () {
    $('a[href=#]').live('click', function () { return false; });
    $(".overlay").hide();
    $(".hoverlay").hide();


    hsayisi = $('#newslist_content ul li').size();
    hslides = parseInt(hsayisi / 3);
    if (hslides * 3 < hsayisi) hslides = hslides + 1;

    $('#nwPre').html("<img src=\"/Skin/sol_ok_pasif.jpg\" />");
    $('#nwPre').css("cursor", "default");
    if (hslides <= 1) {
        $('#nwNext').html("<img src=\"/Skin/ok_sag_pasif.jpg\" />");
        $('#nwNext').css("cursor", "default");
    }


    hs = $("#services_content").height();
    $("#services_content").height(0);
    $("#services_content").hide();


    hw = $("#works_content").height();
    $("#works_content").height(0);
    $("#works_content").hide();

    hn = $("#news_content").height();
    $("#news_content").height(0);
    $("#news_content").hide();

    $("#fgNext").click(function () { NextBack(1); });
    $("#fgPre").click(function () { NextBack(-1); });

    $("#nwNext").click(function () { newsNextBack(1); });
    $("#nwPre").click(function () { newsNextBack(-1); });



    $("#portfolio_content ul li a").click(
    function () {
        if ($("#works_content").is(":visible")) {
            if ($(this).find(".overlay").css("background-image").indexOf("zclicked") > 0) {
                worksClose();
            }
        }
        $(".overlay").css("background-image", "url(/Skin/zover.png)");
        $(".overlay").hide();
        $(this).find(".overlay").show();
        $(this).find(".overlay").css("background-image", "url(/Skin/zclicked.png)");
        if ($(this).attr("rel") != wid) {
            wid = $(this).attr("rel");
            $("#works_content .section_det").load("/Incs/" + wid + ".html?dt=" + cacheTime, function () {                
                $('#featured').orbit({
                    animationSpeed: 500,  // how fast animtions are
                    timer: false,
                    directionalNav: true, // manual advancing directional navs
                    captions: false,
                    bullets: true, 		  // true or false to activate the bullet navigation
                    bulletThumbs: false  // thumbnails for the bullets
                });                  
            });
        }

    });



    $("#portfolio_content ul li a").hover(
    function () {
        $(this).find(".overlay").show();
    },
    function () {
        if ($("#works_content").is(":hidden")) {
            $(this).find(".overlay").hide();
        } else {
            if ($(this).find(".overlay").css("background-image").indexOf("zover") > 0) {
                $(this).find(".overlay").hide();
            }
        }
    }
    );



    $("#newslist_content ul li a").hover(
    function () {
        $(this).find(".hoverlay").show();
        $(this).find("h2").css("color", "#ffcc00");
    },
    function () {
        if ($("#news_content").is(":hidden")) {
            $(this).find(".hoverlay").hide();
            $(this).find("h2").css("color", "#ffffff");
        } else {
            if ($(this).find(".hoverlay").css("background-image").indexOf("hzover") > 0) {
                $(this).find(".hoverlay").hide();
                $(this).find("h2").css("color", "#ffffff");
            }
        }
    }
    );



    $("#newslist_content ul li a").click(
    function () {
        if ($("#news_content").is(":visible")) {
            if ($(this).find(".hoverlay").css("background-image").indexOf("hzclicked") > 0) {
                newsClose();
            }
        }
        $(".hoverlay").css("background-image", "url(/Skin/hzover.png)");
        $(".hoverlay").hide();
        $(".hbaslik").css("color", "#ffffff");
        $(this).find(".hoverlay").show();
        $(this).find(".hoverlay").css("background-image", "url(/Skin/hzclicked.png)");
        $(this).find(".hbaslik").css("color", "#ffcc00");
                if ($(this).attr("rel") != nid) {
                    nid = $(this).attr("rel");
                    $("#news_content .section_det").unload();
                    $("#news_content .section_det").html("<center><img src=\"/Skin/loading.gif\" width=\"31\" height=\"31\" style=\"padding-top:80px;\" /></center>");
                    $("#news_content .section_det").load("/Incs/" + nid + ".html");
                }

    });



});                       // end document ready



function services() {    
    if ($("#services_content").is(":hidden")) {

        $("#services_content").show();
        $.scrollTo(("#services"), { speed: 600 });
        $("#services_content").animate({
            height: hs
        }, 350, function () {
            $("#ser_ok").attr("src", "/Skin/ser_ok_up.jpg");
        });        

    } else {

        $("#services_content").animate({
            height: 0
        }, 350, function () {
            $("#services_content").hide();
            $("#ser_ok").attr("src", "/Skin/ser_ok.jpg");
        });

    }
} // end function


function works() {
    if ($("#works_content").is(":hidden")) {
        $("#works_content").show();
        $.scrollTo(("#works_content"), { speed: 600 });
        $("#works_content").animate({
            height: hw
        }, 750, function () {
            
        });

    } 
} // end function

function worksClose() {
    $("#works_content").animate({
        height: 0
    }, 750, function () {
        $("#works_content").hide();       
        $(".overlay").hide();
        $(".overlay").css("background-image", "url(/Skin/zover.png)");        
        $("#works_content .section_det").unload();
    });
    //$.scrollTo(("#works"), { speed: 600 });
} // end function




function news() {
    if ($("#news_content").is(":hidden")) {

        $("#news_content").show();
        $.scrollTo(("#news_content"), { speed: 600 });
        $("#news_content").animate({
            height: hn
        }, 500, function () {            

        });

    }
} // end function

function newsClose() {
    $("#news_content").animate({
        height: 0
    }, 500, function () {
        $("#news_content").hide();        
        $(".hoverlay").hide();
        $(".hoverlay").css("background-image", "url(/Skin/hzover.png)");
        $(".hbaslik").css("color", "#ffffff");
        $("#news_content .section_det").unload();
    });
} // end function







// Portfolio Slider
var konum = 0;
var tmp = 0;
var scIndex = 0;
function Kaydir(knm) {
    konum = knm;
    $('#portfolio_content').animate({ left: tmp + 'px' }, 500);
    $('#Portfolio_content').animate({ left: konum + 'px' }, 200);
}

function GoOn(ind) {
    if (scIndex != ind) {
        if (ind > 4) ind = 0;
        if (ind < 0) ind = 4;
        tmp = 0 - (ind * 900);
        Kaydir(tmp);
        scIndex = ind;
        $('img.fgItm').attr({ src: "/Skin/pg.jpg" });
        $('img.fgItm:eq(' + ind + ')').attr({ src: "/Skin/py.jpg" });
    }
}

function NextBack(yon) {
    tmp = scIndex + yon;
    GoOn(tmp);
}

function Next() { NextBack(1); }






// haber Slider
var nkonum = 0;
var ntmp = 0;
var nscIndex = 0;

function newsKaydir(knm) {
    nkonum = knm;
    $('#newslist_content').animate({ left: ntmp + 'px' }, 500);
    $('#newslist_content').animate({ left: nkonum + 'px' }, 200);
}

function newsGoOn(ind) {
    
    if (nscIndex != ind) {
        if (ind >= (hslides-1)) {
            ind = (hslides - 1);
            $('#nwNext').html("<img src=\"/Skin/ok_sag_pasif.jpg\" />");
            $('#nwNext').css("cursor", "default");
        } else {
            if (hslides > 1) {
                $('#nwNext').html("");
                $('#nwNext').css("cursor", "pointer");            
            }
        }
        if (ind <= 0) {
            ind = 0;
            $('#nwPre').html("<img src=\"/Skin/sol_ok_pasif.jpg\" />");
            $('#nwPre').css("cursor", "default");
        } else {
            $('#nwPre').html("");
            $('#nwPre').css("cursor", "pointer");
        }

        ntmp = 0 - (ind * 900);
        newsKaydir(ntmp);
        nscIndex = ind;
    }
}

function newsNextBack(yon) {
    ntmp = nscIndex + yon;
    newsGoOn(ntmp); 
}

function newsNext() { newsNextBack(1); }

function eml(u) {
    var a = 'mai';
    var b = 'lto';
    var c = ':';
    var t = '%40ek';
    var y = 'ir.';
    var j = 'sib';
    var k = 'c';
    var w = 'om';
    location.href = a + b + c + u + t + j + y + k + w;
}
