function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

///////////////////////////////////////////////////////////////


// decrypt helper function
function CMS_decryptCharcode(n,start,end,offset)
	{
	n = n + offset;
	if (offset > 0 && n > end)	{
		n = start + (n - end - 1);
	} else if (offset < 0 && n < start)	{
		n = end - (start - n - 1);
	}
	return String.fromCharCode(n);
	}
// decrypt string
function CMS_decryptString(enc,offset)
	{
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += CMS_decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		} else if (n >= 0x40 && n <= 0x5A)	{
			dec += CMS_decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		} else if (n >= 0x61 && n <= 0x7A)	{
			dec += CMS_decryptCharcode(n,0x61,0x7A,offset);	// a-z
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
	}
// decrypt spam-protected emails
function CMS_uncryptMailto(s)
	{
	location.href = CMS_decryptString(s,-2);
	}

///////////////////////////////////////////////////////////////////////


// Funktion zum Setzen einer Bookmark / eines Favoriten
function createBookmarkLink(url,title)
	{
	//url = "Webpage URL";
	//title = "Webpage Title";
	if(window.sidebar)
		{
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
		}
	else if(window.external)
		{ // IE Favorite
		window.external.AddFavorite( url, title);
		}
	else if(window.opera && window.print)
		{ // Opera Hotlist
		return true;
		}
	}
	
/*
if(window.external)
		{ document.write('<a href = "javascript:CreateBookmarkLink()");">Add to Favorites</a>'); }
	else if(window.sidebar)
		{ document.write('<a href = "javascript:CreateBookmarkLink()");">Bookmark Page</a>');  }
	else if(window.opera && window.print)
		{ document.write('<a href = "javascript:CreateBookmarkLink()");">Add Bookmark</a>'); }
*/


///////////////////////////////////////////////////////////////


// V1.0 Fenster fuer Druckansicht
function createPrintLink(url,w,h)
	{
    l = screen.width/2-50;
    t = screen.height/2-150;
    w = eval(w) + 16;
    options = "width="+w+",height="+h+",left="+l+",top="+t+",menubar=yes,resizable=yes,scrollbars=yes,status=yes";
    Druckwindow = window.open(url,'Details',options);
    Druckwindow.focus();
	}


///////////////////////////////////////////////////////////////


// V 2.0 Detailbild anzeigen
function openDetail(img,sizeW,sizeH)
	{
	if(sizeW=='' || sizeH=='')
		{
		sizeW = 300;
		sizeH = 300;
		var resize = true;
		}

	l = screen.width/2-50;
	o = screen.height/2-150;
	windowOptions = 'width='+sizeW+',height='+sizeH+',left='+l+',top='+o+',status=1,scrollbars=0,resizable=1';
	Detailwindow=window.open('incl/blank.html','Detailwindow',windowOptions);
	Detailwindow.document.write('<html>'
	+'<head> '
	+'<title>'+img+'</title> '
	+'<'+'script language="javascript"'+'> '
	+'function resize() { '
	+'if(document.images[0]) { window.resizeTo(document.images[0].width+10,document.images[0].height+54); } '
	+'self.focus();'
	+'} '
	+'<'+'/script'+'>'
	+'</head>'
	+'<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" onLoad="javascript:resize();" onBlur="javascript:window.close();">'
//	+'<table border="0" cellspacing="0" cellpadding="0">'
//	+'<tr>'
//	+'<td valign="top"><img src="'+img+'" id="bigImage" border="0" onClick="JavaScript:window.close();"></td>'
	+'<img src="'+img+'" id="bigImage" border="0" onClick="JavaScript:window.close();">'
//	+'</tr>'
//	+'</table>'
	+'</body>'
	+'</html>');

	Detailwindow.document.close(); 
	}


///////////////////////////////////////////////////////////////


function toggleAreaSelect()
	{
	optionContent = document.getElementById('areaSelectContent');
	optionArea = document.getElementById('areaSelectOptions');

	if(optionArea.style.display == 'none')
		{
		optionContent.style.background = 'url(/pix/but-area-select-close.png) top right no-repeat';
		optionArea.style.display = 'block';
		}
	else
		{
		optionContent.style.background = 'url(/pix/but-area-select-open.png) top right no-repeat';
		optionArea.style.display = 'none';
		}
	}


