
// On KeyUp / KeyDown
function input_keycode( evt )
{
	evt = (evt) ? evt : ((event) ? event : null);
	if (evt)
	{
		var key_pressed = evt.keyCode;
		var charCode = (evt.charCode) ? evt.charCode : evt.keyCode;
	}
	return charCode;
}

// On KeyUp
function input_autocompleter( obj_input, obj_choices, str_ajax_request, obj_indicator )
{
	$( obj_indicator ).show();

	var position = $( obj_input ).cumulativeOffset();
	$( obj_choices).setStyle( { 'position':'absolute', 'left':position[0]+'px', 'top':position[1]+$( obj_input ).getHeight()+'px' } );

	new Ajax.Request( str_ajax_request,
		{	method: 'get',
			onSuccess: function(transport)
				{
					$( obj_choices ).update(transport.responseText);
				},
			onFailure: function(transport)
				{
					$( obj_choices ).update(transport.responseText);
				}
		}
	);

	$( obj_choices ).show();
	$( obj_indicator ).hide();
}

// On KeyUp
function input_date_keypad( object )
{
	if( object )
	{
		var value = object.value;

		if( value.match(/^[4-9]$/) )
		{
			object.value = "0"+value+".";
		}
		if( value.match(/^[0-9][0-9]$/) )
		{
			if( value < 1 ) value = "01";
			if( value > 31 ) value = "31";
			object.value = value+".";
		}
		if( value.match(/^[0-9][0-9]\.[2-9]$/) )
		{
			value = value.substring(0,3)+"0"+value.substring(3,5);
			object.value = value;
		}
		if( value.match(/^[0-9][0-9]\.[0-9][0-9]$/) )
		{
			if( value.substring(3,5) > 12 ) value = value.substring(0,3)+"12";
			if( value.substring(3,5) < 1 ) value = value.substring(0,3)+"01";

			object.value = value+".";
		}
		if( value.length > 10 ) object.value = value.substring(0,10);
	}
}

// On KeyUp
function input_time_keypad( object )
{
	if( object )
	{
		var value = object.value;

		if( value.match(/^[3-9]$/) )
		{
			object.value = "0"+value+":";
		}
		if( value.match(/^[0-9][0-9]$/) )
		{
			if( value < 0 ) value = "00";
			if( value == 24 ) value = "00";
			if( value > 23 ) value = "23";
			object.value = value+":";
		}
		if( value.match(/^[0-9][0-9]\:[6-9]$/) )
		{
			value = value.substring(0,3)+"0"+value.substring(3,5);
			object.value = value;
		}
		if( value.match(/^[0-9][0-9]\:[0-9][0-9]$/) )
		{
			if( value.substring(3,5) > 59 ) value = value.substring(0,3)+"59";
			if( value.substring(3,5) < 0 ) value = value.substring(0,3)+"01";

		}
		if( value.length > 5 ) object.value = value.substring(0,5);
	}
}// -------------------------------------------------
function select_box_clear( object )
{
	// Anzahl der Optionen ermitteln
	var length = object.options.length;
	// Lösche jede Option
	for( i = 0; i < length; i++ ) object.remove(object.options[i]);
}

