/**
 * PAGEBUTLER JavaScript
 * (c) Copyright 2004-2007 Media Trooper GmbH
 * www.mediatrooper.de
 */
 
function submitAdminForm( sa )
{
	var f = document.getElementById('adminform');
	if( sa )
	{
		f.submitaction.value = sa;
	}
	if( f.getAttribute("ajax") )
	{
		var tas = f.getElementsByTagName("iframe");
		if( tas.length>0 )
		{
			tinyMCE.triggerSave();
		}
		for (i = 0; i < tas.length; i++)
		{ 
			if( tas[i].className=="mceEditorIframe" )
			{
				tinyMCE.execCommand("mceRemoveControl", false, tas[i].id); 
			}
		}
		submitAjaxForm('adminform','ajaxAdminForm');
	}
	else
	{
		f.submit();
	}
}

function pbRedirect( url, pause )
{
	window.setTimeout("document.location='"+url+"';", pause*1000);
}

function getSelectValue( domid )
{
	var s = document.getElementById(domid);
	var i = s.selectedIndex;
	return s.options[i].value;
}

function clearInput(i,s)
{
	if(i.value==s)i.value='';
}
function unclearInput(i,s)
{
	if(i.value=='')i.value=s;
}

/**
 * Sonstige Helferlein
 */

function setAttrib(elm, attrib, value) 
{
	if (typeof(value) == "undefined" || value == null)
		value = "";
		
	if (value != "") 
	{
		elm.setAttribute(attrib, value);

		if (attrib == "style")
			attrib = "style.cssText";

		if (attrib == "width") 
		{
			attrib = "style.width";
			value = value + "px";
			value = value.replace(/%px/g, 'px');
		}

		if (attrib == "height") 
		{
			attrib = "style.height";
			value = value + "px";
			value = value.replace(/%px/g, 'px');
		}

		if (attrib == "class")
			attrib = "className";

		eval('elm.' + attrib + "=value;");
	} else
		elm.removeAttribute(attrib);
}

function makeAttrib(attrib, value) 
{
	if (typeof(value) == "undefined" || value == null)
		value = "";
		
	if (value == "")
		return "";

	// XML encode it
	value = value.replace(/&/g, '&amp;');
	value = value.replace(/\"/g, '&quot;');
	value = value.replace(/</g, '&lt;');
	value = value.replace(/>/g, '&gt;');

	return ' ' + attrib + '="' + value + '"';
}

function reloadLightbox()
{
	myLightbox.updateImageList();
}





