function setAnchors(){
			var acol = document.getElementsByTagName('a');
			var base = document.getElementsByTagName('base')[0].href;
			var href = new String(window.location.href).replace(/#.*$/, '');
			for(var i=0;i<acol.length;i++){
				var target = new String(acol[i].href);
				if(target.indexOf('#') > -1){
					if(target.split('#')[0] == base)
						acol[i].href = target.replace(base, href);
			}
	}
};

var lastImg = null;

function imgSwap(ev,imgName) {
	if (imgName != 0) {
		lastImg = ev.src;
		ev.src = imgName;
	}	
	else
	{
		ev.src = lastImg;
	}
}
function checkFields(newForm) {
	if (newForm.title.value == '') {
		alert('Brak tytu??u');
		return ;
	} else if (newForm.body.value == '') {
		alert('Brak tre??ci');
		return ;
	}
	newForm.submit();
}


function fullsize(pI,title,desc) {
	if(document.all){picId = "/_uTils/site/gallery.html?" + pI + "&title=" + encodeURIComponent(escape(title)) + "&desc=" + encodeURIComponent(escape(desc));}
	else{picId = "/_uTils/site/gallery.html?" + pI + "&title=" + escape(title) + "&desc=" + escape(desc);}
	//picId = encodeURI(picId);
	Win = window.open(picId,'DispalyWindow','width=300, height=300, resizable=yes, scrollbars=auto menubar=no, location=no, left=0, top=0');
	return;
}
function isN(v,f,n) {
	if(v.length>0)if((v!=~~v)||(v<=0)){alert('Wymagana jest liczba całkowita dodatnia.');o=eval('document.'+f+"."+n);o.value="";}
}
function openInNewWindow(href){
	return window.open(href, null, 'left=0, top=0, resizable=yes');
}

function openWindow(url,top,left,width,height) {
	var p = "";
	if (top>-1) p=",top="+top;
	if (left>-1) p=p+",left="+left;
	if (width>-1) p=p+",width="+width;
	if (height>-1) p=p+",height="+height;
	window.open(url,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=yes'+p);
}

function openPrint(url,top,left,width,height) {
	var p = "";
	if (top>-1) p=",top="+top;
	if (left>-1) p=p+",left="+left;
	if (width>-1) p=p+",width="+width;
	if (height>-1) p=p+",height="+height;
	window.open(url,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes'+p);
}

function openNewWindow(url,top,left,width,height) {
	var p = "";
	if (top>-1) p=",top="+top;
	if (left>-1) p=p+",left="+left;
	if (width>-1) p=p+",width="+width;
	if (height>-1) p=p+",height="+height;
	window.open(url,'','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=yes'+p);
}

function getLang() {
	if (typeof siteLang == "string") {
		switch (siteLang) {
			case "en":	return 0; break;
			case "pl":	return 1; break;
			case "de":	return 2; break;
			case "es":	return 3; break;
			case "se":	return 4; break;
		}
	} else {
		return 1; /*"en"*/
	}
}

function externalLinks() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") ==
				"external") {
			anchor.target = "_blank";
		}
	}
}
window.onload = externalLinks;


/* Wyniki wyszukiwania */
function swapPage(offset) {
	document.forms['searchNav'].elements['offset'].value = offset;
	document.forms['searchNav'].submit();
}

var aHash = {};

function changeTo ( toShow, toHides) {
	var toHide = toHides.split("|");
	for (var loop = 0; loop < toHide.length; loop ++) {
		if(toHide[loop]) {
			hide(toHide[loop]);
		}
	}			
	document.getElementById(toShow).style.display = 'block';
}

function changeTo2 ( toShow, toHides) {
	var toHide = toHides.split("|");
	for (var loop = 0; loop < toHide.length; loop ++) {
		if(toHide[loop]) {
			hide2(toHide[loop]);
		}
	}			
	document.getElementById(toShow).style.fontWeight = 'bold';
}

function hide(id) { document.getElementById(id).style.display = 'none'; }	

function hide2(id) { document.getElementById(id).style.fontWeight = 'normal'; }

function fields_default(field, fvalue) {
	if (field.value == fvalue) {
		field.value = "";
	}
	else if (field.value == "") {
		field.value = fvalue;
	}
}

function showTabs(full_url) {
	var i = 0;
//	var full_url = location.href;
	if(full_url.indexOf('?')!=-1){
		var parameters_string = full_url.split("?");
		var parameters = parameters_string[1].split("&");
		var parameters_length = parameters.length;
		var temp = 'false';
		
		for (i=0;i<parameters_length;i++) {
			var parameter = (parameters[i].split("="))[0];
			if (parameter == "refresh")
				var temp = 'true';
		}
	
		if (temp == 'true') {
			var string = parameters_string[0] + "?";
			for (i=0;i<parameters_length;i++) {
				var parameter = (parameters[i].split("="))[0];
				if (parameter != 'refresh' && parameter != 'x' && parameter != 'y') {
					if (i > 0)
						string = string + '&';
					string = string + parameters[i];
				}
			}
			document.location.href = string;
		}
		
		if (location.hash.length > 0) {
			var hash = (location.hash.split("#"))[1];
			/* tablica divow do odkrycia */
			var divs_id = hash.split(",");
			var div_id_count = divs_id.length;
			/* odkrywamy tylko te co ida w urlu */
			for (i=0;i<div_id_count;i++) {
				var divToShow = 'parent' + (divs_id[i].split("."))[0] + 'id' + (divs_id[i].split("."))[1];
				if (document.getElementById(divToShow))
					document.getElementById(divToShow).style.display = "block";
			}
		}
	}
}

