﻿function googleMap() {
    jQuery.facebox("<iframe name=\"kutu\" src=\"kroki.aspx\"  width=\"600px\" height=\"350px\" frameborder=\"0\" scrolling=\"auto\"></iframe>");
}

function menuIsaret(id) {
    $(".solmenu li[rel^='ct']").removeClass('currentLi');
    $(".solmenu li[rel='ct" + id + "']").addClass('currentLi');
    $(".solmenu li[rel='ct" + id + "'] a").removeClass('altLink');
}

function aktifX(id) {
    $("#divOfisListesi div[id^='ofis']").removeClass('aktifOfis');
    $("#divOfisListesi div[id='ofis" + id + "']").addClass('aktifOfis');
}

function ozelScroll(nesneId) {
    $('#' + nesneId).jScrollPane({ showArrows: true, scrollbarWidth: 10 });
}

function scrollX(nesneId) {
    
    var ustEkH = 0;
    if ($("#sayfaResimIcerik img").size()>0) {
        ustEkH = 216;
    } else {
        $("#sayfaResimIcerik").css("display", "none");
    }
    var altH = 0;
    if ($("#altKapsam").height() != null) altH = $("#altKapsam").height();
    var ortaH = $(window).height() - ($("#ustKapsam").height() + altH + 90 + ustEkH); //290
    $("#" + nesneId).height(ortaH + "px");
    ozelScroll(nesneId);
}


function adresYukle(liste, idNo) {
    adresTemizlik();
    var aktifGrup = null;
    $.each(liste, function (id) {
        if (liste[id]['i'] == idNo) aktifGrup = liste[id];
    });
    if (aktifGrup != null) {
        $("#adresBaslik").html(aktifGrup['g']);
        $("#adresData").html(aktifGrup['k']+"<br/>"+aktifGrup['b']);
    } else {
        $("#adresBaslik").html("<div class=\"uyari\" style=\"margin-top:30px; font-size:15px; font-weight:bold\">Kayıt bulunamadı...</div>");
    }
}

function adresTemizlik() {
    $("#adresBaslik").html("");
    $("#adresData").html("");
}

function haberPopup(id) {
    $.facebox("<iframe src='mediaDetail.aspx?id=" + id + "' name='popup' frameborder='0' width='700' height='400' scrolling='auto'></iframe>");
    return false;
}

function solYukle(dv,code, userCult) {
    $.ajax({
        type: "POST",
        url: "./solMenu.ashx",
        cache: false,
        data: { 'cd': code, 'uc': userCult },
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        dataType: "html",
        beforeSend: function (xhr) { },
        success: function (msg) {
            var obj = jQuery.parseJSON(msg);
            jQuery("#solAlan").html(obj.data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        }
    });
}

function gorunum(icerik) {
    /*obje = $("#" + icerik);
    var genislik = obje.width();
    var yukseklik = obje.height();
    if (genislik > 900) { genislik = 900; } else if (genislik < 300) { genislik = 300; }
    if (yukseklik > 500) { yukseklik = 500; } else if (yukseklik < 250) { yukseklik = 250; }

    window.resizeTo(genislik, yukseklik);
    var ypos = Math.ceil(($(top.window).height() - window.top.$('#facebox').height()) / 2);
    var xpos = Math.ceil(($(top.window).width() - window.top.$('#facebox').width()) / 2);
    window.top.$('#facebox').css('top', ypos + "px");
    window.top.$('#facebox').css('left', xpos + "px");*/
}

function resimSlider(divId,numaratorDurum) {
    if (numaratorDurum) $(divId + ".paging").show();
    $(divId + ".paging a:first").addClass("active");
    var imageWidth = $(divId + ".window").width();
    var imageSum = $(divId + ".image_reel img").size();
    var imageReelWidth = imageWidth * imageSum;
    $(divId + ".image_reel").css({ 'width': imageReelWidth });

    rotate = function () {
        var triggerID = $active.attr("rel") - 1; //Get number of times to slide
        var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

        $(divId + ".paging a").removeClass('active'); //Remove all active class
        $active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)

        $(divId + ".image_reel").animate({
            left: -image_reelPosition
        }, 500);
    };

    rotateSwitch = function () {
        play = setInterval(function () { //Set timer - this will repeat itself every 3 seconds
            $active = $(divId + '.paging a.active').next();
            if ($active.length === 0) { //If paging reaches the end...
                $active = $(divId + '.paging a:first'); //go back to first
            }
            rotate(); //Trigger the paging and slider function
        }, 3000); //Timer speed in milliseconds (3 seconds)
    };

    rotateSwitch(); //Run function on launch

    //On Hover
    $(divId + ".image_reel a").hover(function () {
        clearInterval(play); //Stop the rotation
    }, function () {
        rotateSwitch(); //Resume rotation
    });

    //On Click
    $(divId + ".paging a").click(function () {
        $active = $(this); //Activate the clicked paging
        //Reset Timer
        clearInterval(play); //Stop the rotation
        rotate(); //Trigger rotation immediately
        rotateSwitch(); // Resume rotation
        return false; //Prevent browser jump to link anchor
    });
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
