// DBX2.05 :: Docking Boxes (dbx)
// *****************************************************
// DOM scripting by brothercake -- http://www.brothercake.com/
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
//******************************************************
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[(function(e){return d[e]})];e=(function(){return'\\w+'});c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('c 6;f 1u(1m){6=4;8(!/^[-3J-3K-9]+$/i.v(1m)){3y(\'3L 3M 1u:\\n"\'+1m+\'" 3w 3O 3v 4y 3P\');u}4.2q=!(q.2V(\'*\').P==0||(1X.2p==\'4A\'&&m O.4t==\'o\'));8(!4.2q){u}4.U=m q.3D!=\'o\'?\'3D\':m q.1O!=\'o\'?\'1O\':\'2N\';4.1a=(4.U==\'1O\'?\'3t\':\'\');8(m O.26!=\'o\'&&4u(1X.4v.4w().1c(/26[\\/ ]/)[1].1c(\' \')[0],10)<7.5){4.U=\'2N\'}8(4.U==\'2N\'){4.2q=s;u}4.21=0;4.1m=1m;4.1F={};4.15=4.3N()};1u.w.3I=f(){c 2m=1Q 4r();2m.4x(2m.4B()+(4C*24*3z*3z*4D));c 2G=\'\';S(j 2h 4.1F){8(m 4.1F[j]!=\'f\'){2G+=j+\'=\'+4.1F[j]+\'&\'}}4.3p=2G.R(/^(.+)&$/,\'$1\');4.2j=4.3p.R(/,/g,\'|\');4.2j=4.2j.R(/=/g,\':\');8(m 4.3r==\'o\'||4.3r()){q.C=\'6-\'+4.1m+\'=\'+4.2j+\'; 4F=\'+2m.4H()+\'; 4I=/\'}};1u.w.3N=f(){4.15=l;8(q.C){8(q.C.4J(\'6-\'+4.1m)!=-1){4.C=q.C.1c(\'6-\'+4.1m+\'=\')[1].1c(\';\')[0].1c(\'&\');S(c i 2h 4.C){8(m 4.C[i]!=\'f\'){4.C[i]=4.C[i].R(/\\|/g,\',\');4.C[i]=4.C[i].R(/:/g,\'=\');4.C[i]=4.C[i].1c(\'=\');4.C[i][1]=4.C[i][1].1c(\',\')}}4.15={};S(i 2h 4.C){8(m 4.C[i]!=\'f\'){4.15[4.C[i][0]]=4.C[i][1]}}}}u 4.15};1u.w.2W=f(Q,16){4.1F[Q]=16};1u.w.1M=f(2P){u m q.3G!=\'o\'?q.3G(\'4L://4N.4O.4P/4Q/4R\',2P):q.1M(2P)};1u.w.1i=f(e,3B,W){8(m W!=\'o\'){c Z=W}19{Z=m e.Z!=\'o\'?e.Z:e.3q}c 3E=1Q 4S(3B,\'\');29(!3E.v(Z.h)){Z=Z.1Y}u Z};f H(Q,2o,3S,3T,3V,2T,2U,J,1z,1y,z,1N,2b,25){8(!/^[-3J-3K-9]+$/i.v(Q)){3y(\'3L 3M H:\\n"\'+Q+\'" 3w 3O 3v B 3P\');u}4.B=q.4X(Q);8(4.B==l||!6.2q){u}c p=4;4.Q=Q;4.1K=s;4.d=l;4.I=2o==\'I\';4.1d=2c(3S,10);4.2L=3T==\'3u\';4.1j=2c(3V,10);4.1R=2T==\'3u\';4.2X=2U!=\'1l\';4.N={\'J\':J,\'1z\':1z,\'1y\':1y,\'z\':z,\'1N\':1N,\'2b\':2b,\'25\':25};4.B.k.1k=\'2E\';4.B.k.1H=\'23\';8(m O.26!=\'o\'){4.B.k.1H=\'3X-2h\'}4.A=[];4.1b=[];4.16=[];4.r=4.B.2V(\'*\');S(c i=0;i<4.r.P;i++){8(/6\\-d/i.v(4.r[i].h)&&!/6\\-X/i.v(4.r[i].h)){4.r[i].k.1k=\'2E\';4.r[i].k.1H=\'23\';4.A.1V(4.r[i]);4.r[i].h+=\' 6-d-J\';4.r[i].h+=\' 2J\'+4.16.P;4.16.1V(4.16.P.3Y()+\'+\');4.r[i][6.U](6.1a+\'2a\',f(e){8(!e){e=O.1p}p.2a(e,6.1i(e,\'6\\-d\'))},s)}8(/6\\-1A/i.v(4.r[i].h)){4.r[i].k.1k=\'2E\';4.r[i].k.1H=\'23\';4.r[i].h+=\' 6-1A-2s\';4.r[i].31(\'1D\',4.r[i].3Z(\'1D\')==l||4.r[i].1D==\'\'?4.N.1y:4.N.25.R(\'%41%\',4.r[i].1D).R(\'%42%\',4.N.1y));8(4.1R){4.1b.1V(4.2Z(4.r[i]))}19{4.r[i][6.U](6.1a+\'43\'+(m q.32!=\'o\'||1X.2p==\'2R 2z, 2A.\'?\'34\':\'35\'),f(e){8(!e){e=O.1p}u p.2M(e,6.1i(e,\'6\\-1A\'))},s);4.r[i][6.U](6.1a+\'1P\',f(e){8(!e){e=O.1p}p.2F(l,6.1i(e,\'6\\-1A\'))},s);4.r[i][6.U](6.1a+\'3s\',f(){p.1C()},s)}}}6.2W(4.Q,4.16.3H(\',\'));c X=4.B.1s(6.1M(\'3k\'));X.h=\'6-d 6-X\';X.k.1H=\'23\';X.k.3Q=\'0\';X.k.3R=\'0\';X.k.46=\'1G\';8(4.I){X.h+=\' 6-47\'}4.A.1V(X);8(6.15!=l&&m 6.15[4.Q]!=\'o\'){c 2u=6.15[4.Q].P;8(2u==4.A.P-1){S(i=0;i<2u;i++){c 2w=2c(6.15[4.Q][i],10);4.B.2B(4.A[2w],X);8(4.1R&&/\\-$/.v(6.15[4.Q][i])){4.2l(4.1b[2w],s)}}4.1L()}}19 8(!4.2X&&4.1R){c Y=4.1b.P;S(i=0;i<Y;i++){4.2l(4.1b[i],E)}}q[6.U](6.1a+\'3f\',f(e){8(m e.Z==\'o\'){e=O.1p;e.2Y=e.48}8(e.2Y==l){p.1W(e)}},s);q[6.U](6.1a+\'28\',f(e){p.28(e);u!p.1K},s);q[6.U](6.1a+\'1W\',f(e){p.1W(e)},s);4.1q=s;q[6.U](6.1a+\'1q\',f(){p.1q=E},s);q[6.U](6.1a+\'3o\',f(){p.1q=s},s)};H.w.2Z=f(){c p=4;c t=1g[0].1s(6.1M(\'a\'));t.1s(q.2H(\'\\49\'));t.k.2s=\'4a\';t.4b=\'4c:4d(l)\';t.h=\'6-z 6-z-J\';t.31(\'1D\',4.N.z.R(\'%z%\',4.N.1z));t.1r=m O.26!=\'o\'||1X.2p==\'2R 2z, 2A.\'?l:s;4.F=l;t.4e=f(){8(4.1r===E||4.1r===l){p.1C();p.2l(4,E)}};t[\'4f\'+(m q.32!=\'o\'||1X.2p==\'2R 2z, 2A.\'?\'34\':\'35\')]=f(e){8(!e){e=O.1p}u p.2M(e,4)};t.4g=f(){c Y=p.1b.P;S(c i=0;i<Y;i++){p.1b[i].h=p.1b[i].h.R(/[ ](6\\-z\\-2n\\-)(J|1l)/,\'\')}c T=(/6\\-z\\-J/.v(4.h));4.h+=\' 6-z-2n-\'+(T?\'J\':\'1l\');p.2F(T,4);4.2O=E;8(4.1r!==l){4.1r=E}};t.4h=f(){4.h=4.h.R(/[ ](6\\-z\\-2n\\-)(J|1l)/,\'\');p.1C();8(4.1r!==l){4.1r=s}};u t};H.w.2l=f(t,3e){c T=(/6\\-z\\-J/.v(t.h));c G=6.1i(l,\'6\\-d\',t);6.d=G;6.z=t;8(m 6.B==\'o\'){6.1o=6.1i(l,\'6\\-1o\',G)}19{6.1o=6.B}8((!T&&(m 6.3b==\'o\'||6.3b()))||(T&&(m 6.3c==\'o\'||6.3c()))){t.h=\'6-z 6-z-\'+(T?\'1l\':\'J\');t.1D=4.N.z.R(\'%z%\',T?4.N.J:4.N.1z);8(m t.2O!=\'o\'){t.h+=\' 6-z-2n-\'+(T?\'1l\':\'J\')}G.h=G.h.R(/[ ](6-d-)(J|1l)/,\' $1\'+(T?\'1l\':\'J\'));8(3e){4.1L()}}};H.w.3x=f(e,K,1e){c G=6.1i(l,\'6\\-d\',K);6.1o=4.B;6.d=G;6.1p=e;8(m 6.2f==\'o\'||6.2f()){c 1Z=[];c Y=4.A.P;S(c i=0;i<Y;i++){1Z[i]=[i,4.A[i][4.I?\'12\':\'13\']];8(G==4.A[i]){4.3g=i}}1Z.4i(4.3j);S(i=0;i<Y;i++){8(1Z[i][0]==4.3g){8((1e&&i<Y-2)||(!1e&&i>0)){c V=4.A[1Z[i+(1e?1:-1)][0]];8(4.1j>0){c 2d={\'x\':G.13,\'y\':G.12};c 3i={\'x\':V.13,\'y\':V.12}}c 2D={\'3h\':(1e?V:G),\'1n\':(1e?G:V)};4.B.2B(2D.3h,2D.1n);8(4.1j>0){c 4k={\'V\':1Q 1S(4,V,3i,4.1j,E,K),\'G\':1Q 1S(4,G,2d,4.1j,E,K)}}19{K.1P()}3l}}}4.1L()}};H.w.3j=f(a,b){u a[1]-b[1]};H.w.2F=f(T,K){8(4.1q){4.F=4.B.1s(6.1M(\'3k\'));4.F.k.17=\'1G\';4.F.h=\'6-F\';8(T!=l){4.F.1s(q.2H(4.N.1N+4.N.2b.R(\'%z%\',T?4.N.1z:4.N.J)))}19{4.F.1s(q.2H(4.N.1N))}c G=6.1i(l,\'6\\-d\',K);4.F.k.2i=G.13+\'1f\';4.F.k.2k=G.12+\'1f\';c F=4.F;O.4m(f(){8(F!=l){F.k.17=\'1J\'}},4n)}};H.w.1C=f(){8(4.F!=l){4.F.1Y.2v(4.F);4.F=l}};H.w.2a=f(e,d){c W=m e.Z!=\'o\'?e.Z:e.3q;8(W.4o==\'#4p\'){W=W.1Y}8(!/6\\-(z|d|1o)/i.v(W.h)){29(!/6\\-(1A|d|1o)/i.v(W.h)){W=W.1Y}}8(/6\\-1A/i.v(W.h)){4.1C();4.2K=s;4.1t={\'x\':e.1w,\'y\':e.1x};4.M={\'x\':0,\'y\':0};4.3U(d);8(m e.1B!=\'o\'){e.1B()}8(m q.2g!=\'o\'){q.2g=f(){u s}}}};H.w.28=f(e){8(4.1K&&4.d!=l){4.1e=4.I?(e.1x>4.M.y?E:s):(e.1w>4.M.x?E:s);4.M={\'x\':e.1w,\'y\':e.1x};c L={\'x\':4.M.x-4.1t.x,\'y\':4.M.y-4.1t.y};8(((L.x>=0&&L.x<=4.1d)||(L.x<=0&&L.x>=0-4.1d))&&((L.y>=0&&L.y<=4.1d)||(L.y<=0&&L.y>=0-4.1d))){4.M.x-=L.x;4.M.y-=L.y}8(4.2K||L.x>4.1d||L.x<(0-4.1d)||L.y>4.1d||L.y<(0-4.1d)){6.1o=4.B;6.d=4.d;6.1p=e;8(m 6.2f==\'o\'||6.2f()){4.2K=E;8(!4.2L||!4.I){4.1h.k.2i=(4.M.x-4.1I.x)+\'1f\'}8(!4.2L||4.I){4.1h.k.2k=(4.M.y-4.1I.y)+\'1f\'}4.2t(4.M.x,4.M.y);8(m e.1B!=\'o\'){e.1B()}}}}u E};H.w.1W=f(e){8(4.d!=l){4.2t(e.1w,e.1x);4.3a();4.1L();8(m q.2g!=\'o\'){q.2g=f(){u E}}}4.1K=s};H.w.2M=f(e,K){8(/^(3[7-9])|(40)$/.v(e.2r)){4.1C();8((4.I&&/^(38|40)$/.v(e.2r))||(!4.I&&/^(37|39)$/.v(e.2r))){4.3x(e,K,/^[3][4z]$/.v(e.2r)?s:E);8(m e.1B!=\'o\'){e.1B()}19{u s}m e.3n!=\'o\'?e.3n():e.4G=E;4.1q=s}}u E};H.w.1L=f(){4.16=[];c Y=4.r.P;S(c j=0;j<Y;j++){8(/6\\-d/i.v(4.r[j].h)&&!/6\\-(D|X)/i.v(4.r[j].h)){4.16.1V(4.r[j].h.1c(\'2J\')[1]+(/6\\-d\\-J/i.v(4.r[j].h)?\'+\':\'-\'))}}6.1F[4.Q]=4.16.3H(\',\');6.3I()};H.w.2I=f(){c D=4.B.1s(1g[0].4T(E));D.h+=\' 6-D\';D.k.1k=\'4U\';D.k.17=\'1G\';D.k.4W=1g[1];D.k.2i=1g[2].x+\'1f\';D.k.2k=1g[2].y+\'1f\';D.k.3Q=1g[0].2y+\'1f\';D.k.3R=1g[0].2x+\'1f\';u D};H.w.3U=f(d){4.d=d;4.1k={\'x\':4.d.13,\'y\':4.d.12};4.1I={\'x\':(4.1t.x-4.1k.x),\'y\':(4.1t.y-4.1k.y)};4.1h=4.2I(4.d,3W,4.1k);4.1h.k.2s=\'1y\';4.1K=E};H.w.3a=f(){4.B.2v(4.1h);4.d.k.17=\'1J\';4.d=l};H.w.2t=f(1w,1x){c 1v={\'11\':4.I?1x-4.1I.y:1w-4.1I.x,\'27\':4.I?4.1h.2x:4.1h.2y};4.d.k.17=\'1G\';4.1h.k.17=\'1J\';c Y=4.A.P;S(c i=0;i<Y;i++){c 1E={\'11\':4.I?4.A[i].12:4.A[i].13,\'27\':4.I?4.A[i].2x:4.A[i].2y};8((4.1e&&1v.11+1v.27>1E.11&&1v.11<1E.11)||(!4.1e&&1v.11<1E.11&&1v.11+1v.27>1E.11)){8(4.A[i]==4.d){u}c V=4.d.33;29(V.h==l||!/6\\-d/.v(V.h)){V=V.33}8(4.A[i]==V){u}8(4.1j>0){8(4.d[4.I?\'12\':\'13\']<1E.11){c 18=4.A[i].3d;29(18.h==l||!/6\\-d/.v(18.h)){18=18.3d}}19{18=4.A[i]}c 2d={\'x\':18.13,\'y\':18.12}}c 2C={\'x\':4.d.13,\'y\':4.d.12};4.B.2B(4.d,4.A[i]);4.1t.x+=(4.d.13-2C.x);4.1t.y+=(4.d.12-2C.y);8(4.1j>0&&18!=4.d){c 4j=1Q 1S(4,18,2d,4.1j,s,l)}19{}3l}}};f 1S(14,d,3m,1U,22,K){4.14=14;4.d=d;4.2e=l;c 1n=3m[4.14.I?\'y\':\'x\'];c 1T=4.d[4.14.I?\'12\':\'13\'];8(1n!=1T){8(6.21>4.14.A.P-1){u}c D=4.14.2I(4.d,4q,1g[2]);D.k.17=\'1J\';4.d.k.17=\'1G\';4.3A(D,1n,1T>1n?1T-1n:0-(1n-1T),4.14.I?\'2k\':\'2i\',1U,22,K)}};1S.w.3A=f(D,M,3F,2o,1U,22,K){c p=4;c 2S=0;6.21++;4.2e=O.4K(f(){2S++;M+=3F/1U;D.k[2o]=M+\'1f\';8(2S==1U){O.4Y(p.2e);p.2e=l;6.21--;p.14.B.2v(D);p.d.k.17=\'1J\';8(22){8(K!=l&&K.1Y.k.17!=\'1G\'){K.1P()}19 8(p.14.1R){c t=p.14.1b[2c(p.d.h.1c(\'2J\')[1],10)];8(t!=l&&m t.2O!=\'o\'){t.1P()}}}}},20)};8(m O.1O!=\'o\'){O.1O(\'44\',f(){c 2Q=[\'2a\',\'28\',\'1W\',\'3f\',\'4l\',\'1q\',\'3o\',\'1P\',\'3s\',\'4s\',\'4E\',\'4M\',\'4V\',\'45\'];c 3C=2Q.P;c 36=q.30.P;S(c i=0;i<36;i++){S(c j=0;j<3C;j++){q.30[i][\'3t\'+2Q[j]]=l}}})}',62,309,'||||this||dbx||if||||var|box||function||className|||style|null|typeof||undefined|self|document|eles|false|button|return|test|prototype|||toggle|boxes|container|cookie|clone|true|tooltip|parent|dbxGroup|vertical|open|anchor|overall|current|vocab|window|length|gid|replace|for|isopen|etype|sibling|node|dummy|len|target||xy|offsetTop|offsetLeft|caller|cookiestate|order|visibility|visibox|else|eprefix|buttons|split|threshold|positive|px|arguments|boxclone|getTarget|resolution|position|closed|sid|before|group|event|keydown|hasfocus|appendChild|initial|dbxManager|cloneprops|clientX|clientY|move|close|handle|preventDefault|removeTooltip|title|boxprops|savedata|hidden|display|difference|visible|dragok|getBoxOrder|createElement|kmove|attachEvent|focus|new|toggles|dbxAnimator|after|res|push|mouseup|navigator|parentNode|positions||running|kbd|block||syntax|opera|wh|mousemove|while|mousedown|ktoggle|parseInt|visipos|timer|onboxdrag|onselectstart|in|left|cookiestring|top|toggleBoxState|now|hilite|dir|vendor|supported|keyCode|cursor|moveOriginalToPosition|num|removeChild|index|offsetHeight|offsetWidth|Computer|Inc|insertBefore|prepos|obj|relative|createTooltip|str|createTextNode|createClone|dbxid|released|restrict|keypress|none|isactive|tag|ev|Apple|count|togs|def|getElementsByTagName|addDataMember|defopen|relatedTarget|addToggleBehavior|all|setAttribute|uniqueID|nextSibling|down|press|dl||||removeCloneBox|onboxopen|onboxclose|previousSibling|regen|mouseout|idref|insert|siblingpos|compare|span|break|pos|stopPropagation|keyup|state|srcElement|onstatechange|blur|on|yes|invalid|is|shiftBoxPosition|alert|60|animateClone|pattern|el|addEventListener|regex|change|createElementNS|join|setCookieState|_a|z0|Error|from|getCookieState|an|ID|width|height|thresh|fix|createCloneBox|ani|30000|run|toString|getAttribute||mytitle|dbxtitle|key|onunload|boxclose|overflow|offdummy|toElement|u00a0|pointer|href|javascript|void|onclick|onkey|onfocus|onblur|sort|animator|animators|click|setTimeout|500|nodeName|text|29999|Date|selectstart|sidebar|parseFloat|userAgent|toLowerCase|setTime|session|78|KDE|getTime|365|1000|statechange|expires|cancelBubble|toGMTString|path|indexOf|setInterval|http|boxdrag|www|w3|org|1999|xhtml|RegExp|cloneNode|absolute|boxopen|zIndex|getElementById|clearTimeout'.split('|'),0,{}))

