// MagiClick Javascript Framework v0.1
// some routines dropped from prototype.js ;)
// Author: Omerz
/*
var MinDate = Date.parse("01.01.0001 00:00:00");
var _alert = null, _alertBoxIndex = 0, _alertBoxVisibleCount = 0;
var EnableClientDebugging = false;
function debug(debDetails) {
    if (EnableClientDebugging && $.browser.msie) {
        console.log(debDetails)
    }
}

Array.prototype.indexOf = Array.prototype.indexOf || function(_value) {
    var index = -1;
    for (var i = 0; i < this.length; i++)
        if (this[i] == _value) {
        index = i;
        break;
    }
    return index;
};

jQuery.fn.extend({
    scrollTo: function(speed, easing) {
        return this.each(function() {
            var targetOffset = $(this).offset().top;
            $('html,body').animate({ scrollTop: targetOffset }, speed, easing);
        });
    }
});

*/
function getCenter(pwidth, pheight) {
    wwidth = screen.width;
    wheigth = screen.height;
    lpos = (wwidth - pwidth) / 2;
    tpos = (wheigth - pheight) / 2;
    return lpos, tpos;
}

function PopItUp(src, w, h, s) {
    if (s) w = w + 17;
    getCenter(w, h);
    Popwin = window.open(src, "pop_up", "toolbar=0,width=" + w + ", height=" + h + ", left=" + lpos + ", top=" + tpos + "; location=0, directories=0, status=1, scrollbars=" + s + ", menubar=0, resizable=0, copyhistory=0");
    Popwin.focus();

}
/*
function setLoading(strTarget, message) {
    var targetObj = $(strTarget);
    if (targetObj.css("display") == "none")
        return;
    if (targetObj.length <= 0)
        return;

    var strHtmlLoading = $("#ajaxLoader").html();
    var strLoaderID = targetObj[0].id + "_loader";
    var strLoaderPrgID = targetObj[0].id + "_loader_prg";
    var strLoaderMsgID = targetObj[0].id + "_loader_msg";
    var strContentID = targetObj[0].id + "_content";

    // if loader not removed or already created?
    if ($("#" + strLoaderID).length > 0)
        return;

    strHtmlLoading = strHtmlLoading.replace(/id_replacement/i, strLoaderID);
    strHtmlLoading = strHtmlLoading.replace(/id_replacement_prg/i, strLoaderPrgID);
    strHtmlLoading = strHtmlLoading.replace(/id_replacement_msg/i, strLoaderMsgID);

    // append loader data top of the target object.
    targetObj.before(strHtmlLoading);
    //targetObj.parent().prepend(strHtmlLoading);

    var objLoader = $("#" + strLoaderID);
    objLoader.width(targetObj.width());
    if (targetObj.height() > 100) {
        objLoader.height(targetObj.height());

        $("#" + strLoaderPrgID).css("margin-top", (targetObj.height() / 2) - $("#" + strLoaderPrgID).height());
    }

    if (message != null)
        $('#' + strLoaderMsgID).text(message);
    objLoader.show();
}

function resetLoading(strTarget) {
    var targetObj = $(strTarget);
    if (targetObj.length <= 0)
        return;
    var objLoader = $("#" + targetObj[0].id + "_loader");
    if (objLoader.length <= 0)
        return;

    objLoader.remove();

}



function showPageLoader() {
    $("#loaderLayer").show();
    if ($.browser.msie && ($.browser.version.indexOf("6.") > -1 ? true : false)) {
        $("#loaderLayer").height($(document).height());
    }
}

function hidePageLoader() {
    $("#loaderLayer").hide();
}


function lookupRecord(intRecID, dataSource, equals) {
    if (dataSource == null)
        return null;
    // lookup record in loaded records
    var x;
    for (var x = 0; x < dataSource.length; x++) {
        if (eval("dataSource[x]." + equals + "==intRecID")) {
            return { record: dataSource[x], index: x };
        }
    }
}

function lookupRecords(intRecID, dataSource, equals) {
    var resultset = new Array();
    if (dataSource == null)
        return null;
    // lookup record in loaded records
    var x;
    for (var x = 0; x < dataSource.length; x++) {
        if (eval("dataSource[x]." + equals + "==intRecID")) {
            resultset.push(dataSource[x]);
        }
    }
    return resultset;
}

function onlyLetter(e) {
    var InvalidChars = "!#/*{[()]},;%^><\\?+:='`|é&æ~£$½¨ß";

    var keyCode = ($.browser.mozilla) ? e.which : event.keyCode;

    if (keyCode > 47 && keyCode < 58) {
        return false;
    }
    for (i = 0; i <= InvalidChars.length - 1; i++) {
        if (keyCode == InvalidChars.charCodeAt(i)) {
            return false;
        }
    }
}


function onlyNumber(e) {
    var keyCode = ($.browser.mozilla) ? e.which : event.keyCode;
    if ((keyCode < 48 || keyCode > 57) && keyCode != 8 && keyCode != 0) {
        return false;
    }
}


function onlyEmail(e) {
    var InvalidChars = " !#/*{[()]},;%^><\\?+:='`|þÞÐðÜüÇçÝýÖö";

    kCode = InvalidChars.charAt(5);

    var keyCode = ($.browser.mozilla) ? e.which : event.keyCode;

    if (keyCode > 127) {
        return false;
    }
    for (i = 0; i <= InvalidChars.length - 1; i++) {
        if (keyCode == InvalidChars.charCodeAt(i)) {
            return false;
        }
    }
    return true;
}

function gotoUrl() { //based on mm_goToURL
    for (var i = 0; i < (gotoUrl.arguments.length - 1); i += 2)
    //with arg pairs
        eval(gotoUrl.arguments[i] + ".location='" + gotoUrl.arguments[i + 1] + "'");
    //document.MM_returnValue = false;
}

*/

