maxindex=1000;popups=new Array();forms=new Array();function findPos(a){var b=curtop=0;if(a.offsetParent){do{b+=a.offsetLeft;curtop+=a.offsetTop}while(a=a.offsetParent)}return[b,curtop]}function windowSize(){var b=0,a=0;if(typeof(window.innerWidth)=="number"){b=window.innerWidth;a=window.innerHeight}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){b=document.documentElement.clientWidth;a=document.documentElement.clientHeight}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){b=document.body.clientWidth;a=document.body.clientHeight}}}return[b,a]}function chkelement(a,c,d){if(d){var b=new Request.HTML({url:"index.php?p=popup_"+a+"&"+d+"="+encodeURIComponent($(c).value)});b.send();return}}function createpopup(c,g,b,f,e){if(popups[c]){return openpopup(c)}forms[c]=new Array();var a=new Element("div",{id:"popup_"+c,"class":"popup"});$(document.body).adopt(a);a.innerHTML='<div id="handle_'+c+'" class="popup-title"><h3 id="caption_'+c+'">'+g+"</h3><a href=\"javascript:closepopup('"+c+'\');" class="close">&nbsp;&nbsp;&nbsp;</a></div><div class="popup-content" id="content_'+c+'">'+b+"</div>";popups[c]=new Drag.Move(a,{handle:$("handle_"+c),onStart:function(h){h.fade(0.8);h.style.zIndex=(++maxindex)},onComplete:function(h){h.fade(1)}});if(typeof(f)!="undefined"){a.style.left=Math.min(f[0],430)+"px";a.style.top=Math.min(f[1],300)+"px"}else{var d=windowSize();a.style.left=(Math.max(((d[0]-parseInt(a.clientWidth))/2),50))+"px";a.style.top=(Math.max(((d[1]-parseInt(a.clientHeight))/2),50))+"px"}if(e){openpopup(c)}}function loadpopup(a,c,e){if(popups[a]){return openpopup(a)}var d="";if(typeof(e)!="undefined"){d=e}forms[a]=new Array();var b=new Request.HTML({url:"index.php?p=popup_"+a+d,onSuccess:function(i,g,k,j){closepopup(a);if((!$chk($("popup_"+a)))||(k.length<2)){return}var f=$("popup_"+a);f.set("html",k);if(typeof(c)!="undefined"){f.style.left=Math.min(c[0],430)+"px";f.style.top=Math.min(c[1],300)+"px"}else{var h=windowSize();f.style.left=(Math.max(((h[0]-parseInt(f.clientWidth))/2),50))+"px";f.style.top=(Math.max(((h[1]-parseInt(f.clientHeight))/2),50))+"px"}openpopup(a);popups[a]=new Drag.Move(f,{handle:$("handle_"+a),onStart:function(l){l.fade(0.8);l.style.zIndex=(++maxindex)},onComplete:function(l){l.fade(1)}})},onFailure:function(){alert("Connection error: Cannot load requested information!")}});openpopup(a);$("popup_"+a).set("html",$("pleasewait").get("html"));b.send()}function poptxt(b,a,c){alert(a);if(c==1){clearpopup(b)}}function setsel(e,d){var b=parseInt(d);var a=$(e);if(!(b>=0)||(!$chk(a))){return}for(var f=0;f<a.length;f++){if(a[f].value==d){return a.selectedIndex=f}}}function closepopup(a){var b=$("popup_"+a);b.fade(0)}function openpopup(a){if(!$chk($("popup_"+a))){return}var b=$("popup_"+a);b.style.zIndex=(++maxindex);b.fade(1)}function clearpopup(a){$("popup_"+a).set("text","");$("popup_"+a).fade("hide");popups[a]=null}function refreshpopup(b,a){if(popups[b]){var c=findPos($("popup_"+b));clearpopup(b);loadpopup(b,c,a)}else{loadpopup(b,[100,100],a)}}function enableform(a,b){if(forms[a][b]){delete forms[a][b]}}function disableform(a,b){forms[a][b]=true}function attachform(a,d){var c="";if(typeof(d)!="undefined"){c=d}var b=new Request.HTML({url:"index.php?p=popup_"+a+c,method:"post",evalScripts:true,onSuccess:function(f,e,h,g){if(g.indexOf("poptxt")<0){clearpopup(a)}},onFailure:function(){alert("Connection error: Cannot process requested information!")}});if($chk($(a+"_secimg"))){$(a+"_secimg").src=""}b.send($(a+"form"));return false}function openmacro(b,a){if(b>0){loadpopup("macro"+a,[300,100],"&prod="+b+"&s="+(a+3))}else{loadpopup("macro"+Math.abs(a),[300,100],"&prod=0&s="+a)}};
