regwindow=new Array();
maxindex=100;
resxElem=""; resyElem=""; dmxTopLeft="";

//window.onresize=function rsx(){setdmxcontent(this);}

if (document.addEventListener) { //poprawic, ta wersja wywolania nie dziala pod opera, pod opera dziala linnia ponizej, przez window.onload
	window.addEventListener('load',function(){setWcontent(); setHeadButton(); setWtitle();},false);
	window.addEventListener('resize',function(){setWcontent();},false);
} else if (document.attachEvent) {
	window.attachEvent('onload',function(){setWcontent(); setHeadButton(); setWtitle();});
	window.attachEvent('onresize',function(){setWcontent();});
}

//window.onload=function mydmx(){setdmxcontent(this);setdmxtitle(this);}

//window.onload=function glnk(e){alert(document.links.length);}

function setWcontent(){ //skrypt uruchamiany na koncu skalowania lub przesuwania okna
//alert(top.frames[resob.id.substr(0,resob.id.length-1)+"if"].document.getElementById('rodzaj').value);
//alert(top.frames[resob.id.substr(0,resob.id.length-1)+"if"].getWdSize());
//var resob=top.frames[resob.name.substr(0,resob.name.length-1)+"if"];

	var wndSize=getWdSize();
//	alert(wndSize);
//	alert(resob.name)

	if(resxElem && resxElem.length>0){
		for(var rx=0,rix=resxElem.length;rx<rix;rx++){
			var xsize=(wndSize[0]+parseInt(resxElem[rx][1])>=0)?wndSize[0]+parseInt(resxElem[rx][1]):0;
			document.getElementById(resxElem[rx][0]).style.width=xsize+"px";
		}
	}

	if(resyElem && resyElem.length>0){
		for(var ri=0,riy=resyElem.length;ri<riy;ri++){
			var ysize=(wndSize[1]+parseInt(resyElem[ri][1])>=0)?wndSize[1]+parseInt(resyElem[ri][1]):0;
			document.getElementById(resyElem[ri][0]).style.height=ysize+"px";
		}
	}
}

function setHeadButton(){
	if(dmxTopLeft!=""){
//		alert(self.name);
//		alert(parent.newWBox[1][this.name].paramArr.id);
//		alert(dmxTopLeft);
		parent.newWBox[1][this.name].tlbut.setwbutton(dmxTopLeft,parent.newWBox[1][this.name].paramArr);
		parent.newWBox[1][this.name]['source'].getbmark('',this.name);
	}
}

function setWtitle(){
	
}

/*
function createprzykrywka(){
	if(!document.getElementById('przykrywka')){
		mypDiv=document.createElement("div");
		mypDiv.id="przykrywka";
		mypDiv.name="przykrywka";
//		mypDiv.style.backgroundColor="#cccccc";
//		mypDiv.style.position="absolute";
//		mypDiv.style.zIndex="2050";
//		mypDiv.style.posLeft="0";
//		mypDiv.style.posTop="0";
	
	//onMouseMove="getposition(event);" onmouseup="stopDrag(event);"
			if (document.addEventListener) {
				mypDiv.addEventListener('mousemove',function(event){getposition(event);},false);
				mypDiv.addEventListener('mouseup',function(event){stopDrag(event);},false);
			} else if (document.attachEvent) {
				mypDiv.attachEvent('onmousemove',function(event){getposition(event);});		
				mypDiv.attachEvent('onmouseup',function(event){stopDrag(event);});
			}
		
//	myDiv.className=iclass;
		document.body.appendChild(mypDiv);
		document.getElementById('przykrywka').className="przykrywka"; //className musi byc dodane do istniejacego objektu w dokumencie
	} else {
		mypDiv=document.getElementById('przykrywka');
	}
	
	return mypDiv;
}
*/

function createnewcat(catid){
	setmyWindow('cc'+((!maxindex)?100:maxindex),'500','150','backstage.php?40,'+catid,'','');
}

function deletecat(catid){
	switch(catid){
		case '0':
			alert('Proszę wybrać katalog do usunięcia');
		break;
		case '1':
			alert('Nie można usunąć tego katalogu');
		break;
		default:
			if(confirm("Czy napewno chcesz usunąć ten katalog")){
				setmyWindow('cc'+((!maxindex)?100:maxindex),'500','150','backstage.php?42,'+catid+',1','','');
			}
		break;
	}
}

function movecat(catid){
	if(catid>0){
		setmyWindow('cc'+((!maxindex)?100:maxindex),'500','300','backstage.php?43,'+catid+',1','','');
	} else {
		alert('Proszę wybrać katalog do przesunięcia');
	}
}