function check(first) {
	var parents = new Array;
	var i = 0;
	if (location.hash.length > 0) {
		if (first.length > 0) {
			if(document.getElementById(first)) {
				document.getElementById(first).style.display = "none";	
			}
		}
		var hash = (location.hash.split("#"))[1];
		var divs_id = hash.split(",");
		var div_id_count = divs_id.length;
		for (i=0;i<div_id_count;i++)
			parents[i] = ((divs_id[i].split("."))[0]);
		if (first.length > 0)
			var parent = (first.split("id")[0]).split("parent")[1];
		var test = 'false';
		for (i=0;i<div_id_count;i++)
			if (parent == parents[i])
				test = 'true';
		if (test == 'false'){
			if(document.getElementById(first)){
				document.getElementById(first).style.display = "block";
			}
		}	
	}
	else {
		if (first.length > 0) {
			if(document.getElementById(first)){
				document.getElementById(first).style.display = "block";
			}
		return false;
		}
	}
}

function setTimeRefresh(layout, page) {
	if(page=='0' && (layout=='0'|| layout=='fx_0')){
		timeoutPeriod = 180;
		setTimeout("location.reload(true);",timeoutPeriod*1000);
	}	
}

/* funkcja laczy url z nowym hashem */
function connect(parent,id,full_url) {
	var url = (full_url.split("#"))[0];
	var ids = new Array;
	var uri = "/index.jsp?";
	var parents = new Array;
	var params='';
	var temps = '';
	var i = 0;
	if (location.hash != '') {
		var hash = (location.hash.split("#"))[1];
		var divs_id = hash.split(",");
		var div_id_count = divs_id.length;
		for (i=0;i<div_id_count;i++) {
			ids[i] = (divs_id[i].split("."))[1];
			parents[i] = (divs_id[i].split("."))[0];
		}
		for (i=0;i<div_id_count;i++) 
			if (parents[i] == parent) {
				ids[i] = id;
				parents[i] = parent;
				for (i=0;i<div_id_count;i++) {
					if (i>0)
						params = params + ',';
					params = params + parents[i]+'.'+ids[i];
				}
				return url+'#'+params+'#';
			}
		return url+'#'+hash+','+parent+'.'+id+'#';  
	}
	else {
		var parameters = (full_url.split("?")[1]).split("&");
		var parameters_count = parameters.length;
		var temp = 0;
		for (i=0;i<parameters_count;i++) {
			parents[i] = ((parameters[i].split("="))[0]);
			ids[i] = ((parameters[i].split("="))[1]);
			var temporary = "parent"+parent;
			if (parents[i] != temporary && parents[i] != 'refresh') {
				if (temp != 0)
					uri = uri + "&";
				uri = uri + parameters[i];
			}
			else {
				if (parent != parents[i].split("parent")[1])
					temps = temps + "," + parents[i].split("parent")[1] + "." + ids[i];						
			}
			temp = temp + 1;
		}
		return uri + '#' + parent + '.' + id +temps+'#';
	}
}	

function changePage(select) {
	var url = select.options[select.selectedIndex].value;
	if (url != 0)
		document.location.href = url;
	select.options[select.selectedIndex].selected='true';
	return false;
}

function validateCsf(form, comm) {
	var res = false
		for (i=0;i<form.corporationId.options.length;i++) {
			if (form.corporationId.options[i].selected) res =true;			
		}
	if (res) {
		return true;
	}else {
		alert(comm+' !!!');
		return false;
	}

} 

function checkSelected(select) {
	var j= 0;
	for (i=0;i<select.options.length;i++) {
		if (select.options[i].selected) j=j+1;							
		if (j>6) select.options[i].selected=false;			
	}
	if (j>=6) {
		if (j>6) alert ('Można wybrać tylko sześć spółek !'); 
		for (i=0;i<select.options.length;i++) if (!select.options[i].selected) select.options[i].disabled='disabled';			
	}else for (i=0;i<select.options.length;i++) if (!select.options[i].selected) select.options[i].disabled=false;
}

function setSectorIdUrl(id) {
	var i = 0;
	var full_url = location.href;
	if(full_url.indexOf()==-1){
	
	var parameters_string = full_url.split("?");
	var parameters = parameters_string[1].split("&");
	var parameters_length = parameters.length;
	var temp = 'false';
	for (i=0;i<parameters_length;i++) {
		var parameter = (parameters[i].split("="))[0];
		if (parameter == "sectorId")
			var temp = 'true';
	}
	if (temp == 'true') {
		var string = parameters_string[0] + "?";
		for (i=0;i<parameters_length;i++) {
			var parameter = (parameters[i].split("="))[0];
			if (parameter != 'sectorId') {
				if (i > 0)
					string = string + '&';
				string = string + parameters[i];
			}
		}
		window.location.href = string+'&sectorId='+id;
	}else window.location.href = location.href+'&sectorId='+id;
	}
}

var gpwToFullName = [];

function showPopup(url,width,height,page){
	var szerokosc = width;
	var wysokosc = height;
	if (page == 6) {
		var szerokosc = width+30;
		var wysokosc = height+45;
	}
	if (page == 4) {
		var szerokosc = width-100;
		var wysokosc = height+310;
	}
	if (page == 1) {
		var szerokosc = width+60;
		var wysokosc = height+60;
	}
	if (page == 2) {
		var szerokosc = width+500;
		var wysokosc = height+380;
	}
	if (page == 3) {
		var szerokosc = width-150;
		var wysokosc = height-180;
	}
	if (page == 8) {
		var szerokosc = width+700;
		var wysokosc = height+500;
	}
	if (page == 9) {
		var szerokosc = width+450;
		var wysokosc = height+500;
	}
	if (page == 4 || page == 8 || page == 9)
		window.open(url,'','resizable=yes,width='+szerokosc+',height='+wysokosc+',scrollbars=yes,left=5,top=0').focus();
	else
		window.open(url,'','resizable=yes,width='+szerokosc+',height='+wysokosc+',left=5,top=0').focus();
}
function $(id){
	return document.getElementById(id);
}
function getTimeRefresh () {
		var sel = document.refreshpage.refresh;
		var time = sel.options[sel.selectedIndex].value;
		var sel = document.refreshpage.refresh;
		var time = sel.options[sel.selectedIndex].value;
		var komunikat = '<span id="hidden">Aktualizacja za: <span id="refresh_seconds">' + time + '</span> sek.</span>';
		document.getElementById("time_refresh").innerHTML=komunikat;
}

