function popkorn (path)
{
    window.open(path, 'popupwindow','width=600,height=500,scrollbars,resizable');
    return false;
}
function showsearch ()
{
    var searchbox = document.getElementById('searchbox');
    if (searchbox.style.display == 'none') {
        searchbox.style.display = 'block';
        searchbox.style.visibility = 'visible';
        var sinput = document.getElementById('sinput');
        sinput.focus();
    } else {
        searchbox.style.display = 'none';
        searchbox.style.visibility = 'hidden';
    }
}
function show_friendbox ()
{
    var friendbox = document.getElementById('friendbox');
    if (friendbox.style.display == 'none') {
        friendbox.style.display = 'block';
        friendbox.style.visibility = 'visible';
        //var sinput = document.getElementById('sinput');
        //sinput.focus();
    } else {
        friendbox.style.display = 'none';
        friendbox.style.visibility = 'hidden';
    }
}
function send_friend ()
{
    var friend_email = escape(dgi('friend_email').value);
    var your_email = escape(dgi('your_email').value);
    var friend_name = escape(dgi('friend_name').value);
    
    var vara = dgi('vara').value;
    
    request('option=com_ahsshop&do=send_friend&no_html=1&friend_email='+friend_email+'&your_email='+your_email+'&friend_name='+friend_name+'&vara='+vara);


}
function dgi (id)
{
    return document.getElementById(id);
}
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function request(query_string)
{
    document.getElementById('msg').innerHTML = 'sendi...';
    http.onreadystatechange = handleResponse;
    /* ŽETTA ER FYRIR GET
    http.open('get', 'rpc.php?'+query_string);
    http.send(null);
    */

    /* try instead */
    http.open('POST', 'index2.php', true);
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", query_string.length);
    http.setRequestHeader("Connection", "close");
    http.send(query_string);
}

function handleResponse() {

    var response = http.responseText;
    if(http.readyState == 4){
        document.getElementById('msg').innerHTML = response;
    }
}