///////////////////////////////////////////////////////////////


function niceSelectFieldToggle(fieldName)
	{
	niceSelectFieldContent = document.getElementById('niceSelectFieldContent_'+fieldName);
	niceSelectFieldOptions = document.getElementById('niceSelectFieldOptions_'+fieldName);

	if(niceSelectFieldOptions.style.display == 'none')
		{
		niceSelectFieldOptions.style.display = 'block';
		niceSelectFieldOptions.style.width = niceSelectFieldContent.firstChild.offsetWidth+'px';
		niceSelectFieldOptions.style.top = niceSelectFieldContent.offsetHeight+'px';
		if(niceSelectFieldOptions.offsetHeight > 150)
			{ niceSelectFieldOptions.style.height = '150px'; }
		niceSelectFieldContent.className = 'niceSelectFieldContentOpened';
		}
	else
		{
		niceSelectFieldOptions.style.display = 'none';
		niceSelectFieldContent.className = 'niceSelectFieldContentClosed';
		}
	}


///////////////////////////////////////////////////////////////


function niceSelectFieldSet(name,value,text)
	{
	// set Value
	document.getElementById('niceSelectFieldValue_'+name).value = value;
	// set Text
	document.getElementById('niceSelectFieldContent_'+name).firstChild.firstChild.nodeValue = text;
	}


///////////////////////////////////////////////////////////////


// Funktion zum Ein-/Ausklappen eines Listeneintrages
function CMS_foldDiv(idDiv,idIcon,height,iconOn,iconOff)
	{
	// Hoehe fuer eingeklapptes Item fixen
	if(!height)
		{ height = 0; }
	// Ebene und Symbol finden
	theDIV = document.getElementById(idDiv);
	theSYM = document.getElementById(idIcon);

// wenn Dateiname des Symbols ...iconOn... dann oeffnen
	if(theSYM.src == iconOn)
		{
		theDIV.style.height = 'auto';
		theDIV.style.overflow = 'visible';
		theSYM.src = iconOff;
		}
	// wenn Dateiname des Symbols ...iconOff... dann schliessen
	else if(theSYM.src == iconOff)
		{
		theDIV.style.height = height+'px';
		theDIV.style.overflow = 'hidden';
		theSYM.src = iconOn;
		}
	return false;
	}


///////////////////////////////////////////////////////////////


// Funktion zum Ein-/Ausklappen eines Listeneintrages
function CMS_toggleListItem(id)
	{
	// Ebene und Symbol finden
	theDIV = document.getElementById('div_'+id);
	theSYM = document.getElementById('sym_'+id);

	// wenn "plus" in Dateinamen dann oeffnen und Symbol -> "-"
	if(theSYM.src.indexOf("plus.png") >= 1)
		{
		theDIV.style.display = 'block';
		theSYM.src = 'pix/icon-minus-2.png';
		}
	// wenn "minus" in Dateinamen dann schliessen und Symbol -> "+"
	else if(theSYM.src.indexOf("minus-2.png") >= 1)
		{
		theDIV.style.display = 'none';
		theSYM.src = 'pix/icon-plus.png';
		}
	return false;
	}


///////////////////////////////////////////////////////////////


