//window.onerror=new Function("return true;");

//	Funkcje do rozwiązywania problemu z wyświetlaniem ramki wokół obiektów Flash (początek)

window.onload = function()
{
	
	var objects = document.getElementsByTagName('noscript');
	for (var i = objects.length - 1; i >= 0 ; i--)
	{
		var html = objects[i].innerHTML;
		html = html.substring(12, html.length-12);
		objects[i].outerHTML = html;
	}
}

/*
window.onload = function(){
	var o,n,j,i,p,t,ob = new Array(),objs = document.getElementsByTagName('object');	
	for(i=0;i<objs.length;i++) if (!objs[i].className.match(/(^|\s)noninteractive($|\s)/)) ob.push(objs[i]);
	objs=null;
	for(i=0;i<ob.length;i++)
	{
		t='';
		for(j=0;j<ob[i].childNodes.length;j++)
		{
			if (ob[i].childNodes[j].tagName != 'OBJECT')
			t += ob[i].childNodes[j].outerHTML;
		}
		t = ob[i].outerHTML.replace("</OBJECT>",t + "</OBJECT>");
		
		n = ob[i].nextSibling;
		p = ob[i].parentNode;
		
		p.removeChild(ob[i]);
		ob[i] = null;
	
		o = document.createElement('span');
		o.innerHTML = t;
		o = o.firstChild;
	
		p.insertBefore(o,n);
	}
}
*/

/*
window.onload = function(){
	o=document.getElementsByTagName('object');l=o.length
	for(j=0;j<l;j++){
        a=p=A=P=''
		A=o[j].attributes; 
		P=o[j].parentNode.getElementsByTagName('param'); 
		for(i=0;i<A.length;i++){a+=A[i].name+'="'+A[i].value+'" '+"\n";}
		for(i=0;i<P.length;i++){p+='<param name="'+P[i].name+'" value="'+P[i].value+'"/>'+"\n"}
		o[j].outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+a+'>'+p+'</object>';
	}
}
*/
//	Funkcje do rozwiązywania problemu z wyświetlaniem ramki wokół obiektów Flash (koniec)


var nn4 = (document.layers) ? true:false; 
var ie4 = (document.all) ? true:false; 
var ie6nn6 = (document.getElementById) ? true:false; 

	//Utworzenie obiektu, który będzie zbierał zdarzenia od kliknięć myszki
	//Element ten będzie poza bubble, więc będzie go można wykorzystać w otwierającym się okienku
	//aby można było dowiedzieć się, z jakiego elementu pochodzi zdarzenie
	//np. window.opener.elementClicked.title
	window.elementClicked = null;
	function mDown(){
	  window.elementClicked = event.srcElement;
	}
	document.onmousedown = new Function("mDown()");
	//



function ScrollText(text,seed)
{
	var msg = text;
	var out = " ";
	var c   = 1;
	if (seed > 100)
	{
		seed--;
		var cmd="ScrollText(\"" + msg + "\"," + seed + ")";
		timerTwo=window.setTimeout(cmd,100);
	}
	else if (seed <= 100 && seed > 0)
	{
		for (c=0 ; c < seed ; c++)
		{
			out+=" ";
		}
		out+=msg;
		seed--;
		var cmd="ScrollText(\"" + msg + "\"," + seed + ")";
		window.status=out;
		timerTwo=window.setTimeout(cmd,100);
	}
	else if (seed <= 0)
	{
		if (-seed < msg.length)
		{
			out+=msg.substring(-seed,msg.length);
			seed--;
			var cmd="ScrollText(\"" + msg + "\"," + seed + ")";
			window.status=out;
			timerTwo=window.setTimeout(cmd,100);
		}
		else
		{
			var cmd="ScrollText(\"" + msg + "\",100)";
			window.status=" ";
			timerTwo=window.setTimeout(cmd,75);
		}
	}
}

