﻿var lstMnu = -1;

function openMnu(id, dvPre) {
    var obj;

    if (parseFloat(lstMnu) > 0) {
        obj = document.getElementById(dvPre + lstMnu);

        if (obj != null)
            obj.className = "item";

    }

    if (lstMnu != id) {
        lstMnu = id;

        obj = document.getElementById(dvPre + id);

        if (obj != null)
            obj.className = "item active";
    }
    else
        lstMnu = -1;

}


function echeck(str) {
    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)

    if (str.indexOf(at) == -1) {
        alert(message2);
        return false
    }

    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        alert(message2);
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        alert(message2);
        return false
    }

    if (str.indexOf(at, (lat + 1)) != -1) {
        alert(message2);
        return false
    }

    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        alert(message2);
        return false
    }

    if (str.indexOf(dot, (lat + 2)) == -1) {
        alert(message2);
        return false
    }

    if (str.indexOf(" ") != -1) {
        alert(message2);
        return false
    }

    return true;
}

function setTabMenuIcerik(nm) {
    $(".big-menu li").removeClass("active");
    //$(this).addClass("active");


    if (nm == 'tbMakaleler') {
        var obj = document.getElementById('dvTabContent');
        if (obj != null) {
            obj.className = 'big-menu-block display';
            obj.innerHTML = '<br />&nbsp;&nbsp;&nbsp;<img alt="" src="images/loading.gif" />';
        }

        var objLi = document.getElementById('liMakale');
        objLi.className = 'active';

        $.ajax({
            type: "POST",
            url: $("#ajaxProPath").attr('value'),
            data: '{}',
            cache: false,
            beforeSend: function (xhr) {
                xhr.setRequestHeader("X-AjaxPro-Method", "getMakalelerHTML");
            },
            success: function (s) {
                if (s.indexOf('r.error = {"Message":"', 1) > 0)
                    alert(s.substring(s.indexOf('r.error = {"Message":"', 1) + 22, s.indexOf('","', 1)).replace('":"', ' : '));
                else {
                    var o = null;
                    eval("o = " + s + "*" + "/");

                    var obj = document.getElementById('dvTabContent');
                    if (obj != null)
                        obj.innerHTML = o;
                    else
                        window.location.href = 'ipuclari.aspx';
                }

            },
            error: function (request, error) {
                alert(error);
            }
        });
    }
    else if (nm == 'tbEgitimArama') {
        window.location.href = 'egitimarama.aspx';
    }
    else if (nm == 'tbUyeOzel') {
        window.location.href = 'uyeozel.aspx';
    }
    else if (nm == 'tbEgitimSepetim') {
        var obj = document.getElementById('dvTabContent');
        if (obj != null) {
            obj.className = 'big-menu-block display';
            obj.innerHTML = '<br />&nbsp;&nbsp;&nbsp;<img alt="" src="images/loading.gif" />';
        }

        var objLi = document.getElementById('liSepetim');
        objLi.className = 'active';

        $.ajax({
            type: "POST",
            url: $("#ajaxProPath").attr('value'),
            data: '{}',
            cache: false,
            beforeSend: function (xhr) {
                xhr.setRequestHeader("X-AjaxPro-Method", "getHaberler4AnaSayfa");
            },
            success: function (s) {
                if (s.indexOf('r.error = {"Message":"', 1) > 0)
                    alert(s.substring(s.indexOf('r.error = {"Message":"', 1) + 22, s.indexOf('","', 1)).replace('":"', ' : '));
                else {
                    var o = null;
                    eval("o = " + s + "*" + "/");

                    var obj = document.getElementById('dvTabContent');
                    if (obj != null)
                        obj.innerHTML = o;
                    else
                        window.location.href = 'ipuclari.aspx';
                }

            },
            error: function (request, error) {
                window.location.href = 'ipuclari.aspx';
            }
        });
        
        //window.location.href = 'egitimsepetim.aspx';
    }
    else if (nm == 'tbKarsilastirma') {
        var objLi = document.getElementById('liKarsilastirma');
        objLi.className = 'active';

        var obj = document.getElementById('dvTabContent');
        if (obj != null) {
            obj.className = 'big-menu-block cart';
            obj.innerHTML = '<br />&nbsp;&nbsp;&nbsp;<img alt="" src="images/loading.gif" />';
        }

        $.ajax({
            type: "POST",
            url: $("#ajaxProPath").attr('value'),
            data: '{}',
            cache: false,
            beforeSend: function (xhr) {
                xhr.setRequestHeader("X-AjaxPro-Method", "getKarsilastirmaSepetHTML");
            },
            success: function (s) {
                if (s.indexOf('r.error = {"Message":"', 1) > 0)
                    alert(s.substring(s.indexOf('r.error = {"Message":"', 1) + 22, s.indexOf('","', 1)).replace('":"', ' : '));
                else {
                    var o = null;
                    eval("o = " + s + "*" + "/");

                    var obj = document.getElementById('dvTabContent');
                    if (obj != null)
                        obj.innerHTML = o;
                    else
                        window.location.href = 'karsilastirma.aspx';
                }

            },
            error: function (request, error) {
                alert(error);
            }
        });
    }
    else if (nm == 'tbUzaktanEgitim') {
        window.location.href = 'uzaktanegitim.aspx';
    }
    else if (nm == 'tbYurtdisiEgitim') {
        window.location.href = 'yurtdisiegitim.aspx';
    }
    else if (nm == 'tbPromosyonluOkullar') {
        window.location.href = 'sizeozel.aspx';
    }
}
