/*
CSS Browser Selector v0.2.9
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/
var css_browser_selector = function() {var ua=navigator.userAgent.toLowerCase(),is=function(t){return ua.indexOf(t) != -1;},h=document.getElementsByTagName('html')[0],b=(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?'gecko ff2':is('firefox/3')?'gecko ff3':is('gecko/')?'gecko':is('opera/9')?'opera opera9':/opera\s(\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('chrome')?'chrome webkit safari':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';var c=b+os+' js'; h.className += h.className?' '+c:c;}();


function concat (a, b)
{
	for (i in b)
	{
		a[i] = b[i];
	}
	return a;
}

function isString(s)
{
	return typeof(s) == "string";
}

function isArray(a)
{
	return typeof(a) == "object" && a.length;
}

function isFunction(f)
{
	return typeof(f) == "function";
}

function isObject(o)
{
	return typeof(o) == "object";
}

function myNumber(n)
{
	var t = Number(n);
	if (t + '' == "NaN") return 0;
	return t;
}

/*
	util.js
*/

var BrowserSize;
var DocumentSize;
var ClientArea_TopLeft;
var ClientArea_Size;

function RunSchedule()
{
	this.count = 0;
	this.list = {};
	this.contentHeight = 0;
	
	this.add = function (func)
	{
		this.list[this.count] = func;
		this.count++;
	}
	
	this.reset = function ()
	{
		this.list = {};
		this.count = 0;
	}
	
	this.run = function ()
	{
		for (i in this.list)
		{
			this.list[i]();
		}
	}
}
var Run = new RunSchedule();

function refreshPage(more)
{
	if (typeof(more) == "undefined") more = '';
	
	if (typeof(READYONETADMIN) != "undefined" && READYONETADMIN == 1)
	{
		if (typeof(location.replace) != "undefined")
			location.replace('main.php?menu=' + menu_id + more);
		else
			location.href = 'main.php?menu=' + menu_id + more;
	}
	else
	{
		if (typeof(location.replace) != "undefined")
			location.replace('main.php?refresh=1' + more);
		else
			location.href = 'main.php?refresh=1' + more;
	}
}

function replacePage(url)
{
	if (typeof(location.replace) != "undefined")
		location.replace(url);
	else
		location.href = url;
}

function dummy()
{
}

function getBrowserSize()
{
	size = new Object();
	
  	if (typeof(window.innerWidth) == 'number')
  	{
	    //Non-IE
	    size.w = window.innerWidth;
	    size.h = window.innerHeight;
  	}
  	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
	    //IE 6+ in 'standards compliant mode'
	    size.w = document.documentElement.clientWidth;
	    size.h = document.documentElement.clientHeight;
  	}
  	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
  	{
	    //IE 4 compatible
	    size.w = document.body.clientWidth;
	    size.h = document.body.clientHeight;
  	}
	else
	{
		size.w = 0;
		size.h = 0;
	}
  	
	return size;
}

function calculateClientArea()
{
	ClientArea_TopLeft = getAnchorPosition('TopLeft');
	
	ClientArea_Size = getElementSize('OuterTable');
	ClientArea_Size.w -= ClientArea_TopLeft.x * 2;
	ClientArea_Size.h -= ClientArea_TopLeft.y;
}

function getElementSize(id)
{
	var size = {'w': 0, 'h': 0};
	var e = document.getElementById(id);
	if (e)
	{
		size.w = e.offsetWidth;
		size.h = e.offsetHeight;
	}
	return size;
}

function dlgCenter(e)
{
	var size = getElementSize(e.id);
	
	var x = (BrowserSize.w - size.w) / 2;
	var y = (BrowserSize.h - size.h) / 2;
	var scroll_x = document.body.scrollLeft;
	var scroll_y = document.body.scrollTop;
	
	e.style.left = (parseInt(scroll_x) + parseInt(x)) + 'px';
	e.style.top = (parseInt(scroll_y) + parseInt(y)) + 'px';
}

function dlgPosition(e, x, y)
{
	e.style.left = x + 'px';
	e.style.top = y + 'px';
}

function dlgRelativePosition(e, x, y)
{
	var scroll_x = document.body.scrollLeft;
	var scroll_y = document.body.scrollTop;
	
	e.style.left = (parseInt(scroll_x) + x) + 'px';
	e.style.top = (parseInt(scroll_y) + y) + 'px';
}

function dlgActivate(e)
{
	e.style.visibility = 'hidden';
	e.style.left = '-2000px';
	e.style.top = '0px';
	e.style.display = 'block';
}

function dlgDisplay(e)
{
	setTimeout("document.getElementById('" + e.id + "').style.visibility = 'visible';", 10);
	//e.style.visibility = 'visible';
}

function dlgHide(e)
{
	e.style.visibility = 'hidden';
	e.style.display = 'none';
}

function dlgDestroy(e)
{
	e.style.visibility = 'hidden';
	e.innerHTML = '';
	e.style.display = 'none';
}

function dlgDelayedDestroy(e)
{
	setTimeout("dlgDestroy(document.getElementById('" + e.id + "'));", 100);
}

function onReturnKey(action, event)
{
	if (!event) event = window.event;
	
	if (event.keyCode == 13)
	{
		eval(action);
	}
}

function getSel()
{
	var s = '';
	if (window.getSelection) s = window.getSelection();
	else if (document.getSelection) s = document.getSelection();
	else if (document.selection) s = document.selection.createRange().text;
	
	return s;
}

function setSelRange(inputEl, selStart, selEnd)
{
	if (inputEl.setSelectionRange)
	{ 
		inputEl.focus(); 
		inputEl.setSelectionRange(selStart, selEnd); 
	}
	else if (inputEl.createTextRange)
	{ 
		var range = inputEl.createTextRange(); 
		range.collapse(true); 
		range.moveEnd('character', selEnd); 
		range.moveStart('character', selStart); 
		range.select(); 
	}
}

function insertAtCursor(e, s)
{
	//IE/Opera support
	if (document.selection)
	{
		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		
		sel = document.selection.createRange();
		sel.text = s;
	}
	//Mozilla/Firefox/Netscape 7+ support 
	else if (e.selectionStart || e.selectionStart == '0')
	{
		//Here we get the start and end points of the 
		//selection. Then we create substrings up to the 
		//start of the selection and from the end point 
		//of the selection to the end of the field value. 
		//Then we concatenate the first substring, myValue, 
		//and the second substring to get the new value. 
		
		var startPos = e.selectionStart;
		var endPos = e.selectionEnd;
		var newPos = startPos + s.length;
		var scroll = e.scrollTop;
		e.value = e.value.substring(0, startPos) + s + e.value.substring(endPos, e.value.length); 
		e.selectionStart = newPos;
		e.selectionEnd = newPos;
		e.scrollTop = scroll;
	}
	else
	{
		e.value += s;
	}
}

function fieldsetAction(id)
{
	var e = document.getElementById(id);
	if (e)
	{
		if (!e.style.display || e.style.display == 'none')
			fieldsetOpen(id);
		else
			fieldsetClose(id);
	}
}

function fieldsetInit(id, caption)
{
	var legend = document.getElementById(id + 'Legend');
	if (legend)
		legend.caption = caption;
	
	var e = document.getElementById(id);
	if (e)
	{
		if (!e.style.display || e.style.display == 'none')
			legend.innerHTML = '<img src="images/fieldset_closed.gif"\>' + legend.caption;
		else
			legend.innerHTML = '<img src="images/fieldset_opened.gif"\>' + legend.caption;
	}
}

function fieldsetOpen(id)
{
	var legend = document.getElementById(id + 'Legend');
	
	var e = document.getElementById(id);
	if (e)
	{
		e.style.display = 'block';
		legend.innerHTML = '<img src="images/fieldset_opened.gif"\>' + legend.caption;
	}
}

function fieldsetClose(id)
{
	var legend = document.getElementById(id + 'Legend');
	
	var e = document.getElementById(id);
	if (e)
	{
		e.style.display = 'none';
		legend.innerHTML = '<img src="images/fieldset_closed.gif"\>' + legend.caption;
	}
}

function OpenNewWindow(url, title, w, h)
{
	newwin = window.open(url, title, "height=" + h +", width=" + w + ", scrollbars, menubar, resizable");
	newwin.document.close();
	return newwin;
}

function C_AutoLogout()
{
	this.start = function ()
	{
		setTimeout('AutoLogout.check();', 300000);	// 5 minutes ping
	};
	
	this.check = function ()
	{
		CSC_Request('auto_logout.csc.php', 'check', {});
	};
	
}

window.AutoLogout = new C_AutoLogout();

function C_Ping()
{
	this.start = function ()
	{
		setTimeout('window.Ping.ping();', 300000);	// 5 minutes ping
	};
	
	this.ping = function ()
	{
		CSC_Request('ping.csc.php', '', {});
	};
	
}

window.Ping = new C_Ping();


// Copyright (C) Raditha Dissanyake 2003
function ProgressBar_popUP(mypage, myname, w, h, scroll, titlebar)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4)
	{
		win.window.focus();
	}
}

// Copyright (C) Raditha Dissanyake 2003
function ProgressBar_postIt(formname)
{
	baseUrl = 'main.php?execute[executeFile]=pgbar.php';
	sid = document.forms[formname].sessionId.value;
	iTotal = escape("-1");
	baseUrl += "&iTotal=" + iTotal;
	baseUrl += "&iRead=0";
	baseUrl += "&iStatus=1";
	baseUrl += "&sessionid=" + sid;
	
	ProgressBar_popUP(baseUrl, "Uploader", 460, 150, false, false);
	document.forms[formname].submit();
}

/*
*Version 2.1 Copyright(C)Paul Johnston 1999-2002.
*Other contributors: Greg Holt,Andrew Kepert,Ydnar,Lostinet
*Distributed under the BSD License
 */
