/*
 * $Id: functions.js,v 1.7 2007/02/18 18:49:22 hp Exp $
 */

/* 
 * Pasitikslinimo klausimas 
 */
function ask(theLink, askmsg) {
    var is_confirmed = confirm(askmsg);
    if (is_confirmed) {
        theLink.href;
    }
    return is_confirmed;
}

/*
 * Parodome puslapį
 */
function show_page(url, width, height) {
    var left = (screen.width - width)/2;
    var top = (screen.height - height)/2; 
    window.open(url, 'aWin', 
        'toolbars=no,resizeable=no,scrollbars=no,left='
        +left+',top='+top+',width='+width+',height='+height);
    return false;    
}

/*
 * Parodome paveiksliuką
 */
function show_img(img, title, width, height) {
    var left = (screen.width - width)/2;
    var top = (screen.height - height)/2; 
    wnd = window.open('', 'aWin', 
        'toolbars=no,resizeable=no,scrollbars=no,left='
        +left+',top='+top+',width='+width+',height='+height);
    wnd.document.write('<html><head><title>' + title + '</title></head><body style="margin:0; padding:0;"><img src="' + img + '"alt=""/></body></html>');
    return false;
}

/*
 * Stringą paverčiame url'u.
 */
function str2url(str) {
    str = str.replace(/ą/g, "%C4%85");
    str = str.replace(/č/g, "%C4%8D");
    str = str.replace(/ę/g, "%C4%99");
    str = str.replace(/ė/g, "%C4%97");
    str = str.replace(/į/g, "%C4%AF");
    str = str.replace(/š/g, "%C5%A1");
    str = str.replace(/ų/g, "%C5%B3");
    str = str.replace(/ū/g, "%C5%AB");
    str = str.replace(/ž/g, "%C5%BE");

    str = str.replace(/Ą/g, "%C4%84");
    str = str.replace(/Č/g, "%C4%8C");
    str = str.replace(/Ę/g, "%C4%98");
    str = str.replace(/Ė/g, "%C4%96");
    str = str.replace(/Į/g, "%C4%AE");
    str = str.replace(/Š/g, "%C5%A0");
    str = str.replace(/Ų/g, "%C5%B2");
    str = str.replace(/Ū/g, "%C5%AA");
    str = str.replace(/Ž/g, "%C5%BD");

    return str;
}

/*
 * Funkcija sukurianti AJAX objekta bendradarbiavimui
 */
function get_http_request() {
    var http_request = false;
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Jūs naudojatės per sena naršyklės versija. Jums reiktų ją atsinaujinti.');
    }
    return http_request;
}

function SubmitFrm(event, form) {
    var code = 0;
    if (event.which) {
        code = event.which;
    } else {
        code = event.keyCode;
    }
    if (code == 13) {
        form.submit();
    }
}

function showMenu(menu) {
    var el = document.getElementById(menu);
    if (el == null) return;
    el.style.visibility = "visible";
}

/*
 * Paslepiame meniu
 */
function hideMenu(menu) {
    var el = document.getElementById(menu);
    if (el == null) return;
    el.style.visibility = "hidden";
}

/*
# vim: expandtab ts=4 sw=4 sts=4
# vim: encoding=utf-8
# vim: fileencoding=utf-8
*/