function obetnij_spacje(Str)
{
	dlugosc=Str.length;
	while (Str.slice(0,1) == " ")
	{
		 Str = Str.substr(1,dlugosc-1);
	 	 dlugosc = Str.length
	}
	while (Str.slice(dlugosc-1,dlugosc)== " ")
	{
	 	 Str = Str.substr(0,dlugosc-1);
	 	 dlugosc = Str.length
 	}
	return Str;
}

function blank(pole)
{
	return (pole=="");
}

function search()
{
	if (blank(obetnij_spacje(sz.search_txt.value)))
	{
		sz.search_txt.value='szukaj...';
		sz.op.value='';
	}
	else
		sz.op.value='o';
}

function test()
{
	ok = true;
	if ((!sz.op.value.length)||blank(obetnij_spacje(sz.search_txt.value)))
		ok=false; //szukana nazwa
	(ok==true)?sz.submit():alert("Wprowadź tekst, który chcesz wyszukać.");
	return false;
}

function zmien(obiekt,numer,link_nr)
{
	aid=document.getElementById(link_nr)
	if(numer>0) {
		obiekt.bgColor = '#FFFFFF';
		aid.style.color='#004185';
	}
	else {
		obiekt.bgColor = '#004185';
		aid.style.color='#FFFFFF';
	}
	return true;
}

function showimg(imgPath,imgFile,imgWidth,imgHeight,imgDescription,imgScale)
{
//Jeśli opis podamy jaki tekst, to pokaże się on bezpośrednio
//Jeśli opis będzie miał wpisane 0 (zero), to będzie poszukiwany w treści
//Jeśli opis będzie miał wartość >0, to będzie wartością opisu z pola imgDesc{imgID} np. imgDesc1234

	//document.images.imgImg.src='/edytorek/edytorimg/empty.gif';
	document.images.imgImg.width=137;
	document.images.imgImg.height=12;
	document.images.imgImg.src='/edytorek/edytorimg/loading.gif';
	var MAX_MIN_WIDTH=640;
	var MAX_MIN_HEIGHT=480;
	imgW=imgWidth;
	imgH=imgHeight;
	imgS=imgScale;
	if ((imgS>0) && (parseInt(imgWidth)>MAX_MIN_WIDTH || parseInt(imgHeight)>MAX_MIN_HEIGHT)) {
		dXY = Math.min(MAX_MIN_WIDTH/imgWidth,MAX_MIN_HEIGHT/imgHeight);
		imgW = parseInt(imgWidth*dXY);
		imgH = parseInt(imgHeight*dXY);
		//alert ("imgWidth="+imgWidth+", imgHeight="+imgHeight+"\nimgW="+imgW+", imgH="+imgH);
	}
	else
		imgS=0;

	//Odległość od lewej krawędzi
	if (imgW<document.body.clientWidth)
		document.getElementById("imgTable").style.left=document.body.scrollLeft+((document.body.clientWidth)/2)-(imgW/2)-5;
	else
		document.getElementById("imgTable").style.left=document.body.scrollLeft+5;

	//Odległość od góry
	if (imgH<document.body.clientHeight)
		document.getElementById("imgTable").style.top=document.body.scrollTop+((document.body.clientHeight)/2)-(imgH/2)-15;
	else
		document.getElementById("imgTable").style.top=document.body.scrollTop+15;

	document.images.imgImg.width=imgW;
	document.images.imgImg.height=imgH;
	document.images.imgImg.src=imgPath+imgFile;
	document.getElementById("imgFooter").width=imgW;
	document.getElementById("imgTable").style.visibility='visible';

	imgHeader.innerHTML='<img hspace=1 vspace=1 align=right src=/edytorek/edytorimg/close.gif alt="zamknij" style="cursor:pointer" onclick="imgTable.style.visibility=\'hidden\';imgTable2.style.visibility=\'hidden\';document.images.imgImg.src=\'/edytorek/edytorimg/empty.gif\';hideIMG();">';
	//imgHeader.innerHTML='<img hspace=1 vspace=1 align=right src=/edytorek/edytorimg/close.gif alt="zamknij" style="cursor:pointer" onclick="imgTable.style.visibility=\'hidden\';imgTable2.style.visibility=\'hidden\';document.images.imgImg.src=\'/pimg/loading.gif\';">';
	if (imgS>0) {
		imgHeader.innerHTML+='<img hspace=1 vspace=1 align=right src="/edytorek/edytorimg/max.gif" alt="Maksymalizuj" style="cursor:pointer" onclick="showimg(\''+imgPath+'\',\''+imgFile+'\','+imgWidth+','+imgHeight+','+imgDescription+',0);">';
	}
	//imgHeader.innerHTML+='<img src=/edytorek/edytorimg/empty.gif height=13>Ilustracja&nbsp;<b>'+imgFile+'</b>';
	imgHeader.innerHTML+='Ilustracja';
	if (isNaN(imgDescription)){
		imgFooter.innerHTML=imgDescription;
	}
	else if (imgDescription>0){
		imgFooter.innerHTML=eval('imgDesc'+imgDescription+'.innerHTML');
	}
	else {
		//Komentarz z treści dokumentu
		var str = document.body.innerHTML;
		var re1 = new RegExp('title=["?](.*?)["?](.*)'+imgFile+'(.*)', 'gi');//Jeśli wielowyrazowe, to w cudzysłowach
		var re2 = new RegExp('title=([^ ]+)(.*)'+imgFile+'(.*)', 'gi');//Jeśli jednowyrazowe, to bez cudzysłowów
		var a;
		if (!(a=re1.exec(str)))
			a=re2.exec(str);
		if (a) {
			imgFooter.innerHTML=""+a[1]+"";
		}
		else
			imgFooter.innerHTML="";
	}
	document.getElementById("imgTable2").style.left=parseInt(document.getElementById("imgTable").style.left)-1;
	document.getElementById("imgTable2").style.top=parseInt(document.getElementById("imgTable").style.top)-1;
	document.getElementById("imgTable2").style.width=imgTable.clientWidth+5;
	document.getElementById("imgTable2").style.height=imgTable.clientHeight+5;
	document.getElementById("imgTable2").style.visibility='visible';
}