var hexcase=0;
var chrsz=8;
function hex_md5(s){return binl2hex(core_md5(str2binl(s),s.length*chrsz));}
function md5_vm_test()
{
return hex_md5("abc")=="900150983cd24fb0d6963f7d28e17f72";
}
function core_md5(x,len)
{
x[len>>5]|=0x80<<((len)%32);
x[(((len+64)>>>9)<<4)+14]=len;
var a=1732584193;
var b=-271733879;
var c=-1732584194;
var d=271733878;
for(var i=0;i<x.length;i+=16)
{
var olda=a;
var oldb=b;
var oldc=c;
var oldd=d;
a=md5_ff(a,b,c,d,x[i+ 0],7,-680876936);
d=md5_ff(d,a,b,c,x[i+ 1],12,-389564586);
c=md5_ff(c,d,a,b,x[i+ 2],17,606105819);
b=md5_ff(b,c,d,a,x[i+ 3],22,-1044525330);
a=md5_ff(a,b,c,d,x[i+ 4],7,-176418897);
d=md5_ff(d,a,b,c,x[i+ 5],12,1200080426);
c=md5_ff(c,d,a,b,x[i+ 6],17,-1473231341);
b=md5_ff(b,c,d,a,x[i+ 7],22,-45705983);
a=md5_ff(a,b,c,d,x[i+ 8],7,1770035416);
d=md5_ff(d,a,b,c,x[i+ 9],12,-1958414417);
c=md5_ff(c,d,a,b,x[i+10],17,-42063);
b=md5_ff(b,c,d,a,x[i+11],22,-1990404162);
a=md5_ff(a,b,c,d,x[i+12],7,1804603682);
d=md5_ff(d,a,b,c,x[i+13],12,-40341101);
c=md5_ff(c,d,a,b,x[i+14],17,-1502002290);
b=md5_ff(b,c,d,a,x[i+15],22,1236535329);
a=md5_gg(a,b,c,d,x[i+ 1],5,-165796510);
d=md5_gg(d,a,b,c,x[i+ 6],9,-1069501632);
c=md5_gg(c,d,a,b,x[i+11],14,643717713);
b=md5_gg(b,c,d,a,x[i+ 0],20,-373897302);
a=md5_gg(a,b,c,d,x[i+ 5],5,-701558691);
d=md5_gg(d,a,b,c,x[i+10],9,38016083);
c=md5_gg(c,d,a,b,x[i+15],14,-660478335);
b=md5_gg(b,c,d,a,x[i+ 4],20,-405537848);
a=md5_gg(a,b,c,d,x[i+ 9],5,568446438);
d=md5_gg(d,a,b,c,x[i+14],9,-1019803690);
c=md5_gg(c,d,a,b,x[i+ 3],14,-187363961);
b=md5_gg(b,c,d,a,x[i+ 8],20,1163531501);
a=md5_gg(a,b,c,d,x[i+13],5,-1444681467);
d=md5_gg(d,a,b,c,x[i+ 2],9,-51403784);
c=md5_gg(c,d,a,b,x[i+ 7],14,1735328473);
b=md5_gg(b,c,d,a,x[i+12],20,-1926607734);
a=md5_hh(a,b,c,d,x[i+ 5],4,-378558);
d=md5_hh(d,a,b,c,x[i+ 8],11,-2022574463);
c=md5_hh(c,d,a,b,x[i+11],16,1839030562);
b=md5_hh(b,c,d,a,x[i+14],23,-35309556);
a=md5_hh(a,b,c,d,x[i+ 1],4,-1530992060);
d=md5_hh(d,a,b,c,x[i+ 4],11,1272893353);
c=md5_hh(c,d,a,b,x[i+ 7],16,-155497632);
b=md5_hh(b,c,d,a,x[i+10],23,-1094730640);
a=md5_hh(a,b,c,d,x[i+13],4,681279174);
d=md5_hh(d,a,b,c,x[i+ 0],11,-358537222);
c=md5_hh(c,d,a,b,x[i+ 3],16,-722521979);
b=md5_hh(b,c,d,a,x[i+ 6],23,76029189);
a=md5_hh(a,b,c,d,x[i+ 9],4,-640364487);
d=md5_hh(d,a,b,c,x[i+12],11,-421815835);
c=md5_hh(c,d,a,b,x[i+15],16,530742520);
b=md5_hh(b,c,d,a,x[i+ 2],23,-995338651);
a=md5_ii(a,b,c,d,x[i+ 0],6,-198630844);
d=md5_ii(d,a,b,c,x[i+ 7],10,1126891415);
c=md5_ii(c,d,a,b,x[i+14],15,-1416354905);
b=md5_ii(b,c,d,a,x[i+ 5],21,-57434055);
a=md5_ii(a,b,c,d,x[i+12],6,1700485571);
d=md5_ii(d,a,b,c,x[i+ 3],10,-1894986606);
c=md5_ii(c,d,a,b,x[i+10],15,-1051523);
b=md5_ii(b,c,d,a,x[i+ 1],21,-2054922799);
a=md5_ii(a,b,c,d,x[i+ 8],6,1873313359);
d=md5_ii(d,a,b,c,x[i+15],10,-30611744);
c=md5_ii(c,d,a,b,x[i+ 6],15,-1560198380);
b=md5_ii(b,c,d,a,x[i+13],21,1309151649);
a=md5_ii(a,b,c,d,x[i+ 4],6,-145523070);
d=md5_ii(d,a,b,c,x[i+11],10,-1120210379);
c=md5_ii(c,d,a,b,x[i+ 2],15,718787259);
b=md5_ii(b,c,d,a,x[i+ 9],21,-343485551);
a=safe_add(a,olda);
b=safe_add(b,oldb);
c=safe_add(c,oldc);
d=safe_add(d,oldd);
}
return Array(a,b,c,d);
}
function md5_cmn(q,a,b,x,s,t)
{
return safe_add(bit_rol(safe_add(safe_add(a,q),safe_add(x,t)),s),b);
}
function md5_ff(a,b,c,d,x,s,t)
{
return md5_cmn((b&c)|((~b)&d),a,b,x,s,t);
}
function md5_gg(a,b,c,d,x,s,t)
{
return md5_cmn((b&d)|(c&(~d)),a,b,x,s,t);
}
function md5_hh(a,b,c,d,x,s,t)
{
return md5_cmn(b^c^d,a,b,x,s,t);
}
function md5_ii(a,b,c,d,x,s,t)
{
return md5_cmn(c^(b|(~d)),a,b,x,s,t);
}
function safe_add(x,y)
{
var lsw=(x&0xFFFF)+(y&0xFFFF);
var msw=(x>>16)+(y>>16)+(lsw>>16);
return(msw<<16)|(lsw&0xFFFF);
}
function bit_rol(num,cnt)
{
return(num<<cnt)|(num>>>(32-cnt));
}
function str2binl(str)
{
var bin=Array();
var mask=(1<<chrsz)-1;
for(var i=0;i<str.length*chrsz;i+=chrsz)bin[i>>5]|=(str.charCodeAt(i/chrsz)&mask)<<(i%32);
return bin;
}
function binl2hex(binarray)
{
var hex_tab=hexcase?"0123456789ABCDEF":"0123456789abcdef";
var str="";
for(var i=0;i<binarray.length*4;i++)
{
str+=hex_tab.charAt((binarray[i>>2]>>((i%4)*8+4))&0xF)+hex_tab.charAt((binarray[i>>2]>>((i%4)*8))&0xF);
}
return str;
}
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/

function getAnchorPosition(anchorname){
var useWindow=false;
var coordinates=new Object();
var x=0,y=0;
var use_gebi=false, use_css=false, use_layers=false;
if(document.getElementById){ use_gebi=true;}
else if(document.all){ use_css=true;}
else if(document.layers){ use_layers=true;}
if(use_gebi&&document.all){
x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
}
else if(use_gebi){
var o=document.getElementById(anchorname);
x=AnchorPosition_getPageOffsetLeft(o);
y=AnchorPosition_getPageOffsetTop(o);
}
else if(use_css){
x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
}
else if(use_layers){
var found=0;
for(var i=0; i<document.anchors.length; i++){
if(document.anchors[i].name==anchorname){ found=1; break;}
}
if(found==0){
coordinates.x=0; coordinates.y=0; return coordinates;
}
x=document.anchors[i].x;
y=document.anchors[i].y;
}
else{
coordinates.x=0; coordinates.y=0; return coordinates;
}
coordinates.x=x;
coordinates.y=y;
return coordinates;
}

function getAnchorWindowPosition(anchorname){
var coordinates=getAnchorPosition(anchorname);
var x=0;
var y=0;
if(document.getElementById){
if(isNaN(window.screenX)){
x=coordinates.x-document.body.scrollLeft+window.screenLeft;
y=coordinates.y-document.body.scrollTop+window.screenTop;
}
else{
x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
}
}
else if(document.all){
x=coordinates.x-document.body.scrollLeft+window.screenLeft;
y=coordinates.y-document.body.scrollTop+window.screenTop;
}
else if(document.layers){
x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
}
coordinates.x=x;
coordinates.y=y;
return coordinates;
}

