﻿var showModal = function() {
    var mpop = $('#backgroundPopup');
    mpop.css({ "opacity": "0.7" });
    mpop.fadeIn("fast");

    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#content").height();
    var popupWidth = $("#content").width();
    //centering
    $("#content").css({
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    $('#content').fadeIn("fast");
}
var closePopup = function() {
    $("#content3").html('');
    $('#backgroundPopup, #content').fadeOut("fast");
}

var showLoadingPopUp = function() {
    var mpop = $('#loadingpopup_bg');
    mpop.css({ "opacity": "0.7" });
    mpop.fadeIn("fast");

    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#loadingpopup").height();
    var popupWidth = $("#loadingpopup").width();
    //centering
    $("#loadingpopup").css({
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    $('#loadingpopup').fadeIn("fast");
}
var closeLoadingPopUp = function() {
    $('#loadingpopup_bg, #loadingpopup').fadeOut("fast");
}

var HaberOku = function(OID) {
    $('#content3').css({ 'height': '360px', 'width': '610px' });
    $('#content3').empty();

    showModal();

    $.ajax({ //call the Page method using JQuery ajax
        type: "GET",
        url: "/HaberOku.aspx",
        data: "OID=" + OID,
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        dataType: "html",
        success: function(data)  //show the result
        {
            $('#content3').html(data);
        },
        timeout: 15000,
        error: function(request, error) {
            $("#content3").html(request.responseText);
            request.abort();
        },
        beforeSend: function() {
            $('#content3').html('<center><div style="padding-top:80px;"><img src="/img/loading1.gif" alt="" /></div></center>');
        }
    });
}

var HaberOkuEn = function(OID) {
    $('#content3').css({ 'height': '300px', 'width': '500px' });
    $('#content3').empty();

    showModal();

    $.ajax({ //call the Page method using JQuery ajax
        type: "GET",
        url: "/EN/HaberOku.aspx",
        data: "OID=" + OID,
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        dataType: "html",
        success: function(data)  //show the result
        {
            $('#content3').html(data);
        },
        timeout: 15000,
        error: function(request, error) {
            $("#content3").html(request.responseText);
            request.abort();
        },
        beforeSend: function() {
            $('#content3').html('<center><div style="padding-top:80px;"><img src="/img/loading1.gif" alt="" /></div></center>');
        }
    });
}

var Gizlilik = function(dil) {
    $('#content3').css({ 'height': '500px', 'width': '750px' });
    $('#content3').empty();

    showModal();
    var _url = dil!=undefined && dil=='EN' ? "/EN/Gizlilik.html" : "/Gizlilik.html";
    $.ajax({ //call the Page method using JQuery ajax
        url: _url,
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        dataType: "html",
        success: function(u)  //show the result
        {
            $('#content3').html(u);
        },
        timeout: 15000,
        error: function(request, error) {
            $("#content3").html(request.responseText);
            request.abort();
        },
        beforeSend: function() {
            $('#content3').html('<center><div style="padding-top:80px;"><img src="/img/loading1.gif" alt="" /></div></center>');
        }
    });
}

var GetMap = function() {
    $('#content3').css({ 'height': '400px', 'width': '740px' });
    $('#content3').empty();

    showModal();

    $.ajax({ //call the Page method using JQuery ajax
        url: "/Harita.aspx",
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        dataType: "html",
        success: function(u)  //show the result
        {
            $('#content3').html(u);
        },
        timeout: 15000,
        error: function(request, error) {
            $("#content3").html(request.responseText);
            request.abort();
        },
        beforeSend: function() {
            $('#content3').html('<center><div style="padding-top:80px;"><img src="/img/loading1.gif" alt="" /></div></center>');
        }
    });

}

var Kullanim = function(dil) {
    $('#content3').css({ 'height': '500px', 'width': '750px' });
    $('#content3').empty();
    
    showModal();
    var _url = dil != undefined && dil == 'EN' ? "/EN/Kullanim.html" : "/Kullanim.html";
    $.ajax({ //call the Page method using JQuery ajax
        url: _url,
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        dataType: "html",
        success: function(u)  //show the result
        {
            $('#content3').html(u);
        },
        timeout: 15000,
        error: function(request, error) {
            $("#content3").html(request.responseText);
            request.abort();
        },
        beforeSend: function() {
            $('#content3').html('<center><div style="padding-top:80px;"><img src="/img/loading1.gif" alt="" /></div></center>');
        }
    });

}


var MailSend = function(AdresFrom, AdresTo, Link2, Eknot) {
    var jsonText = JSON.stringify({ adrFrom: AdresFrom, adrTo: AdresTo, LinkText: Link2, Eknt : Eknot });

    $.ajax({
        type: 'POST',
        url: '/GayrimenkulDetay.aspx/Send',
        data: jsonText,
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        success: function(result) {
            alert('e-mail Gönderildi.');
        },
        beforeSend: function() {

        },
        error: function(request, error) {
            alert(request.responseText);
            request.abort();
        }
    });
}