// end DBX

// another shorthand
function byId(el)
{
	return document.getElementById(el);
}

// used to set click handler to do nothing (e.g <a> will no take effect.. useful to disable link)
function dummyClick()
{
	return false;
}

function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	var w = 400;
	var h = 500;
	var left = (screen.width - w) / 2;
	var top = (screen.height - h) / 2;
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=" + w + ",height=" + h + ",left=" + left + ",top=" + top + "');");
}

// cookie functions got from www.quirksmode.org  Peter Paul Koch's blog
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	}
// end cookie functions
	function toggleBox() {
		key = $(this).attr("id");
		if($('#info_box_'+key).css("display")=='none') {
			$('#info_box_'+key).slideDown("slow");
			$(this).html("<img src=\"img/btn-collapse.gif\" alt=\"collapse\" />");
		}
		else {
			$('#info_box_'+key).slideUp("slow");
			$(this).html("<img src=\"img/btn-expand.gif\" alt=\"expand\" />");
		}
		saveAdminState();
	}

	function saveAdminState() {
		var x = getExpandedList();
		createCookie("menustate", x);
	}

	function initAdminState() {
		var menuState = readCookie("menustate");
		if(menuState!=null) {
			var menus = menuState.split(",");
			collapseAll(true);
			for(i=0; i < menus.length; i++) {
				if ('' == menus[i]) continue;
				$("#"+menus[i]).show();
				x = menus[i].split("_");
				$("#"+x[2]).html("<img src=\"img/btn-collapse.gif\" alt=\"collapse\" />");
			}
		}
	}

	// get comma seperated list of expanded menu (used to store to the cookie)
	function getExpandedList() {
		var menuState = "";
		$("div.dbx-handle a").each(function()
		{
			if($(this).find("img").attr("alt") == 'collapse')
			{
				menuState+="info_box_"+$(this).attr('id')+",";
			}			
		});
		return menuState;
	}

	function expandAll() {
		$("div.dbx-handle a").each(function() {
			$('#info_box_'+$(this).attr('id')+':hidden').slideDown("slow");
			$(this).html("<img src=\"img/btn-collapse.gif\" alt=\"collapse\" />");
		});
		saveAdminState();		
	}

	function collapseAll(onInit) {
		$("div.dbx-handle a").each(function() {
			// called when page starts then hide it without animation
			if(onInit==true) {
				$('#info_box_'+$(this).attr('id')).hide();
			}
			else {
				$('#info_box_'+$(this).attr('id')+':visible').slideUp("slow");
			}
			$(this).html("<img src=\"img/btn-expand.gif\" alt=\"expand\" />");
		});
		if(onInit==false)
		{
			saveAdminState();
		}
	}
	
	function savePrefs()
	{
		var x = getExpandedList();
		createCookie("menustate", x);
		$.post("../admin/ajax_actions.php", { prefs: 'save', preferences: x}, function(data)
		{
		    alert(data);
		});
	}
	
	function revertPrefs()
	{
		$.post("../admin/ajax_actions.php", { prefs: 'get'}, function(data)
		{
			var menuState = data;
			if(menuState!=null)
			{
				var menus = menuState.split(",");
				collapseAll(true);
				for(i=0; i < menus.length; i++) {
					if ('' == menus[i]) continue;
					$("#"+menus[i]).show();
					x = menus[i].split("_");
					$("#"+x[2]).html("<img src=\"img/btn-collapse.gif\" alt=\"collapse\" />");
				}
			}
		});
	}
	
