//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

/////////////////////////////////////////////////////////////

function iteruj(obj){
//var obj = tinyMCEPopup.getWin();
/*
	if(obj.length)
		jQuery.each(obj, function(i, val) {
			if ((typeof val)=="object")
				iteruj(val)
			else
				alert(i+' '+val);
		});
	else
		alert(obj.location);
*/
}

function findDigits(text) {
  var re = new RegExp(/[0-9]+/);
  var m = re.exec(text);
  if (m == null) {
    //alert("No match");
    return false;
  } else {
    /*
    var s = "Match at position " + m.index + ":\n";
    for (i = 0; i < m.length; i++) {
      s = s + m[i] + "\n";
    }
    alert(s);
    */
    return m[0];
  }
}
//Prawie identyczne jak findDigits, ale cyfry zawsze musz± byæ na koncu np. abc_123, a NIE abc_123_def
function findID(text) {
  //return findDigits(text);
  var re = new RegExp(/[0-9]+$/);
  var m = re.exec(text);
  if (m == null) {
    return false;
  } else {
    return m[0];
  }}

//Dodaje zdarzenie do obiektu (w IE, FF, Opera)
//Przykï¿½ad zastosowania w funkcji showimg
function addEvent(obj, type, fn) { 
	//obj.attachEvent("on"+type, fn); 
	//return false;
	if (obj.addEventListener) { 
		obj.addEventListener(type, fn, false); 
	} else if (obj.attachEvent) { 
		obj["e"+type+fn] = fn; 
		obj[type+fn] = function() {obj["e"+type+fn](window.event); } 
		obj.attachEvent("on"+type, obj[type+fn]); 
	} 
}

// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG()
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])
	
	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}
}

