function baseURL() {
    if (document.location.pathname.toLowerCase().indexOf("module") > 0)
        return ("..\/");
    else
        return ("");
}


var modal_dlg_result, modal_dlg_text, modal_dlg_checkbox; //do not remove these! these variables used for MODAL DIALOG
modal_dlg_result = -1;
modal_dlg_text = '';
modal_dlg_checkbox = false;


function showDialog(msg, dlg_type, btn1_text, btn2_text, btn3_text, inputtext, isPassword, isModal, checkboxtext, inputtext_default_value) 
{
    //    try
    //    {
    //	    if ((msg == null) || (dlg_type == null))
    //		    return;
    
    var m, p;
    if (isModal == null)
        m = true;
    else if (isModal == true)
        m = true;
    else
        m = false;
    //m = false;
    
    if (checkboxtext == null)
        checkboxtext = '';

    if (isPassword == null)
        p = 0;
    else if (isPassword == true)
        p = 1;
    else
        p = 0;

    msg = replaceAll(msg, '<', '~!');
    msg = replaceAll(msg, '>', '~^');
    msg = EncodeTurkishCharacters(msg);

    btn1_text = EncodeTurkishCharacters(btn1_text);
    btn2_text = EncodeTurkishCharacters(btn2_text);
    btn3_text = EncodeTurkishCharacters(btn3_text);
    inputtext = EncodeTurkishCharacters(inputtext);
    checkboxtext = EncodeTurkishCharacters(checkboxtext);

    if (inputtext_default_value != null)
        inputtext_default_value = EncodeTurkishCharacters(inputtext_default_value);
    else
        inputtext_default_value = '';

    var window_w = 426; //width for IE 6
    var window_h = 275; //width for IE 6

    //adjust the popup width and height according to browser version
    if (window.XMLHttpRequest) {
        // IE 7, mozilla, safari, opera 9
        window_w = 420;
        window_h = 250;
    }

    if (true && m) 
    {
        window.showModalDialog("ModalDialog.aspx?Type=" + dlg_type + "&b1text=" + btn1_text + "&b2text=" + btn2_text + "&b3text=" + btn3_text + "&inputtext=" + inputtext + "&checkboxtext=" + checkboxtext + "&ispw=" + p + "&msg=" + msg + "&dv=" + inputtext_default_value, window, "dialogWidth:" + window_w + "px;dialogHeight:" + window_h + "px;scroll:no;center:yes;status:no;help:no;resizable:no;");
    }
    else 
    {
        window.open(baseURL() + "ModalDialog.aspx?Type=" + dlg_type + "&b1text=" + btn1_text + "&b2text=" + btn2_text + "&b3text=" + btn3_text + "&inputtext=" + inputtext + "&ispw=" + p + "&msg=" + msg + "", 'test'); //, 'height=250,width=420,status=no,toolbar=no,menubar=no,location=no');
    }
    //RemoveFilter();	

    return modal_dlg_result;
    //    }
    //    catch(e)
    //    {
    //        alert("Exception in showDialog : " + e);
    //        return -1;
    //    }    
}

function EncodeTurkishCharacters(str) {
    try {
        str = replaceAll(str, String.fromCharCode(305), "~0"); //str = replaceAll(str, 'ý', '~0');
        str = replaceAll(str, String.fromCharCode(351), "~1"); //str = replaceAll(str, 'þ', '~1');
        str = replaceAll(str, String.fromCharCode(231), "~2"); //'ç'
        str = replaceAll(str, String.fromCharCode(287), "~3"); ////str = replaceAll(str, 'ð', '~3');
        str = replaceAll(str, String.fromCharCode(246), "~4"); ////str = replaceAll(str, 'ö', '~4');
        str = replaceAll(str, String.fromCharCode(252), "~5"); ////str = replaceAll(str, 'ü', '~5');
        str = replaceAll(str, String.fromCharCode(304), "~6"); ////str = replaceAll(str, 'Ý', '~6');
        str = replaceAll(str, String.fromCharCode(350), "~7"); ////str = replaceAll(str, 'Þ', '~7');
        str = replaceAll(str, String.fromCharCode(199), "~8"); ////str = replaceAll(str, 'Ç', '~8');
        str = replaceAll(str, String.fromCharCode(286), "~9"); ////str = replaceAll(str, 'Ð', '~9');
        str = replaceAll(str, String.fromCharCode(214), "~A~"); ////str = replaceAll(str, 'Ö', '~A~');
        str = replaceAll(str, String.fromCharCode(220), "~B~"); ////str = replaceAll(str, 'Ü', '~B~');

        return str;
    }
    catch (e) {
        alert("exception in EncodeTurkishCharacters");
        return "";
    }
}

function DecodeTurkishCharacters(str) {
    try {
        str = replaceAll(str, "&#305;", String.fromCharCode(305)); //str = replaceAll(str, 'ý', '~0');
        str = replaceAll(str, "&#351;", String.fromCharCode(351)); //str = replaceAll(str, 'þ', '~1');
        str = replaceAll(str, "&#231;", String.fromCharCode(231)); //'ç'
        str = replaceAll(str, "&#287;", String.fromCharCode(287)); ////str = replaceAll(str, 'ð', '~3');
        str = replaceAll(str, "&#246;", String.fromCharCode(246)); ////str = replaceAll(str, 'ö', '~4');
        str = replaceAll(str, "&#252;", String.fromCharCode(252)); ////str = replaceAll(str, 'ü', '~5');
        str = replaceAll(str, "&#304;", String.fromCharCode(304)); ////str = replaceAll(str, 'Ý', '~6');
        str = replaceAll(str, "&#350;", String.fromCharCode(350)); ////str = replaceAll(str, 'Þ', '~7');
        str = replaceAll(str, "&#199;", String.fromCharCode(199)); ////str = replaceAll(str, 'Ç', '~8');
        str = replaceAll(str, "&#286;", String.fromCharCode(286)); ////str = replaceAll(str, 'Ð', '~9');
        str = replaceAll(str, "&#214;", String.fromCharCode(214)); ////str = replaceAll(str, 'Ö', '~A~');
        str = replaceAll(str, "&#220;", String.fromCharCode(220)); ////str = replaceAll(str, 'Ü', '~B~');

        return str;
    }
    catch (e) {
        alert("exception in DecodeTurkishCharacters");
        return "";
    }
}

function FixEncodedCharacters(str) {
    try {
        str = replaceAll(str, "&quot;", "\"");
        str = replaceAll(str, "&lt;", "\<");
        str = replaceAll(str, "&gt;", "\>");
        str = replaceAll(str, "&amp;", "\&");

        return str;
    }
    catch (e) {
        alert("FixEncodedCharacters");
        return "";
    }
}

function balert(msg) {
    showDialog(msg, "ALERT", get_RSC_TAMAM(), "", "", "", 0, true);
}


function confirm(msg) {
    try {
        var res = showDialog(msg, "CONFIRM", "EVET", "HAYIR", "", "", 0, true);

        if (res == 1)
            return true;
        else
            return false;
    }
    catch (e) {
        alert("confirm");
        return false;
    }

}

function ApplyGrayscaleFilter() {
    try {
        document.body.style.filter = 'progid:DXImageTransform.Microsoft.BasicImage(grayScale=1)';
    }
    catch (e) {
        alert("ApplyGrayscaleFilter");
        return false;
    }

}

function RemoveFilter() {
    try {
        document.body.style.filter = '';
    }
    catch (e) {
        alert("RemoveFilter");
        return false;
    }
}