// -------------------------------------------------
function select_box_add( object, text, value )
{
	// Neues DOM Object erzeugen
	var option = document.createElement("option");
	// Value / Beschreibung setzen
	option.value = value; option.text = text;
	// an die Box anhängen
	object.add( option, object.length );
}function insertFlash( strSrc, intWidth, intHeight, strWMode, strScale, strPlayMode, strCLSID, strCODEBASE, strBGcolor, strPosition, strFlashVars, strContentDiv, strFlashParameter, returnAsString, isInteractive )
{
	if(strWMode == null || strWMode == "") strWMode = "Opaque";
	if(strScale == null || strScale == "") strScale = "noscale";
	if(strPlayMode == null || strPlayMode == "") strPlayMode = "true";
	if(strContentDiv == null || strContentDiv == "") strContentDiv = "";
	if(returnAsString == null || returnAsString == "") returnAsString = false;
	var strIDIE = isInteractive ? " id=\"embflashie\"" : "";
	var strIDMoz = isInteractive ? " id=\"embflash\"" : "";
	var strLiveConn = isInteractive ? " swliveconnect=\"true\"" : "";


	var strFlash	=  '<object' + strIDIE + ' classid="' + strCLSID + '" codebase="' + strCODEBASE + '" ';
	var embedFlashParameter = "";
	strFlash += ' width="' + intWidth + '" height="' + intHeight + '">';

	strFlash += '<param name="movie" value="' + strSrc + '" />';
	strFlash += '<param name="quality" value="high" />';
	strFlash += '<param name="play" value="' + strPlayMode + '" />';
	strFlash += '<param name="wmode" value="' + strWMode + '" />';
	strFlash += '<param name="scale" value="' + strScale + '" />';
	strFlash += '<param name="menu" value="false" />';

	/**
	*	handle flash params
	*/
	if(strFlashVars == null) {
		strFlashVars = "";
	}
	// add slt system variable for flash tool
	if(window.cms_sltpath) {
		if(strFlashVars == "") {
			strFlashVars += "cms_sltpath=" + window.cms_sltpath;
		} else {
			strFlashVars += '&cms_sltpath=' + window.cms_sltpath;
		}
	}

	if(strFlashParameter != null && strFlashParameter != "") {
		var flashParameter = strFlashParameter.split("&");
		for (var i = 0; i < flashParameter.length; i++){
			var flashNameValue = flashParameter[i].split("=");
			if(flashNameValue.length==1) {
				strFlash += '<param name="'+flashNameValue[0]+'" value="" />';
				embedFlashParameter += ' ' + flashNameValue[0]+'="" ';
			} else if(flashNameValue.length==2) {
				strFlash += '<param name="'+flashNameValue[0]+'" value="' + flashNameValue[1] + '" />';
				embedFlashParameter += ' ' + flashNameValue[0]+'="'+flashNameValue[1] + '" ';
			}
		}
	}

	if(strFlashVars != null && strFlashVars != "") strFlash += '<param name="FlashVars" value="' + strFlashVars + '" />';
	if(strPosition != null && strPosition != "") strFlash += '<param name="align" value="' + strPosition + '" />';
  	if(strBGcolor != null && strBGcolor != "") strFlash	+= '<param name="bgcolor" value="' + strBGcolor + '" />';

	strFlash += '<embed' + strIDMoz +  strLiveConn + ' src="' + strSrc + '" width="' + intWidth + '" height="' + intHeight + '" wmode="' + strWMode + '" play="' + strPlayMode + '" scale="' + strScale  + '" menu="false"';
	if(strBGcolor != null && strBGcolor != "") strFlash	+= ' bgcolor="' + strBGcolor + '"';
	if(embedFlashParameter != null && embedFlashParameter != "") strFlash	+= embedFlashParameter;
	if(strFlashVars != null && strFlashVars != "") strFlash	+= ' FlashVars="' + strFlashVars + '"';
	if(strPosition != null && strPosition != "") strFlash	+= ' align="' + strPosition + '"';
	strFlash += ' quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">';
	strFlash += '</embed>';
	strFlash += '</object>';

	// If require, return as String
	if (returnAsString) {
		return strFlash;
	}

	if(strContentDiv != "" && document.getElementById(strContentDiv)) {
		document.getElementById(strContentDiv).innerHTML = strFlash;
	}
	else {
		document.write( strFlash );
		// BUG Drag 'n' Drop: Document must not be closed!
		// document.close( );
	}
}