var theTopXF = -10;
var oldXF = theTopXF;

function ajaxLoaderPosition()
{
	if (window.innerHeight)
	{
		  pos = window.pageYOffset
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		pos = document.documentElement.scrollTop
	}
	else if (document.body)
	{
		  pos = document.body.scrollTop
	}
	if (pos < theTopXF) pos = theTopXF;
	else pos += 10;
	if (pos == oldXF)
	{
		$("#ajax-loader").css("top", pos+"px");
	}
	oldXF = pos;

	setTimeout(ajaxLoaderPosition, 1000);
}

function dbxer() {
	//initialise the docking boxes manager
	var manager = new dbxManager('main'); 	//session ID [/-_a-zA-Z0-9/]

	//create new docking boxes group
	var purple = new dbxGroup(
		'menugroup', 		// container ID [/-_a-zA-Z0-9/]
		'vertical', 		// orientation ['vertical'|'horizontal']
		'10', 			// drag threshold ['n' pixels]
		'yes',			// restrict drag movement to container axis ['yes'|'no']
		'0', 			// animate re-ordering [frames per transition, or '0' for no effect]
		'no', 			// include open/close toggle buttons ['yes'|'no']
		'open', 		// default state ['open'|'closed']
		'open', 		// word for "open", as in "open this box"
		'close', 		// word for "close", as in "close this box"
		'click-down and drag to move this box', // sentence for "move this box" by mouse
		'click to %toggle% this box', // pattern-match sentence for "(open|close) this box" by mouse
		'use the arrow keys to move this box', // sentence for "move this box" by keyboard
		', or press the enter key to %toggle% it',  // pattern-match sentence-fragment for "(open|close) this box" by keyboard
		'%mytitle%  [%dbxtitle%]' // pattern-match syntax for title-attribute conflicts
		);
}