function AnchorPosition_getPageOffsetLeft(el){
var ol=el.offsetLeft;
while((el=el.offsetParent) !=null){ ol+=el.offsetLeft;}
return ol;
}
function AnchorPosition_getWindowOffsetLeft(el){
return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
}	
function AnchorPosition_getPageOffsetTop(el){
var ot=el.offsetTop;
while((el=el.offsetParent) !=null){ ot+=el.offsetTop;}
return ot;
}
function AnchorPosition_getWindowOffsetTop(el){
return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
}

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x){return(x<0||x>9?"":"0")+x}
function isDate(val,format){
var date=getDateFromFormat(val,format);
if(date==0){ return false;}
return true;
}
function compareDates(date1,dateformat1,date2,dateformat2){
var d1=getDateFromFormat(date1,dateformat1);
var d2=getDateFromFormat(date2,dateformat2);
if(d1==0||d2==0){
return -1;
}
else if(d1 > d2){
return 1;
}
return 0;
}
function formatDate(date,format){
format=format+"";
var result="";
var i_format=0;
var c="";
var token="";
var y=date.getYear()+"";
var M=date.getMonth()+1;
var d=date.getDate();
var E=date.getDay();
var H=date.getHours();
var m=date.getMinutes();
var s=date.getSeconds();
var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
var value=new Object();
if(y.length < 4){y=""+(y-0+1900);}
value["y"]=""+y;
value["yyyy"]=y;
value["yy"]=y.substring(2,4);
value["M"]=M;
value["MM"]=LZ(M);
value["MMM"]=MONTH_NAMES[M-1];
value["NNN"]=MONTH_NAMES[M+11];
value["d"]=d;
value["dd"]=LZ(d);
value["E"]=DAY_NAMES[E+7];
value["EE"]=DAY_NAMES[E];
value["H"]=H;
value["HH"]=LZ(H);
if(H==0){value["h"]=12;}
else if(H>12){value["h"]=H-12;}
else{value["h"]=H;}
value["hh"]=LZ(value["h"]);
if(H>11){value["K"]=H-12;} else{value["K"]=H;}
value["k"]=H+1;
value["KK"]=LZ(value["K"]);
value["kk"]=LZ(value["k"]);
if(H > 11){ value["a"]="PM";}
else{ value["a"]="AM";}
value["m"]=m;
value["mm"]=LZ(m);
value["s"]=s;
value["ss"]=LZ(s);
while(i_format < format.length){
c=format.charAt(i_format);
token="";
while((format.charAt(i_format)==c)&&(i_format < format.length)){
token+=format.charAt(i_format++);
}
if(value[token] !=null){ result=result + value[token];}
else{ result=result + token;}
}
return result;
}
function _isInteger(val){
var digits="1234567890";
for(var i=0; i < val.length; i++){
if(digits.indexOf(val.charAt(i))==-1){ return false;}
}
return true;
}
function _getInt(str,i,minlength,maxlength){
for(var x=maxlength; x>=minlength; x--){
var token=str.substring(i,i+x);
if(token.length < minlength){ return null;}
if(_isInteger(token)){ return token;}
}
return null;
}
function getDateFromFormat(val,format){
val=val+"";
format=format+"";
var i_val=0;
var i_format=0;
var c="";
var token="";
var token2="";
var x,y;
var now=new Date();
var year=now.getYear();
var month=now.getMonth()+1;
var date=1;
var hh=now.getHours();
var mm=now.getMinutes();
var ss=now.getSeconds();
var ampm="";

while(i_format < format.length){
// Get next token from format string
c=format.charAt(i_format);
token="";
while((format.charAt(i_format)==c)&&(i_format < format.length)){
token+=format.charAt(i_format++);
}
// Extract contents of value based on format token
if(token=="yyyy"||token=="yy"||token=="y"){
if(token=="yyyy"){ x=4;y=4;}
if(token=="yy"){ x=2;y=2;}
if(token=="y"){ x=2;y=4;}
year=_getInt(val,i_val,x,y);
if(year==null){ return 0;}
i_val+=year.length;
if(year.length==2){
if(year > 70){ year=1900+(year-0);}
else{ year=2000+(year-0);}
}
}
else if(token=="MMM"||token=="NNN"){
month=0;
for(var i=0; i<MONTH_NAMES.length; i++){
var month_name=MONTH_NAMES[i];
if(val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()){
if(token=="MMM"||(token=="NNN"&&i>11)){
month=i+1;
if(month>12){ month -=12;}
i_val+=month_name.length;
break;
}
}
}
if((month < 1)||(month>12)){return 0;}
}
else if(token=="EE"||token=="E"){
for(var i=0; i<DAY_NAMES.length; i++){
var day_name=DAY_NAMES[i];
if(val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()){
i_val+=day_name.length;
break;
}
}
}
else if(token=="MM"||token=="M"){
month=_getInt(val,i_val,token.length,2);
if(month==null||(month<1)||(month>12)){return 0;}
i_val+=month.length;}
else if(token=="dd"||token=="d"){
date=_getInt(val,i_val,token.length,2);
if(date==null||(date<1)||(date>31)){return 0;}
i_val+=date.length;}
else if(token=="hh"||token=="h"){
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>12)){return 0;}
i_val+=hh.length;}
else if(token=="HH"||token=="H"){
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>23)){return 0;}
i_val+=hh.length;}
else if(token=="KK"||token=="K"){
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<0)||(hh>11)){return 0;}
i_val+=hh.length;}
else if(token=="kk"||token=="k"){
hh=_getInt(val,i_val,token.length,2);
if(hh==null||(hh<1)||(hh>24)){return 0;}
i_val+=hh.length;hh--;}
else if(token=="mm"||token=="m"){
mm=_getInt(val,i_val,token.length,2);
if(mm==null||(mm<0)||(mm>59)){return 0;}
i_val+=mm.length;}
else if(token=="ss"||token=="s"){
ss=_getInt(val,i_val,token.length,2);
if(ss==null||(ss<0)||(ss>59)){return 0;}
i_val+=ss.length;}
else if(token=="a"){
if(val.substring(i_val,i_val+2).toLowerCase()=="am"){ampm="AM";}
else if(val.substring(i_val,i_val+2).toLowerCase()=="pm"){ampm="PM";}
else{return 0;}
i_val+=2;}
else{
if(val.substring(i_val,i_val+token.length)!=token){return 0;}
else{i_val+=token.length;}
}
}
if(i_val !=val.length){ return 0;}
if(month==2){
if(((year%4==0)&&(year%100 !=0) )||(year%400==0) ){ // leap year
if(date > 29){ return 0;}
}
else{ if(date > 28){ return 0;}}
}
if((month==4)||(month==6)||(month==9)||(month==11)){
if(date > 30){ return 0;}
}
if(hh<12&&ampm=="PM"){ hh=hh-0+12;}
else if(hh>11&&ampm=="AM"){ hh-=12;}
var newdate=new Date(year,month-1,date,hh,mm,ss);
return newdate.getTime();
}
function parseDate(val){
var preferEuro=(arguments.length==2)?arguments[1]:false;
generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
dateFirst=new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
var d=null;
for(var i=0; i<checkList.length; i++){
var l=window[checkList[i]];
for(var j=0; j<l.length; j++){
d=getDateFromFormat(val,l[j]);
if(d!=0){ return new Date(d);}
}
}
return null;
}

function PopupWindow_getXYPosition(anchorname){
var coordinates;
if(this.type=="WINDOW"){
coordinates=getAnchorWindowPosition(anchorname);
}
else{
coordinates=getAnchorPosition(anchorname);
}
this.x=coordinates.x;
this.y=coordinates.y;
}
function PopupWindow_setSize(width,height){
this.width=width;
this.height=height;
}
function PopupWindow_populate(contents){
this.contents=contents;
this.populated=false;
}
function PopupWindow_setUrl(url){
this.url=url;
}
function PopupWindow_setWindowProperties(props){
this.windowProperties=props;
}
function PopupWindow_refresh(){
if(this.divName !=null){
if(this.use_gebi){
document.getElementById(this.divName).innerHTML=this.contents;
}
else if(this.use_css){ 
document.all[this.divName].innerHTML=this.contents;
}
else if(this.use_layers){ 
var d=document.layers[this.divName]; 
d.document.open();
d.document.writeln(this.contents);
d.document.close();
}
}
else{
if(this.popupWindow !=null&&!this.popupWindow.closed){
if(this.url!=""){
this.popupWindow.location.href=this.url;
}
else{
this.popupWindow.document.open();
this.popupWindow.document.writeln(this.contents);
this.popupWindow.document.close();
}
this.popupWindow.focus();
}
}
}
function PopupWindow_showPopup(anchorname){
this.getXYPosition(anchorname);
this.x+=this.offsetX;
this.y+=this.offsetY;
if(!this.populated&&(this.contents !="")){
this.populated=true;
this.refresh();
}
if(this.divName !=null){
if(this.use_gebi){
document.getElementById(this.divName).style.left=this.x + "px";
document.getElementById(this.divName).style.top=this.y + "px";
document.getElementById(this.divName).style.visibility="visible";
}
else if(this.use_css){
document.all[this.divName].style.left=this.x;
document.all[this.divName].style.top=this.y;
document.all[this.divName].style.visibility="visible";
}
else if(this.use_layers){
document.layers[this.divName].left=this.x;
document.layers[this.divName].top=this.y;
document.layers[this.divName].visibility="visible";
}
}
else{
if(this.popupWindow==null||this.popupWindow.closed){
if(this.x<0){ this.x=0;}
if(this.y<0){ this.y=0;}
if(screen&&screen.availHeight){
if((this.y + this.height) > screen.availHeight){
this.y=screen.availHeight - this.height;
}
}
if(screen&&screen.availWidth){
if((this.x + this.width) > screen.availWidth){
this.x=screen.availWidth - this.width;
}
}
var avoidAboutBlank=window.opera||( document.layers&&!navigator.mimeTypes['*'] )||navigator.vendor=='KDE'||( document.childNodes&&!document.all&&!navigator.taintEnabled );
this.popupWindow=window.open(avoidAboutBlank?"":"about:blank","window_"+anchorname,this.windowProperties+",width="+this.width+",height="+this.height+",screenX="+this.x+",left="+this.x+",screenY="+this.y+",top="+this.y+"");
}
this.refresh();
}
}
function PopupWindow_hidePopup()
{
if(this.divName !=null)
{
if(this.use_gebi)
{
try
{
document.getElementById(this.divName).style.visibility="hidden";
}
catch(e)
{
}
}
else if(this.use_css){
document.all[this.divName].style.visibility="hidden";
}
else if(this.use_layers){
document.layers[this.divName].visibility="hidden";
}
}
else{
if(this.popupWindow&&!this.popupWindow.closed){
this.popupWindow.close();
this.popupWindow=null;
}
}
}
function PopupWindow_isClicked(e){
if(this.divName !=null){
if(this.use_layers){
var clickX=e.pageX;
var clickY=e.pageY;
var t=document.layers[this.divName];
if((clickX > t.left)&&(clickX < t.left+t.clip.width)&&(clickY > t.top)&&(clickY < t.top+t.clip.height)){
return true;
}
else{ return false;}
}
else if(document.all)
{
var t=window.event.srcElement;
while(t.parentElement !=null)
{
if(t.id==this.divName)
{
return true;
}
t=t.parentElement;
}
return false;
}
else if(this.use_gebi&&e)
{
var t=e.originalTarget;
try
{
while(t.parentNode !=null)
{
if(t.id==this.divName)
{
return true;
}
t=t.parentNode;
}
}
catch(e)
{
}
return false;
}
return false;
}
return false;
}
function PopupWindow_hideIfNotClicked(e){
if(this.autoHideEnabled&&!this.isClicked(e)){
this.hidePopup();
}
}
function PopupWindow_autoHide(){
this.autoHideEnabled=true;
}
function PopupWindow_hidePopupWindows(e){
for(var i=0; i<popupWindowObjects.length; i++){
if(popupWindowObjects[i] !=null){
var p=popupWindowObjects[i];
p.hideIfNotClicked(e);
}
}
}
function PopupWindow_attachListener(){
if(document.layers){
document.captureEvents(Event.MOUSEUP);
}
window.popupWindowOldEventListener=document.onmouseup;
if(window.popupWindowOldEventListener !=null){
document.onmouseup=new Function("window.popupWindowOldEventListener(); PopupWindow_hidePopupWindows();");
}
else{
document.onmouseup=PopupWindow_hidePopupWindows;
}
}
function PopupWindow(){
if(!window.popupWindowIndex){ window.popupWindowIndex=0;}
if(!window.popupWindowObjects){ window.popupWindowObjects=new Array();}
if(!window.listenerAttached){
window.listenerAttached=true;
PopupWindow_attachListener();
}
this.index=popupWindowIndex++;
popupWindowObjects[this.index]=this;
this.divName=null;
this.popupWindow=null;
this.width=0;
this.height=0;
this.populated=false;
this.visible=false;
this.autoHideEnabled=false;

this.contents="";
this.url="";
this.windowProperties="toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable,alwaysRaised,dependent,titlebar=no";
if(arguments.length>0){
this.type="DIV";
this.divName=arguments[0];
}
else{
this.type="WINDOW";
}
this.use_gebi=false;
this.use_css=false;
this.use_layers=false;
if(document.getElementById){ this.use_gebi=true;}
else if(document.all){ this.use_css=true;}
else if(document.layers){ this.use_layers=true;}
else{ this.type="WINDOW";}
this.offsetX=0;
this.offsetY=0;
this.getXYPosition=PopupWindow_getXYPosition;
this.populate=PopupWindow_populate;
this.setUrl=PopupWindow_setUrl;
this.setWindowProperties=PopupWindow_setWindowProperties;
this.refresh=PopupWindow_refresh;
this.showPopup=PopupWindow_showPopup;
this.hidePopup=PopupWindow_hidePopup;
this.setSize=PopupWindow_setSize;
this.isClicked=PopupWindow_isClicked;
this.autoHide=PopupWindow_autoHide;
this.hideIfNotClicked=PopupWindow_hideIfNotClicked;
}

