
//sprawdza czy na danej stronie pojawia sie iframe, jesli tak to wysyla o tym informacje do wlasnieciela strony
function CheckIframe() {
	if ($("iframe").length>0 && readCookie("ajax_notify")=="") {
		createCookie("ajax_notify","posted",7);
		$.ajax({
			type: "GET",
			url: "index.php?a=read.notify"
		});
	}
}

function mapBaseActions() {
	//zamienia tinyMCE'owy popup na lightboxa
	$("div.text a").each(function() {
		var link = $(this);
		var new_href = "";
						//za ?url=
		var ile_dodac = 5;
		
		var search_str = "popup.php";
		
		if (link.attr('href')=='javascript:void(0)') {
			var onclick = new String(link.attr('onclick'));
			
			new_href = onclick.substring(onclick.indexOf(search_str)+ile_dodac+search_str.length,onclick.indexOf("&clTxt"));
			
			$(this).attr('href',new_href);
			$(this).attr('onclick',"void(0)");
			$(this).attr('title',"");
			$(this).addClass("lightbox2");
		}
	});
	
	$("a.newwindow").attr("target","_blank");
	$('a.lightbox').lightBox();
	$('a.lightbox2').lightBox();
	$('#history_back').click(function() {
		history.back();
	});
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function getTime4Form() {
	var thisdate=new Date();
	var returned=new String();

	if (thisdate.getHours()>9)
	{
		returned=thisdate.getHours();
	}
	else {
		returned="0"+thisdate.getHours();
	}

	returned+=":";

	if (thisdate.getMinutes()>9)
	{
		returned+=thisdate.getMinutes();
	}
	else {
		returned+="0"+thisdate.getMinutes();
	}

	return returned;
}

function addFavourite(url, title) {
	if (window.sidebar) {
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite(url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function setNumOnly(instr) {
	var str = new String(instr);
	str = str.replace(/ /g, "");
	str = str.replace(/-/g, "");
	str = str.replace(/[a-z]/ig, "");
	return str;
}

function TooltipBodyHandler(instr) {
	var str = new String(instr);
	str = str.replace(/headopen/g,"<h3>");
	str = str.replace(/headclose/g,"</h3>");
	str = str.replace(/breakline/g, "<br/>");
	str = str.replace(/headline/g, "<hr/>");
	return str;
}