function createInput(iid,iname,ivalue,itype,iclass,istyle){
	myinput=document.createElement("input");
	myinput.id=iid;
	myinput.name=iname;
	myinput.type=itype;
	myinput.value=ivalue;
	myinput.className=iclass;
	if(istyle!=""){
		istyle=istyle.split(";");
		for(is=0,isc=istyle.length;is<isc;is++){
			istyle[is]=istyle[is].split(":");
			eval("myinput.style."+istyle[is][0]+"='"+istyle[is][1]+"'");
		}
	}
	return myinput;
}

function insertTd(iid,iname,iwidth,iheight,ialign,ivalign,istyle,iclass,icolspan,irowspan,co,where){
	mytd=this[co].insertCell(where);
	if(iid!="") mytd.id=iid;
	if(iname!="") mytd.name=iname;
	if(iwidth!="") mytd.width=iwidth;
	if(iheight!="") mytd.height=iheight;
	if(ialign!="") mytd.align=ialign;
	if(ivalign!="") mytd.valign=ivalign;
	if(iclass!="") mytd.className=iclass;
	if(icolspan!="") mytd.colspan=icolspan;
	if(irowspan!="") mytd.rowspan=irowspan;
	if(istyle!=""){
		istyle=istyle.split(";");
		for(is=0,isc=istyle.length;is<isc;is++){
			istyle[is]=istyle[is].split(":");
			eval("mytd.style."+istyle[is][0]+"='"+istyle[is][1]+"'");
		}
	}
	return mytd;
}

function createImg(imgarg){
	myImg=document.createElement("img");
	if(imgarg!=""){
		imgarg=imgarg.split("|");
		for(iarg=0,iargc=imgarg.length;iarg<iargc;iarg++){
			imgargvar=imgarg[iarg].split("=");
			switch(imgargvar[0]){
				case "style":
					imgargvarst=imgargvar[1].split(";");
					for(is=0,isc=imgargvarst.length;is<isc;is++){
						imgargvarstfc=imgargvarst[is].split(":");
						eval("myImg.style."+imgargvarstfc[0]+"='"+imgargvarstfc[1]+"'");
					}
				break;
				default:
					myImg[imgargvar[0]]=imgargvar[1];
				break;
			}
		}
	}
	return myImg;
}

function polehaslo(co,gdzie,change){
	myRow=gdzie.insertRow(-1);
	myCell1=insertTd('','','56%','21','','','','rhead','','','myRow','-1');
	myCell4=insertTd('','','20%','','','','','rhead','','','myRow','-1');
	myCell5=insertTd('','','20%','','','','','rhead','','','myRow','-1');
	myCell6=insertTd('','','4%','','right','valign','','rhead','','','myRow','-1');
	
	myCell1.appendChild(createInput('haslo[]','haslo[]','','text','inptcz','width:100%'));
	myCell4.appendChild(createInput('showtime[]','showtime[]','','text','inptcz','width:100%'));
	myCell5.appendChild(createInput('pause[]','pause[]','','text','inptcz','width:100%'));
	img1=createImg('src=images/but_iks.jpg|width=19|height=19|style=cursor:pointer');
	myCell6.appendChild(img1);
	img1.onclick=function(){this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);}
}

function poleznak(co,gdzie,change){
	myRow=gdzie.insertRow(-1);
	myCell1=insertTd('','','56%','21','','','','rhead','','','myRow','-1');
	myCell4=insertTd('','','20%','','','','','rhead','','','myRow','-1');
	myCell5=insertTd('','','20%','','','','','rhead','','','myRow','-1');
	myCell6=insertTd('','','4%','','right','valign','','rhead','','','myRow','-1');
	
	myCell1.appendChild(createInput('haslozn[]','haslozn[]','','text','inptcz','width:100%'));
	myCell4.appendChild(createInput('showtimezn[]','showtimezn[]','','text','inptcz','width:100%'));
	myCell5.appendChild(createInput('pausezn[]','pausezn[]','','text','inptcz','width:100%'));
	img1=createImg('src=images/but_iks.jpg|width=19|height=19|style=cursor:pointer');
	myCell6.appendChild(img1);
	img1.onclick=function(){this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);}
}

function showkartki(ktora, path){
	document.getElementById('kartkabig').style.display='block';
	document.getElementById('kartkabig').style.left=(window.document.body.scrollWidth/2-340) + "px";
	setprzykrywka();
	showcard(ktora, path);
	return false;
}

function closecard(){
	document.getElementById('kartkabig').style.display='none';
	unsetprzykrywka();
	return false;
}

function showcard(wcard,path){

	if(wcard>opis.length-1) wcard=0;
	if(wcard>(opis.length-2)){
		document.getElementById('ffvd').style.display="none";
		document.getElementById('fvd').style.display="none";
	} else {
		document.getElementById('ffvd').style.display="inline";
		document.getElementById('fvd').style.display="inline";
	}
	if(wcard<1){
		document.getElementById('fprev').style.display="none";
		document.getElementById('prev').style.display="none";
	} else {
		document.getElementById('fprev').style.display="inline";
		document.getElementById('prev').style.display="inline";
	}
	document.getElementById('mycard').blur();
	document.getElementById('mycard').src="images/blank.png";
	document.getElementById('mycard').src=path+opis[wcard][0]; /*del by pm "images/galeria/"+*/
	document.getElementById('mycard').title="kliknij aby przejść do następnego zdjęcia";
	metka=(opis[wcard][1]!="")?"<b>"+opis[wcard][1]+"</b>":"";
	format=(opis[wcard][2]!="")?" - "+opis[wcard][2]:"";
	optxt=(opis[wcard][3]!="")?"<br>"+opis[wcard][3]:"";
	document.getElementById('cardtxt').innerHTML=metka+format+optxt;
	ccard=parseInt(wcard);
	
}

function setprzykrywka(){
	var przykrywka=document.getElementById('przykrywka');
	przykrywka.style.width = window.document.body.scrollWidth + "px";
	przykrywka.style.height = window.document.body.scrollHeight + "px";
	przykrywka.style.display = 'block';
}

function unsetprzykrywka(){
	var przykrywka=document.getElementById('przykrywka');
	przykrywka.style.width = "1px";
	przykrywka.style.height = "1px";
	przykrywka.style.display = 'none';
}

function galpreloader(myimages){
	var imagecollection = myimages;
	var myarrImages=new Array();
	di=document.images.length;
	for(var i=di,il=imagecollection.length;i<(di+il-1);i++) {
		myarrImages[i]=new Image;
		myarrImages[i].src="images/galeria/"+imagecollection[i-di][0];
	}
}
