function get_view_name(){
	var indexA = location.pathname.indexOf("admin")+6;
	var indexB = location.pathname.indexOf("/", indexA)
	var view = location.pathname.substring(indexA, indexB);	
	return view;
}

function get_home_url(){
	return jQuery("base").attr("href");
}

function get_url_to_ajax(){
	return get_home_url()+"ajax/";
}

String.prototype.trim = function() { 
        a = this.replace(/^\s+/, ''); 
        return a.replace(/\s+$/, '');
    };	

String.prototype.polskie_znaki = function(){
		
	var string = this;
	var re;
	var polskie = new Array(" ","-",",","ł","Ł","ó","Ó","ń","Ń","ę","Ę","ć","Ć","ś","Ś","ź","Ź","ż","Ż","Ą","ą");
	var podmiana = new Array("_","_","_","l","L","o","O","n","N","e","E","c","C","s","S","z","Z","z","Z","A","a");	
	for(var i=0;i<polskie.length;i++){
		re = new RegExp(polskie[i], "g"); 
		string = string.replace(re,podmiana[i]);
	}	
		
	return string;
}

function reklama_klik(adres, id){
	
	$.post("modules/ajax/reklama.html", {
		id: id,
		adres: adres,
		reklama: "ok"
	}, function(data){
		
		location.href = adres;
		
	});	
	
}

$(document).ready(function(){

	$(function() {
		$('a[@rel*=lightbox]').lightBox(); 
		$('a.lightbox').lightBox(); 
	});

	for (i=0; i<document.links.length;) {
		document.links[i].onfocus=document.links[i++].blur;
	}
	
	
	var max_pasek = 0;
	$(".info_text").each(function() {
		max_pasek += 1;
	});
		
	function top_news_slider(numer) {

		var nowy = (numer == max_pasek) ? 1 : numer+1;
		//alert("nr "+numer+" / nowy: "+nowy);
		
		$("#info_"+numer).fadeOut(500);
		setTimeout(function() {
			$("#info_"+nowy).fadeIn(500);
		},500);
	
	}

	
	/* przewijarka top news */
	var wybrany = 0;
	setInterval(function() {
		
		if(wybrany == max_pasek) {
			wybrany = 1;
			top_news_slider(wybrany);
		} else {
			wybrany += 1;
			top_news_slider(wybrany);
		}
		
	},5000);
	
	
	$(function() {
        $('.zoom').lightBox();
    });
	

});


function expand(url, w, h)
{
  open(url, "stdpic", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+w+",height="+h);
}   