function showDialog(panel,psrc,wid,hei,posx,posy){
	with(document.getElementById(panel)){
		width=wid;
		height=hei;
		style.display='';
	}
	
	with(document.getElementById('wdsrcpanel')){
		width=wid;
		height=hei-20;
		src=psrc;
	}
}

function closeDialog(panel,ifpanel){
	with(document.getElementById(panel)){
		style.display='none';
	}
	
	with(document.getElementById(ifpanel)){
		src="template/empty.html";
	}
}

function opentree(branch,branchname){
	if(document.getElementById(branchname).style.display=='none'){
		document.getElementById(branchname).style.display='';
		branch.src="images/system/exp_open.gif";
	} else {
		document.getElementById(branchname).style.display='none';
		branch.src="images/system/exp_closed.gif";
	}
}

function selecttree(bid,branch,branchname,sekcja,linker){
	if(branchname!="" && document.getElementById(branchname).style.display=='none'){
		document.getElementById(branchname).style.display='';
		document.getElementById(branch).src="images/system/exp_open.gif";
		switch(branch.substr(0,3)){
			case "ept" :
				document.getElementById('filepath').value=bid;
				document.getElementById('secpath').value=sekcja;
			break;
			case "ste" :
				document.getElementById('symlink').value=bid;
				document.getElementById('slinksecpath').value=sekcja;
			break;
		}
		createlinkpoz(branch,'');
		if(window.explorer){
			explorer.location.href='backstage.php?'+linker+','+bid;
		}
	} else {
//		document.getElementById(branchname).style.display='none';
//		document.getElementById(branch).src="images/exp_closed.gif";
		switch(branch.substr(0,3)){
			case "ept" :
				document.getElementById('filepath').value=bid;
				document.getElementById('secpath').value=sekcja;
			break;
			case "ste" :
				document.getElementById('symlink').value=bid;
				document.getElementById('slinksecpath').value=sekcja;
			break;
		}
		createlinkpoz(branch,'');
		if(window.explorer){
			explorer.location.href='backstage.php?'+linker+','+bid;
		}
	}
}

function selecttree2(bid,branch,branchname,linker){
	if(branchname!="" && document.getElementById(branchname).style.display=='none'){
		document.getElementById(branchname).style.display='';
		document.getElementById(branch).src="images/system/exp_open.gif";
		document.getElementById('filepath').value=bid;
		if(window.explorer){
			explorer.location.href='backstage.php?'+linker+','+bid;
		}
	} else {
//		document.getElementById(branchname).style.display='none';
//		document.getElementById(branch).src="images/exp_closed.gif";
		document.getElementById('filepath').value=bid;
		if(window.explorer){
			explorer.location.href='backstage.php?'+linker+','+bid;
		}
	}
}

	function expandtree(treeid,parentid,poz,clp){
		var treeid=treeid;
		if(parentid!=""){var mydoc=parentid} else {var mydoc=document.getElementById(treeid);}
		switch(mydoc.id.substr(0,3)){
			case "ept" :
				if(mydoc.nodeName=="UL" && mydoc.id!=""){
		//			alert(mydoc.id.slice(0,4)+mydoc.id.slice(6));
					if(clp==0) {createlinkpoz((mydoc.id.slice(0,4)+mydoc.id.slice(6)),poz); clp++;}
					mydoc.style.display='';
				};
			break;
			case "ste" :
				if(clp==0) {createlinkpoz((treeid),poz); clp++;}
				if(mydoc.nodeName=="UL" && mydoc.id!=""){
		//			alert(mydoc.id.slice(0,4)+mydoc.id.slice(6));

					mydoc.style.display='';
				};
			break;
		}
		
//		if(mydoc.id!=expfinish) expandtree('',mydoc.parentNode,poz,expfinish);
		if(mydoc.nodeName!="DIV") expandtree('',mydoc.parentNode,poz,clp);
		
		return false;
	}

	function idento(e){
		if (!e) var e = window.event;
	
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) targ = targ.parentNode;