function SmallWindow() {
	window.open('popup.jsp?layout=commPopup&page=4&news_cat_id=88','newsl','scrollbars=yes,resizable=yes,width=700,height=600,left=1,top=1').focus();
}

function fxSmallWindow(newsCatId) {
	window.open('popup.jsp?layout=fx_commPopup&page=5&news_cat_id=' + newsCatId,'newsl','scrollbars=yes,resizable=yes,width=700,height=600,left=1,top=1').focus();
}

function changeSelectedCategories(papType,checkboxElem){
	var hiddenSelect=document.getElementById("selectCatsHiddenList");	
	var select=document.getElementById("selectCats");

	if(checkboxElem!=null){
		select.options.length = 1;	
		for (var i=1; i<hiddenSelect.options.length; i++){
			
			var optionElem=hiddenSelect.options[i];
			var optionId=optionElem.getAttribute("id");
			var optionValue=optionElem.value;
			var optionText=optionElem.text;

			if ((document.getElementById("checkboxPapFX").checked==true) && (optionId==5 || optionId==6 || optionId==9 || optionId==45)){

				var newOptionElement = document.createElement('option');
				newOptionElement.text = " "+optionText+" ";
				newOptionElement.value = optionValue;
				newOptionElement.setAttribute("id",optionId);

				try { 
					select.add(newOptionElement, null); // standards compliant; doesn't work in IE
				} catch(ex) { 
					select.add(newOptionElement); // IE only 
				}	

			} else if ((document.getElementById("checkboxPapPL").checked==true) && !(optionId==5 || optionId==6 || optionId==9 || optionId==45)) {

				var newOptionElement = document.createElement('option');
				newOptionElement.text = " "+optionText+" ";
				newOptionElement.value = optionValue;
				newOptionElement.setAttribute("id",optionId);

				try {
					select.add(newOptionElement, null); // standards compliant; doesn't work in IE
				} catch(ex) {
					select.add(newOptionElement); // IE only
				}
			}
		}	

	} 

	if(document.getElementById("checkboxPapPL").checked==true && document.getElementById("checkboxPapFX").checked==true){
		select.disabled=false;
		select.options[0].text="Wybierz";
		select.options[0].selected="1";
	} else if (document.getElementById("checkboxPapPL").checked==true){
		select.disabled=false;
		select.options[0].text="Giełda";
		select.options[0].selected="1";
	} else if (document.getElementById("checkboxPapFX").checked==true){
		select.disabled=false;
		select.options[0].text="Forex";
		select.options[0].selected="1";
	} else {
		select.disabled=true;
		select.options[0].text="";
		select.options[0].selected="1";
	}
}

function removeCatsOnEntryAdvanced(papType,checkboxElem){
	var hiddenSelect=document.getElementById("selectCatsHiddenList");	
	var select=document.getElementById("selectCats");

	if(checkboxElem!=null){

		for (var i=1; i<hiddenSelect.options.length; i++){
			
			var optionElem=hiddenSelect.options[i];
			var optionId=optionElem.getAttribute("id");
			var optionValue=optionElem.value;
			var optionText=optionElem.text;

			if ((papType=="fx") && (checkboxElem.checked==true) && (optionId==5 || optionId==6 || optionId==9 || optionId==45)){

				var newOptionElement = document.createElement('option');
				newOptionElement.text = " "+optionText+" ";
				newOptionElement.value = optionValue;
				newOptionElement.setAttribute("id",optionId);

				try { 
					select.add(newOptionElement, null); // standards compliant; doesn't work in IE
				} catch(ex) { 
					select.add(newOptionElement); // IE only 
				}	

			} else if ((papType=="pl") && (checkboxElem.checked==true) && !(optionId==5 || optionId==6 || optionId==9 || optionId==45)) {

				var newOptionElement = document.createElement('option');
				newOptionElement.text = " "+optionText+" ";
				newOptionElement.value = optionValue;
				newOptionElement.setAttribute("id",optionId);

				try {
					select.add(newOptionElement, null); // standards compliant; doesn't work in IE
				} catch(ex) {
					select.add(newOptionElement); // IE only
				}
			}
		}	

	} 

	if(document.getElementById("checkboxPapPL").checked==true && document.getElementById("checkboxPapFX").checked==true){
		select.disabled=false;
		select.options[0].text="Wybierz"
	} else if (document.getElementById("checkboxPapPL").checked==true){
		select.disabled=false;
		select.options[0].text="Giełda"		  
	} else if (document.getElementById("checkboxPapFX").checked==true){
		select.disabled=false;
		select.options[0].text="Forex"
	} else {
		select.disabled=true;
		select.options[0].text="";
	}

	var urlParams = window.location.href.split("?");
	var params = urlParams[1].split("&");
	var cat = -1;
	for(x=0; x<params.length; x++){
		p = params[x].split("=");
		if (p[0] == "categoryId") {
			cat =  p[1];
		}
	}
	if (cat != -1) {
		for (x=0; x<select.options.length; x++) {
			if(select.options[x].getAttribute("id") == cat) {
				select.options[x].selected="1";
			}
		}
	} else {
		select.options[0].selected="1";
	}
}