$.fn.fastSerialize = function() {
    var a = [];

    $('input,textarea,select,button', this).each(function() {
        var n = this.name;
        var t = this.type;

        if ( !n || this.disabled || t == 'reset' ||
            (t == 'checkbox' || t == 'radio') && !this.checked ||
            (t == 'submit' || t == 'image' || t == 'button') && this.form.clicked != this ||
            this.tagName.toLowerCase() == 'select' && this.selectedIndex == -1)
            	return;

        if (t == 'image' && this.form.clicked_x)
            return a.push(
                {name: n+'_x', value: this.form.clicked_x},
                {name: n+'_y', value: this.form.clicked_y}
            );

        if (t == 'select-multiple')
        {
            $('option:selected', this).each( function()
            {
                a.push({name: n, value: this.value});
            });
            return;
        }

        a.push({name: n, value: this.value});
    });

    return a;
}

function gotoLocation(ur)
{
	window.location = ur;
}

	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	Updated:	April, 6th 2006, Using iframe in IE in order to make the tooltip cover select boxes.

	www.dhtmlgoodies.com
	Alf Magne Kalleland

	************************************************************************************************************/	
	var dhtmlgoodies_tooltip = false;
	var dhtmlgoodies_tooltipShadow = false;
	var dhtmlgoodies_shadowSize = 4;
	var dhtmlgoodies_tooltipMaxWidth = 200;
	var dhtmlgoodies_tooltipMinWidth = 100;
	var dhtmlgoodies_iframe = false;
	var tooltip_is_msie = (navigator.userAgent.indexOf('MSIE')>=0 && navigator.userAgent.indexOf('opera')==-1 && document.all)?true:false;

	function showTooltip(e,tooltipTxt)
	{
		var bodyWidth = Math.max(document.body.clientWidth,document.documentElement.clientWidth) - 20;
	
		if(!dhtmlgoodies_tooltip){
			dhtmlgoodies_tooltip = document.createElement('DIV');
			dhtmlgoodies_tooltip.id = 'dhtmlgoodies_tooltip';
			dhtmlgoodies_tooltipShadow = document.createElement('DIV');
			dhtmlgoodies_tooltipShadow.id = 'dhtmlgoodies_tooltipShadow';
			
			document.body.appendChild(dhtmlgoodies_tooltip);
			document.body.appendChild(dhtmlgoodies_tooltipShadow);	
			
			if(tooltip_is_msie){
				dhtmlgoodies_iframe = document.createElement('IFRAME');
				dhtmlgoodies_iframe.frameborder='5';
				dhtmlgoodies_iframe.style.backgroundColor='#FFFFFF';
				dhtmlgoodies_iframe.src = '#'; 	
				dhtmlgoodies_iframe.style.zIndex = 100;
				dhtmlgoodies_iframe.style.position = 'absolute';
				document.body.appendChild(dhtmlgoodies_iframe);
			}
		}

		dhtmlgoodies_tooltip.style.display='block';
		dhtmlgoodies_tooltipShadow.style.display='block';
		if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='block';
		
		var st = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
		if(navigator.userAgent.toLowerCase().indexOf('safari')>=0)st=0; 
		var leftPos = e.clientX + 10;
		
		dhtmlgoodies_tooltip.style.width = null;	// Reset style width if it's set 
		dhtmlgoodies_tooltip.innerHTML = tooltipTxt;
		dhtmlgoodies_tooltip.style.left = leftPos + 'px';
		dhtmlgoodies_tooltip.style.top = e.clientY + 10 + st + 'px';

		
		dhtmlgoodies_tooltipShadow.style.left =  leftPos + dhtmlgoodies_shadowSize + 'px';
		dhtmlgoodies_tooltipShadow.style.top = e.clientY + 10 + st + dhtmlgoodies_shadowSize + 'px';
		
		if(dhtmlgoodies_tooltip.offsetWidth>dhtmlgoodies_tooltipMaxWidth){	/* Exceeding max width of tooltip ? */
			dhtmlgoodies_tooltip.style.width = dhtmlgoodies_tooltipMaxWidth + 'px';
		}
		
		var tooltipWidth = dhtmlgoodies_tooltip.offsetWidth;		
		if(tooltipWidth<dhtmlgoodies_tooltipMinWidth)tooltipWidth = dhtmlgoodies_tooltipMinWidth;
		
		
		dhtmlgoodies_tooltip.style.width = tooltipWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
		dhtmlgoodies_tooltipShadow.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';		
		
		if((leftPos + tooltipWidth)>bodyWidth){
			dhtmlgoodies_tooltip.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth)) + 'px';
			dhtmlgoodies_tooltipShadow.style.left = (dhtmlgoodies_tooltipShadow.style.left.replace('px','') - ((leftPos + tooltipWidth)-bodyWidth) + dhtmlgoodies_shadowSize) + 'px';
		}
		
		if(tooltip_is_msie){
			dhtmlgoodies_iframe.style.left = dhtmlgoodies_tooltip.style.left;
			dhtmlgoodies_iframe.style.top = dhtmlgoodies_tooltip.style.top;
			dhtmlgoodies_iframe.style.width = dhtmlgoodies_tooltip.offsetWidth + 'px';
			dhtmlgoodies_iframe.style.height = dhtmlgoodies_tooltip.offsetHeight + 'px';
		}
	}

	function hideTooltip()
	{
		dhtmlgoodies_tooltip.style.display='none';
		dhtmlgoodies_tooltipShadow.style.display='none';		
		if(tooltip_is_msie)dhtmlgoodies_iframe.style.display='none';		
	}