//	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 obetnij_spacje_new(Str)
{
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

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 getId(id)
{
	return document.all ? document.all[id] : document.getElementById(id) ;
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}



function showimg(imgPath,imgFile,imgWidth,imgHeight,imgDescription,imgScale,event)
{
//Pamiï¿½taï¿½ o tym, aby wszystkie flash na stronie miaï¿½y ustawione
//<param name="wmode" value="transparent" />
//oraz wszystkie inne warstwy niï¿½ "wyskakujï¿½cego" obrazka miaï¿½y z-index<50
//Style z ustawieniami do warstwy obrazka znajduj? siï¿½ w style.css
//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
//relativeToCursor - obrazek zostanie wy¶wietlony przy kursorze

	//document.images.imgImg.width=137;
	//document.images.imgImg.height=12;
	var imgDesc = new Array(2);
	if (isNaN(imgDescription)){
		imgDesc = imgDescription.split('~');
	}
	else{
		imgDesc[0]='';
		imgDesc[1]='';
	}
	loadImg = '/edytorek/edytorimg/loading.gif';
	aktualnyImg = document.images.imgImg.src;
	var re = new RegExp(/empty/);
	var m = re.exec(aktualnyImg);
	if (m != null) {
		aktualnyImg=loadImg;
		document.images.imgImg.width='137px';
		document.images.imgImg.height='12px';
		nowyImg = 1;
		//alert('nowy obrazek');
	}
	else
		nowyImg = 0;
	var MAX_MIN_WIDTH=1000;
	var MAX_MIN_HEIGHT=600;
	var imgW=parseInt(imgWidth);
	var imgH=parseInt(imgHeight);
	var imgS=parseInt(imgScale);
	var scrollX=0;
	var scrollY=0;
	var relLeft=0;//Przesuniêcie obrazka w stosunku do innego obiektu w poziomie
	var relTop=0;//Przesuniêcie obrazka w stosunku do innego obiektu w pionie
	/*
	if(document.body)
		scrollX=document.body.scrollLeft;//IE6, Opera
	else if (window.scrollX)
		scrollX=window.scrollX;//FF
	else if(document.documentElement)
		scrollX=document.documentElement.scrollLeft;//IE7, FF, Opera
	else
		scrollX=0;

	if(document.body)
		scrollY=document.body.scrollTop;//IE6, Opera
	else if(document.documentElement)
		scrollY=document.documentElement.scrollTop;//IE7, FF, Opera
	else if (window.scrollY)
		scrollY=window.scrollY;//FF
	else
		scrollY=0;
	*/
	var zdarzenie='';
	if(event){
		zdarzenie = event['type'];
	}

	if (document.getElementById("imgZamknij")&&document.getElementById("imgHeader")){
		if (zdarzenie!='mousemove'){
			document.getElementById("imgZamknij").style.visibility='visible';
			document.getElementById("imgHeader").style.display='';
		}
		else{
			document.getElementById("imgZamknij").style.visibility='hidden';
			document.getElementById("imgHeader").style.display='none';
		}
	}
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	
	scrollX=document.all? iebody.scrollLeft : pageXOffset
	scrollY=document.all? iebody.scrollTop : pageYOffset

	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 (zdarzenie=='mousemove'){
		relLeft = tempX+20;
		relTop  = tempY-imgH-40;
		//$('#divDebugger').text(imgH);
		//Je¶li góra okna mia³a by byæ powy¿ej górnej ramki, to góra ma byæ przesuniêta tyle co scroll
		if(relTop<(scrollY+5))
			relTop = scrollY+5;
	}
	
	if (imgW<iebody.clientWidth||zdarzenie=='mousemove'){
		//if(!relLeft)
		if (zdarzenie!='mousemove')
			relLeft = (scrollX+((iebody.clientWidth)/2)-(imgW/2)-5);
		document.getElementById("imgTable").style.left=relLeft+"px";
	}
	else
		document.getElementById("imgTable").style.left=(scrollX+5)+"px";

	//Odlegï¿½o?ï¿½ od gï¿½ry
	if (imgH<iebody.clientHeight||zdarzenie=='mousemove'){
		//if(!relTop)
		if (zdarzenie!='mousemove')
			relTop = (scrollY+((iebody.clientHeight)/2)-(imgH/2)-5);
		document.getElementById("imgTable").style.top=relTop+"px";
	}
	else
		document.getElementById("imgTable").style.top=(scrollY+5)+"px";

	if(nowyImg){
		document.images.imgImg.src=imgPath+imgFile;
	}		
	document.images.imgImg.width=imgW;
	document.images.imgImg.height=imgH;
	document.getElementById("imgFooter").width=imgW+"px";
	document.getElementById("imgTable").style.visibility='visible';

	if (document.getElementById("imgMax")){
	//Nowa wersja
		if (imgS>0&&zdarzenie!='mousemove') {
			addEvent(document.getElementById("imgMax"), 'click', function(){showimg(imgPath,imgFile,imgWidth,imgHeight,imgDescription,0);});
			document.getElementById("imgMax").style.display="block";
		}
		else{
			document.getElementById("imgMax").style.display="none";
		}
		
		if(imgDesc[1])
			document.getElementById("imgTitle").innerHTML=imgDesc[1];
	}
	else{
	//Stara wersja
		document.getElementById("imgHeader").innerHTML='<img hspace=\"1\" vspace=\"1\" align=\"right\" src="/edytorek/edytorimg/close.gif" alt="zamknij" style="cursor:pointer" onclick="hideIMG();" />';	
		if (imgS>0) {
			document.getElementById("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);" />';
		}
		document.getElementById("imgHeader").innerHTML+='Ilustracja';
	}
	if (isNaN(imgDescription)){
		document.getElementById("imgFooter").innerHTML=imgDesc[0];
	}
	else if (imgDescription>0){
		document.getElementById("imgFooter").innerHTML=eval('imgDesc'+imgDescription+'.innerHTML');
	}
	else {
		//Komentarz z tre?ci dokumentu
		var str = document.body.innerHTML;
		//dla poni¿szego a[1]
		//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
		//dla poni¿szego a[2]
		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);
		/*
		var re1 = new RegExp('(<span title=["?](.*?)["?](.*)'+imgFile+'(.*)</span>)', 'gi');//Je?li wielowyrazowe, to w cudzysï¿½owach
		a=re1.exec(str);
		for (i=0; i<a.length; i++){
			alert(a[i]);
		}
		*/
		if (a) {
			document.getElementById("imgFooter").innerHTML=""+a[2].replace("powiêksz zdjêcie ", "")+"";
		}
		else if (document.getElementById("txtGaleria")){
			document.getElementById("imgFooter").innerHTML=document.getElementById("txtGaleria").innerHTML;
		}
		else {
			document.getElementById("imgFooter").innerHTML="";
		}
	}
	//alert(document.getElementById("imgTable").clientHeight);
	document.getElementById("imgTable2").style.left=(parseInt(document.getElementById("imgTable").style.left)-1)+"px";
	document.getElementById("imgTable2").style.top=(parseInt(document.getElementById("imgTable").style.top)-1)+"px";
	document.getElementById("imgTable2").style.width=(document.getElementById("imgTable").clientWidth+5)+"px";
	document.getElementById("imgTable2").style.height=(document.getElementById("imgTable").clientHeight+5)+"px";
	document.getElementById("imgTable2").style.visibility='visible';
}

function hideIMG()
{
	if (document.getElementById("imgZamknij"))
		document.getElementById("imgZamknij").style.visibility='hidden';
	document.getElementById('imgTable').style.visibility='hidden';
	document.getElementById('imgTable2').style.visibility='hidden';
	document.images.imgImg.src='/edytorek/static/pimg/empty.gif';
	//document.getElementById("imgTable2").style.left="0px";
	//document.getElementById("imgTable2").style.width="0px";
	//document.getElementById("imgTable").style.left="0px";
	//document.images.imgImg.width="0px";
}

//do zmiennych tempX i tempY zapisuje wspó³rzêdne kursora
// If NS -- that is, !IE -- then set up for mouse capture
if (!ie4) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
	/*$('#divDebugger').text('');
	for(var i in e)
		$('#divDebugger').text($('#divDebugger').text()+' '+i+':'+e[i]);*/
  if (ie4) { // grab the x-y pos.s if browser is IE
//	scrollX=document.all? iebody.scrollLeft : pageXOffset
//	scrollY=document.all? iebody.scrollTop : pageYOffset
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
    tempX = event.clientX + iebody.scrollLeft;
    tempY = event.clientY + iebody.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  //$('#divDebugger').text(tempX+" x "+tempY);
  return true
}



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';
  if(document.getElementById(idObj)){
	  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;
 } 
} 
/*
Ta wersja jest IDENTYCZNA jak D:\htdocs\klienci\talens_sklep\js\popup_iframe.js
*/
function popFrameLoad(plik, stan, opis, w, h){
	var IFW=800;//Szeroko¶æ wyskakuj±cego "okienka"
	var IFH=480;//Wysoko¶æ wyskakuj±cego "okienka"
	if(parseInt(w)>0)	IFW=w;
	if(parseInt(h)>0)	IFH=h;
	var scrollX=0;
	var scrollY=0;
	
	var arrayPageSize = getPageSize();

	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body
	
	scrollX=document.all? iebody.scrollLeft : pageXOffset
	scrollY=document.all? iebody.scrollTop : pageYOffset
	offsetX=document.all? iebody.offsetWidth : document.body.offsetWidth
	offsetY=document.all? iebody.offsetHeight : document.body.offsetHeight

	if (plik){
		document.getElementById("popIF").contentWindow.location.href=plik;
	}

	if (opis)
		document.getElementById("tdIFhead").innerHTML="&nbsp;"+opis;


	//Odleg³o¶æ od lewej krawêdzi
	document.getElementById("iFrameTable").style.left=(scrollX+((iebody.clientWidth)/2)-(IFW/2)-5)+"px";

	//Odleg³o¶æ od góry
	document.getElementById("iFrameTable").style.top=(scrollY+((iebody.clientHeight)/2)-(IFH/2)-15)+"px";
	
	//Szeroko¶æ
	document.getElementById("iFrameTable").style.width=IFW+"px";
	document.getElementById("popIF").style.width=(IFW-2)+"px";
	//Wysoko¶æ
	document.getElementById("iFrameTable").style.height=IFH+"px";
	document.getElementById("popIF").style.height=(IFH-20)+"px";


	if (stan>0){
		document.getElementById("overlayIframe").style.height=arrayPageSize[1]+"px";
		document.getElementById("overlayIframe").style.display="";
		document.getElementById("iFrameTable").style.display="block";
		document.getElementById("iFrameTable").style.zIndex=254;
		//document.getElementById("overlayIframe").style.height=offsetY+iebody.clientHeight+"px";
	}
	else{
		document.getElementById("iFrameTable").style.display="none";
		document.getElementById("iFrameTable").style.zIndex=100;
		document.getElementById("overlayIframe").style.height="0px";
		document.getElementById("overlayIframe").style.display="none";
	}
}

