function addFormsClass()
{
	for( i = 0; i < document.forms.length; ++i )
	{
		for( j = 0; j < document.forms[i].length; ++j )
		{
			switch( document.forms[i].elements[j].type )
			{
				case 'text':
				case 'password':
					document.forms[i].elements[j].className = 'ipText';
					break;

				case 'submit':
				case 'button':
					document.forms[i].elements[j].className = 'ipButton';
					break;

				case 'select-one':
				case 'textarea':
					if( document.forms[i].elements[j].style.width )
					{
						// get old width
						width = document.forms[i].elements[j].style.width;
						width = parseInt(width.slice(0, width.indexOf('p')));
						width += 6;

						// set new width
						document.forms[i].elements[j].style.width = width + 'px';
					}
					break;
			}
		}
	}

	//document.getElementsByTagName('body')[0].style.visibility = 'visible';
}


/**
 * for the wysiwyg-editor
 */
var mcewin;
var mcefield_name;
 
function fileBrowserCallBack(field_name, url, type, win)
{
	mcefield_name = field_name;
	mcewin = win;
	app_url = top.document.getElementById("js_app_url").value;
	
	switch( type )
	{
		case 'flash':
		case 'image':
			href = app_url + "/index.php?module=mod_media&action=admin_browse";
			break;

		case 'file':
			alert('n/a');
			return;
			break;
	}

	width = 640;
	height = 480;	
	wleft = (screen.width / 2) - width / 2;
	wtop = (screen.height / 2) - height / 2;
	window.open(href, 'fileBrowser', 'width='+width+',height='+height+',resizable=no,scrollbars=no,statusbar=no,menubar=no,toolbar=no,locationbar=no,left='+wleft+',top='+wtop);
}

/**
 * Tab-Class
 */

function Tab()
{
	this.activeTab;
	this.tabs = new Array();
}

Tab.prototype.appendTab = function(caption, id)
{
	this.tabs.push([caption, id]);
}

Tab.prototype.setActiveTab = function(id)
{
	this.activeTab = id;
}

Tab.prototype.hoverTab = function(id)
{
	document.getElementById(id).className = "tabhover";
}

Tab.prototype.leaveTab = function(id)
{
	newclass = this.activeTab == id ? "tabactive" : "tabnormal";
	document.getElementById(id).className = newclass;
}

Tab.prototype.activateTab = function(id)
{
	// reset old tab
	document.getElementById(this.activeTab).className = "tabnormal";
	document.getElementById(this.activeTab + "AREA").style.display = "none";

	// set new tab
	document.getElementById(id).className = "tabactive";
	document.getElementById(id + "AREA").style.display = "block";
	this.activeTab = id;
}

Tab.prototype.paint = function()
{
	if( typeof this.activeTab == "undefined" )
		return alert("Please set active tab first!");

	document.write('<ul class="tabbar">');
	for( i = 0; i < this.tabs.length; ++i )
	{
		className = this.tabs[i][1] == this.activeTab ? "tabactive" : "tabnormal";
		document.write('<li><a href="javascript:void(0)" id="' + this.tabs[i][1] + '" class="' + className + '" onmouseover="Tab.hoverTab(this.id)" onmouseout="Tab.leaveTab(this.id)" onclick="Tab.activateTab(this.id)">' + this.tabs[i][0] + '</a></li>');
	}
	document.write("</ul>");
}

/**
 * Functions Against eMail-Abuse
 */

function mailTo(adress, tail)
{
	location.href = "mailto:" + adress + "@" + tail;
}

function printMail(adress, tail)
{
	document.write(adress + "@" + tail);
}