//		var targi=targ.src;
		return targ;
	}

	function explorerman(th,prx){
		if(th!=""){var md=th;} else {var md=document.getElementById(prx);}
		if(md.childNodes.length>0){
			for(var m=0,mi=md.childNodes.length;m<mi;m++){
//			alert(md.childNodes[m].nodeName);
//			if(md.childNodes[m].id){
//			switch(md.childNodes[m].id.substr(4,3)){
			switch(md.childNodes[m].nodeName){
				case "img":
				if (document.addEventListener) {
					md.childNodes[m].addEventListener('mouseover',function(event){alert(md.childNodes[m])},false);
					md.childNodes[m].addEventListener('mouseout',function(event){alert(md.childNodes[m]);},false);
				} else if (document.attachEvent) {
					md.childNodes[m].attachEvent('onmouseover',function(event){alert(md.childNodes[m]);});
					md.childNodes[m].attachEvent('onmouseout',function(event){alert(md.childNodes[m]);});
				}
				break;
				case "A":
				var myidob=md.childNodes[m];
				if (document.addEventListener) {
					md.childNodes[m].addEventListener('mouseover',function(event){this.style.backgroundColor="#999999";},false);
					md.childNodes[m].addEventListener('mouseout',function(event){this.style.backgroundColor="";},false);
				} else if (document.attachEvent) {
					md.childNodes[m].attachEvent('onmouseover',function(event){myidob.style.backgroundColor="#999999";});
					md.childNodes[m].attachEvent('onmouseout',function(event){myidob.style.backgroundColor="";});
				}
				break;

			}
//			}
				explorerman(md.childNodes[m],prx);
			}
		}
//		alert(md.childNodes.length);
	}

	function createlinkpoz(lpozid,pozi){
		switch(lpozid.substr(0,3)){
			case "ept" :
				document.getElementById('filename').value=document.getElementById(lpozid).parentNode.childNodes[1].innerHTML;
//		if(parentid!=""){mydoc=parentid} else {mydoc=document.getElementById(treeid)}
		if(document.getElementById('linkpoz')){
//			alert(lpozid.substr(0,4)+"my"+lpozid.substr(4));
			if((mydoc=document.getElementById(lpozid.substr(0,4)+"my"+lpozid.substr(4)))){
				var allmychild=mydoc.childNodes.length;
			} else {var allmychild=0;}
			
			var doclpoz=document.getElementById('linkpoz');
			doclpoz.length=2;
			var itr=0;
			var itw=0;
			
			if(allmychild>0 && mydoc.nodeName=="UL" && mydoc.id!=""){
				for(var i=0;i<allmychild;i++){
					if(mydoc.childNodes[i].nodeName=="LI"){
						itr=doclpoz.length;
//						alert(itr)
						if(itw!=(pozi-1)){
							doclpoz.length+=1;
//							alert(mydoc.childNodes[i].childNodes[2].innerHTML);
							doclpoz.options[itr].text="po "+mydoc.childNodes[i].childNodes[1].innerHTML;
							doclpoz.options[itr].value=itw+1.5;
							itw+=1;
						} else {itw+=1;}
					}
				}
			}
			if(pozi) doclpoz.value=parseInt(pozi)-.5;
		}
			break;
			case "ste" :
//			alert(lpozid+"= sss ="+document.getElementById(lpozid).parentNode.childNodes[2].innerHTML);
				document.getElementById('slinkname').value=document.getElementById(lpozid).parentNode.childNodes[1].innerHTML;
			break;
		}

		return false;
	}


function openActiveDoc(actdoc){
	if(actdoc){
//		javascript:void(setmyWindow(\'cc\'+((!maxindex)?100:maxindex),\'700\',\'500\',\'backstage.php?6,%activedocument%\',\'\',\'\'));
		openDocBox('backstage.php?6,'+actdoc,'edycjadokumentu','editdocbox','editdocsrc');
//		javascript:openDocBox(\'backstage.php?4\',\'srvkatalog\',\'srvkatbox\',\'srvkatalog\');
//		setmyWindow('cc'+((!maxindex)?100:maxindex),'700','500','backstage.php?6,'+actdoc,'','');
	} else {
		alert("Nie wybrano dokumentu do edycji,\nproszę otworzyć dokument na stronie lub skorzystać z eksploratora");
	}
}

function openDoc(panel,psrc,wid,hei,posx,posy){
//	parent.showDialog('wdpanel','backstage.php?6,'+document.getElementById('fileid').value, 600, 550);"
}

function checkDuplicateFile(){
	
}

/*
opis parametrow okna
0 lub pusty - nie dzieje sie nic
1 - po wykonaniu zamyka

*/

function saveasDoc(ifpanel,forma,fid,fname,fpath){
//	closeDialog(panel,ifpanel);
//alert(eval(ifpanel+".wndback"));
//		ifpanel=ifpanel.substr(0,ifpanel.length-2);
		
//		alert(ifpanel);
// t1		top.frames[eval(ifpanel+".wndback")+"if"].xinhasend();
//		alert(eval(ifpanel+".wndback"));
		ifpanel=newWBox[1]['sexpbox']['referer'];
		if(fid!="") ifpanel.getElementById('fileid').value=fid;
		ifpanel.getElementById('filename').value=fname;
		ifpanel.getElementById('filepath').value=fpath;
		ifpanel.getElementById(forma).submit();

		closeW('sexpbox','sexpsrc');

/*
		switch(eval(ifpanel+".srcparam")){
			case 1:
				document.body.removeChild(document.getElementById(ifpanel+"e"));
			break;
		}
*/
}