function removeCatsOnEntrySimple(papType,checkboxElem){
	var hiddenSelect=document.getElementById("selectCatsHiddenList");	
	var select=document.getElementById("selectCats");

	for (var i=1; i<hiddenSelect.options.length; i++){
			
		var optionElem=hiddenSelect.options[i];
		var optionId=optionElem.getAttribute("id");
		var optionValue=optionElem.value;
		var optionText=optionElem.text;

		if (((papType=="fx") && (optionId==5 || optionId==6 || optionId==9 || optionId==45)) || ((papType=="pl") && !(optionId==5 || optionId==6 || optionId==9 || optionId==45)) || (papType=="all")) {

			var newOptionElement = document.createElement('option');
			newOptionElement.text = " "+optionText+" ";
			newOptionElement.value = optionValue;
			newOptionElement.setAttribute("id",optionId);

			try { 
				select.add(newOptionElement, null); // standards compliant; doesn't work in IE
			} catch(ex) { 
				select.add(newOptionElement); // IE only 
			}	
		}
	}

	var urlParams = window.location.href.split("?");
	var params = urlParams[1].split("&");
	var cat = -1;
	for(x=0; x<params.length; x++){
		p = params[x].split("=");
		if (p[0] == "categoryId") {
			cat = p[1];
		}
	}
	if (cat != -1) {
		for (x=0; x<select.options.length; x++) {
			if(select.options[x].getAttribute("id") == cat) {
				select.options[x].selected="1";
			}
		}
	} else {
		select.options[0].selected="1";
	}
}

function fxHintWindow() {
window.open('popup.jsp?layout=hintPopup&page=1','newsl','scrollbars=yes,resizable=yes,width=700,height=600,left=1,top=1').focus();
}
function not_hid() {
   if(document.getElementById("submenu_not_hid").style.display == "block") {
   		document.getElementById("submenu_not_hid").style.display = "none";
   		document.getElementById("submenu_not_navi").innerHTML = '&#8595;';
   }
   else {
   		document.getElementById("submenu_not_hid").style.display = "block";
   		document.getElementById("submenu_not_navi").innerHTML = '&#8593;';
   }
}

function hiddenLegend(ff){
	document.getElementById('hiddenLegend' + ff).style.display = "none";
};