// Extending jquery
// Copyright: (c) 2006, Michal Tatarynowicz (tatarynowicz@gmail.com)
// Licenced as Public Domain (http://creativecommons.org/licenses/publicdomain/)
// $Id: jquery_std.js 568 2006-06-05 09:40:53Z Michal $


// Additions to the wonderful jQuery Javascript library

$.text = function(content) {
	return document.createTextNode(content);
};

// patch for jquery ajax to handle json natively
// Opera 9 doesn't like text/json header, use text/javascript
$.httpData = function(r, type) {
	var h = r.getResponseHeader("content-type");
	return h.indexOf("xml") > 0 || type == "xml"
		? r.responseXML
		: h.indexOf("json") > 0 || h.indexOf("javascript") > 0 || type == "json"
			? eval('('+r.responseText+')')
			: r.responseText;
};
	

$.fn.enable = function() {
	return this.each(function(){
		this.disabled = false;
	});
}

$.fn.disable = function() {
	return this.each(function(){
		this.disabled = true;
	});
}


/*
*
*	Got from Drupal CMS admin part
*	Drupal is GPLed so I think this script is also GPLed
*
*	the script (continuous until the line // --till there)
*
*	:)
*/

function getMousePosition(e) {
	return { x: e.clientX + document.documentElement.scrollLeft, y: e.clientY + document.documentElement.scrollTop};
}