function flash_versioncheck(vno) {
	var isIE=(navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin=(navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;

	if(isIE && isWin) {
		try {
			return ((typeof(ActiveXObject) == "function") && (typeof(new ActiveXObject("ShockwaveFlash.ShockwaveFlash.8")) == "object"));
		} catch (error) {
			return false;
		}
	} else if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) {
		var flashplugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
		var flashplugindesc;
		if (flashplugin.description) {
			flashplugindesc = parseInt(flashplugin.description.substring(flashplugin.description.indexOf(".")-1));
		}
	   	return !(!flashplugindesc || flashplugindesc < vno);
	} else {
		return false;
	}
}

function insertQuickTime( strSrc, strID, intWidth, intHeight, strScale, strPlayMode, strController, strCLSID, strCODEBASE, strContentDiv )
{
	if(strScale == null || strScale == "") strScale = "TOFIT";
	if(strPlayMode == null || strPlayMode == "") strPlayMode = "true";
	if(strController == null || strController == "") strController = "true";

  	var strQuickTime = '<object classid="' + strCLSID + '" codebase="' + strCODEBASE + '" ';
  	strQuickTime += 'width="' + intWidth + '" height="' + intHeight + '" ';
  	strQuickTime += 'id="' + strID + '">';
  	strQuickTime += '<param name="src" value="' + strSrc + '"/>';
  	strQuickTime += '<param name="AUTOPLAY" value="' + strPlayMode + '" />';
  	strQuickTime += '<param name="CONTROLLER" value="' + strController + '" />';
  	strQuickTime += '<param name="SCALE" value="' + strScale + '" />';
  	strQuickTime += '<embed src="' + strSrc + '" type="video/quicktime" pluginspace="http://www.apple.com/quicktime/download/" width="' + intWidth + '" height="' + intHeight + '" ';
  	strQuickTime += 'scale="' + strScale + '" autoplay="' + strPlayMode + '" controller="' + strController + '" name="' + strID + '" >';
  	strQuickTime += '</embed></object>';

	if(strContentDiv != "" && document.getElementById(strContentDiv)) {
		document.getElementById(strContentDiv).innerHTML = strQuickTime;
	}
	else {
		document.write( strQuickTime );
		// BUG Drag 'n' Drop: Document must not be closed!
		// document.close( );
	}
}

function insertRealVideo( strSrc, strID, intWidth, intHeight, strPosition, strPlayMode, strController, strCLSID, strCODEBASE, strContentDiv )
{
  	if(strID == null || strID == "") strID = "realmovie";
  	if(strPosition == null || strPosition == "") strPosition = "true";
  	if(strPlayMode == null || strPlayMode == "") strPlayMode = "false";
  	if(strController == null || strController == "") strController = "ImageWindow";

  	var strRealVideo = '<object classid="' + strCLSID + '" codebase="' + strCODEBASE + '" ';
  	strRealVideo += 'width="' + intWidth + '" height="' + intHeight + '">';
  	strRealVideo += '<param name="src" value="' + strSrc + '"/>';
  	strRealVideo += '<param name="console" value="' + strID + '"/>';
  	strRealVideo += '<param name="controls" value="' + strController + '" />';
  	strRealVideo += '<param name="center" value="' + strPosition + '" />';
  	strRealVideo += '<param name="autostart" value="' + strPlayMode + '" />';
  	strRealVideo += '</object>';

	if(strContentDiv != "" && document.getElementById(strContentDiv)) {
		document.getElementById(strContentDiv).innerHTML = strRealVideo;
	}
	else {
		document.write( strRealVideo );
		// BUG Drag 'n' Drop: Document must not be closed!
		// document.close( );
	}
}


function insertApplet( strSrc, strCode, intWidth, intHeight, strPosition, strCLSID, strCODEBASE, strContentDiv )
{
	if(strPosition == null || strPosition == "") strPosition = "baseline";

  	var strApplet = '<object classid="' + strCLSID + '" codebase="' + strCODEBASE + '" ';
  	strApplet += 'width="' + intWidth + '" height="' + intHeight + '" align="' + strPosition + '" code="' + strSrc + '">';
  	strApplet += '<param name="code" value="' + strSrc + '"/>';
  	strApplet += '<param name="type" value="application/x-java-applet"/>';
  	strApplet += '</object>';

	if(strContentDiv != "" && document.getElementById(strContentDiv)) {
		document.getElementById(strContentDiv).innerHTML = strApplet;
	}
	else {
		document.write( strApplet );
		// BUG Drag 'n' Drop: Document must not be closed!
		// document.close( );
	}
}
/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
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 deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.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;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!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);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
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;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;
	function submit_content()
	{
		new Ajax.Request('{_SYSTEM_WORKSPACE}submit_entry.php?system='+encodeURIComponent('../../system.php')+'&content='+encodeURIComponent($('plugin_chat_content').value)+'&name='+encodeURIComponent($('plugin_chat_user').value), {
			onSuccess: function(transport) {
				if(transport.responseText != '') {
					alert(transport.responseText);
				}
			}
		});
		$('plugin_chat_content').value = '';
	}

	function chat_at( user )
	{
		$('plugin_chat_content').focus();
		$('plugin_chat_content').value = $('plugin_chat_content').value + '@' + user + ' ';
	}function plugin_gallery_image_show( int_id )
{
	$('plugin_gallery_'+int_id+'_image').setStyle({'width':'100px','height':'100px'});
	$('plugin_gallery_'+int_id+'_image').src = ".system/plugin/plugin_gallery/navigation_load.gif";

	new Effect.Parallel( [
							new Effect.Appear('plugin_gallery_'+int_id+'_background', { from:0, to:0.6, sync: true }),
						  	new Effect.Appear('plugin_gallery_'+int_id+'_show', { from:0, to:1, sync: true })
						], { duration: 0.3 }
						);
}