function saveas(okienko){
//	okienko.document.getElementById('parentwindow').value=okienko;
//	okienko=okienko.substr(0,okienko.length-2);
	okienko.wndback=okienko;
//	eval(okienko+".wndback='"+okienko+"'");
//	alert(eval(okienko+".wndback"));
	wndname=okienko;
	openDocBox('backstage.php?8','saveeksplorator','sexpbox','sexpsrc');
	newWBox[1]['sexpbox']['referer']=okienko;
//	setmyWindow('cc'+((!maxindex)?100:maxindex),'700','500','backstage.php?8', okienko, 1);
}

function saveDoc(panel,ifpanel,forma,okienko){
//	alert(okienko);
//	okienko=okienko.substr(0,okienko.length-2);

//	if(top.frames[okienko+"if"].document.getElementById('newdoc').value==0){
	if(okienko.getElementById('newdoc').value==0){
		saveas(okienko);
//		setmyWindow('cc'+((!maxindex)?100:maxindex),'700','500','backstage.php?8');
		alert("To jest nowo utworzony dokument, proszę wybrać katalog w którym ma być zapisany");
//		showDialog('wdpanel','backstage.php?8',500,400);
	} else {
// t1		xinhasend();
		okienko.getElementById(forma).submit();
//		with(top.frames[okienko+"if"].document.getElementById(forma)){
//			submit();
//		}
	}
}

function publikujgdzie(pblob,plink){
	if(plink=='0') {alert("Proszę wybrać link w którym ma zostać opublikowany dokument");
	} else {
//		document.getElementById("publikacja").action="backstage.php?9";
		pblob.getElementById("publikacja").submit();
	}
	
}

function publikuj(fid,statid){
	if(statid==0){
		openDocBox('backstage.php?8','saveeksplorator','sexpbox','sexpsrc');
//		setmyWindow('cc'+((!maxindex)?100:maxindex),'700','500','backstage.php?8');
		alert("To jest nowo utworzony dokument, aby mógł zostać opublikowany, najpierw musi zostać zapisany!");
	} else {
		openDocBox('backstage.php?16,'+fid,'publikacja','publicbox','publicsrc');
//		setmyWindow('cc'+((!maxindex)?100:maxindex),'400','420','backstage.php?16,'+fid);
	}
}

function publikujlink(fid,statid){
//	if(statid==0){
//		setmyWindow('cc'+((!maxindex)?100:maxindex),'700','500','backstage.php?8');
//		alert("To jest nowo utworzony dokument, aby mógł zostać opublikowany, najpierw proszę go zapisać");
//	} else {
		openDocBox('backstage.php?35,'+fid+','+statid,'saveeksplorator','sexpbox','sexpsrc');
//		setmyWindow('cc'+((!maxindex)?100:maxindex),'400','420','backstage.php?35,'+fid+','+statid);
//	}
}

function savepublikuj(){
		
}

function divshowmanager(shdiv,alldiv){
	for(xd=0,xda=alldiv.length;xd<xda;xd++){
		document.getElementById(alldiv[xd]).style.display='none';
	}
		document.getElementById(shdiv).style.display='';
//		document.getElementById('opcje').value=shdiv;
}

/*
function getWdSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
//	alert("1 = "+document.body.offsetHeight);
//	alert("2 = "+document.documentElement.clientHeight);
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return Array(myWidth,myHeight);
}
*/

var maxindex=100;

function registerwindow(){
	regwindow.push();
}

/*
function startdrag(moveob){

if(moveob){
		posx = moveob.style.left;
		posy = moveob.style.top;
		
		maxindex+=1;
		moveob.style.zIndex=maxindex;
}
*/

var gie = document.all;
var gnn6 = document.getElementById && !document.all;
var mouseDownX, mouseDownY;
var curobject;
var startX, startY;

function startDrag(e, myobject){

	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) targ = targ.parentNode;

	if(myobject && targ.id!="przykrywka"){
	mouseDownX = gnn6 ? e.clientX : event.clientX;
	mouseDownY = gnn6 ? e.clientY : event.clientY;	

	curobject = document.getElementById(myobject+"e");
	maxindex++;
	curobject.style.zIndex=maxindex;
//	alert(document.getElementById(myobject+"e").style[0]);
	startX = parseInt(curobject.style.left);
	startY = parseInt(curobject.style.top);
	
	var przykrywka = createprzykrywka();
	
//	document.getElementById('przykrywka');
	przykrywka.style.width = window.document.body.scrollWidth + "px";
	przykrywka.style.height = window.document.body.scrollHeight + "px";
	curtype='mov';
	przykrywka.style.cursor = 'move';
	przykrywka.style.display = 'block';
	przykrywka.style.visibility="visible";
	}
}