function hideIMG()
{
	document.getElementById("imgTable2").style.left=0;
	document.getElementById("imgTable2").style.width=0;
	document.getElementById("imgTable").style.left=0;
	document.images.imgImg.width=0;
}

function rekom()
{
	var r_w = '';
	r_w = window.open("linki.php","linki","width=400,height=400,toolbar=no,menubar=no,scrollbars=yes");
	r_w.location.reload();
	r_w.focus();
//	window.open("/linki.php","linki","width=400,height=400,toolbar=no,menubar=no,scrollbars=yes");
}

function PokazUkryj(idObj, pokaz) 
{ 
nn6 = (document.getElementById) ? true:false; 
nn4 = (document.layers) ? true:false; 
ie4 = (document.all) ? true:false; 
//if ((nn6) && (ie4)) {nn6=null;} 
 
var attribV;
var attribD;
 if (nn6) {
  attribV = (pokaz) ? 'visible' : 'hidden';
  attribD = (pokaz) ? '' : 'none';
  document.getElementById(idObj).style.visibility=attribV; 
  document.getElementById(idObj).style.display=attribD;	
 } 
 else if (ie4){ 
    attribV = (pokaz) ? 'visible' : 'hidden';
	attribD = (pokaz) ? '' : 'none';
	document.all[idObj].style.visibility=attribV;
    document.all[idObj].style.display=attribD;	
 } 
 else if (nn4){ 
     attribV = (pokaz) ? 'show' : 'hide';
     document.layers[idObj].visibility = attribV;
 } 
} 