function CalendarPopup(){
var c;
if(arguments.length>0){
c=new PopupWindow(arguments[0]);
}
else{
c=new PopupWindow();
c.setSize(150,175);
}
c.offsetX=-152;
c.offsetY=25;
c.autoHide();
c.monthNames=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
c.monthAbbreviations=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
c.dayHeaders=new Array("S","M","T","W","T","F","S");
c.returnFunction="CP_tmpReturnFunction";
c.returnMonthFunction="CP_tmpReturnMonthFunction";
c.returnQuarterFunction="CP_tmpReturnQuarterFunction";
c.returnYearFunction="CP_tmpReturnYearFunction";
c.weekStartDay=0;
c.isShowYearNavigation=false;
c.displayType="date";
c.disabledWeekDays=new Object();
c.disabledDatesExpression="";
c.yearSelectStartOffset=2;
c.currentDate=null;
c.todayText="Today";
c.cssPrefix="";
c.isShowNavigationDropdowns=false;
c.isShowYearNavigationInput=false;
window.CP_calendarObject=null;
window.CP_targetInput=null;
window.CP_dateFormat="MM/dd/yyyy";
c.copyMonthNamesToWindow=CP_copyMonthNamesToWindow;
c.setReturnFunction=CP_setReturnFunction;
c.setReturnMonthFunction=CP_setReturnMonthFunction;
c.setReturnQuarterFunction=CP_setReturnQuarterFunction;
c.setReturnYearFunction=CP_setReturnYearFunction;
c.setMonthNames=CP_setMonthNames;
c.setMonthAbbreviations=CP_setMonthAbbreviations;
c.setDayHeaders=CP_setDayHeaders;
c.setWeekStartDay=CP_setWeekStartDay;
c.setDisplayType=CP_setDisplayType;
c.setDisabledWeekDays=CP_setDisabledWeekDays;
c.addDisabledDates=CP_addDisabledDates;
c.setYearSelectStartOffset=CP_setYearSelectStartOffset;
c.setTodayText=CP_setTodayText;
c.showYearNavigation=CP_showYearNavigation;
c.showCalendar=CP_showCalendar;
c.hideCalendar=CP_hideCalendar;
c.getStyles=getCalendarStyles;
c.refreshCalendar=CP_refreshCalendar;
c.getCalendar=CP_getCalendar;
c.select=CP_select;
c.setCssPrefix=CP_setCssPrefix;
c.showNavigationDropdowns=CP_showNavigationDropdowns;
c.showYearNavigationInput=CP_showYearNavigationInput;
c.copyMonthNamesToWindow();
return c;
}
function CP_copyMonthNamesToWindow(){
if(typeof(window.MONTH_NAMES)!="undefined"&&window.MONTH_NAMES!=null){
window.MONTH_NAMES=new Array();
for(var i=0; i<this.monthNames.length; i++){
window.MONTH_NAMES[window.MONTH_NAMES.length]=this.monthNames[i];
}
for(var i=0; i<this.monthAbbreviations.length; i++){
window.MONTH_NAMES[window.MONTH_NAMES.length]=this.monthAbbreviations[i];
}
}
}
function CP_tmpReturnFunction(y,m,d){ 
if(window.CP_targetInput!=null){
var dt=new Date(y,m-1,d,0,0,0);
if(window.CP_calendarObject!=null){ window.CP_calendarObject.copyMonthNamesToWindow();}
window.CP_targetInput.value=formatDate(dt,window.CP_dateFormat);
}
else{
alert('Use setReturnFunction() to define which function will get the clicked results!'); 
}
}
function CP_tmpReturnMonthFunction(y,m){ 
alert('Use setReturnMonthFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , month='+m); 
}
function CP_tmpReturnQuarterFunction(y,q){ 
alert('Use setReturnQuarterFunction() to define which function will get the clicked results!\nYou clicked: year='+y+' , quarter='+q); 
}
function CP_tmpReturnYearFunction(y){ 
alert('Use setReturnYearFunction() to define which function will get the clicked results!\nYou clicked: year='+y); 
}
function CP_setReturnFunction(name){ this.returnFunction=name;}
function CP_setReturnMonthFunction(name){ this.returnMonthFunction=name;}
function CP_setReturnQuarterFunction(name){ this.returnQuarterFunction=name;}
function CP_setReturnYearFunction(name){ this.returnYearFunction=name;}
function CP_setMonthNames(){
for(var i=0; i<arguments.length; i++){ this.monthNames[i]=arguments[i];}
this.copyMonthNamesToWindow();
}
function CP_setMonthAbbreviations(){
for(var i=0; i<arguments.length; i++){ this.monthAbbreviations[i]=arguments[i];}
this.copyMonthNamesToWindow();
}
function CP_setDayHeaders(){
for(var i=0; i<arguments.length; i++){ this.dayHeaders[i]=arguments[i];}
}
function CP_setWeekStartDay(day){ this.weekStartDay=day;}
function CP_showYearNavigation(){ this.isShowYearNavigation=(arguments.length>0)?arguments[0]:true;}
function CP_setDisplayType(type){
if(type!="date"&&type!="week-end"&&type!="month"&&type!="quarter"&&type!="year"){ alert("Invalid display type! Must be one of: date,week-end,month,quarter,year"); return false;}
this.displayType=type;
}
function CP_setYearSelectStartOffset(num){ this.yearSelectStartOffset=num;}
function CP_setDisabledWeekDays(){
this.disabledWeekDays=new Object();
for(var i=0; i<arguments.length; i++){ this.disabledWeekDays[arguments[i]]=true;}
}
function CP_addDisabledDates(start, end){
if(arguments.length==1){ end=start;}
if(start==null&&end==null){ return;}
if(this.disabledDatesExpression!=""){ this.disabledDatesExpression+="||";}
if(start!=null){ start=parseDate(start); start=""+start.getFullYear()+LZ(start.getMonth()+1)+LZ(start.getDate());}
if(end!=null){ end=parseDate(end); end=""+end.getFullYear()+LZ(end.getMonth()+1)+LZ(end.getDate());}
if(start==null){ this.disabledDatesExpression+="(ds<="+end+")";}
else if(end==null){ this.disabledDatesExpression+="(ds>="+start+")";}
else{ this.disabledDatesExpression+="(ds>="+start+"&&ds<="+end+")";}
}
function CP_setTodayText(text){
this.todayText=text;
}
function CP_setCssPrefix(val){ 
this.cssPrefix=val; 
}
function CP_showNavigationDropdowns(){ this.isShowNavigationDropdowns=(arguments.length>0)?arguments[0]:true;}
function CP_showYearNavigationInput(){ this.isShowYearNavigationInput=(arguments.length>0)?arguments[0]:true;}
function CP_hideCalendar(){
if(arguments.length > 0){ window.popupWindowObjects[arguments[0]].hidePopup();}
else{ this.hidePopup();}
}
function CP_refreshCalendar(index){
var calObject=window.popupWindowObjects[index];
if(arguments.length>1){ 
calObject.populate(calObject.getCalendar(arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]));
}
else{
calObject.populate(calObject.getCalendar());
}
calObject.refresh();
}
function CP_showCalendar(anchorname){
if(arguments.length>1){
if(arguments[1]==null||arguments[1]==""){
this.currentDate=new Date();
}
else{
this.currentDate=new Date(parseDate(arguments[1]));
}
}
this.populate(this.getCalendar());
this.showPopup(anchorname);
}
function CP_select(inputobj, linkname, format){
var selectedDate=(arguments.length>3)?arguments[3]:null;
if(!window.getDateFromFormat){
alert("calendar.select: To use this method you must also include 'date.js' for date formatting");
return;
}
if(this.displayType!="date"&&this.displayType!="week-end"){
alert("calendar.select: This function can only be used with displayType 'date' or 'week-end'");
return;
}
if(inputobj.type!="text"&&inputobj.type!="hidden"&&inputobj.type!="textarea"){ 
alert("calendar.select: Input object passed is not a valid form input object"); 
window.CP_targetInput=null;
return;
}
if(inputobj.disabled){ return;}
window.CP_targetInput=inputobj;
window.CP_calendarObject=this;
this.currentDate=null;
var time=0;
if(selectedDate!=null){
time=getDateFromFormat(selectedDate,format)
}
else if(inputobj.value!=""){
time=getDateFromFormat(inputobj.value,format);
}
if(selectedDate!=null||inputobj.value!=""){
if(time==0){ this.currentDate=null;}
else{ this.currentDate=new Date(time);}
}
window.CP_dateFormat=format;
this.showCalendar(linkname);
}
function getCalendarStyles(){
var result="";
var p="";
if(this!=null&&typeof(this.cssPrefix)!="undefined"&&this.cssPrefix!=null&&this.cssPrefix!=""){ p=this.cssPrefix;}
result+="<STYLE>\n";
result+="."+p+"cpYearNavigation,."+p+"cpMonthNavigation{ background-color:#C0C0C0; text-align:center; vertical-align:center; text-decoration:none; color:#000000; font-weight:bold;}\n";
result+="."+p+"cpDayColumnHeader, ."+p+"cpYearNavigation,."+p+"cpMonthNavigation,."+p+"cpCurrentMonthDate,."+p+"cpCurrentMonthDateDisabled,."+p+"cpOtherMonthDate,."+p+"cpOtherMonthDateDisabled,."+p+"cpCurrentDate,."+p+"cpCurrentDateDisabled,."+p+"cpTodayText,."+p+"cpTodayTextDisabled,."+p+"cpText{ font-family:arial; font-size:8pt;}\n";
result+="TD."+p+"cpDayColumnHeader{ text-align:right; border:solid thin #C0C0C0;border-width:0px 0px 1px 0px;}\n";
result+="."+p+"cpCurrentMonthDate, ."+p+"cpOtherMonthDate, ."+p+"cpCurrentDate{ text-align:right; text-decoration:none;}\n";
result+="."+p+"cpCurrentMonthDateDisabled, ."+p+"cpOtherMonthDateDisabled, ."+p+"cpCurrentDateDisabled{ color:#D0D0D0; text-align:right; text-decoration:line-through;}\n";
result+="."+p+"cpCurrentMonthDate, .cpCurrentDate{ color:#000000;}\n";
result+="."+p+"cpOtherMonthDate{ color:#808080;}\n";
result+="TD."+p+"cpCurrentDate{ color:white; background-color: #C0C0C0; border-width:1px; border:solid thin #800000;}\n";
result+="TD."+p+"cpCurrentDateDisabled{ border-width:1px; border:solid thin #FFAAAA;}\n";
result+="TD."+p+"cpTodayText, TD."+p+"cpTodayTextDisabled{ border:solid thin #C0C0C0; border-width:1px 0px 0px 0px;}\n";
result+="A."+p+"cpTodayText, SPAN."+p+"cpTodayTextDisabled{ height:20px;}\n";
result+="A."+p+"cpTodayText{ color:black;}\n";
result+="."+p+"cpTodayTextDisabled{ color:#D0D0D0;}\n";
result+="."+p+"cpBorder{ border:solid thin #808080;}\n";
result+="</STYLE>\n";
return result;
}
function CP_getCalendar(){
if(this.currentDate==null) var now=new Date();
else var now=this.currentDate;
if(this.type=="WINDOW"){ var windowref="window.opener.";}
else{ var windowref="";}
var result="";
if(this.type=="WINDOW"){
result+="<HTML><HEAD><TITLE>Calendar</TITLE>"+this.getStyles()+"</HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 TOPMARGIN=0 RIGHTMARGIN=0 LEFTMARGIN=0>\n";
result+='<CENTER><TABLE WIDTH=100% BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>\n';
}
else{
result+='<TABLE CLASS="'+this.cssPrefix+'cpBorder" WIDTH=144 BORDER=1 BORDERWIDTH=1 CELLSPACING=0 CELLPADDING=1>\n';
result+='<TR><TD ALIGN=CENTER>\n';
result+='<CENTER>\n';
}
if(this.displayType=="date"||this.displayType=="week-end"){
now=new Date();
if(this.currentDate==null){ this.currentDate=now;}
if(arguments.length > 0){ var month=arguments[0];}
else{ var month=this.currentDate.getMonth()+1;}
if(arguments.length > 1&&arguments[1]>0&&arguments[1]-0==arguments[1]){ var year=arguments[1];}
else{ var year=this.currentDate.getFullYear();}
var daysinmonth=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if(((year%4==0)&&(year%100 !=0) )||(year%400==0) ){
daysinmonth[2]=29;
}
var current_month=new Date(year,month-1,1);
var display_year=year;
var display_month=month;
var display_date=1;
var weekday=current_month.getDay();
var offset=0;

offset=(weekday >=this.weekStartDay) ? weekday-this.weekStartDay : 7-this.weekStartDay+weekday ;
if(offset > 0){
display_month--;
if(display_month < 1){ display_month=12; display_year--;}
display_date=daysinmonth[display_month]-offset+1;
}
var next_month=month+1;
var next_month_year=year;
if(next_month > 12){ next_month=1; next_month_year++;}
var last_month=month-1;
var last_month_year=year;
if(last_month < 1){ last_month=12; last_month_year--;}
var date_class;
if(this.type!="WINDOW"){
result+="<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
}
result+='<TR>\n';
var refresh=windowref+'CP_refreshCalendar';
var refreshLink='javascript:' + refresh;
if(this.isShowNavigationDropdowns){
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="78" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpMonthNavigation" name="cpMonth" onChange="'+refresh+'('+this.index+',this.options[this.selectedIndex].value-0,'+(year-0)+');">';
for( var monthCounter=1; monthCounter<=12; monthCounter++ ){
var selected=(monthCounter==month) ? 'SELECTED' : '';
result+='<option value="'+monthCounter+'" '+selected+'>'+this.monthNames[monthCounter-1]+'</option>';
}
result+='</select></TD>';
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';

result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="56" COLSPAN="3"><select CLASS="'+this.cssPrefix+'cpYearNavigation" name="cpYear" onChange="'+refresh+'('+this.index+','+month+',this.options[this.selectedIndex].value-0);">';
for( var yearCounter=year-this.yearSelectStartOffset; yearCounter<=year+this.yearSelectStartOffset; yearCounter++ ){
var selected=(yearCounter==year) ? 'SELECTED' : '';
result+='<option value="'+yearCounter+'" '+selected+'>'+yearCounter+'</option>';
}
result+='</select></TD>';
}
else{
if(this.isShowYearNavigation){
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;</A></TD>';
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="58"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+'</SPAN></TD>';
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;</A></TD>';
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="10">&nbsp;</TD>';

result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year-1)+');">&lt;</A></TD>';
if(this.isShowYearNavigationInput){
result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><INPUT NAME="cpYear" CLASS="'+this.cssPrefix+'cpYearNavigation" SIZE="4" MAXLENGTH="4" VALUE="'+year+'" onBlur="'+refresh+'('+this.index+','+month+',this.value-0);"></TD>';
}
else{
result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="36"><SPAN CLASS="'+this.cssPrefix+'cpYearNavigation">'+year+'</SPAN></TD>';
}
result+='<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="10"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="'+refreshLink+'('+this.index+','+month+','+(year+1)+');">&gt;</A></TD>';
}
else{
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+last_month+','+last_month_year+');">&lt;&lt;</A></TD>\n';
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="100"><SPAN CLASS="'+this.cssPrefix+'cpMonthNavigation">'+this.monthNames[month-1]+' '+year+'</SPAN></TD>\n';
result+='<TD CLASS="'+this.cssPrefix+'cpMonthNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpMonthNavigation" HREF="'+refreshLink+'('+this.index+','+next_month+','+next_month_year+');">&gt;&gt;</A></TD>\n';
}
}
result+='</TR></TABLE>\n';
result+='<TABLE WIDTH=120 BORDER=0 CELLSPACING=0 CELLPADDING=1 ALIGN=CENTER>\n';
result+='<TR>\n';
for(var j=0; j<7; j++){

result+='<TD CLASS="'+this.cssPrefix+'cpDayColumnHeader" WIDTH="14%"><SPAN CLASS="'+this.cssPrefix+'cpDayColumnHeader">'+this.dayHeaders[(this.weekStartDay+j)%7]+'</TD>\n';
}
result+='</TR>\n';
for(var row=1; row<=6; row++){
result+='<TR>\n';
for(var col=1; col<=7; col++){
var disabled=false;
if(this.disabledDatesExpression!=""){
var ds=""+display_year+LZ(display_month)+LZ(display_date);
eval("disabled=("+this.disabledDatesExpression+")");
}
var dateClass="";
if((display_month==this.currentDate.getMonth()+1)&&(display_date==this.currentDate.getDate())&&(display_year==this.currentDate.getFullYear())){
dateClass="cpCurrentDate";
}
else if(display_month==month){
dateClass="cpCurrentMonthDate";
}
else{
dateClass="cpOtherMonthDate";
}
if(disabled||this.disabledWeekDays[col-1]){
result+='	<TD CLASS="'+this.cssPrefix+dateClass+'"><SPAN CLASS="'+this.cssPrefix+dateClass+'Disabled">'+display_date+'</SPAN></TD>\n';
}
else{
var selected_date=display_date;
var selected_month=display_month;
var selected_year=display_year;
if(this.displayType=="week-end"){
var d=new Date(selected_year,selected_month-1,selected_date,0,0,0,0);
d.setDate(d.getDate() +(7-col));
selected_year=d.getYear();
if(selected_year < 1000){ selected_year+=1900;}
selected_month=d.getMonth()+1;
selected_date=d.getDate();
}
result+='	<TD CLASS="'+this.cssPrefix+dateClass+'"><A HREF="javascript:'+windowref+this.returnFunction+'('+selected_year+','+selected_month+','+selected_date+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+this.cssPrefix+dateClass+'">'+display_date+'</A></TD>\n';
}
display_date++;
if(display_date > daysinmonth[display_month]){
display_date=1;
display_month++;
}
if(display_month > 12){
display_month=1;
display_year++;
}
}
result+='</TR>';
}
var current_weekday=now.getDay() - this.weekStartDay;
if(current_weekday < 0){
current_weekday+=7;
}
result+='<TR>\n';
result+='	<TD COLSPAN=7 ALIGN=CENTER CLASS="'+this.cssPrefix+'cpTodayText">\n';
if(this.disabledDatesExpression!=""){
var ds=""+now.getFullYear()+LZ(now.getMonth()+1)+LZ(now.getDate());
eval("disabled=("+this.disabledDatesExpression+")");
}
if(disabled||this.disabledWeekDays[current_weekday+1]){
result+='		<SPAN CLASS="'+this.cssPrefix+'cpTodayTextDisabled">'+this.todayText+'</SPAN>\n';
}
else{
result+='		<A CLASS="'+this.cssPrefix+'cpTodayText" HREF="javascript:'+windowref+this.returnFunction+'(\''+now.getFullYear()+'\',\''+(now.getMonth()+1)+'\',\''+now.getDate()+'\');'+windowref+'CP_hideCalendar(\''+this.index+'\');">'+this.todayText+'</A>\n';
}
result+='		<BR>\n';
result+='	</TD></TR></TABLE></CENTER></TD></TR></TABLE>\n';
}
if(this.displayType=="month"||this.displayType=="quarter"||this.displayType=="year"){
if(arguments.length > 0){ var year=arguments[0];}
else{ 
if(this.displayType=="year"){	var year=now.getFullYear()-this.yearSelectStartOffset;}
else{ var year=now.getFullYear();}
}
if(this.displayType!="year"&&this.isShowYearNavigation){
result+="<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
result+='<TR>\n';
result+='	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-1)+');">&lt;&lt;</A></TD>\n';
result+='	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="100">'+year+'</TD>\n';
result+='	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="22"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+1)+');">&gt;&gt;</A></TD>\n';
result+='</TR></TABLE>\n';
}
}
if(this.displayType=="month"){
result+='<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
for(var i=0; i<4; i++){
result+='<TR>';
for(var j=0; j<3; j++){
var monthindex=((i*3)+j);
result+='<TD WIDTH=33% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnMonthFunction+'('+year+','+(monthindex+1)+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+this.monthAbbreviations[monthindex]+'</A></TD>';
}
result+='</TR>';
}
result+='</TABLE></CENTER></TD></TR></TABLE>\n';
}
if(this.displayType=="quarter"){
result+='<BR><TABLE WIDTH=120 BORDER=1 CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER>\n';
for(var i=0; i<2; i++){
result+='<TR>';
for(var j=0; j<2; j++){
var quarter=((i*2)+j+1);
result+='<TD WIDTH=50% ALIGN=CENTER><BR><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnQuarterFunction+'('+year+','+quarter+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">Q'+quarter+'</A><BR><BR></TD>';
}
result+='</TR>';
}
result+='</TABLE></CENTER></TD></TR></TABLE>\n';
}
if(this.displayType=="year"){
var yearColumnSize=4;
result+="<TABLE WIDTH=144 BORDER=0 BORDERWIDTH=0 CELLSPACING=0 CELLPADDING=0>";
result+='<TR>\n';
result+='	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year-(yearColumnSize*2))+');">&lt;&lt;</A></TD>\n';
result+='	<TD CLASS="'+this.cssPrefix+'cpYearNavigation" WIDTH="50%"><A CLASS="'+this.cssPrefix+'cpYearNavigation" HREF="javascript:'+windowref+'CP_refreshCalendar('+this.index+','+(year+(yearColumnSize*2))+');">&gt;&gt;</A></TD>\n';
result+='</TR></TABLE>\n';
result+='<TABLE WIDTH=120 BORDER=0 CELLSPACING=1 CELLPADDING=0 ALIGN=CENTER>\n';
for(var i=0; i<yearColumnSize; i++){
for(var j=0; j<2; j++){
var currentyear=year+(j*yearColumnSize)+i;
result+='<TD WIDTH=50% ALIGN=CENTER><A CLASS="'+this.cssPrefix+'cpText" HREF="javascript:'+windowref+this.returnYearFunction+'('+currentyear+');'+windowref+'CP_hideCalendar(\''+this.index+'\');" CLASS="'+date_class+'">'+currentyear+'</A></TD>';
}
result+='</TR>';
}
result+='</TABLE></CENTER></TD></TR></TABLE>\n';
}
if(this.type=="WINDOW"){
result+="</BODY></HTML>\n";
}
return result;
}