function blockLegend(ff){
	document.getElementById('hiddenLegend' + ff).style.display = "block";
};
   
	function insert(dstbox, option) {
		var options = dstbox.options;
		var inserted = false;
		for( var i = 0; i < options.length; i++ ) {
			if(options[i].text > option.text) {
				// tak dziwnie, zeby pod ie dzialalo
				var o = document.createElement("option");
				o.text = option.text;
				o.value =option.value;
				dstbox.insertBefore(o,options[i]);
				
				// tak dziwnie, zeby pod ie dzialalo
				options[i].text = option.text;
				options[i].value = option.value;
				
				inserted = true;
				break;
			}
		}
		if(!inserted){
			options[options.length] = option;
		}
	}

	function moveIt( src, dst, messageBox ) {
		var temp_opts = new Array(); 
		var box =  document.getElementById(messageBox);
		if(box) {
			box.style.display = "none";
		}
		var dstbox = document.getElementById(dst);
		var srcbox = document.getElementById(src);
		var j=0;
		var lastOption = null;
		for( var i = 0; i < srcbox.options.length; i++ ) { 
			if( srcbox.options[i].selected) { 
				var option = new Option(); 
				option.value = srcbox.options[i].value; 
				option.text = srcbox.options[i].text;
				srcbox.remove(i--);
				insert(dstbox,option);
			} 
		}
	}
			
	function send(formid, src, maxQuantity, message) {
		var srcbox = document.getElementById(src);
		if(srcbox.options.length > maxQuantity) {
			alert(message);
			return;
		}
		var form = document.getElementById(formid);
		if(srcbox.options.length > 0) {
			var values = new Array();
			for( var i = 0; i < srcbox.options.length; i++ ) {
				values[i] = srcbox.options[i].value;
			}
			form.codes.value = values.join(':');
		} else {
			form.codes.value = '';
		}
		form.submit();
	}

	function checkOneDate(data) {
		if(!data.length){
			return true;
		}
		var dayfield=data.split(".")[2];
		var monthfield=data.split(".")[1];		
		var yearfield=data.split(".")[0];
		var dayobj = new Date(yearfield, monthfield-1, dayfield);
		var validformat=/^\d{4}\.\d{2}\.\d{2}$/ ;//Basic check for format validity
		if(yearfield<1200 || yearfield>2900 )
			return 0;//Rok powinien mieścić się w przedziale <1200;2900>
		if(!validformat.test(data)) {
			return -1;//Niepoprawny format daty
		}else if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)) {
			return -2;//Niepoprawny Dzień, Miesiąc, lub Rok 
		}else{
			return 1;
		}		
	}

	function compareDate(from, to){
		var dayfield1=from.split(".")[2];
		var monthfield1=from.split(".")[1];		
		var yearfield1=from.split(".")[0];
		var fromObj = new Date(yearfield1, monthfield1-1, dayfield1);
		
		var dayfield2=to.split(".")[2];
		var monthfield2=to.split(".")[1];		
		var yearfield2=to.split(".")[0];
		var toObj = new Date(yearfield2, monthfield2-1, dayfield2);
		if(fromObj>toObj){
			return 1;
		}else if (fromObj==toObj){
			return 0;
		}else if (fromObj < toObj ){
			return -1;
		}
	}
	
	function checkDate(form, message) {	
		var data = form.data.value;
		var result = checkOneDate(data);
		if(result==0) {
			alert("Niepoprawny format daty. Rok powinien mieścić się w przedziale od 1200 do 2900");
			return false;
		}else if ( result==-1 ){
			alert("Niepoprawny format daty. Proszę wprowadzić poprawny format daty: rrrr.mm.dd.");
			return false;
		}else if (result==-2) {
			alert("Niepoprawny Dzień, Miesiąc, lub Rok. Proszę wprowadzić poprawną datę");
			return false;
		}else{
			return true;
		}
	}
	
	function checkDateFX(form, message) {	
		var data = form.dataFx.value;
		var result = checkOneDate(data);
		if(result==0) {
			alert("Niepoprawny format daty. Rok powinien mieścić się w przedziale od 1200 do 2900");
			return false;
		}else if ( result==-1 ){
			alert("Niepoprawny format daty. Proszę wprowadzić poprawny format daty: rrrr.mm.dd.");
			return false;
		}else if (result==-2) {
			alert("Niepoprawny Dzień, Miesiąc, lub Rok. Proszę wprowadzić poprawną datę");
			return false;
		}else{
			return true;
		}
	}	
		
	function checkTwoDate(form, message) {
		var data1 = form.start_date;
		var data2 = form.end_date;
		return checkDates(data1,data2)
		}

	function checkDates(data1,data2){
		if(data1){
			var result1 = checkOneDate(data1.value);
			if(result1==0) {
				alert("Rok powinien mieścić się w przedziale od 1200 do 2900");
				return false;
			}else if ( result1==-1 ){
				alert("Niepoprawny format daty. Proszę wprowadzić poprawny format daty: rrrr.mm.dd.");
				return false;
			}else if (result1==-2) {
				alert("Niepoprawny Dzień, Miesiąc, lub Rok. Proszę wprowadzić poprawną datę");
				return false;
			}
		}
		if(data2){
			var result2 = checkOneDate(data2.value);
			if(result2==0) {
				alert("Niepoprawny format daty. Rok powinien mieścić się w przedziale od 1200 do 2900");
				return false;
			}else if ( result2==-1 ){
				alert("Niepoprawny format daty. Proszę wprowadzić poprawny format daty: rrrr.mm.dd.");
				return false;
			}else if (result2==-2) {
				alert("Niepoprawny Dzień, Miesiąc, lub Rok. Proszę wprowadzić poprawną datę");
				return false;
			}else{
				if(compareDate(data1.value,data2.value)>0){
					alert("Data od nie może być większa niż data do.");
					return false;
				}else{
					return true;
				}
			}
		} else {
			return true;
		}
	}	
	
	function checkTwoDateCalendarium(form, message) {
		var data1 = form.dateFrom;
		var data2 = form.dateTo;
		return checkDates(data1,data2)
	}

	function resizeHeight() {
		//alert("resizeHeight()");
	if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){

		if (document.getElementById("ISPAGApplet")) {
			d=document;
   			 if (typeof window.innerHeight!='undefined') {
    		    var winHeight = window.innerHeight;
  			  } else {
    			    if (d.documentElement && typeof d.documentElement.clientHeight!='undefined' && d.documentElement.clientHeight!=0) {
     			       var winHeight = d.documentElement.clientHeight
     			   	} else {
     			       if (d.body && typeof d.body.clientHeight!='undefined') {
       			         var winHeight = d.body.clientHeight
            			}
       		 		}
   			 }
			 
			 if (typeof window.innerWidth!='undefined') {
    		    var winWidth = window.innerWidth;
  			  } else {
    			    if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
     			       var winWidth = d.documentElement.clientWidth
     			   	} else {
     			       if (d.body && typeof d.body.clientWidth!='undefined') {
       			         var winWidth = d.body.clientWidth
            			}
       		 		}
   			 }
			 
        	if (winHeight < 600) {
           		var wys = winHeight - 15;
           		//setTimeout("document.getElementById('ISPAGApplet').style.height = '600px'",1000);
          	 //	setTimeout("document.getElementById('ISPAGApplet').style.height = (winHeight - 15)+'px'",1000);
          	 	setTimeout("document.getElementById('ISPAGApplet').style.height = (appletHeight()-15)+'px'",1000);
			}else {
				
				setTimeout("document.getElementById('ISPAGApplet').style.height = '600px'",1000);
			}
			
			if (winWidth < 960) {
				var szer = winWidth -15;
          	 	
				//setTimeout("document.getElementById('ISPAGApplet').style.width = szer +'px'",1000);
				setTimeout("document.getElementById('ISPAGApplet').style.width = (appletWidth() - 15)+'px'",1000);
				}else {
				
				setTimeout("document.getElementById('ISPAGApplet').style.width = '100%'",1000);
			}
    	}
	}else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
	
		if (document.getElementById("ISPAGApplet")) {
			d=document;
   			 if (typeof window.innerHeight!='undefined') {
    		    var winHeight = window.innerHeight;
  			  } else {
    			    if (d.documentElement && typeof d.documentElement.clientHeight!='undefined' && d.documentElement.clientHeight!=0) {
     			       var winHeight = d.documentElement.clientHeight
     			   	} else {
     			       if (d.body && typeof d.body.clientHeight!='undefined') {
       			         var winHeight = d.body.clientHeight
            			}
       		 		}
   			 }
			 
			 if (typeof window.innerWidth!='undefined') {
    		    var winWidth = window.innerWidth;
  			  } else {
    			    if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
     			       var winWidth = d.documentElement.clientWidth
     			   	} else {
     			       if (d.body && typeof d.body.clientWidth!='undefined') {
       			         var winWidth = d.body.clientWidth
            			}
       		 		}
   			 }
			 
        	if (winHeight < 600) {
           		var wys = winHeight - 15;
           		//setTimeout("document.getElementById('ISPAGApplet').style.height = '600px'",1000);
          	 //	setTimeout("document.getElementById('ISPAGApplet').style.height = (winHeight - 15)+'px'",1000);
          	 	setTimeout("document.getElementById('ISPAGApplet').style.height = (appletHeight()-15)+'px'",1000);
			}else {
				
				setTimeout("document.getElementById('ISPAGApplet').style.height = '600px'",1000);
			}
			
			if (winWidth < 960) {
				var szer = winWidth -15;
          	 	
				//setTimeout("document.getElementById('ISPAGApplet').style.width = szer +'px'",1000);
				setTimeout("document.getElementById('ISPAGApplet').style.width = (appletWidth() - 15)+'px'",1000);
				}else {
				
				setTimeout("document.getElementById('ISPAGApplet').style.width = '100%'",1000);
			}
    	}
	}else{

		if (document.getElementById("ISPAGApplet")) {
			d=document;
   			 if (typeof window.innerHeight!='undefined') {
    		    var winHeight = window.innerHeight;
  			  } else {
    			    if (d.documentElement && typeof d.documentElement.clientHeight!='undefined' && d.documentElement.clientHeight!=0) {
     			       var winHeight = d.documentElement.clientHeight
     			   	} else {
     			       if (d.body && typeof d.body.clientHeight!='undefined') {
       			         var winHeight = d.body.clientHeight
            			}
       		 		}
   			 }
			 
			 if (typeof window.innerWidth!='undefined') {
    		    var winWidth = window.innerWidth;
  			  } else {
    			    if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
     			       var winWidth = d.documentElement.clientWidth
     			   	} else {
     			       if (d.body && typeof d.body.clientWidth!='undefined') {
       			         var winWidth = d.body.clientWidth
            			}
       		 		}
   			 }
			 
        	if (winHeight < 600) {
           		var wys = winHeight - 15;
          	 	document.getElementById("ISPAGApplet").style.height = wys+'px';
			}else {
				document.getElementById("ISPAGApplet").style.height = "600px";
			}
			
			if (winWidth < 960) {
				var szer = winWidth -15;
          	 	document.getElementById("ISPAGApplet").style.width = szer +'px';
				}else {
				document.getElementById("ISPAGApplet").style.width = "100%";
			}
			
    	}
    	
    	
    	}
	}	

	function resizePopupHeight() {
		//alert("resizePopupHeight()");
		
		if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);

				if (document.getElementById("ISPAGApplet")) {
			d=document;
			//d.location.reload(true);
			//alert("yes");

		var winHeight = appletHeight();
		var winWidth = appletWidth();

		
	     if (winHeight < 600) {
             var wys = winHeight - 15;
             //setTimeout("document.getElementById('ISPAGApplet').style.height = wys+'px'",1000);
             setTimeout("document.getElementById('ISPAGApplet').style.height = (appletHeight()-15)+'px'",1000);
             }else {
			var wys = winHeight - 15;
            		///setTimeout("document.getElementById('ISPAGApplet').style.height = wys +'px'",1000);
			setTimeout("document.getElementById('ISPAGApplet').style.height = (appletHeight()-15)+'px'",1000);
			
             }
             if (winWidth < 960) {
		         var szer = winWidth -15;
		         
		         setTimeout("document.getElementById('ISPAGApplet').style.width = (appletWidth() - 15)+'px'",1000);
         		//setTimeout("document.getElementById('ISPAGApplet').style.width = szer +'px'",1000);
		        
             }else {
            		 setTimeout("document.getElementById('ISPAGApplet').style.width = '100%'",1000);
		        }
                
                
                }			
		} else if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);

		if (document.getElementById("ISPAGApplet")) {
			d=document;
		
		var winHeight = appletHeight();
		var winWidth = appletWidth();
		
		
		 if (winHeight < 600) {
		     var wys = winHeight - 15;
		     //setTimeout("document.getElementById('ISPAGApplet').style.height = wys+'px'",1000);
		     setTimeout("document.getElementById('ISPAGApplet').style.height = (appletHeight()-15)+'px'",1000);
		     }else {
			var wys = winHeight - 15;
		    		///setTimeout("document.getElementById('ISPAGApplet').style.height = wys +'px'",1000);
			setTimeout("document.getElementById('ISPAGApplet').style.height = (appletHeight()-15)+'px'",1000);
			
		     }
		     if (winWidth < 960) {
		         var szer = winWidth -15;
		         
		         setTimeout("document.getElementById('ISPAGApplet').style.width = (appletWidth() - 15)+'px'",1000);
		 		//setTimeout("document.getElementById('ISPAGApplet').style.width = szer +'px'",1000);
		        
		     }else {
		    		 setTimeout("document.getElementById('ISPAGApplet').style.width = '100%'",1000);
		        }
		        
		        
		        }			
		}else
			{
	
				if (document.getElementById("ISPAGApplet")) {
				
					d=document;
					if (typeof window.innerHeight!='undefined') {
					var winHeight = window.innerHeight;
					} else {
					if (d.documentElement && typeof d.documentElement.clientHeight!='undefined' && d.documentElement.clientHeight!=0) {
					var winHeight = d.documentElement.clientHeight
					} else {
						if (d.body && typeof d.body.clientHeight!='undefined') {
						var winHeight = d.body.clientHeight
						}
					}
				}
				if (typeof window.innerWidth!='undefined') {
				var winWidth = window.innerWidth;
				} else {
					if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
					var winWidth = d.documentElement.clientWidth
					} else {
						if (d.body && typeof d.body.clientWidth!='undefined') {
						var winWidth = d.body.clientWidth
						}
					}
				}
				

		                if (winHeight < 600) {
		                var wys = winHeight - 15;
		                if(wys<=0){
		                wys = 100;
		                }
 
		                document.getElementById("ISPAGApplet").style.height = wys+'px';
		                }else {
					var wys = winHeight - 15;
		               		document.getElementById("ISPAGApplet").style.height = wys +'px';
		                }
		                if (winWidth < 960) {
				         var szer = winWidth -15;
		            		 document.getElementById("ISPAGApplet").style.width = szer +'px';
		                }else {
		               		 document.getElementById("ISPAGApplet").style.width = "100%";
				        }
		                }
				
			}
			 
		
	}
	
	
	
	
	
	function appletHeight(){
		 d = document.getElementById("ISPAGApplet");
		if (typeof window.innerHeight!='undefined') {
			var winHeight = window.innerHeight;
			} else {
			if (d.documentElement && typeof d.documentElement.clientHeight!='undefined' && d.documentElement.clientHeight!=0) {
			var winHeight = d.documentElement.clientHeight
			} else {
				if (d.body && typeof d.body.clientHeight!='undefined') {
				var winHeight = d.body.clientHeight
				}
			}
		}
		return winHeight;
	}
	
	
	function appletWidth(){
		d = document.getElementById("ISPAGApplet");
		if (typeof window.innerWidth!='undefined') {
			var winWidth = window.innerWidth;
			} else {
				if (d.documentElement && typeof d.documentElement.clientWidth!='undefined' && d.documentElement.clientWidth!=0) {
				var winWidth = d.documentElement.clientWidth
				} else {
					if (d.body && typeof d.body.clientWidth!='undefined') {
					var winWidth = d.body.clientWidth
					}
				}
			}
		return winWidth;
	}

	function getPositionY(o){
		var y = o.offsetTop;
		while(o = o.offsetParent){				
			y += o.offsetTop;
		}			
		return y;
	}
	function pageAnchor() {
		var href=window.location.href;			
		var ie=(document.all)?true:false;
		if (ie && href.indexOf("#")!=-1) {
			var h=href.split("#");
			o = document.getElementById(h[1]);		
			window.scrollTo(0,getPositionY(o));					
		}
	}
	
	function setCookie(c_name,value) {
		document.cookie=c_name + "=" + "";
		document.cookie=c_name + "=" + escape(value);
	}	

	
