
	var popupCache = new Array();


	function gotoUrlNewWinSizeCentered(s, iWidth, iHeight)
	{
	    iWidth += 20;
	    iHeight += 25;
	    iWidth = screen.width;
	    iHeight = screen.height;
	    iLeft = Math.round((screen.width - iWidth) / 2);
	    iTop = Math.round((screen.height - iHeight) / 2);
	    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + iWidth + ",height=" + iHeight + ",left=" + iLeft + ",top=" + iTop + ",dependent=no,location=no,resizable=no,scrollbars=no,status=no");
	}

	function getRandomInt(max)
	{
	    return Math.round( Math.random() * (max-1) );
	}

	function gotoUrlNewWinMaximized(s)
	{
	    iWidth = screen.width;
	    iHeight = screen.height;
	    iLeft = Math.round((screen.width - iWidth) / 2);
	    iTop = Math.round((screen.height - iHeight) / 2);
	    newWin = window.open(s, "newWin" + getRandomInt(10000), "width=" + iWidth + ",height=" + iHeight + ",left=" + iLeft + ",top=" + iTop + ",dependent=no,location=no,resizable=no,scrollbars=no,status=no");
	}

	function showPopup(id) {
    	showPopupCommon("index.php?id="+id)
    }
	function showPopupCommon(url) {
    	$('#popup').html();
	    docsize=jQuery.iUtil.getSize($('body').get(0));
        docheight=docsize.h;
	    docscroll=jQuery.iUtil.getScroll();
	    $('#overlay').css('display','block').css('top','-50px').height((docheight+100)+'px');
        $('#overlay').click(function(){popupClose();});
        $('#popup').css('display','block').css('top',(docscroll.t+110)+'px').css('left',(docsize.w/2 - 200)+'px');
        data=popupCache[url];
        if (data) {
            $('#popup').html(data);
            $('#closeButton').click(function(){popupClose();});
        } else {
	        $('#popup').html('<div class="popupCzekaj">please wait...</div>');
	        $('#closeButton').click(function(){popupClose();});
	        $.get(url, function(data){
            	popupCache[url]=data;
	            $('#popup').html(data);
	            $('#closeButton').click(function(){popupClose();});
	        });
        }
    }


    function popupClose() {
		$('#popup').html('');
		$('#popup').css('display','none');
        $('#overlay').css('display','none');
    }
	function videoPolec(id) {
		popupClose();
		showPopup('107&f='+id);
    }
	function mainOnLoad() {

	}

	function showVideo(id) {
    	$('#popup').html();
	    docsize=jQuery.iUtil.getSize($('body').get(0));
        docheight=docsize.h;
	    docscroll=jQuery.iUtil.getScroll();
//	    $('#overlay').css('display','block').top('-50px').height((docheight+100)+'px');
//        $('#overlay').click(function(){popupClose();});
//****        $('#popup').css('display','block').top((docscroll.t+120)+'px').left((docsize.w/2 - 150)+'px');
        $('#popup').css('display','block').css('top',(docscroll.t+120)+'px').css('left',(docsize.w/2 - 150)+'px');
        data=popupCache[id];
        if (0) {
            $('#popup').html(data);
            $('#closeButton').click(function(){popupClose();});
        } else {
	        $('#popup').html('<div class="popupCzekaj">please wait...</div>');
	        $('#closeButton').click(function(){popupClose();});
	        $.get("/page/video.php?id="+id, function(data){
            	popupCache[id]=data;
	            $('#popup').html('<div id="FCvideo"></div>');
	            $('#closeButton').click(function(){popupClose();});
                p=data.split('|');
	            var so = new SWFObject("/fileadmin/flash/kfc_video.swf", "video", "421", "359", "8", "#ffffff");
	            so.addParam("wmode", "transparent");
	            so.addVariable("id", p[0]);
	            so.addVariable("videopath", p[1]);
	            so.addVariable("mpgpath", p[2]);
	            so.addVariable("videotitle", p[3]);
	            so.addVariable("imagepath", p[4]);
	            so.write("popup");
	            $('#popup').css('z-index','2000');
	        });
        }
    }

    function powiadomZnajomego(f) {
    	se=f['s_email'].value;
    	sn=f['s_name'].value;
    	re=f['r_email'].value;
        if (se.length<6) {
        	alert ('Enter your e-mail!');
            return false;
        }
        if (sn.length<1) {
            alert ('Enter your name!');
            return false;
        }
        if (re.length<6) {
        	alert ('Enter recipient\'s e-mail!');
            return false;
        }
        f['submit'].value="please wait";
        $.get("powiadom.php?se="+se+"&sn="+sn+"&re="+re, function(data){
            $('#popup').html(data);
	        $('#closeButton').click(function(){popupClose();});
        });
		return false;
    }