// Author: Matt Kruse <matt@ajaxtoolbox.com>
// WWW: http://www.AjaxToolbox.com/
function AjaxRequest() {
	var req = new Object();
	req.timeout = null;
	req.generateUniqueUrl = true;
	req.url = window.location.href;
	req.method = "GET";
	req.async = true;
	req.username = null;
	req.password = null;
	req.parameters = new Object();
	req.requestIndex = AjaxRequest.numAjaxRequests++;
	req.responseReceived = false;
	req.groupName = null;
	req.queryString = "";
	req.responseText = null;
	req.responseXML = null;
	req.status = null;
	req.statusText = null;
	req.aborted = false;
	req.xmlHttpRequest = null;
	req.onTimeout = null; 
	req.onLoading = null;
	req.onLoaded = null;
	req.onInteractive = null;
	req.onComplete = null;
	req.onSuccess = null;
	req.onError = null;
	req.onGroupBegin = null;
	req.onGroupEnd = null;
	req.xmlHttpRequest = AjaxRequest.getXmlHttpRequest();
	if (req.xmlHttpRequest==null) { return null; }
	req.xmlHttpRequest.onreadystatechange = 
	function() {
		if (req==null || req.xmlHttpRequest==null) { return; }
		if (req.xmlHttpRequest.readyState==1) { req.onLoadingInternal(req); }
		if (req.xmlHttpRequest.readyState==2) { req.onLoadedInternal(req); }
		if (req.xmlHttpRequest.readyState==3) { req.onInteractiveInternal(req); }
		if (req.xmlHttpRequest.readyState==4) { req.onCompleteInternal(req); }
	};
	req.onLoadingInternalHandled = false;
	req.onLoadedInternalHandled = false;
	req.onInteractiveInternalHandled = false;
	req.onCompleteInternalHandled = false;
	req.onLoadingInternal = 
		function() {
			if (req.onLoadingInternalHandled) { return; }
			AjaxRequest.numActiveAjaxRequests++;
			if (AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function") {
				AjaxRequestBegin();
			}
			if (req.groupName!=null) {
				if (typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined") {
					AjaxRequest.numActiveAjaxGroupRequests[req.groupName] = 0;
				}
				AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
				if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function") {
					req.onGroupBegin(req.groupName);
				}
			}
			if (typeof(req.onLoading)=="function") {
				req.onLoading(req);
			}
			req.onLoadingInternalHandled = true;
		};
	req.onLoadedInternal = 
		function() {
			if (req.onLoadedInternalHandled) { return; }
			if (typeof(req.onLoaded)=="function") {
				req.onLoaded(req);
			}
			req.onLoadedInternalHandled = true;
		};
	req.onInteractiveInternal = 
		function() {
			if (req.onInteractiveInternalHandled) { return; }
			if (typeof(req.onInteractive)=="function") {
				req.onInteractive(req);
			}
			req.onInteractiveInternalHandled = true;
		};
	req.onCompleteInternal = 
		function() {
			if (req.onCompleteInternalHandled || req.aborted) { return; }
			req.onCompleteInternalHandled = true;
			AjaxRequest.numActiveAjaxRequests--;
			if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
				AjaxRequestEnd(req.groupName);
			}
			if (req.groupName!=null) {
				AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
				if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
					req.onGroupEnd(req.groupName);
				}
			}
			req.responseReceived = true;
			req.status = req.xmlHttpRequest.status;
			req.statusText = req.xmlHttpRequest.statusText;
			req.responseText = req.xmlHttpRequest.responseText;
			req.responseXML = req.xmlHttpRequest.responseXML;
			if (typeof(req.onComplete)=="function") {
				req.onComplete(req);
			}
			if (req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function") {
				req.onSuccess(req);
			}
			else if (typeof(req.onError)=="function") {
				req.onError(req);
			}
			delete req.xmlHttpRequest['onreadystatechange'];
			req.xmlHttpRequest = null;
		};
	req.onTimeoutInternal = 
		function() {
			if (req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled) {
				req.aborted = true;
				req.xmlHttpRequest.abort();
				AjaxRequest.numActiveAjaxRequests--;
				if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
					AjaxRequestEnd(req.groupName);
				}
				if (req.groupName!=null) {
					AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
					if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
						req.onGroupEnd(req.groupName);
					}
				}
				if (typeof(req.onTimeout)=="function") {
					req.onTimeout(req);
				}
			delete req.xmlHttpRequest['onreadystatechange'];
			req.xmlHttpRequest = null;
			}
		};
	req.process = 
		function() {
			if (req.xmlHttpRequest!=null) {
				// Some logic to get the real request URL
				if (req.generateUniqueUrl && req.method=="GET") {
					req.parameters["AjaxRequestUniqueId"] = new Date().getTime() + "" + req.requestIndex;
				}
				var content = null; // For POST requests, to hold query string
				for (var i in req.parameters) {
					if (req.queryString.length>0) { req.queryString += "&"; }
					//req.queryString += encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);
					req.queryString += AjaxRequest.encodeURIComponent(i) + "=" + AjaxRequest.encodeURIComponent(req.parameters[i]);
				}
				if (req.method=="GET") {
					if (req.queryString.length>0) {
						req.url += ((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;
					}
				}
				req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
				if (req.method=="POST") {
					if (typeof(req.xmlHttpRequest.setRequestHeader)!="undefined") {
						req.xmlHttpRequest.setRequestHeader('Content-type', "application/x-www-form-urlencoded");
					}
					content = req.queryString;
				}
				if (req.timeout>0) {
					setTimeout(req.onTimeoutInternal,req.timeout);
				}
				
				req.xmlHttpRequest.send(content);
			}
		};
	req.handleArguments = 
		function(args) {
			for (var i in args) {
				if (typeof(req[i])=="undefined") {
					req.parameters[i] = args[i];
				}
				else {
					req[i] = args[i];
				}
			}
		};
	req.getAllResponseHeaders =
		function() {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getAllResponseHeaders();
				}
				alert("Cannot getAllResponseHeaders because a response has not yet been received");
			}
		};
	req.getResponseHeader =
		function(headerName) {
			if (req.xmlHttpRequest!=null) {
				if (req.responseReceived) {
					return req.xmlHttpRequest.getResponseHeader(headerName);
				}
				alert("Cannot getResponseHeader because a response has not yet been received");
			}
		};
	return req;
}
AjaxRequest.getXmlHttpRequest = function() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		// Based on http://jibbering.com/2002/4/httprequest.html
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				return null;
			}
		}
		@end @*/
	}
	else {
		return null;
	}
};
AjaxRequest.isActive = function() {
	return (AjaxRequest.numActiveAjaxRequests>0);
};
AjaxRequest.get = function(args) {
	AjaxRequest.doRequest("GET",args);
};
AjaxRequest.post = function(args) {
	AjaxRequest.doRequest("POST",args);
};
AjaxRequest.doRequest = function(method,args) {
	if (typeof(args)!="undefined" && args!=null) {
		var myRequest = new AjaxRequest();
		myRequest.method = method;
		myRequest.handleArguments(args);
		myRequest.process();
	}
}	;
AjaxRequest.submit = function(theform, args) {
	var myRequest = new AjaxRequest();
	if (myRequest==null) { return false; }
	var serializedForm = AjaxRequest.serializeForm(theform);
	myRequest.method = theform.method.toUpperCase();
	myRequest.url = theform.action;
	myRequest.handleArguments(args);
	myRequest.queryString = serializedForm;
	myRequest.process();
	return true;
};
AjaxRequest.serializeForm = function(theform) {
	var els = theform.elements;
	var len = els.length;
	var queryString = "";
	this.addField = 
		function(name,value) { 
			if (queryString.length>0) { 
				queryString += "&";
			}
			//queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
			queryString += this.encodeURIComponent(name) + "=" + this.encodeURIComponent(value);
		};
	for (var i=0; i<len; i++) {
		var el = els[i];
		if (!el.disabled) {
			switch(el.type) {
				case 'text': case 'password': case 'hidden': case 'textarea': 
					this.addField(el.name,el.value);
					break;
				case 'select-one':
					if (el.selectedIndex>=0) {
						this.addField(el.name,el.options[el.selectedIndex].value);
					}
					break;
				case 'select-multiple':
					for (var j=0; j<el.options.length; j++) {
						if (el.options[j].selected) {
							this.addField(el.name,el.options[j].value);
						}
					}
					break;
				case 'checkbox': case 'radio':
					if (el.checked) {
						this.addField(el.name,el.value);
					}
					break;
			}
		}
	}
	return queryString;
};
AjaxRequest.encodeURIComponent = function(str)
{
	var s = escape(str);
	s = s.replace('+', '%2B');
	s = s.replace('@', '%40');
	s = s.replace('/', '%2F');
	return s;
}
AjaxRequest.numActiveAjaxRequests = 0;
AjaxRequest.numActiveAjaxGroupRequests = new Object();
AjaxRequest.numAjaxRequests = 0;