// get substring count with limit
$.fn.substrCount = function(needle)
{
	var h = this.text();
	var times = 0;
	while((pos=h.indexOf(needle)) != -1)
	{
		h = h.substr(pos+needle.length);
		times++;
	}

	return times;
}

textareaResizer = function() {
  $('textarea').each(function() {
    var obj = $(this);
	
	cl = obj.attr("class");
	if(cl && -1 != cl.indexOf("noresize"))
	{
		return false;
	}
	
	
    var content = obj.text();
    var Height = 30;
    if(content.length)
    {
    	// IE - doesnt find \n I gave up I don't know why it is so ..
    	// Firefox works just as it must work as well as Opera
    	var times = obj.substrCount($.browser.msie ? "\r" : "\n");
    	if(times > 20)
    	{
    		Height = 200;
    	}
    	else
    	{
    		Height = 70+10*times;
    	}
    }

	obj.height(Height);

    var offset = null;

    $(this).wrap('<div class="resizable-textarea"></div>')
      .parent().append($('<div class="resizable-textarea2"></div>').bind("mousedown", dragBegins));

    var image = $('div.resizable-textarea2', $(this).parent())[0];
    image.style.marginRight = (image.offsetWidth - $(this)[0].offsetWidth) +'px';

    function dragBegins(e)
    {
      offset = obj.height() - getMousePosition(e).y;
      if($.browser.opera)
      {
      	offset -= 6;
      }
      $(document).bind("mousemove", doDrag).bind("mouseup", dragEnds);
      stopPropagation(e);
    }

    function doDrag(e)
    {
      obj.height(Math.max(15, offset + getMousePosition(e).y) + 'px');
      stopPropagation(e);
    }

    function dragEnds(e)
    {
		$(document).unbind();
    }
  });
}