function popFrameUnload(){
	document.getElementById('iFrameTable').style.display='none';
	document.getElementById('overlayIframe').style.display='none';
	document.getElementById('popIF').contentWindow.location.href='about:blank';
}

function popFrameLoad_stara_wersja(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(parseInt(w)>0)	IFW=w;
	if(parseInt(h)>0)	IFH=h;
	var scrollX=0;
	var scrollY=0;

	if (window.scrollX)
		scrollX=window.scrollX;//FF
	else
		scrollX=document.body.scrollLeft;//IE, Opera

	if (window.scrollY)
		scrollY=window.scrollY;
	else
		scrollY=document.body.scrollTop;

if (plik){
		//if (ie6nn6 && ie4 || ie4)//Tylko IE
		/*
		if (ie4)//Tylko IE
			popIF.location.href=plik;
		else if (ie6nn6)//Tylko FF
		*/
			document.getElementById("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)+"px";
	else
		document.getElementById("iFrameTable").left=(document.body.scrollLeft+5)+"px";

	//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)+"px";
	else
		document.getElementById("iFrameTable").style.top=(document.body.scrollTop+15)+"px";

		document.getElementById("popIF").style.width=(IFW-2)+"px";
		document.getElementById("popIF").style.height=(IFH-20)+"px";

//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 popFrameLoad2(plik, stan, opis, w, h){
	var okno = window.open("","","left=0, top=0, width=1024, height=738, scrollbars=no, toolbar=no,resizable=yes, status=no,directories=no,menubar=no,fullscreen=yes,channelmode=yes,location=no");
	var tresc= "<HTML><BODY style='padding:0px;margin:0px;overflow:hidden;'><iframe id='popIF' frameborder='0'  width='100%' height='100%' style='width:100%;height:100%;border:0px;' src='"+plik+"'></iframe></BODY></HTML>";
	//var tresc= "<HTML><BODY style='padding:0px;margin:0px;overflow:hidden;'><iframe id='popIF' frameborder='0'  width='100%' height='100%' style='width:100%;height:100%;border:0px;' src='about:blank'></iframe></BODY></HTML>";
	okno.document.write(tresc);
	//okno.document.getElementById("popIF").contentWindow.location.href=plik;
	return false;
}

function obj_visible(obj) {
	
//	var pozycje = Array('kategor','images','tables','references','links','sondy','ankiety');
	var pozycje = Array('kategor','images','tables','links','sondy','ankiety','formularze','mapy_google');
	for (x=0; x<pozycje.length; x++) 
	{ 
		if (document.getElementById(pozycje[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';");
				}
			}
		}
	} 
}

//Funkcje do efektownego wyszarzania obrazkï¿½w
function high(which2)
{ theobject=which2
highlighting=setInterval("highlightit(theobject)",30)}
function low(which2)
{clearInterval(highlighting)
if (which2.style.MozOpacity)
which2.style.MozOpacity=0.3
else if (which2.filters)
which2.filters.alpha.opacity=50
}

function highlightit(cur2){
if (cur2.style.MozOpacity<1)
cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
else if (cur2.filters&&cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
/**
Obrazka dodaï¿½ kod:
style="FILTER: alpha(opacity = 50); moz-opacity: 0.3; "
onmouseover="high(this)" 
onmouseout="low(this)"

czyli np:
<IMG SRC="adres_pliku" onmouseover="high(this)" style="FILTER: alpha(opacity = 50); moz-opacity: 0.3" onmouseout="low(this)">
*/
// sprawdzanie poprawnoï¿½ci emaila
function emailCheck (emailStr) {
var checkTLD=1; // sprawdzanie koï¿½cï¿½wki
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Niepoprawny adres email (sprawdï¿½ poï¿½oï¿½enie @ oraz .)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Nazwa u¿ytkownika zawiera niedozwolone znaki.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Nazwa domeny zawiera niedozwolone znaki.");
return false;
   }
}
if (user.match(userPat)==null) {
alert("Niepoprawna nazwa u¿tkownika.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Docelowy adres IP jest niepoprawny!");
return false;
   }
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("Niepoprwana nazwa domeny.");
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Adres musi siê koñczyæ nazw± domeny lub dwuliterowej nazwy " + "kraju.");
return false;
}
if (len<2) {
alert("W adresie brakuje nazwy hosta!");
return false;
}
return true;
}

//Sprawdzenie ksiï¿½gi goï¿½ci
function test_ks_g(forma){
ok=true;

if(ok&&blank(obetnij_spacje(forma.elements['ks_g_imie'].value))) 
	{	forma.elements['ks_g_imie'].style.background = "#ff0000";	ok=false;} //nazwa firmy

if(!blank(forma.elements['ks_g_email'].value)){	
	if(ok&&!emailCheck(forma.elements['ks_g_email'].value))
		{	forma.elements['ks_g_email'].style.background = "#ff0000";	ok=false;} 			//email
}

if(ok&&blank(obetnij_spacje(forma.elements['ks_g_tresc'].value))) 
	{	forma.elements['ks_g_tresc'].style.background = "#ff0000";	ok=false;} //nazwa firmy


(ok==true)?forma.submit():alert("Wprowadzono niepoprawne dane!");
}

//Pokazanie okna z wpisem do ksiï¿½gi goï¿½ci
function kg_show_add() {
	menu = 'ksiega_dodaj';
	if (document.getElementById) { // IE NS6
		obj = document.getElementById(menu);
		actual = obj.style.display ;
		if(actual=='none') obj.style.display='';
		else obj.style.display='none';
	} 
	else { // NS4
		var actual = eval("document.layers['"+menu+"'].display");
		if(actual=='none') eval("document.layers['"+menu+"'].display='';");
		else eval("document.layers['"+menu+"'].display='none';");
	}
}

function download_file(hddFile, orgFile)
{
if (hddFile=="" || orgFile==""){
	alert("Plik nie zosta³ odnaleziony na serwerze.");
	return false;
}
if (orgFile=="")
	orgFile=hddFile;

var dx = screen.width;
var dy = screen.height;
var szer = dx/2;
var wys = dy/2;
//var s = "/edytorek/download_file.php?hddFile="+hddFile+"&orgFile="+orgFile;
var s = "/download_file.php?hddFile="+hddFile+"&orgFile="+orgFile;
var okno_down = window.open(s,'DownloadFile','width='+ szer +' ,height='+ wys +' , left=0 ,top=0, scrollbar=yes, toolbar=no, resizable=yes, status=no, directories=no, menubar=no, fullscreen=no');
}

/**
 * Flash detect
 */
if ((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("Mac") == -1 && navigator.appVersion.indexOf("3.1") == -1)
	 || (navigator.plugins && navigator.plugins["Shockwave Flash"])
	 ||  navigator.plugins["Shockwave Flash 2.0"]){

	FlashEnabled = true;
}
else{
	FlashEnabled = false;
}

