﻿$(document).ready(function () {
    $("ul.subnav").parent().append("<span></span>");
    var config = { sensitivity: 3, interval: 200, over: makeOver, timeout: 500, out: makeOut };
    function makeOver() { $('ul', this).slideDown(250); }
    function makeOut() { $('ul', this).slideUp(250); }
    $("#nav li").hoverIntent(config);
    $("#body").css('min-height', $(window).height() - 183);

    $("body").append("<div id='locked' class='lock'></div>");


  
});

function BeginRequestHandler(sender, args) {
    var elem = args.get_postBackElement();
    if (elem.id != "autosave" && elem.id != 'content_autosave') {
        $('#locked').css("display", "block");
        $('#locked').css("z-index", "4");
        $('#loading').css("display", "block");
        $('#loading').css("z-index", "5");
        $('#loading').center();
    }
}

function EndRequestHandler(sender, args) {
    $('#loading').css("display", "none");
    if ($('div[rel="dialog"][style*=block]').length == 0) {
        $('#locked').css("display", "none");
    }
    $('#locked').css("z-index", "1");
    if ($('div[rel="alert"][style*=block]').length > 0) {
        $('#locked').css("display", "block");
        $('#locked').css("z-index", "3");
    }
}

function EndRequestAlert(args) {
    $('#msg_in').html(args);
    $('#msg').css("display", "block");
    $('#msg').attr("rel", "alert");
    $('#msg').css("z-index", "4");
    $('#msg').center();
}



function dailogShow(dialogID, width, height) {
    $().css("overflow", "hidden");
    $('#loading').css("display", "none");
    $('#' + dialogID).css("display", "block");
    $('#' + dialogID).css("z-index", "3");
    $('#' + dialogID).attr("rel", "dialog");
    if (width != null) {
        $('#' + dialogID).width(width);
    }
    if (height != null) {
        $('#' + dialogID).height(height);
    }
    $('#' + dialogID).center();
    $('#locked').css("display", "block");
    $('#locked').css("z-index", "2");
}

function dailogAlert(dialogID) {
    $('#loading').css("display", "none");
    $('#' + dialogID).css("display", "block");
    $('#' + dialogID).css("z-index", "4");
    $('#' + dialogID).attr("rel", "alert");
    $('#' + dialogID).center();
    $('#' + dialogID).center();
    $('#locked').css("display", "block");
    $('#locked').css("z-index", "2");
}

function msgHide() {
    dailogHide("msg");
}

function dailogHide(dialogID) {
    $('#' + dialogID).css("display", "none");
    if ($('div[rel="dialog"][style*=block]').length == 0) {
        $('#locked').css("display", "none");
    }
    $('#locked').css("z-index", "1");
}

function showChange(dialogID) {
    lock = false;
    if ($(dialogID).css("display") == "block") {
        $(dialogID).css("display", "none");
    }
    else {
        $(dialogID).css("display", "block");
    }
}

function goPage(page) {
    if (document.getElementsByName("ctl00$content$sayfa").length == 1) {
        $("#content_sayfa").val(page);
        __doPostBack('ctl00$content$kayıtlar_refresh', '');
    }
    if (document.getElementsByName("ctl00$ctl00$content$sayfa").length == 1) {
        $("#content_sayfa").val(page);
        __doPostBack('ctl00$ctl00$content$kayıtlar_refresh', '');
    }
}

jQuery.fn.center = function () {
    this.css("position", "absolute");
    this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
    this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
    return this;
}

function slide(navigation_id, pad_out, pad_in, pad_left, time, multiplier) {
    var list_elements = navigation_id + " li.item";
    var link_elements = list_elements + " a";
    var timer = 0;

    $(list_elements).each(function (i) {
        timer = (timer * multiplier + time);
        $(this).animate({ marginLeft: pad_left }, timer);
        $(this).animate({ marginLeft: pad_left + pad_out }, timer);
        $(this).animate({ marginLeft: pad_left }, timer);
    });

    $(link_elements).each(function (i) {
        $(this).hover(
		function () {
		    $(this).animate({ marginLeft: pad_out }, 150);
		},
		function () {
		    $(this).animate({ marginLeft: pad_in }, 150);
		});
    });
}

function ShowContent(div) {
    jQuery("#" + div).css("display", "block");
}

function HideContent(div) {
    jQuery("#" + div).css("display", "none");
}