$(document).ready(function() {
   
   /*
    if ($.WebServices != null) {
        $.WebServices.onError = function(err, extraDetails) {
            if (err.message = !null && err.message.indexOf("[401.2]") > -1) {
                gotoUrl('parent', 'ErisimYetkiHatasi.aspx');
            } else {
                alert("Veri alýnýrken hata oluþtu!", "Hata");
                console.warn("$.WebServices.onError ->");
                if (extraDetails != null)
                    console.error(extraDetails);
                console.error(err.name);
                console.error(err.description);
                if ($.browser.msie) console.open();
            }
        };
    }

    if (EnableClientDebugging && $.browser.msie) {
        console.info("Magic Debugging Enabled");
        window.onerror = function(msg, url, lno) {
            alert('JavaScript hatasý! <br/> Dosya :' + url + ', satýr: ' + lno + ' <br/>Mesaj: ' + msg, 'JavaScript hatasý!');
            //console.error("Document Error ->" + url + " at line " + lno);
            //console.error("Message:" + msg);
            //if($.browser.msie) console.open();
            return true;
        };

        $.WebServices.onBeforeCall = function(xhr, uri, soapEnv) {
            console.group("$.WebServices.onBeforeCall -> URI:" + uri);
            console.log(soapEnv);
            console.groupEnd();
            return true;
        };

        $.WebServices.onFinally = function(xhr, textStatus) {
            //console.info("$.WebServices.onFinally -> State:" + textStatus);
            console.group("$.WebServices.onFinally -> State:" + textStatus);
            console.log(xhr.responseText);
            console.groupEnd();
            //debug(xhr.responseText);
            return true;
        };
    }
    */

    $('.menu').flash({ src: '/_swf/menu.swf', width: 700, height: 108, menu: false, wmode: 'transparent' }, { version: 8 });
    $('.banner').flash({ src: '/_swf/banner.swf', width: 950, height: 316, menu: false, wmode: 'transparent' }, { version: 8 });

    /* sifr */
    jfr$('h1.sifr').jfr({
        src: '/_swf/jfr/MyriadPro.swf',
        css: [
            '* { color: #0F6A8C; text-align: left; font-size: 36px;   }',
            'a { color: #0F6A8C; text-decoration: none; }',
            'a:hover { text-decoration: underline; }'
            ]
    });
    $.jfr.render();
    /* sifr! */


    /* tab */
    $(".tabItem .tabTitle a").click(function() {

        var _index = $(".tabItem .tabTitle a").index(this);
        if ($(".tabItem").eq(_index).hasClass("active")) {
            $(".tabItem").eq(_index).removeClass("active")
            $(".tabItem .tabContent").eq(_index).slideUp("slow");
            return false;
        }
        if ($(".tabItem .tabContent").eq(_index).text() == "") {

            return false;
        }

        $(".tabItem").eq(_index).addClass("active");
        $($(".tabItem .tabContent").eq(_index)).slideToggle("slow");

        return false;
    });

});









 