/*
	csc.js	-	Client Server Communication
*/
var debugstr = '';
function CSC_Request(action, request, params)
{
	url = 'main.php' + "?ts=" + (new Date()).getTime() + "&req[requestFile]=" + action + "&req[request]=" + request + "&req[charEncode]=UTF8";
	
	var list = new Object();
	for (i in params)
	{
		list = concat(list, toPHP(params[i], i));
	}
	
	for (i in list)
	{
		var name_len = i.indexOf('[');
		if (name_len < 0) name_len = i.length;
		
		var name = 'req[' + i.substr(0, name_len) + ']' + i.substr(name_len);
		url += "&" + name + "=" + encodeURIComponent(list[i]);
	}

	var o = document.getElementById("CSC_42");
	var head = document.getElementsByTagName("head").item(0);
	
	// Destory object
	if (o) head.removeChild(o);

	// Create object
	o = document.createElement("script");
	o.setAttribute("src", url);
	o.setAttribute("id", "CSC_42");
	
	// Add object to head of page
	head.appendChild(o);
	
	displayLoadDlg();
}

function CSC_RequestPOST(action, request, params)
{
	var p = { "req[requestFile]": action, "req[request]": request };
	
	var list = new Object();
	for (i in params)
	{
		list = concat(list, toPHP(params[i], i));
	}
	
	for (i in list)
	{
		var name_len = i.indexOf('[');
		if (name_len < 0) name_len = i.length;
		
		var name = 'req[' + i.substr(0, name_len) + ']' + i.substr(name_len);
		p[name] = list[i];
	}
	
	AjaxRequest.post(
	{
		'url': 'main.php',
		'parameters': p,
		'onSuccess' : CSC_OnSuccessPOST
	});
	
	displayLoadDlg();
}

