// joker@joker.art.pl
// la_mo_16.06.06



photowindow_op = null;

function photowindow(url, nazwa, width, height){
  if (photowindow_op) photowindow_op.close();
  width += 18;
  height += 18;
	params = "status=no, statusbar=no, menubar=no, scrollbars=no, resizeable=yes, toolbar=no, location=no, directories=no, left=20, top=20, width=" + width + ", height=" + height;	
  photowindow_op = window.open(url, 'photobig', params);
  photowindow_op.focus();
}


function check(url, co) {
	if (confirm(co)) { 
		window.location.replace(url); 
	} else { 
		return false;
	}
}


function checksubmit(a, co) {
	if (confirm(co)) { 
		a.submit(); 
	} else { 
		return false;
	}
}


function io_onchange(foremka, aa, bb) {
	arr=new Array();
	if (bb.match(',')) arr=bb.split(',');
	else arr.push(bb);
	for (i=0; i<arr.length; i++) {
		if (aa.checked) {
			foremka.elements[arr[i]].disabled=true;
		} else {
			foremka.elements[arr[i]].disabled=false;
		}
	}
}


function openDialogWin(file,name) {
	if (arguments.length>=3) {
		ww=arguments[2]
	} else {
		ww=500;
	}
	if (arguments.length==4) {
		wh=arguments[3]
	} else {
		wh=400;
	}
	leftnw = (window.screen.availWidth - ww )/2;
	topnw = (window.screen.availHeight - wh)/2;
	window.open(file,name, 'toolbar=no,status=no,resizable=yes,scrollbars=yes,scrollable=yes,dependent=yes,top='+topnw+',left='+leftnw+',width='+ww+',height='+wh);
}

function openDialogWinFB(file,name) {
		ww=600;
		wh=400;
	leftnw = (window.screen.availWidth - ww )/2;
	topnw = (window.screen.availHeight - wh)/2;
	window.open(file,name, 'toolbar=no,status=yes,resizable=no,scrollbars=no,scrollable=no,dependent=yes,top='+topnw+',left='+leftnw+',width='+ww+',height='+wh);
}

function openOutFile(file,name) {
	window.open(file,name, 'scrollbars=yes, resizeable=yes, width=600, height=500');
}

function outFileSetSelect(id,val) {
	opener.document.getElementById(id).value=val;
	window.close();
}

function jform_collapse(idel, a, b) {
	ob = document.getElementById(idel);
	img = document.getElementById('jform_collapse_img_'+idel);
	if (ob.style.height==b+'px') {
		ob.style.height=a+'px';
		img.src='gfx/up.gif';
	} else {
		ob.style.height=b+'px';
		img.src='gfx/down.gif';
	}
}

function rel1n_sel(fid, fidv, fs, fsv) {
	opener.document.getElementById(fid).value=fidv;
	opener.document.getElementById(fs).value=fsv;
	window.close();
}

function winjs_url(wtitle, ww,wh, wt, wl, wurl) {

	if (wt==0) {
		wl = (window.screen.availWidth - ww )/2;
		wt = (window.screen.availHeight - wh)/2 -80;
	}
	
	wname = 'nw1'+Math.random();
	win = new Window(wname, {title: wtitle, opacity: 0.95, width:ww, height:wh, top:wt, left:wl, showEffect:Element.show, hideEffect: Effect.SwitchOff, maximizable:true, minimizable:true, closable:true, resizable:true, url: wurl});   
	win.setDestroyOnClose();
	win.show();
}

function winjs_txt(wtitle, ww, wh, wt, wl, wtxt) {
	if (wt==0) {
		wl = (window.screen.availWidth - ww)/2;
		wt = (window.screen.availHeight - wh)/2-80;
	}
	wname = 'nw1'+Math.random();
	win = new Window(wname, {title: wtitle, opacity: 0.95, showEffect:Element.show, hideEffect: Effect.SwitchOff, width:ww, height:wh, top:wt, left:wl, maximizable:true, minimizable:true, closable:true, resizable:true});   
	win.getContent().innerHTML=wtxt;
	win.setDestroyOnClose();
	win.show();
}

function winjs_pure_url(wtitle, ww, wh, wt, wl, wurl) {
	if (wt==0) {
		wl = (window.screen.availWidth - ww )/2;
		wt = (window.screen.availHeight - wh)/2-80;
	}
	wname = 'nw1'+Math.random();
	win = new Window(wname, {title: wtitle, opacity: 0.95, showEffect:Element.show, hideEffect: Effect.SwitchOff, width:ww, height:wh, top:wt, left:wl, maximizable:false, minimizable:false, closable:true, resizable:false, url: wurl});   
	win.setDestroyOnClose();
	win.show();
}

function winjs_pure_txt(wtitle, ww,wh, wt, wl, wtxt) {
	if (wt==0) {
		wl = (window.screen.availWidth - ww )/2;
		wt = (window.screen.availHeight - wh)/2-80;
	}
	wname = 'nw1'+Math.random();
	win = new Window(wname, {title: wtitle, opacity: 0.95, showEffect:Element.show, hideEffect: Effect.SwitchOff, width:ww, height:wh, top:wt, left:wl, maximizable:false, minimizable:false, closable:true, resizable:false});   
	win.setDestroyOnClose();
	win.getContent().innerHTML=wtxt;
	win.show();
}

function setCookie(cookieName,cookieValue,nSec) {
 var today = new Date();
 var expire = new Date();
 if (nSec==null || nSec==0) nSec=3600;
 expire.setTime(today.getTime() + 1000*nSec);
 document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString();
}


function collapseGroup(elementid) {
	el=document.getElementById(elementid);
	
	mainelid = el.getAttribute('CONNECT');
	mainel = document.getElementById(mainelid);
	imgon = el.getAttribute('ONACTIVE');
	imgoff = el.getAttribute('ONUNACTIVE');
	imagecollapse = document.getElementById(elementid+'_cimg');
	if (mainel.style.display=='none') {
		setCookie(elementid,'on',3600);
		mainel.style.display='block';
		imagecollapse.src=imgon;
	} else {
		setCookie(elementid,'off',3600);
		mainel.style.display='none';
		imagecollapse.src=imgoff;
	}
}

function collapseElement(elementid) {
	el=document.getElementById(elementid);
	
	if (el.style.display=='none') {
		el.style.display='block';
	} else {
		el.style.display='none';
	}
}

function jdbet_chpass(crypto, dest, src1, src2) {
	
	s1=document.getElementById(src1).value;
	s2=document.getElementById(src2).value;

	if (s1==s2 & s1!='') {
		if (crypto=='md5')
			opener.document.getElementById(dest).value=hex_md5(s1);
		else 
			opener.document.getElementById(dest).value=s1;
		window.close();
	} else if (s1=='') {
		alert('Hasło nie może być puste');
		return false;
	} else if (s1!=s2) {
		alert('Hasło i powtórzenie nie zgadzają się!');
		return false;
	} 
	
}