// Funktion zur hierarchischen Aktivierung/Deaktivierung
function selectParentCategories(categoriesString,currentCategory)
	{
	// Kategorie-String splitten
	categories = categoriesString.split(',');
	currentCheckbox = document.getElementById('catergoryCheckbox_'+currentCategory);

	// Eltern-Kategorien aktivieren, wenn aktuelles Element aktiv
	if(currentCheckbox.checked == true)
		{
		for(i=1;i<categories.length;i++)
			{
			document.getElementById('catergoryCheckbox_'+categories[i]).checked = true;
			}
		}
	// Kind-Kategorien deaktivieren
	else
		{
		// 1. Unterebene Start
		if(currentCheckbox.nextSibling.nextSibling && currentCheckbox.nextSibling.nextSibling.nodeName == 'UL')
			{
			ul2 = currentCheckbox.nextSibling.nextSibling;
			ul2.firstChild ? ul2li = ul2.firstChild : ul2li = false;
			while(ul2li)
				{
				// Input deaktivieren
				if(ul2li.nodeName == 'LI')
					{ ul2li.firstChild.nextSibling.checked = false; }

				// 2. Unterebene Start
				// naechste Listenebene finden
				if(ul2li.firstChild.nextSibling.nextSibling.nextSibling && ul2li.firstChild.nextSibling.nextSibling.nextSibling.nodeName == 'UL')
					{
					ul3 = ul2li.firstChild.nextSibling.nextSibling.nextSibling;
					ul3.firstChild ? ul3li = ul3.firstChild : ul3li = false;
					while(ul3li)
						{
						// Input deaktivieren
						if(ul3li.nodeName == 'LI')
							{ ul3li.firstChild.nextSibling.checked = false; }

						// 3. Unterebene Start
						// naechste Listenebene finden
						if(ul3li.firstChild.nextSibling.nextSibling.nextSibling && ul3li.firstChild.nextSibling.nextSibling.nextSibling.nodeName == 'UL')
							{
							ul4 = ul3li.firstChild.nextSibling.nextSibling.nextSibling;
							ul4.firstChild ? ul4li = ul4.firstChild : ul4li = false;
							while(ul4li)
								{
								// Input deaktivieren
								if(ul4li.nodeName == 'LI')
									{ ul4li.firstChild.nextSibling.checked = false; }
								// naechstes Element suchen
								(ul4li.nextSibling ? ul4li = ul4li.nextSibling : ul4li = false);
								}
							}
							// 3. Unterebene Ende

						// naechstes Element suchen
						(ul3li.nextSibling ? ul3li = ul3li.nextSibling : ul3li = false);
						}
					}
					// 2. Unterebene Ende

				// naechstes Element suchen
				(ul2li.nextSibling ? ul2li = ul2li.nextSibling : ul2li = false);
				}
			// 1. Unterebene Ende
			}
		}
	}


////////////////////////////////////////////////////////////////////////


// Funktion zum Umschalten der Grafik-Optionen (Upload / Delete)
function switchImageAction(itemName,action)
	{
	if(document.getElementById(itemName+'_uploadButton'))
		{
		uploadButton = document.getElementById(itemName+'_uploadButton');
		uploadArea = document.getElementById(itemName+'_uploadArea');
		uploadField = document.getElementById(itemName+'_uploadField');
		}

	if(document.getElementById(itemName+'_deleteButton'))
		{
		deleteButton = document.getElementById(itemName+'_deleteButton');
		deleteArea = document.getElementById(itemName+'_deleteArea');
		deleteField = document.getElementById(itemName+'_deleteField');
		}

	// UPLOAD IMAGE
	if(action == 'upload')
		{
		if(document.getElementById(itemName+'_deleteButton'))
			{
			deleteField.value = '';
			deleteArea.style.display = 'none';
			deleteButton.src = 'pix/icon-list-delete.png';
			}

		if(uploadArea.style.display == 'none')
			{
			uploadArea.style.display = 'block';
			uploadButton.src = 'pix/icon-list-edit-off.png';
			}
		else
			{
			uploadField.value = '';
			uploadArea.style.display = 'none';
			uploadButton.src = 'pix/icon-list-edit.png';
			}
		}
	// DELETE IMAGE
	else if(action == 'delete')
		{
		if(document.getElementById(itemName+'_deleteButton'))
			{
			uploadField.value = '';
			uploadArea.style.display = 'none';
			uploadButton.src = 'pix/icon-list-edit.png';
			}

		if(deleteArea.style.display == 'none')
			{
			deleteField.value = '1';
			deleteArea.style.display = 'block';
			deleteButton.src = 'pix/icon-list-delete-off.png';
			}
		else
			{
			deleteField.value = '';
			deleteArea.style.display = 'none';
			deleteButton.src = 'pix/icon-list-delete.png';
			}
		}
	}


///////////////////////////////////////////////////////////////


function toggleConfirmDelete(confirmAreaID)
	{
	confirmArea = document.getElementById(confirmAreaID);

	if(confirmArea.style.display == 'none')
		{ confirmArea.style.display = 'block'; }
	else
		{ confirmArea.style.display = 'none'; }
	}