function evtClick(e, myobject){
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) targ = targ.parentNode;

		mouseDownX = gnn6 ? e.clientX : event.clientX;
		mouseDownY = gnn6 ? e.clientY : event.clientY;	
	
		curobject = document.getElementById(myobject+"e");
		maxindex++;
		curobject.style.zIndex=maxindex;
//		alert(targ.id);
switch(targ.id){
	case myobject:
	case myobject+"3d":
	//	alert(document.getElementById(myobject+"e").style[0]);
		startX = parseInt(curobject.style.left);
		startY = parseInt(curobject.style.top);
		
		var przykrywka = createprzykrywka(); //document.getElementById('przykrywka');
		wdSize=window.getWdSize();
/*		przykrywka.style.width = window.document.body.scrollWidth + "px";
		przykrywka.style.height = window.document.body.scrollHeight + "px"; */
		przykrywka.style.width = wdSize[0] + "px";
		przykrywka.style.height = wdSize[1] + "px";
		
		curtype='mov';
		przykrywka.style.cursor = 'move';
		przykrywka.style.display = 'block';
		przykrywka.style.visibility="visible";
//		document.title=getWdSize()[0];
	break;
	case myobject+"res":
/*
		mouseDownX = gnn6 ? e.clientX : event.clientX;
		mouseDownY = gnn6 ? e.clientY : event.clientY;	
	
		curobject = document.getElementById(myobject+"e");
		maxindex++;
		curobject.style.zIndex=maxindex;
*/

		top.frames[myobject+"if"].document.body.scroll="no";
		document.getElementById(myobject+"if").style.overflow="hidden";
//		top.frames[myobject+"if"].document.body.style.display="none";
		document.getElementById(myobject+"if").style.visibility="hidden";
		
		curtypeid=myobject;
	//	alert(document.getElementById(myobject+"e").style[0]);
		startX = parseInt(curobject.style.left);
		startY = parseInt(curobject.style.top);
		
		var przykrywka = createprzykrywka(); //document.getElementById('przykrywka');
		wdSize=window.getWdSize();
		przykrywka.style.width = wdSize[0] + "px";
		przykrywka.style.height = wdSize[1] + "px";

/*		przykrywka.style.width = window.document.body.scrollWidth + "px";
		przykrywka.style.height = window.document.body.scrollHeight + "px";*/
		curtype='res';
		przykrywka.style.cursor = 'se-resize';
		przykrywka.style.display = 'block';
		przykrywka.style.visibility="visible";
	break;
	case myobject+"ahr":
		document.body.removeChild(curobject);
	break;
	
	}
/*
	if(myobject && targ.id!="przykrywka"){
	mouseDownX = gnn6 ? e.clientX : event.clientX;
	mouseDownY = gnn6 ? e.clientY : event.clientY;	

	curobject = document.getElementById(myobject+"e");
	maxindex++;
	curobject.style.zIndex=maxindex;
//	alert(document.getElementById(myobject+"e").style[0]);
	startX = parseInt(curobject.style.left);
	startY = parseInt(curobject.style.top);
	
	var przykrywka = document.getElementById('przykrywka');
	przykrywka.style.width = window.document.body.scrollWidth + "px";
	przykrywka.style.height = window.document.body.scrollHeight + "px";
	curtype='mov';
	przykrywka.style.cursor = 'move';
	przykrywka.style.display = 'block';
	przykrywka.style.visibility="visible";
	} */
}

function startRes(e, myobject){

	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) targ = targ.parentNode;

	if(myobject && targ.id!="przykrywka"){
	mouseDownX = gnn6 ? e.clientX : event.clientX;
	mouseDownY = gnn6 ? e.clientY : event.clientY;	

	curobject = document.getElementById(myobject+"e");
	maxindex++;
	curobject.style.zIndex=maxindex;
	curtypeid=myobject;
//	alert(document.getElementById(myobject+"e").style[0]);
	startX = parseInt(curobject.style.left);
	startY = parseInt(curobject.style.top);
	
	var przykrywka = createprzykrywka(); // document.getElementById('przykrywka');
	przykrywka.style.width = window.document.body.scrollWidth + "px";
	przykrywka.style.height = window.document.body.scrollHeight + "px";
	curtype='res';
	przykrywka.style.cursor = 'move';
	przykrywka.style.display = 'block';
	przykrywka.style.visibility="visible";
	
	}
}