function plugin_gallery_image_hide( int_id )
{
	new Effect.Parallel( [
							new Effect.Fade('plugin_gallery_'+int_id+'_background', { sync: true } ),
							new Effect.Fade('plugin_gallery_'+int_id+'_show', { sync: true } )
						], { duration: 0.3 }
						);
}

function ajax_plugin_gallery_image( str_image, int_id )
{
	$('plugin_gallery_'+int_id+'_image').setStyle({'width':'100px','height':'100px'});
	$('plugin_gallery_'+int_id+'_image').src = ".system/plugin/plugin_gallery/navigation_load.gif";
	var viewportoffset = document.viewport.getScrollOffsets();
	$('plugin_gallery_'+int_id+'_background').setStyle({'top':viewportoffset['top']+'px','left':viewportoffset['left']+'px','width':document.viewport.getWidth()+'px','height':document.viewport.getHeight()+'px'});
	$('plugin_gallery_'+int_id+'_show').setStyle({'top':viewportoffset['top']+'px','left':viewportoffset['left']+'px','width':document.viewport.getWidth()+'px','height':document.viewport.getHeight()+'px'});

	new Ajax.Request('.system/plugin/plugin_gallery/plugin_gallery.ajax.image.php?img='+str_image,
	{
		method: 'get',
		onSuccess: function(transport)
			{
				$('plugin_gallery_'+int_id+'_image').src = transport.responseText;
				$('plugin_gallery_'+int_id+'_image').setStyle({'width':'','height':''});
			}
	});

	if( $('plugin_gallery_'+int_id+'_navigation_left') )
	{
		for( int_image = 0; int_image < plugin_gallery_images.length; int_image = int_image + 1 )
		{
			if( plugin_gallery_images[int_image] == str_image )
			{
				if( int_image > 0 )
					$('plugin_gallery_'+int_id+'_navigation_left').update('<a href="#" onclick="ajax_plugin_gallery_image(\''+plugin_gallery_images[(int_image-1)]+'\',\''+int_id+'\');"><img src=".system/plugin/plugin_gallery/navigation_left.png" alt="" style="width: 100px; height: 100px;" /></a>');
				else
					$('plugin_gallery_'+int_id+'_navigation_left').update('<img src=".system/plugin/plugin_gallery/navigation_left_off.png" alt="" style="width: 100px; height: 100px;" />');
				if( int_image < (plugin_gallery_images.length-1) )
					$('plugin_gallery_'+int_id+'_navigation_right').update('<a href="#" onclick="ajax_plugin_gallery_image(\''+plugin_gallery_images[(int_image+1)]+'\',\''+int_id+'\');"><img src=".system/plugin/plugin_gallery/navigation_right.png" alt="" style="width: 100px; height: 100px;" /></a>');
				else
					$('plugin_gallery_'+int_id+'_navigation_right').update('<img src=".system/plugin/plugin_gallery/navigation_right_off.png" alt="" style="width: 100px; height: 100px;" />');
			}
		}
	}
}