function e4_stop_event(e)
{
   if(!e)
	var e=window.event;

	e.cancelBubble=true;
	if(e.stopPropagation)
		e.stopPropagation();
}

function zliczaj(nr_l, nr_t, maxlen) {

	var tekst = document.getElementById(nr_t).value; // cały text z pola textarea
	var dl_tresc = document.getElementById(nr_t).value.length; // długoś tekstu z textarea
	/*var maxlen = 1000; // maxymalna dozwolona długość */
	var prawdziwa = 0; // licznik znaków
	var entery = 0;

	for (i=0; i<dl_tresc; i++) 
	{
		if (tekst.charAt(i) == "\n") 
		{
			prawdziwa++;
			entery++;
			if (navigator.appName != "Netscape") i++;
		}
		prawdziwa++;
	} // koniec for i

	document.getElementById(nr_l).innerHTML= maxlen - prawdziwa; // wyświetl komunikat o licznie znaków

	if (prawdziwa>maxlen) 
	{
		if (navigator.appName != "Netscape")
		document.getElementById(nr_t).value= document.getElementById(nr_t).value.substring(0,maxlen);
		else
		document.getElementById(nr_t).value = document.getElementById(nr_t).value.substring(0,maxlen-entery);

		document.getElementById(nr_l).value= 1000 - maxlen;
		alert("Maksymalna długość to " + maxlen +" znaków!");
	}
}
function hidden(id)
{
	if (document.getElementById(id))
		document.getElementById(id).style.display='none';
}
function show(id)
{
	if (document.getElementById(id))
		document.getElementById(id).style.display='block';
}
function show2(id)
{
	if (document.getElementById(id))
		document.getElementById(id).style.display='block';
}
function load_page(event,href,lang)
{
	$j('#e4www_view').html('<div style=\'position: relative;border: 1px solid #4F4E4A;width: 800px;padding: 10px;margin: 100px auto 0;\' onclick=\'e4www_view_stop_event(event);\'><a style="position: absolute;right: 20px;top: 30px;/top: 20px;" href="#" onclick=\'e4www_view_close(event);return false;\'><img src="/gfx/lightbox/closelabel'+lang+'.gif" alt="close" /></a><div id=\'page_content\' style="min-height: 100px;background: #fff;"><img style="margin: 30px 0 0 0" src=\'/gfx/loader_green.gif\' alt=\'Loading...\' /></div></div>');
	e4www_view(event,'e4www_view');
	$j('#page_content').load(href);

}



var NS = (navigator.appName=="Netscape" || navigator.appName=="Opera")?true:false;

function change(id)
{
	if (document.getElementById(id))
	{
		if(document.getElementById(id).style.display=='block') 
			document.getElementById(id).style.display='none'; 
		else document.getElementById(id).style.display='block';
	}
	return false;
}
function changex(id)
{
	if (document.getElementById(id))
	{
		if(document.getElementById(id).style.display=='block') 
			document.getElementById(id).style.display='none'; 
		else document.getElementById(id).style.display='block';
		
		return false;
	}
	return true;
}


function change_in(id)
{
	if(document.getElementById(id).style.display=='inline') 
		document.getElementById(id).style.display='none'; 
	else document.getElementById(id).style.display='inline';
	
	return false;
}

function change_row(id)
{


if (!NS) 
		if(document.getElementById(id).style.display=='block')
			document.getElementById(id).style.display='none'; 
		else document.getElementById(id).style.display='block';
	else
		if(document.getElementById(id).style.display=='table-row') 
			document.getElementById(id).style.display='none'; 
		else document.getElementById(id).style.display='table-row';
		
/*
return false;
*/
}




function adstext()
{
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",		
		plugins : "bbcode",
		editor_selector : "adsadd",
		/*fontsizeselect,*/
		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,forecolor,removeformat,cleanup,code",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		theme_advanced_resize_horizontal : false,
		remove_linebreaks : false,
		/*font_size_classes : "fontSize1,fontSize2,fontSize3,fontSize4,fontSize5,fontSize6,fontSize7",*/
		theme_advanced_font_sizes : "10px,11px,12px,13px,14px,18px,24px,30px,36px,48px",
		font_size_style_values : "10px,11px,12px,13px,14px,18px,24px,30px,36px,48px",

		width : "600",
		height : "200",
		// Example content CSS (should be your site CSS)
		content_css : "/css/style_bb.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
}

function drukuj(){
	if (!window.print){
		alert("Twoja przeglądarka nie drukuje!");
		return 0;
	}
	window.print(); 
	return false;
}



function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  /*var regex = /(^[ęĘąĄśŚłŁżŻźŹćĆńŃa-zA-Z0-9_.]*)/;*/
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else if (clearString[x] == '/')
	  {
		output += '&99999;';
	  }
      else if (clearString[x] == '/' || clearString[x] == '<' || clearString[x] == '\\')
        output += ' ';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  output=output.replace("%2F", "&99999;");
  output=output.replace("%2F", "&99999;");
  output=output.replace("%2F", "&99999;");
  output=output.replace("%2F", "&99999;");
  return output;
}

