jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '; path=/';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

window.onload = function()
{
    if (navigator.product=="Gecko" && navigator.userAgent.indexOf("rv:1.7")>=-1)
    { // blad w Gecko 1.7
	var s=document.body.style;
	s.display="none";
	s.display="";
    }
/*    $("#CP").hide();
    $("#CP").css("position","absolute");
    $("#CP").css("top","0px");
    $("#CP").css("left","0px");
    $("#CP").attr("src","img/clipboard.gif");
    if(CC){
    $("#CP").fadeIn();
    }*/
}

function showSubmenu(nazwa)
{
    if(document.getElementById(nazwa))
    {
	if(document.getElementById(nazwa).style.display == 'block')
    	    document.getElementById(nazwa).style.display="none";
	else
	    document.getElementById(nazwa).style.display="block";
    }

}

function Clipboard(a){
    $.post("ajax.php",{func:"C",I:a},
     function(data){
        if(data){
	$("#"+a).html("oferta w schowku <img src='../img/schowek2.gif' height='20' border='0' title='Pokaż schowek' />");
	$("#"+a).attr("href","index2.php?nieruchomosci=schowek");
	$("#"+a).attr("onclick","SA()");
	$("#schowekL").html(" pokaż schowek ("+data+" ofert)<img src='../img/schowek2.gif' height='20' border='0' title='Pokaż schowek' style='text-decoration:none;'/>");
      //  alert("Ilość ofert w schowku: "+data);
	
        }
     }
    );
}

function SA(){

    $.cookie("par",window.location.href);

}


function SLA(){

    if(window.location.href.indexOf("user") == -1 && window.location.href.indexOf("zaloguj") == -1)
        $.cookie("parL",window.location.href);

}


function LoginPlease(){

    alert("Musisz być zalogowany by móc obejrzeć pełną treść ogłoszenia");
    return false;
}