function setcookie(name, value, expires, path, domain, secure) {
    // http://kevin.vanzonneveld.net
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // *     example 1: setcookie('author_name', 'Kevin van Zonneveld');
    // *     returns 1: true
 
    expires instanceof Date ? expires = expires.toGMTString() : typeof(expires) == 'number' && (expires = (new Date(+(new Date) + expires * 1e3)).toGMTString());
    var r = [name + "=" + escape(value)], s, i;
    for(i in s = {expires: expires, path: path, domain: domain}){
        s[i] && r.push(i + "=" + s[i]);
    }
    return secure && r.push("secure"), document.cookie = r.join(";"), true;
}

function validateFormEmails(form) {
	var value = form.mailFrom != null ? form.mailFrom.value : form.replyTo.value;  
	return validateMail(value, "Twojego adresu") && validateMail(form.mailTo.value, "Adresu odbiorcy");	
}


function validateMail(email,label) {
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!email.match(re)) {
        alert("Niepoprawny format "+label+".");
        return false;
    } else {
        return true;
    }
}

function linkToTransactionSystem(i){
window.open('https://www.bossa.pl/bossa/zlec?'+i,
'zlec','scrollbars=yes,resizable=yes,width=675,height=455');
}

var mint;
var disOn = 0;
function changeBoxNew(){
    var boxToChange2 = new Array();
    mint = clearInterval(mint);
    boxToChange = document.getElementById("articles02").getElementsByTagName('div');
    for (k=0;k<boxToChange.length;k++){
        if (boxToChange[k].className.indexOf("scschema_07") > -1) {
            boxToChange2.push(boxToChange[k]);
        }
    }
    for (t=0;t<boxToChange2.length;t++){
        if (boxToChange2[t].style.display == "block"){if(boxToChange2.length == (t+1)){disOn=0}else{disOn=(t+1)}};
        boxToChange2[t].style.display = "none";
    }
    boxToChange2[disOn].style.display = "block";
    mint = setInterval("changeBoxNew();",12000);
}
function changeBoxOnload(){
    mint = setInterval("changeBoxNew();",12000);
}