function toPHP(o, name)
{
	var l = new Object();
	if (typeof(o) == 'object' || typeof(o) == 'array')
	{
		for (i in o)
		{
			l = concat(l, toPHP(o[i], name + '[' + i + ']'));
		}
	}
	else
	{
		l[name] = o;
	}
	return l;
}

function CSC_OnSuccessPOST(req)
{
	eval(req.responseText);
}

function getPackedForm(form)
{
	var els = form.elements;
	var len = els.length;
	
	var str = '';
	var list = new Object();
	
	addField = function(name, value)
	{
		str += name + ": " + value + "\n";
		list[name] = value;
	};
	
	for (var i = 0; i < len; i++)
	{
		var el = els[i];
		if (!el.disabled && el.name != "undefined")
		{
			switch(el.type)
			{
				case 'text':
				case 'password':
				case 'hidden':
				case 'textarea': 
					addField(el.name, el.value);
					break;
				case 'select-one':
					if (el.selectedIndex >= 0)
					{
						addField(el.name, el.options[el.selectedIndex].value);
					}
					break;
				case 'select-multiple':
					for (var j = 0; j < el.options.length; j++)
					{
						if (el.options[j].selected)
						{
							addField(el.name, el.options[j].value);
						}
					}
					break;
				case 'checkbox':
				case 'radio':
					if (el.checked)
					{
						addField(el.name, el.value);
					}
					break;
			}
		}
	}
	
	return list;
};

function displayLoadDlg()
{
	var e = document.getElementById('cscLoadDlg');
	if (e)
	{
		dlgActivate(e);
		dlgRelativePosition(e, 0, 0);
		dlgDisplay(e);
	}
}

function hideLoadDlg()
{
	var e = document.getElementById('cscLoadDlg');
	if (e)
	{
		setTimeout("dlgHide(document.getElementById('cscLoadDlg'));", 150);
	}
}
/*
	file_browser.js
*/

function FileBrowser_c (dlgId)
{
	this.dlg_id = dlgId;
	this.dlg = document.getElementById(dlgId);
	
	this.csc_handler = 0;
	this.onOk = function ()
	{
		alert('Default onOk()\nSelected file: '+this.sel_file+'\nSelected folder: '+this.sel_folder+'\nFilename: '+this.getFilename());
	}
	this.onSelect = function () { return 1; };
	
	this.folder_mode = 0;
	this.save_mode = 0;
	
	this.view_mode = 1;
	
	this.sel_file = 0;
	this.sel_folder = 0;
	this.cur_folder = 3;
	
	this.folders = {};
	this.files = {};
	
	//---------------------------------
	
	this.setup = function (csc, ok_handler, select_handler, folder_mode, save_mode)
	{
		this.csc_handler = csc;
		if (ok_handler) this.onOk = ok_handler;
		if (select_handler) this.onSelect = select_handler;
		this.folder_mode = folder_mode;
		this.save_mode = save_mode;
	}
	
	//---------------------------------
	
	this.setCurrentFolder = function (folder)
	{
		this.cur_folder = folder;
	}
	
	this.getCurrentFolder = function ()
	{
		return this.cur_folder;
	}
	//---
	this.setSelectedFile = function (f)
	{
		this.sel_file = f;
	}
	
	this.getSelectedFile = function ()
	{
		return this.sel_file;
	}
	//---
	this.setSelectedFolder = function (f)
	{
		this.sel_folder = f;
	}
	
	this.getSelectedFolder = function ()
	{
		return this.sel_folder;
	}
	
	this.getFilename = function ()
	{
		return document.forms[this.dlg_id + "_filename"].elements[this.dlg_id + "_file"].value;
	}
	
	this.isNewFile = function ()
	{
		if (this.sel_file == 0 && this.getFilename().length > 0) return 1;
	}
	
	//---------------------------------
	
	this.newFolder = function ()
	{
		var name = prompt('Name of new folder');
		if (name)
		{
			this.req("newFolder", { 'name': name });
		}
	}
	
	this.deleteFolder = function (folder)
	{
		if (confirm('Vald mapp kommer att raderas från systemet.\nTryck OK för att forsätta'))
		{
			this.req("deleteFolder", {'folder': folder});
		}
	}
	
	this.getFileInfo = function (file)
	{
		this.req('getFileInfo', {'file': file});
	}
	
	//---------------------------------
	
	this.createDlg = function (w, h, file_types, img_max_size)
	{
		var e = this.dlg;
		if (e)
		{
			dlgActivate(e);
			
			this.req("createDlg", { 'dlgId': this.dlg_id, 'w': w, 'h': h, 'fileTypes': file_types, 'imgMaxSize': img_max_size, 'folderMode': this.folder_mode, 'saveMode': this.save_mode, 'folder': this.cur_folder });
		}
	}
	
	this.setViewMode = function (mode)
	{
		this.req("setViewMode", { 'mode': mode });
	}
	
	this.fetchFolderContent = function (folder)
	{
		this.req("fetchFolderContent", { 'folder': folder });
	}
	
	this.show = function ()
	{
		var e = this.dlg;
		if (e)
		{
			dlgCenter(e);
			dlgDisplay(e);
		}
	}
	
	this.destroy = function ()
	{
		var e = this.dlg;
		if (e)
		{
			dlgDelayedDestroy(e);
		}
	}
	
	this.finish = function ()
	{
		if (this.folder_mode)
		{
			if (this.sel_folder == 0) return;
		}
		else
		{
			if (this.save_mode)
			{
				if (this.sel_file == 0 && !this.isNewFile()) return;
			}
			else
			{
				if (this.sel_file == 0) return;
			}
		}
		
		this.onOk();
		this.destroy();
	}
	this.onFileChange = function ()
	{
		if (this.save_mode)
		{
			this.sel_file = 0;
		}
	}
	
	this.dblClicked = function (type, id)
	{
		if (type == 1)
		{
			if (this.onSelect(type, id))
			{
				this.sel_file = id;
				this.finish();
			}
		}
		if (type == 2 || this.folder_mode)
		{
			if (this.onSelect(type, id))
			{
				this.sel_folder = id;
			}
			this.cur_folder = id;
			this.fetchFolderContent(id);
		}
		
		this.refreshSelected();
	}
	
	this.clicked = function (type, id)
	{
		if (type == 1)
		{
			if (this.onSelect(type, id))
			{
				this.sel_file = id;
			}
		}
		if (this.folder_mode)
		{
			if (this.onSelect(type, id))
			{
				this.sel_folder = id;
			}
		}
			
		this.refreshSelected();
	}
	
	this.refreshSelected = function ()
	{
		if (this.folder_mode)
		{
			if (this.sel_folder > 0 && this.folders[this.sel_folder])
				document.forms[this.dlg_id + "_filename"].elements[this.dlg_id + "_file"].value = this.folders[this.sel_folder].name;
		}
		else
		{
			if (this.sel_file > 0 && this.files[this.sel_file])
				document.forms[this.dlg_id + "_filename"].elements[this.dlg_id + "_file"].value =  this.files[this.sel_file].name;
		}
	}
	
	this.showUpload = function ()
	{
		var e = document.getElementById('uploadWin');
		if (e) e.style.display = 'block';
		e = document.getElementById('uploadButton');
		if (e) e.style.display = 'none';
	}
	
	//---------------------------------
	
	this.req = function (request, params)
	{
		CSC_Request(this.csc_handler, request, params);
	}
}

