﻿var icerik = '.icerik';
var loading = '<center><strong>Sayfa Yükleniyor..</strong><br /><img border="0px" src="images/loading.gif" /></center>';
var bName = navigator.appName; var firefox = false; if (bName == 'Microsoft Internet Explorer') { bName = 'POST'; } else { bName = 'GET'; firefox = true; }
$(document).ready(function () {

});
$(function () {

});
function makeRequest(url, targetElement, dil) {
    var httpRequest;
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
        if (httpRequest.overrideMimeType) {
            httpRequest.overrideMimeType('text/xml');
        }
    }
    else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) { }
        }
    }
    if ((targetElement == null) | (targetElement == "undefined")) targetElement = "stage";
    var stage = document.getElementById(targetElement);
    if (!httpRequest) {
        stage.innerHTML = 'Şu anda işleminizi yapamıyorum.<br/>Birkaç dakika sonra tekrar deneyiniz.';
        return false;
    }
    httpRequest.onreadystatechange = function () { fillContents(httpRequest, stage); };
    if (!dil) {
        stage.innerHTML = '<center><span style="font-family:Tahoma,Arial;font-size:12px;font-weight:bold;color:#fff;">Gönderiliyor..</span><br /><img src="images/loading.gif" /></center>';
    }
    else { stage.innerHTML = '<br /><br /><center><span style="font-family:Tahoma,Arial;font-size:12px;font-weight:bold;color:#333;">Page Loading, Please Wait..</span><br /><img src="images/loading.gif" /></center>'; }
    httpRequest.open('GET', url, true);
    httpRequest.send('');
}
function fillContents(httpRequest, stage) {
    if (httpRequest.readyState == 4) {
        var tDiv = document.createElement("div");
        if (httpRequest.status == 200) {
            tDiv.innerHTML = httpRequest.responseText;
        } else {
            tDiv.innerHTML = 'İşlem yapılamadı.<br />Hata Kodu : ' + httpRequest.status;
        }
        stage.innerHTML = "";
        stage.appendChild(tDiv);
    }
}
function hoppidi(clsOrId, speed) {
    if (!speed) { speed = 250; }
    $(clsOrId).hover(function () { $(this).stop(true, false).animate({ "margin-top": "5px", "padding-left": "20px"}, { duration: speed }); });
    $(clsOrId).mouseout(function () { $(this).stop(true, false).animate({ "margin-top": "0px", "padding-left": "0px" }, { duration: speed }); });
}
function socialEffect(clsOrId, speed) {
    if (!speed) { speed = 250; }
    $(clsOrId).hover(function () { $(this).stop(true, false).animate({ "margin-bottom": "0px"}, { duration: speed }); });
    $(clsOrId).mouseout(function () { $(this).stop(true, false).animate({ "margin-bottom": "5px" }, { duration: speed }); });
}
var Tvalue = 0;
function makeSlider(clsOrId, gecisHizi, speed, numbers, btnColor) {
    if (!speed) { speed = 1000; } if (!gecisHizi) { gecisHizi = 1000; }
    var kur; var Ctrl = '#HpCtrl';
    $(clsOrId + ' ul').css('list-style', 'none'); $(clsOrId + ' ul').css('margin', '0px'); $(clsOrId + ' ul').css('padding', '0px'); $(clsOrId + ' li').css('position', 'absolute'); $(clsOrId + ' li').css('float:', 'left');
    if (numbers) {
        if (!btnColor) {btnColor = 'Maroon';}
        $(clsOrId).append('<div style="z-index:999;position:absolute;margin:8px 5px 8px 5px;" id="HpCtrl"><ul id="HpList" style="margin:0px;padding:0px;list-style:none;"></ul></div>');
        var ballonCss = 'width:10px;height:10px;border:1px solid #e3e3e3;background-color:' + btnColor + ';cursor:pointer;float:left;margin-left:2px;margin-right:2px;';
    }
    var total = parseInt($(clsOrId + ' li').length);
    $(clsOrId + ' li').each(function (i) {
        if (numbers) { $('#HpList').append('<li title="' + (i + 1) + '" style="' + ballonCss + '"></li>'); }
        this.id = this.id + "harry_" + i;
        $(this).css('z-index', 99 + i);
        if (i != 0) { $(this).animate({ "opacity": 0 }, { duration: 1 }); }
    });
    if (numbers) {
        $(clsOrId).append('<div style="clear:both;margin:0px;padding:0px;border:0px;"></div>');
        $(Ctrl).css('opacity', '0.3');
        var marginT = parseInt($(clsOrId).height()) - parseInt($(Ctrl).height());
        $(Ctrl).css('margin-top', marginT - 15 + 'px');
        var params = {}; params['opacity'] = '0.7'; var paramsex = {}; paramsex['opacity'] = '0.3';
        $(clsOrId + ' ul').hover(function () { $(Ctrl).animate(params, { duration: 400 }); });
        $(clsOrId + ' ul').mouseout(function () { $(Ctrl).animate(paramsex, { duration: 250 }); });
        $(Ctrl + ' li').click(function () {
            if (kur) { clearInterval(kur); };
            $('#harry_' + parseInt($(this).index())).stop(true, false).animate({ "opacity": 1 }, { duration: gecisHizi });
            if (Tvalue != 0) { if ($(this).index() != Tvalue) { $('#harry_' + Tvalue).stop(true, false).animate({ "opacity": 0 }, { duration: gecisHizi }); } }
            Tvalue = $(this).index();
            kur = setInterval("Tkur(" + gecisHizi + "," + speed + "," + total + ")", speed);
        });
    }
    kur = setInterval("Tkur(" + gecisHizi + "," + speed + "," + total + ")", speed);
}
function Tkur(gecisHizi, speed, total) {
    if (total == Tvalue) { Tvalue = 0; }
    var newid = parseInt(Tvalue) + 1; if (newid < 0) { newid = 0; }
    $('#harry_' + newid).stop(true, false).animate({ "opacity": 1 }, { duration: gecisHizi });
    if (Tvalue != 0) { $('#harry_' + Tvalue).stop(true, false).animate({ "opacity": 0 }, { duration: gecisHizi }); }
    Tvalue = parseInt(Tvalue) + 1;
}
function RenkMix(clsOrId, clr, exColor, where, speed) {
    //Where's : backgroundColor    borderBottomColor    borderLeftColor    borderRightColor   borderColor    borderTopColor    color    outlineColor
    if (!speed) { speed = 500; } if (!where) { where = 'color'; } if (!clr) { clr = '#C00'; }
    if (!exColor) { exColor = $(clsOrId).css(where); }
    var params = {}; params[where] = clr; var paramsex = {}; paramsex[where] = exColor;
    $(clsOrId).hover(function () { $(this).stop(true, false).animate(params, { duration: speed }); });
    $(clsOrId).mouseout(function () { $(this).stop(true, false).animate(paramsex, { duration: speed }); });
}
function RakamUret(from, to) { return Math.floor((to - (from - 1)) * Math.random()) + from; }
function makeR(div, page, loading, speed, effect, callback) {
    if (typeof callback != "function") { callback = function () { }; }
    if (!speed) { speed = "slow" }
    if (!loading) { loading = '<center><strong>Sayfa Yükleniyor..</strong><br /><img border="0px" src="images/loading.gif" /></center>'; }
    if (!effect) { $(div).html(loading); $(div).load(page, function () { callback(); }); return false; }
    else {
        if (effect == 1) { effect = RakamUret(2, 8); }
        if (effect == 2) { $(div).toggle(speed, function () { $(div).html(loading); $(div).load(page, function () { $(div).toggle(speed, function () { callback(); }); }); }); return false; }
        if (effect == 3) { $(div).html(loading); $(div).fadeOut(speed, function () { $(div).load(page, function () { $(div).fadeIn(speed, function () { callback(); }); }); }); return false; }
        if (effect == 4) { $(div).html(loading); $(div).hide(speed); $(div).load(page, function () { $(div).show(speed, function () { callback(); }); }); return false; }
        if (effect == 5) { $(div).html(loading); $(div).slideToggle(speed, function () { $(div).hide(speed); $(div).load(page, function () { $(div).slideToggle(speed, function () { callback(); }); }); }); return false; }
        if (effect == 6) { $(div).html(loading); $(div).animate({ width: "hide", "opacity": "toggle", paddingLeft: "hide", paddingRight: "hide", marginLeft: "hide", marginRight: "hide" }, speed, function () { $(div).css('margin-left', '100%'); $(div).load(page, function () { $(div).animate({ paddingLeft: "show", paddingRight: "show", marginLeft: "0px", marginRight: "show", "opacity": "toggle" }, speed, function () { callback(); }); }); }); return false; }
        if (effect == 7) { $(div).html(loading); $(div).animate({ width: "hide", "opacity": "toggle", paddingLeft: "hide", paddingRight: "hide", marginLeft: "hide", marginRight: "hide" }, speed, function () { $(div).load(page, { contentType: "application/json; charset=utf-8" }, function () { $(div).animate({ "opacity": "toggle", width: "show", paddingLeft: "show", paddingRight: "show", marginLeft: "show", marginRight: "show" }, speed, function () { callback(); }); }); }); return false; }
        if (effect == 8) { $(div).animate({ "opacity": "0.1" }, speed, function () { $(div).load(page, function () { $(div).animate({ "opacity": "1" }, speed, function () { callback(); }); }); }); return false; }
    }
}
function mapsLoaded() {
    var map = new google.maps.Map2(document.getElementById("map"));
    map.setCenter(new google.maps.LatLng(37.070310, 37.366560), 15);
    var marker = new GMarker(new GLatLng(37.070310, 37.366560));
    map.addOverlay(marker);
    marker.openInfoWindowHtml("<center><img src='images/maplogo.png' /></center>");

} function saatYaz() {
    var datemx = new Date();
    var mySaat = ("00" + datemx.getHours()).substr(("00" + datemx.getHours()).length - 2, 2);
    var myDakika = ("00" + datemx.getMinutes()).substr(("00" + datemx.getMinutes()).length - 2, 2);
    var mySaniye = ("00" + datemx.getSeconds()).substr(("00" + datemx.getSeconds()).length - 2, 2);
    var saatim = mySaat + ":" + myDakika + ":" + mySaniye;
    return saatim
}
function loadMaps() {
    google.load("maps", "2", { "callback": mapsLoaded });
    $('.ileform').submit(function () {
        $('#bilgim').html('<center><img src="images/loading.gif" /></center>');
        $.ajax({
            type: "POST",
            url: "sendmail.aspx",
            data: { adi: $('#Text1').val(), mail: $('#Text2').val(), mesaj: $('#Text3').val() },
            contentType: "application/x-www-form-urlencoded; charset=utf-8",
            dataType: "JSON",
            success: function (gelen) {
                $('#bilgim').html('<center>' + gelen + '</center>');
                if (gelen.indexOf('hata') != -1) { } else { $('#Reset1').click(); }
            },
            error: function (msg, text) {
                $('#bilgim').html("Mail göndermede hata oluştu : " + text);
            }
        });
        return false;
    });


}
String.prototype.ReplaceAll = function (stringToFind, stringToReplace) {
    var temp = this;
    var index = temp.indexOf(stringToFind);
    while (index != -1) {
        temp = temp.replace(stringToFind, stringToReplace);
        index = temp.indexOf(stringToFind);
    }
    return temp;
}
function fix(str) {
    return str.ReplaceAll(' ', '%20').ReplaceAll('  ', '%20%20').ReplaceAll('+', '').ReplaceAll("'", "").replace(',', '').ReplaceAll(';', '').ReplaceAll('\n', 'vbCrLf');
}
function makeUpload() {
    new Ajax_upload('#uploader', {
        action: 'upload.ashx',
        onSubmit: function (file, ext) {
            if (!(ext && /^(jpg|png|jpeg|gif)$/.test(ext))) {
                return false;
            }
            this.disable();
            $('#result').html('<img border="0px" src="images/loading.gif" />');
        },
        onComplete: function (file, response) {
            document.getElementById('temp').innerHTML = response;
            var txt = $('#temp').text(); var notxt = document.getElementById('mesaj').value;
            $('#result').load('defter.aspx?refid=' + txt + '&not=' + fix(notxt) + '&adi=' + fix($('#isim').val()), { method: bName, contentType: "application/json; charset=utf-8" }, function () {  });
            this.enable();
        }
    });
}
function sendS() {
    if ($('#kod').text() == document.getElementById("kodtxt").value) {
        var mesaj;
        bolumler = ["adtxt", "teltxt", "epostatxt", "aciklamatxt", "hizmet"]
        for (var i = 0; i < bolumler.length; i++) {
            mesaj = mesaj + document.getElementById(bolumler[i]).value + '|';
        }
        makeRequest('sendSip.aspx?gonder=' + mesaj, 'bilgilbl');
        document.getElementById('kod').innerText = RakamUret(1111, 9999);
    }
    else {
        var d = new Date();
        document.getElementById("bilgilbl").innerText = 'Girilen Güvenlik Kodu Hatalı!';
    }
}