var propBoxTool = 0;
function propBox(o){
if (propBoxTool != 0){
for (i=0;i<propBoxTool.length;i++){propBoxTool[i].style.display = "none";}
}
propBoxTool = o.getElementsByTagName('span');
for (i=0;i<propBoxTool.length;i++){propBoxTool[i].style.display = "block";}
}
function validateSearch(form, message){
   	reg = /^[ ]{1,1000}$/;
	ryn = document.forms["searchForm_"].elements['q'].value.match(reg);
		if (ryn == null) {
			if(document.forms["searchForm_q"]){
				if(document.forms["searchForm_q"].elements['q'].value){
					wyn = document.forms["searchForm_q"].elements['q'].value.match(reg);
					if (wyn == null){
					} else { document.forms["searchForm_q"].elements['q'].value = '...';document.forms["searchForm_"].elements['q'].value = '...'}
				}	
			}
			if(document.forms["searchForm_forum"]){
				if(document.forms["searchForm_forum"].elements['q'].value){
					wyn2 = document.forms["searchForm_forum"].elements['q'].value.match(reg);
					if (wyn2 == null){
					} else { 
						document.forms["searchForm_forum"].elements['q'].value = '...';
						document.forms["searchForm_"].elements['q'].value = '...'
					}
				}			
			}
		} else { document.forms["searchForm_"].elements['q'].value = '...'}
		
		return checkTwoDate(form, message);
		
}
function clearBoxEmpty(){
if(document.getElementById("emptyBox")){document.getElementById("emptyBox").style.display = 'none';}
return true;
}



/*zwiń rozwiń nagłówek dla zalogowanych*/