//-------------------------------------------------------

/**
 * FlashObject v1.3d: Flash detection and embed - http://blog.deconcept.com/flashobject/
 *
 * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1d=this.getParams();
for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _20=this.getParams();
for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}
var _22=this.getVariablePairs().join("&");
if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";
}_1c+="</object>";}
return _1c;
},write:function(_23){
if(this.useExpressInstall){
var _24=new com.deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}
}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _23=="string")?document.getElementById(_23):_23;
if(n)n.innerHTML=this.getFlashHTML();
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};
com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
var _28=new com.deconcept.PlayerVersion(0,0,0);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_28=new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{
try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){
axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
_28=new com.deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_26&&_28.major>_26.major){return _28;}
if(!_26||((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major)||_28.major!=6||_27){
try{
_28=new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
}catch(e){}}}
return _28;
};
com.deconcept.PlayerVersion=function(_2c){
this.major=parseInt(_2c[0])||0;
this.minor=parseInt(_2c[1])||0;
this.rev=parseInt(_2c[2])||0;
};
com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};
com.deconcept.util={getRequestParameter:function(_2e){
var q=document.location.search||document.location.hash;
if(q){var _30=q.indexOf(_2e+"=");
var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
if(q.length>1&&_30>-1){
return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
},removeChildren:function(n){
while(n.hasChildNodes()){
n.removeChild(n.firstChild);}}};
if(Array.prototype.push==null){
Array.prototype.push=function(_33){
this[this.length]=_33;
return this.length;};}
var getQueryParamValue=com.deconcept.util.getRequestParameter;
var FlashObject=com.deconcept.FlashObject;


/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){setTimeout(U[Y],0)}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
/*
 * selection_list.php
 *
 * Copyright (C)2010 Viaduct AB
 */

if (typeof(SelectionList) == 'undefined')
{
	var SelectionList = new Object();

	SelectionList.clicked = function (id)
	{
		if (SelectionList[id].disabled) return;

		var	e = document.getElementById("SelectionList_" + id + "_list");
		if (e.className == 'hidden')
		{
			e.className = "selectionList";

			if (SelectionList[id].built == 1)
			{
				SelectionList.showList(id, e);
			}
			else
			{
				setTimeout("SelectionList.showList('" + id + "');", 10);
			}

			if (SelectionList[id].useFilter)
			{
				e = document.getElementById("SelectionList_" + id + "_filter");
				e.className = "selectionListFilter";
				//var dlgPos = getAnchorPosition("SelectionList_" + id + "_list");
				//e.style.top = (dlgPos.y + SelectionList[id].height) + 'px';
			}
		}
		else
		{
			e.className = "hidden";

			if (SelectionList[id].useFilter)
			{
				e = document.getElementById("SelectionList_" + id + "_filter");
				e.className = "hidden";
			}
		}
	}

	SelectionList.showList = function (id)
	{
		SelectionList.buildList(id);

		if (SelectionList[id].useSpecialPositioning) SelectionList.fixSpecialPositioning(id);

		try
		{
			var	e = document.getElementById("SelectionList_" + id + "_list");
			var dlgPos = getAnchorPosition("SelectionList_" + id + "_list");

			var body = document.getElementById('body');
			var bodyHeight = body.clientHeight + body.scrollTop;
			var height = e.clientHeight;
			if (window.SelectionList[id].useFilter)
			{
				var filter = document.getElementById("SelectionList_" + id + "_filter");
				filter.className = "selectionListFilter";
				height += filter.clientHeight;
			}
			var bottomPos = dlgPos.y + height;
			if (bottomPos > bodyHeight)
			{
				e.style.top = (bodyHeight - height - 5) + "px";
				filter.style.top = (bodyHeight - height - 5) + "px";
			}

			var pos = getAnchorPosition('SL_' + id + '_' + SelectionList.getSelected(id));

			if (dlgPos && dlgPos.y > 0 && pos != null && pos.y > 0)
			{
				e.scrollTop = pos.y - dlgPos.y;
			}
		} catch (e) {}
	}

	SelectionList.rowClicked = function (id, row)
	{
		var	e = document.getElementById("SelectionList_" + id + "_ctrl");

		e.innerHTML = SelectionList[id].layoutFunc(SelectionList[id].rows['¤' + row]);
		document.getElementById("SelectionList_" + id + "_list").className = "hidden";

		if (SelectionList[id].useFilter)
		{
			f = document.getElementById("SelectionList_" + id + "_filter");
			f.className = "hidden";
		}

		e = document.getElementById("SelectionList_" + id + "_field");
		if (e.value != row)
		{
			e.value = row;
			if (SelectionList[id].onChange != 0) SelectionList[id].onChange(SelectionList[id]);
		}
	}

	SelectionList.setSelected = function (id, row)
	{
		SelectionList.rowClicked(id, row);
	}

	SelectionList.getSelected = function (id)
	{
		return document.getElementById("SelectionList_" + id + "_field").value;
	}

	SelectionList.getSelectedRowData = function (id)
	{
		var rowId = '¤' + document.getElementById("SelectionList_" + id + "_field").value;
		var data = SelectionList[id].rows[rowId];
		return data;
	}

	SelectionList.buildList = function (id)
	{
		SelectionList.buildFilteredList(id, '');
	}

	SelectionList.buildFilteredList = function (id, filter)
	{
		if (SelectionList[id].built == 1) return;

		var	e = document.getElementById("SelectionList_" + id + "_list");
		var s = '';
		var rows = SelectionList[id].rows;

		for (i in rows)
		{
			//var index = i;
			var index = i.substr(1);
			var value;
			//if (isArray(rows[i]))
			if (typeof(rows[i]) == "object" && rows[i].length)
			{
				value = rows[i][0].toLowerCase();
			}
			else
			{
				value = rows[i].toLowerCase();
			}

			if (filter.length == 0 || value.search(filter) != -1)
			{
				//s += '<div id="SL_' + id + '_' + i + '" class="SLR" style="width: 100%; cursor: pointer;" onMouseOver="this.style.background=\'#d8effc\';" onMouseOut="this.style.background=\'transparent\'; className = \'SLR\';" onClick="this.style.background=\'transparent\'; className = \'SLR\'; SelectionList.rowClicked(\'' + id + '\', \'' + i + '\');">' + SelectionList[id].layoutFunc(rows[i]) + '</div>';
				s += '<div id="SL_' + id + '_' + i + '" class="SLR" style="width: 100%; cursor: pointer;" onMouseOver="className=\'SLRHover\';" onMouseOut="className = \'SLR\';" onClick="className = \'SLR\'; SelectionList.rowClicked(\'' + id + '\', \'' + index + '\');">' + SelectionList[id].layoutFunc(rows[i]) + '</div>';
			}
		}
		e.innerHTML = s;

		SelectionList[id].built = 1;
	}

	SelectionList.filterKeyUp = function (id)
	{
		SelectionList[id].built = 0;
		var e = document.getElementById("SelectionList_" + id + "_filterField");
		if (e)
		{
			var filter = e.value.toLowerCase();
			SelectionList.buildFilteredList(id, filter);
		}
	}

	SelectionList.fixSpecialPositioning = function (id)
	{
		pos = getAnchorPosition('SelectionList_' + id + '_ctrlOuter');
		pos.y += document.getElementById('SelectionList_' + id + '_ctrlOuter').offsetHeight;
		l = document.getElementById('SelectionList_' + id + '_list');
		f = document.getElementById('SelectionList_' + id + '_filter');
		l.style.left = pos.x;
		l.style.top = pos.y;
		f.style.left = pos.x;
		f.style.top = pos.y;
	}

	SelectionList.clearSpecialPositioning = function (id)
	{
		l = document.getElementById('SelectionList_' + id + '_list');
		f = document.getElementById('SelectionList_' + id + '_filter');
		b = document.getElementById('body');
		b.removeChild(l);
		b.removeChild(f);
	}

	//------------------------------------------------------------------------------------

	SelectionList_hidePopupWindows = function (e)
	{
		for (var i in SelectionList)
		{
			if (SelectionList[i] != null && SelectionList[i].isSelectionList == 1)
			{
				var	el = document.getElementById("SelectionList_" + i + "_list");
				if (el != null && el.className != 'hidden' && !SelectionList_isClicked(i, e))
				{
					el.className = 'hidden';

					el = document.getElementById("SelectionList_" + i + "_filter");
					if (el != null)
					{
						el.className = 'hidden';
					}
				}
			}
		}
	}

	SelectionList_isClicked = function (selId, e)
	{
		var id = "SelectionList_" + selId;
		var idList = "SelectionList_" + selId + "_list";
		var idFilter = "SelectionList_" + selId + "_filter";
		
		if (document.all)
		{
			var t = window.event.srcElement;
			while (t.parentElement != null)
			{
				if (t.id == idList || t.id == id || t.id == idFilter)
				{
					return true;
				}
				t = t.parentElement;
			}
			return false;
		}
		else if (e)
		{
			var t = e.target;
			try
			{
				while (t.parentNode != null)
				{
					if (t.id == idList || t.id == id || t.id == idFilter)
					{
						return true;
					}
					t = t.parentNode;
				}
			}
			catch(e)
			{
			}
			return false;
		}
		return false;
	}
	
	Run.add(function()
	{
		// Attach event handler
		if (document.layers)
		{
			document.captureEvents(Event.MOUSEUP);
		}
		SelectionList.oldEventListener = document.onmouseup;
		if (SelectionList.oldEventListener != null)
		{
			document.onmouseup = function(e) { SelectionList.oldEventListener(e); SelectionList_hidePopupWindows(e);};
		}
		else
		{
			document.onmouseup = SelectionList_hidePopupWindows;
		}
	});

}