function stopPropagation(ev)
{
	ev = ev||event;/* get IE event ( not passed ) */
	ev.stopPropagation? ev.stopPropagation() : ev.cancelBubble = true;
}

// Add additional image field
function add(btn) 
{
	var clone = $(btn).parent().clone();
	var counterobj = $('#'+$('input:file', clone).attr('name').substr(0,$('input:file', clone).attr('name').length-2));
	if (counterobj.val() > 0)
	{
		$('input:file', clone).val('');
		$(btn).parent().after(clone);
		counterobj.val(counterobj.val()-1);
	}
	else
	{
		alert(lang.no_more_files);
	}
}
function remove(btn) 
{
	var clone = $(btn).parent().clone();
	var counterobj = $('#'+$('input:file', clone).attr('name').substr(0,$('input:file', clone).attr('name').length-2));

	if ($(btn).parent().prev().attr('class') == 'pictures' || $(btn).parent().next().attr('class') == 'pictures')
	{
		$(btn).parent().remove();
		counterobj.val(counterobj.val()*1+1);
	}
}

function rm_pic_adm(path, link, item, field, itemid)
{
	if (confirm(lang['sure_rm_file']))
	{
		$.post(	'ajax_actions.php',
			{action: 'rm_pic', item: item, field:field, path: path, itemid: itemid},
			function(data)
			{
				$(link).parent().remove();
				var counter = $('#'+field);
				try {
					counter.val(parseInt(counter.val()) + 1);
					if (counter.val() == 0)
					{
						$('#wrap_'+field).show();
					}
				}
				catch (e) {}
			}
		  );
	}
	return false;
}

/**
 * remove picture. used for additional fields, type of 'gallery'
 *
 * @param string path path from script's root  folder to picture
 * @param object link anchor that has been clicked
 * @param string item item name - 'articles', 'listings', etc.
 * @param string field additional field name
 * @param integer itemid item ID
 */
function rm_pic(path, link, item, field, itemid)
{
	if (confirm(lang['sure_rm_file']))
	{
		$.post(	'ajaxed.php',
			{action: 'rm_pic', item: item, field:field, path: path, itemid: itemid},
			function(data) 
			{
				$(link).parent().remove();
				var counter = $('#'+field);
				counter.val(parseInt(counter.val()) + 1);
				if (counter.val() == 0)
				{
					$('#wrap_'+field).show();
				}
			}
		  );
	}
	return false;
}


