function isIE() {
	return (navigator.appName.toUpperCase().match(/MICROSOFT INTERNET EXPLORER/) != null);
}

function doRedir(loc)
{
    location.href=loc;
    return false;
}

function doAsk(loc, question)
{
    if(question == undefined) {
        question = 'Are you sure?';
    }
    if(confirm(question)) {
        doRedir(loc);
    }
}

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent) {
        while(1) {
            curleft += obj.offsetLeft;
            if(!obj.offsetParent) break;
            obj = obj.offsetParent;
        }
    } else if(obj.x) {
        curleft += obj.x;
    }
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent) {
        while(1) {
            curtop += obj.offsetTop;
            if(!obj.offsetParent) break;
            obj = obj.offsetParent;
        }
    } else if(obj.y) {
        curtop += obj.y;
    }
    return curtop;
}

function createAjax()
{
    var ajax = null;
    try {
        // Firefox, Opera 8.0+, Safari
        ajax=new XMLHttpRequest();
    } catch (e) {
        // Internet Explorer
        try {
            ajax=new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                ajax=new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    
    return ajax;
}

function requestAjax(ajaxArg)
{
    ajax = createAjax();
    if(ajax == null) return;
    ajax.onreadystatechange = function() {
        if(ajax.readyState == 4) {
            var txt = ajax.responseText;
            ajaxArg.Receive(txt);
        }
    }
    ajax.open('GET', ajaxArg.geturl,true);
    ajax.send(null);
}

function getobj(objid)
{
    return document.getElementById(objid);
}

function doFocus(obj)
{
    if(obj.value == 'introduceti numele autorului') {
        obj.value = '';
        obj.className = 'norm';
    }
}

function doBlur(obj)
{
    if(obj.value == '') {
        obj.value = 'introduceti numele autorului';
        obj.className = '';
    }
}

function doSearch(obj)
{
    var rs = document.getElementById('sres');
    rs.style.display = 'none';
    var a = new Object();
    a.geturl = 'search.php?val='+obj.value+'&rand='+Math.random();
    a.Receive = function(text)
    {
        if(text.length > 0) {
            rs.style.left = findPosX(obj) + 'px';
            rs.style.top = (findPosY(obj) + 20) + 'px';
            rs.innerHTML = text;
            rs.style.display = 'block';
        }
    }
    
    requestAjax(a);
}