function getposition(e){
	if(curobject){
//document.body.onmousemove=function(e){
//document.getElementById('dragCover').onmousemove=function(e){
	/*
	if(!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}
	*/
	if(curtype=="mov"){
		var posx = gnn6 ? startX + e.clientX - mouseDownX : startX + event.clientX - mouseDownX;
		//left = Math.max(left, 0);
		//left = Math.min(left, document.body.clientWidth - parseInt(gCurrContainer.style.width));
		curobject.style.left = posx+"px";
    	
		var posy = gnn6 ? startY + e.clientY - mouseDownY : startY + event.clientY - mouseDownY;
    	//top = Math.max(top, 0);
    	//top = Math.min(top, document.body.clientHeight - parseInt(gCurrContainer.style.height) - 4);
    	curobject.style.top = posy+"px";
	} else if(curtype=="res"){
		var posx = gnn6 ? e.clientX - startX  : event.clientX - startX ;
		curobject.style.width = posx+"px";
    	
		var posy = gnn6 ? e.clientY  - startY : event.clientY - startY ;
		document.getElementById(curtypeid+"if").style.height=posy-43+"px";
		document.getElementById(curtypeid+"if").style.width=posx-10+"px";
    	curobject.style.height = posy+"px";
	}
//	przesun(posx,posy);
	}
	return false;
}

/*
function stopDrag(e){
//document.body.onmouseup=function(e){
//document.getElementById('dragCover').onmouseup=function(){
//	alert(curobject.id.substr(0,curobject.id.length-1));
//alert(document.getElementById(curobject.id.substr(0,curobject.id.length-1)+"if").id);
//	alert(parent.document.getElementById(curobject.id.substr(0,curobject.id.length-1)));
//	insideres(top.frames[curobject.id.substr(0,curobject.id.length-1)+"if"]);
//	insideres(curobject); // linia inicjujaca funkcje odpowiedzialna za skalowanie elementow w oknach, uruchamiana na koniec skalowania lub przeciagania okna
	var przykrywka = createprzykrywka(); // document.getElementById('przykrywka');
	przykrywka.style.cursor = 'default';
	przykrywka.style.display = 'none';
	przykrywka.style.visibility="hidden";
	setTimeout("delaysetres('"+(curobject.id.substr(0,curobject.id.length-1)+"if")+"')",200); //opoznienie zmiany rozmiarow obiektow w oknie
//	insideres(top.frames[curobject.id.substr(0,curobject.id.length-1)+"if"]);
//	top.frames[curobject.id.substr(0,curobject.id.length-1)+"if"].document.body.scroll="auto";
//	document.getElementById(curobject.id.substr(0,curobject.id.length-1)+"e").style.filter="alpha(opacity=20)";
	activeobject="";
	curobject="";
	curobject=false;
}
*/

function delaysetres(delyob){ // opozniona zmiana rozmiarow obiektow w oknie
	insideres(top.frames[delyob]);
	top.frames[delyob].document.body.scroll="auto";
	document.getElementById(delyob).style.overflow="auto";
	document.getElementById(delyob).style.visibility="visible";
}

//return posx;
//}
//	startmove();
//	alert(ruchomyobjekt.id);
//	ruchomyobjekt.style.left=event.x;
//	ruchomyobjekt.style.top=event.y;
//	przesun=setTimeout(startdrag,200)

//}

function przesun(pozyx,pozyy){
	if(activeobject!=""){
//		cpozx=activeobject.style.left;
//		cpozy=activeobject.style.top;
		activeobject.style.left=pozyx-245+"px";
		activeobject.style.top=pozyy-5+"px";
//		activeobject.style.left = cpozx+(pozyx-cpozx)*0.1
//		activeobject.style.top = cpozy+(pozyy-cpozy)*0.1
//		thCos = Math.abs(pozyx-cpozx);
//		thSos = Math.abs(pozyy-cpozy);
//		if((thCos < 0.8) && (thSos <0.8)){
//			activeobject="";
//		}
	}
}

function setnewindex(obje){
	maxindex+=1;
	document.getElementById(obje+"e").style.zIndex=maxindex;
}

wndname="";

/*
function setmyWindow(myid,wwiedth,wheight,opwname, srcwindwow, srcaction){
	(!maxindex)?maxindex=100:maxindex+=1; 
//	window.scrollbars=false;
	document.body.style.overflow='hidden';
	eval(myid+"=new mywindow()");
	eval(myid+".createwindow(myid,wwiedth,wheight,opwname,srcwindwow,srcaction)");
}
*/

