function bezpiecznaNazwa(str) {
    pl = new Array ('ó', 'ą','ę', 'Ę', 'ś', 'ł', 'ż', 'ź', 'ć', 'ń', 'Ó', 'Ą', 'Ś', 'Ł', 'Ż', 'Ź', 'Ć', 'Ń', ' ');
    un = new Array ('o', 'a', 'e','E', 's', 'l', 'z', 'z', 'c', 'n', 'O', 'A', 'S', 'L', 'Z', 'Z', 'C', 'N', '_');
    tmp = Array()
    for(i=0; i<str.length;i++){
        tmp[i] = str.charAt(i)
        for(j=0; j < pl.length;j++){
            if(str.charAt(i)==pl[j])
                tmp[i] = un[j]
        }
    }
    return tmp.join().replace(/([^A-z0-9._-])/g, '')
}

function pokazYoutube(w,h){
    jQuery("a[href^=http://www.youtube.com/watch]").each(function(i){
        elem = this.href;
        ref = elem.replace("http://www.youtube.com/watch?v=","");
        jQuery("a[href="+elem+"]").replaceWith('<object width="'+w+'" height="'+h+'"><param name="movie" value="http://www.youtube.com/v/'+ref+'&hl=pl&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+ref+'&hl=pl&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>');
    });
}

function inicjujGallery(kontener){
    jQuery('ul.galeria_list').galleria({
        history   : true, // activates the history object for bookmarking, back-button etc.
        clickNext : true, // helper for making the image clickable
        insert    : kontener, // the containing selector for our main image
        onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes

            // fade in the image & caption
            if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
                image.css('display','none').fadeIn(1000);
            }

            // fetch the thumbnail container
            var _li = thumb.parents('li');

            // fade out inactive thumbnail
            _li.siblings().children('img.selected').fadeTo(500,0.3);

            // fade in active thumbnail
            thumb.fadeTo('fast',1).addClass('selected');

            // add a title for the clickable image
            image.attr('title','Następny obraz >>');
            var baner = jQuery(kontener);
            baner.css('text-align', 'center');
            var r = image.width()/image.height();
            if(image.width()>image.height()){
                var nw = 500;
                var nh = nw/r;
                if(nh>300){
                    nh=300;
                    nw = r*nh;
                }
                image.width(nw);
                image.height(nh);
            }else{
                nh = 300;
                nw = r*nh;
                if(nw>500){
                    nw=500;
                    nh = nw/r;
                }
                image.width(nw);
                image.height(nh);
            }
        },
        onThumb : function(thumb) { // thumbnail effects goes here

            // fetch the thumbnail container

            var _li = thumb.parents('li');
            var oh = thumb.height();
            var ow = thumb.width();
            var ratio = ow/oh;
            //if(thumb.width()>_li.width()){
            if(thumb.width()>thumb.height()){
                thumb.width(45);
                var nh = 45.0/ratio;
                thumb.height(nh)
            }else{
                thumb.height(45);
                var nw = ratio*45;
                thumb.width(nw);
            }
            // if thumbnail is active, fade all the way.
            var _fadeTo = _li.is('.active') ? '1' : '0.3';

            // fade in the thumbnail when finnished loading
            thumb.css({
                display:'none',
                opacity:_fadeTo
            }).fadeIn(1500);

            // hover effects
            thumb.hover(
                function() {
                    thumb.fadeTo('fast',1);
                },
                function() {
                    _li.not('.active').children('img').fadeTo('fast',0.3);
                } // don't fade out if the parent is active
                )
        }
    });

    jQuery('ul.galeria_list').css('display','inline');
}

function insertFlash(con_id,file,w,h) {
    var width = w
    var height = h
    var src = 'flash/'+file
    var queries = '';

    var l1 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">';
    var l2 = '<param name="movie" value="'+src+queries+'" />';
    var l3 = '<param name="quality" value="high" />';
    var l4 = '<param name="wmode" value="transparent" />';
    var l5 = '<embed src="'+src+queries+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>';
    var l6 = '</object>'
    $("#"+con_id).html(l1+l2+l3+l4+l5+l6);
}

function insertMap(plotno){
    var p = jQuery(plotno);
    var map = new google.maps.Map2(document.getElementById("plotno_mapy"));
    map.addControl(new GSmallMapControl());
    map.addControl(new GMapTypeControl());
    var center = new google.maps.LatLng(50.813661,19.110599);
    map.setCenter(center, 15);

    var marker = new GMarker(center, {draggable: false});
    map.addOverlay(marker);
}

function szablon(){
}

function rozwin(a){
	var li = jQuery(a).parent('li');
        var children = li.children('ul');
        for(var i=0; i<children.length;i++){
            var cl = children[i].className;
            var o = jQuery(children[i]);
            if(o.hasClass('podlista_rozwinieta')){
                o.removeClass('podlista_rozwinieta');
                o.hide('slow');
            }else{
                o.addClass('podlista_rozwinieta');
                o.show('slow');
            }
        }
	//li.children('ul').show('slow');
}

