var opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
var ie    = (document.all && !opera)? true : false;
var dom   = (document.getElementById)? true : false;

function getStyle(itemID) {
    if(dom) {
        return document.getElementById(itemID);
    } else if(ie) {
        return document.all[itemID];
    }
}

function selectFolder(folderID) {
    folder = cookies.readCookie(folderID);
    swFolder(folderID, folder ? "none" : "block");
    if(folder) {
        cookies.deleteCookie(folderID);
    } else {
        cookies.saveCookie(folderID, 1);
    }
}

function swFolder(folderID, value) {
    getStyle(folderID).style.display = value;
}

function swDisplay(folderID) {
    getStyle(folderID).style.display = getStyle(folderID).style.display == 'none' ? '' : 'none';
}

var clWidth = (ie) ? 'document.body.clientWidth' : 'window.innerWidth';
var clHeight = (ie) ? 'document.body.clientHeight' : 'window.innerHeight';

function onLoadHandler() {
	clWidth = eval(clWidth);
	clHeight = eval(clHeight);
}

function isEmpty(s) {
	if(s != null) {
		em = s.replace( /[\t\r\n ]*/g, '' );
		return (s == null || s == '' || em.length == 0);
	}
}

var ql = {login:0, pass:0};
function checkLoginFields() {
    f = document.qlForm;
    return !isEmpty(f.login.value) && !isEmpty(f.pass.value);
}

function doLogin() {
    qf = document.qlForm;
    qf.login.value = document.ql1.login.value;
    qf.pass.value = document.ql2.pass.value;
    qf.remember.value = document.ql2.remember.checked ? 1 : 0;

    if(checkLoginFields()) qf.submit();
}

function ow(url, name, w, h, center, scrollbars) {
    if(url) url = unescape(url);
    eval('if(typeof win_'+name+' != \'undefined\') win = win_'+name+'; else win = false;');
    if(!win || win.closed) {
        xy = '';
        if(center) {
            x  = (screen.availWidth-w)/2;
            y  = (screen.availHeight-h)/2;
            xy = ',top='+y+',left='+x;
        }
        win = open(url, name, 'toolbar=0,status=0,resizable=0,scrollbars='+(scrollbars?1:0)+',width='+w+',height='+h+xy);
        eval('win_'+name+' = win;');
    }
    else
    {
        win.focus();
        if(url && win.location.pathname + win.location.search != url) win.location = url;
    }
}