/*
function mywindow(){
//	var maxindex+=1;
	this.namex="";
	this.wndback="";
	this.createwindow=createwnd;
	
	function createwnd(setparent,mywidthe,myheighte,wndname,srcwnd,srcact){
//	this.namex=setparent;
	
		switch(srcact){
			case 1:
				this.wndback=srcwnd;
			break;
		}
		
		this.srcparam=srcact;
	
		var nazwax=setparent;
		this.myDiv=document.createElement("div");
		with(this.myDiv){
			id=nazwax+"e";
			name=nazwax+"e";
			width=mywidthe;
			height=myheighte;
			style.display="block";
			style.width=mywidthe+"px";
			style.height=myheighte+"px";
			className="pozycja";
//		style.position="fixed !important";
//		style.position="absolute";
			style.left=window.document.body.scrollWidth/2-mywidthe/2+"px";
			style.top="60px";
			style.zIndex=maxindex;
			style.backgroundColor="#CCCCCC";
		}
		
//	alert("iddiva"+this.myDiv.id);
		
		this.my2Div=document.createElement("div");
		with(this.my2Div){
			id=nazwax+"ut";
			name=nazwax+"ut";
//			setAttribute("value",nazwax);
//			value=nazwax;

//			style.width="100%";//(mywidthe-20)+"px";
//			style.height="20px";
//			style.backgroundImage="url(images/windowtop.gif)";
//		style.styleFloat="left";
//		style.cssFloat="left";
//			style.display="block";
//			mytext=nazwax;
			className="dmxwdutitle";

//		onclick=function()
//		onmousedown=function(event){startDrag(event, gnn6 ? this.value : this.id);}
//		addEventListener('onclick',function(event){startDrag(event, gnn6 ? this.value : this.id);},false)
	
//		onmouseup=function(event){stopDrag(event);}
//		onmouseup=function(){activeobject="";}
			innerHTML="Untitled";
		}
	
		this.myAhref=document.createElement("div");
		with(this.myAhref){
//		innerHTML="<img src=\"images/windowclose.gif\" width=\"20\" height=\"20\" align=\"right\" border=\"0\">";
//		href="javascript:void(document.body.removeChild(document.getElementById('"+nazwax+"e')));";
			id=nazwax+"ahr";
			name=nazwax+"ahr";
			className="dmxwdclose";
		}
		
		this.my3Div=document.createElement("div");
		with(this.my3Div){
			id=nazwax+"3d";
			name=nazwax+"3d";
			className="dmxwdtitle";
//		onclick=function(){mymove=1;}
//			startdrag(document.getElementById(document.getElementById(nazwax).parentNode.id));
//		}
//		onmouseup=function(){stopdrag();}
//		onmouseup=function(){startdrag();}
//			innerHTML="Untitled";
		}
	
		this.myIframe=document.createElement("iframe");
		with(this.myIframe){
			id=nazwax+"if";
			name=nazwax+"if";
			src=wndname;
			
			frameBorder="no";
			marginHeight=0;
			marginWidth=0;
			style.height=(myheighte-43)+"px";
			style.width=(mywidthe-10)+"px";			
			className="dmxwdiframe";
		}
*/

/*
		this.myTitle=document.createElement("input");
		with(this.myTitle){
		type="text";
		id=nazwax+"tlt";
		name=nazwax+"tlt";
		className="dmxwdinpTitle";
		value="asdfasdf";
		}
*/

