function readHashVars()
{
    var hash = window.location.hash;
    hash = hash.substring(1);
    hash = hash.replace(/\|/g, '&');
    hash = hash.replace(/\:/g, '=');
    // lets turn our url hash into a javascript hash (like an associated array)
    // we will use a useful function provided in the prototype library
    hash = hash.parseQuery();
    if ((typeof(hash.details) == 'undefined')) {
        hash.details = 'index';
    }
    return hash;
}

function checkIfThereIsAnyFlatInOfferFolder()
{
    // id user deletes last item in the ofeer folder it displays the message
    var rows=document.getElementById("flat_list").rows.length;
    if (rows == '2') {
        $('list').innerHTML = " <div class=\"no-results\">Twój folder ofertowy jest pusty</div>";
    }
}

function updateOfferFolderFlatsAmount() {
        new Ajax.Updater('flats_amount', '/index.php/offerfolder/updateAmount',
        {
            asynchronous: true
        });
}


function submitAjaxForm(action, formname, method_type, update_div, init_cart){
    new Ajax.Request(action,
    {
        method: method_type,
        parameters: $(formname).serialize(true),
        evalScripts: true,
        onLoading: function(){
            $(update_div).innerHTML = "<br /><br /><img src='/images/ajax-loader.gif' alt='wysyłam' /><br /><br /><b>wczytuję ...</b>";
        },
        onSuccess: function(transport){
            var response = transport.responseText || "wystąpił błąd";
            $(update_div).innerHTML = response;
            if (init_cart == '1') { 
                initCartDisplay();
            }
        },
        onFailure: function(){
            $(update_div).innerHTML = "nie pobrał odpowiedzi";
        }
    });
}


function sendMail(action, formname){
    new Ajax.Request(action,
    {
        method:'post',
        parameters: $(formname).serialize(true),
        evalScripts: true,
        onLoading: function(){
            $('update_div').innerHTML = "<center><img src='/images/ajax-loader.gif' alt='wysyłam' /><br /><br /><b>wczytuję ...</b></center>";
        },
        onSuccess: function(transport){
            var response = transport.responseText || "wystąpił błąd";
            $('update_div').innerHTML = response;
        },
        onFailure: function(){
            $('update_div').innerHTML = "nie pobrał odpowiedzi";
        }
    });
}