/*obsługa ajax*/
var xhr = false;
function ajaxReq(key,value){
	if (window.XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject){
			try{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	if (xhr){
		if (key){
			var url = "/settings/setValue.do";
  			var params = 'key='+key+'&value='+value;
			
			xhr.onreadystatechange = saveContents;
			xhr.open("POST",url,true);
			xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  			xhr.setRequestHeader("Content-length", params.length);
  			xhr.setRequestHeader("Connection", "close");
			xhr.send(params);
		}else{
			xhr.onreadystatechange = showContents;
			xhr.open("GET",'/settings/getValueList.do',true);
			xhr.setRequestHeader('Pragma', 'no-cache');
            xhr.setRequestHeader('Cache-Control', 'must-revalidate');
            xhr.setRequestHeader('Cache-Control', 'no-cache');
            xhr.setRequestHeader('Cache-Control', 'no-store');
            xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
			xhr.send(null);
		}
	}
	else{}		
}

/*pobieranie danych z json*/			
function showContents(){
if (xhr.readyState == 4){
	var resAjax = '';
    resAjax = xhr.responseText;
	openJson(resAjax);
	}
}

/*zapisywanie danych do json*/		
function saveContents(){

}	

function votersDesc(){}		

function openJson(jSon){
	var tablica = new Array();
	var sonda = jSon.split("},");
	for(var i=0;i<sonda.length;i++){
		var p2 = "";
		if(sonda[i].indexOf("{") != -1){
			var poll1 =  sonda[i].search("{");
			var p2 = sonda[i].substring(poll1+1,sonda[i].length)
			tablica.push(p2);
		}
	}

	var tab = new Array();
	var czyNagl = false;

	for(var i=0;i<tablica.length;i++){	
		var hash = new Array();
		hash = tablica[i].split(",");
		tab.push(hash);
	}
	for(var i=0;i<tab.length;i++){	
		if(tab[i][0].indexOf('head') != -1){
			naglowek(tab[i]);
			czyNagl = true;
		} 
	}

	if(czyNagl == false){
		document.getElementById('pH').style.display="block";
		document.getElementById('pD').style.clear="none";
		document.getElementById('pHeadT').innerHTML = '<img class="tToggl" src="/_iMg/bodgets/head-open.gif" alt="" />';	
	}	
}

/*obsługa nagłówka*/
function naglowek(heaD){
	if(heaD[1].indexOf('false') != -1){
		document.getElementById('pH').style.display="none";
		document.getElementById('pD').style.clear="both";
		document.getElementById('pHeadT').innerHTML = '<img class="tToggl" src="/_iMg/bodgets/head-close.gif" alt="" />';
		if(document.getElementById('ver'))document.getElementById('ver').style.top="0px";
		if(document.getElementById('ver'))document.getElementById('ver').style.right="5px";
	}
	else{
		document.getElementById('pH').style.display="block";
		document.getElementById('pD').style.clear="none";
		document.getElementById('pHeadT').innerHTML = '<img class="tToggl" src="/_iMg/bodgets/head-open.gif" alt="" />';
	}
}

function THTog(){
	var naglowek = document.getElementById('pH');
	var ZwRozButton = document.getElementById('pHeadT');
	if(naglowek.style.display=='none'){
		naglowek.style.display="block";
		if(document.getElementById('ver'))document.getElementById('ver').style.top="-59px";
		if(document.getElementById('ver'))document.getElementById('ver').style.right="238px";
		document.getElementById('pD').style.clear="none";
		ZwRozButton.innerHTML = '<img class="tToggl" src="/_iMg/bodgets/head-open.gif" alt="" />';
		ajaxReq('head_1','true');
	}else{
		naglowek.style.display='none';
		if(document.getElementById('ver'))document.getElementById('ver').style.top="0px";
		if(document.getElementById('ver'))document.getElementById('ver').style.right="5px";
		document.getElementById('pD').style.clear="both";
		ZwRozButton.innerHTML = '<img class="tToggl" src="/_iMg/bodgets/head-close.gif" alt="" />';
		ajaxReq('head_1','false');
	}
}

function zliczDaty(sel){
	var ile = 0;
	for(var i=0;i<sel.length;i++){
		if(sel[i].selected == true){
			ile +=1
		}
		if(ile > 5){
			sel[i].selected = false;
			break;
		}
	}	
}

function checkSendLink() {
	fi1 = document.getElementById("fi01");
	fi2 = document.getElementById("fi02");
	fi3 = document.getElementById("fi03");
	sendLink = document.getElementById("notSendLink");
	sendLink2 = document.getElementById("notSendLink2");
	check = false;
	if(fi1) {
		elemLegend = fi1.getElementsByTagName("div");
		for (i=0;i<elemLegend.length;i++) {
			if (elemLegend[i].className == "legend" && elemLegend[i].getElementsByTagName("*").length==0) {
				check = true;
			}
		}
	}
	if(fi2) {
		elemLegend2 = fi2.getElementsByTagName("div");
		for (i=0;i<elemLegend2.length;i++) {
			if (elemLegend2[i].className == "legend" && elemLegend2[i].getElementsByTagName("*").length==0){
				check = true;
			}
		}
	}	
	if(fi3) {
		elemLegend3 = fi3.getElementsByTagName("div");
		for (i=0;i<elemLegend3.length;i++) {
			if (elemLegend3[i].className == "legend" && elemLegend3[i].getElementsByTagName("*").length==0){
				check = true;
			}
		}
	}
	
	tabele2 = document.getElementsByTagName("table");
	notGreen = new Array;
	for (j=0;j<tabele2.length;j++) {
		if (tabele2[j].className.indexOf("not_green") > -1) {
			notGreen.push(tabele2[j].innerHTML);
		}
	}
	
	if (notGreen.length > 0) {
		spr = 0;
		for (k=0;k<notGreen.length;k++) {
			if (notGreen[k].indexOf('<tr class="nodata">') > -1 || notGreen[k].indexOf('<TR class="nodata">') > -1  || notGreen[k].indexOf('<TR class=nodata>') > -1) {
				++spr;
			}
		}
		if (notGreen.length == spr) {
			check = true;
		}
	}

	if (check == false) {
		if (sendLink)
		sendLink.style.display = "block";
		if (sendLink2)
		sendLink2.style.display = "block";	
	}
}