/*
		this.myInput=document.createElement("input");
		with(this.myInput){
		type="hidden";
		id="rep";
		name="rep";
		value=nazwax;
		style.height='20px';
		}
	
		this.myRes=document.createElement("div");
		with(this.myRes){
			id=nazwax+"res";
			name=nazwax+"res";
			className="dmxwdres";
		}
	
		this.myDiv.appendChild(this.my2Div);
		this.myDiv.appendChild(this.my3Div);
//		this.my3Div.appendChild(this.myTitle);
		this.myDiv.appendChild(this.myAhref);
//	my2Div.appendChild(myAhref);
	
		this.myDiv.appendChild(this.myIframe);
		this.myDiv.appendChild(this.myRes);
		this.myDiv.appendChild(this.myInput);
		var newWnd=document.body.appendChild(this.myDiv);
		
		eval(nazwax+"if.window.name='"+(nazwax+"if")+"'");

		if (document.addEventListener) {
			this.myDiv.addEventListener('mousedown',function(event){evtClick(event,nazwax)},false);
//			this.my2Div.addEventListener('mousedown',function(event){evtClick(event,nazwax)},false);
//			this.my3Div.addEventListener('mousedown',function(event){evtClick(event,nazwax)},false);
//		this.myDiv.addEventListener('click',function(event){evtClick(event,nazwax)},false);
			this.my2Div.addEventListener('mouseup',function(event){stopDrag(event);},false);
//		this.myAhref.addEventListener('click',function(event){startClick(event,nazwax)},false);
//			this.myIframe.addEventListener('load',function(){setdmxtitle(nazwax); setdmxcontent(nazwax)},false)
			this.myIframe.addEventListener('mousedown',function(event){evtClick(event,nazwax)},false);
		} else if (document.attachEvent) {
			this.myDiv.attachEvent('onmousedown',function(event){evtClick(event, nazwax);});
			this.my2Div.attachEvent('onmousedown',function(event){stopDrag(event);});
//			this.myIframe.attachEvent('onload',function(){setdmxtitle(nazwax); setdmxcontent(nazwax)})
			this.myIframe.attachEvent('onmousedown',function(event){evtClick(event, nazwax);});
		}
		
//	this.my2Div.addEventListener('mouseup',function(event){stopDrag(event,nazwax)},false)

//	if(setparent!="aaa"){
//		wndname=setparent;
//		window[nazwax+"if"].document.getElementById('parentwindow').value=setparent;
//	}
	}

}
*/

	function setdmxcontent(targi){
		insideres(targi);
/*
		if(insideres(top.frames[targi])){
//			insideres(top.frames[targi]); //dla opery
		} else {
			insideres(top.frames[targi+"if"]);
		}
*/
	}

	function setdmxtitle(targi){
//		alert(top.frames[targi+"if"][targi+"3d"].innerText);
		if(targi.dmxtitle){
			parent.document.getElementById(targi.name.substr(0,targi.name.length-2)+"ut").innerHTML=targi.dmxtitle;
		}

/*
		if(top.frames[targi+"if"].dmxtitle){
			document.getElementById(targi).innerHTML=top.frames[targi+"if"].dmxtitle;
		}
*/
	}


	function zaznacz(path){
		document.getElementById('adres').value=sciezka+path;
		if(path!=".."){
			zaznczas=setTimeout("zaznaczenie('"+path+"')",500);
		}
	}
	
	function odznacz(){
		clearTimeout(zaznczas);
		if(zaznaczone) document.getElementById('adres').value=sciezka+zaznaczone;
	}
	
	function zaznaczenie(tid){
		if(zaznaczone) document.getElementById(zaznaczone).style.background="";
		zaznaczone=tid;
		document.getElementById(zaznaczone).style.background="#cccccc";
	}



function czy_puste(nazwa,messagex,form_name,send_action){
//	telwzor=/^[0-9\-\s\(\)]*$/;
	ppuste="";
		for(pp=0,ppx=nazwa.length;pp<ppx;pp++){
			nazwa_arr=nazwa[pp].split('|');
			switch(nazwa_arr[2]){
				case "mailtest":
					emailwzor=/^[0-9a-zA-Z\.\-\_]+\@(([0-9a-zA-Z\-])+\.)+([0-9a-zA-Z\-])+$/;
					if(document.forms[form_name].elements[nazwa_arr[0]].value!="" && emailwzor.test(document.forms[form_name].elements[nazwa_arr[0]].value)==false) ppuste+=nazwa_arr[1]+"\n";
				break;
				case "porownaj":
					dopor=nazwa_arr[0].split(':');
					if(document.forms[form_name].elements[dopor[0]].value!=document.forms[form_name].elements[dopor[1]].value) ppuste+=nazwa_arr[1]+"\n";
				break;
				case "haslo":
					haslowzor=/^[\D\d]{4,8}$/;
					if(haslowzor.test(document.forms[form_name].elements[nazwa_arr[0]].value)==false) ppuste+=nazwa_arr[1]+"\n";
				break;
				case "issetin":
					dopor=nazwa_arr[0].split(':');
					for(dop=0,dopi=eval(dopor[1]).length;dop<dopi;dop++){
						if(document.forms[form_name].elements[dopor[0]].value!='' && document.forms[form_name].elements[dopor[0]].value==eval(dopor[1])[dop]) ppuste+=nazwa_arr[1]+"\n";
					}
				break;
				default:
					if(document.forms[form_name].elements[nazwa_arr[0]].value=="") ppuste+=nazwa_arr[1]+"\n";
				break;
			}
		}
	if(ppuste==""){document[form_name].action=send_action;document[form_name].submit();} else {alert('uzupełnij lub popraw wymienione poniżej pola\n'+ppuste);}
//	return pustepole;
}