function popFrameLoad(plik, stan, opis, w, h){
//Funkcja służąca do ładowania do "wyskakującego okienka" (ramki) dowolny plik, np. ankietę.
//document.all.iFrameTable.style.left=50;
//document.getElementById("iFrameTable").style.top=150;
//document.getElementById("iFrameTable").style.left=150;
//document.getElementById("popIF").style.width=300;
//alert(document.body.scrollHeight);
//alert(document.body.clientHeight);
var IFW=640;//Szerokość wyskakującego "okienka"
var IFH=480;//Wysokość wyskakującego "okienka"
if(w>0)	IFW=w;
if(h>0)	IFW=h;

	if (plik){
		//if (ie6nn6 && ie4 || ie4)//Tylko IE
		if (ie4)//Tylko IE
			popIF.location.href=plik;
		else if (ie6nn6)//Tylko FF
			popIF.contentWindow.location.href=plik;
	}
//		window.frames['popIF'].location.href=plik;

	if (opis)
		document.getElementById("tdIFhead").innerHTML="&nbsp;"+opis;


	//Odległość od lewej krawędzi
	if (IFW<document.body.clientWidth)
		document.getElementById("iFrameTable").style.left=document.body.scrollLeft+((document.body.clientWidth)/2)-(IFW/2)-5;
	else
		document.getElementById("iFrameTable").left=document.body.scrollLeft+5;

	//Odległość od góry
	if (IFH<document.body.clientHeight)
		document.getElementById("iFrameTable").style.top=document.body.scrollTop+((document.body.clientHeight)/2)-(IFH/2)-15;
	else
		document.getElementById("iFrameTable").style.top=document.body.scrollTop+15;

		document.getElementById("popIF").style.width=638;
		document.getElementById("popIF").style.height=460;

//document.getElementById("iFrameTable").style.top=150;
//document.getElementById("iFrameTable").style.left=150;

	if (stan>0){
		document.getElementById("iFrameTable").style.display="block";
		document.getElementById("iFrameTable").style.zIndex=254;
	}
	else{
		document.getElementById("iFrameTable").style.display="none";
		document.getElementById("iFrameTable").style.zIndex=100;
	}
}


function obj_visible(obj) {
	
//	var pozycje = Array('kategor','images','tables','references','links','sondy','ankiety');
	var pozycje = Array('kategor','images','tables','links','sondy','ankiety');
	for (x=0; x<pozycje.length; x++) 
	{ 
		if(obj==pozycje[x]){ // selected element
	if (ie6nn6){
		var actual = eval("document.getElementById('"+pozycje[x]+"').style.display");
		if(actual=='none') eval("document.getElementById('"+pozycje[x]+"').style.display='';");
		else eval("document.getElementById('"+pozycje[x]+"').style.display='none';");
		var actual = eval("document.getElementById('"+pozycje[x]+"_roll').className");
		if(actual=='ed_roll') eval("document.getElementById('"+pozycje[x]+"_roll').className='ed_roll2'");
		else eval("document.getElementById('"+pozycje[x]+"_roll').className='ed_roll'");
	}
	else if (ie4) { // IE
		var actual = eval("document.all."+pozycje[x]+".style.display");
		if(actual=='none') eval("document.all."+pozycje[x]+".style.display='';");
		else eval("document.all."+pozycje[x]+".style.display='none';");
		var actual = eval("document.all."+pozycje[x]+"_roll.className");
		if(actual=='ed_roll') eval("document.all."+pozycje[x]+"_roll.className='ed_roll2'");
		else eval("document.all."+pozycje[x]+"_roll.className='ed_roll'");
	} 
	else if (nn4){ // NS
		var actual = eval("document.layers['"+pozycje[x]+"'].display");
		if(actual=='none') eval("document.layers['"+pozycje[x]+"'].display='';");
		else eval("document.layers['"+pozycje[x]+"'].display='none';");
	}
		}
		else{ // other elements
			if (ie6nn6){
				eval("document.getElementById('"+pozycje[x]+"').style.display='none';");
				eval("document.getElementById('"+pozycje[x]+"_roll').className='ed_roll'");
			}
			else if (ie4) { // IE
				eval("document.all."+pozycje[x]+".style.display='none';");
				eval("document.all."+pozycje[x]+"_roll.className='ed_roll'");
			} 
			else if (nn4){ // NS
				eval("document.layers['"+pozycje[x]+"'].display='none';");
			}
		}		
	} 
}


