	var Base64 = { 
		// private property
		_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/~",
	 
		// public method for encoding
		encode : function (input) {
			var output = "";
			var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
			var i = 0;
	 
			input = Base64._utf8_encode(input);
	 
			while (i < input.length) {
	 
				chr1 = input.charCodeAt(i++);
				chr2 = input.charCodeAt(i++);
				chr3 = input.charCodeAt(i++);
	 
				enc1 = chr1 >> 2;
				enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
				enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
				enc4 = chr3 & 63;
	 
				if (isNaN(chr2)) {
					enc3 = enc4 = 64;
				} else if (isNaN(chr3)) {
					enc4 = 64;
				}

				output = output +
				this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
				this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
	 
			}	 
			return output;
		},
		// private method for UTF-8 encoding
		_utf8_encode : function (string) {
			string = string.replace(/\r\n/g,"\n");
			var utftext = "";
	 
			for (var n = 0; n < string.length; n++) {
	 
				var c = string.charCodeAt(n);
	 
				if (c < 128) {
					utftext += String.fromCharCode(c);
				}
				else if((c > 127) && (c < 2048)) {
					utftext += String.fromCharCode((c >> 6) | 192);
					utftext += String.fromCharCode((c & 63) | 128);
				}
				else {
					utftext += String.fromCharCode((c >> 12) | 224);
					utftext += String.fromCharCode(((c >> 6) & 63) | 128);
					utftext += String.fromCharCode((c & 63) | 128);
				}
			}
			return utftext;
		}
	}

	function getHandle() {
		//get Handle out of Browser-URL
		var sURL;
		var iFirstSingleSlash = -1;
		//get URL of Page from Browser
		var sThisURL = document.location.toString();	
		//find begin of Selector
		var iLastSlash = sThisURL.lastIndexOf("/");		//find last Slash
		if(iLastSlash == -1) {
			iLastSlash = 0;			//if no Slash found -> Search from beginning
		} else {
			//Yes we have slashes so lets search the first single slash -> Begin of Handle
			var counter = 100;
			var pointer = 0;
			var found = false;
			var sDoubleslash = "";
			var sTrippleslash = "";

			while (counter > 0) {
				iFirstSingleSlash++;
				counter--;
				iFirstSingleSlash = sThisURL.indexOf("/", iFirstSingleSlash);
				if(iFirstSingleSlash == -1) {
					//no Slash at all
					iFirstSingleSlash = 0;
					break;	
				} else {
					//check if the found slash is not a double or tripple-slash
					if(iFirstSingleSlash+2 < sThisURL.length){
						if(sThisURL.substr(iFirstSingleSlash,3) == "///") {
							//we found a tripple so lets continue search
							iFirstSingleSlash += 3;
						} else {
							if(sThisURL.substr(iFirstSingleSlash,2) == "//") {
								//we found a double so lets continue search
								iFirstSingleSlash += 2;
							} else {
							//the found Slash is a single one
							break;
							}
						}
					} else {
						//end of String
						break;		
					} 
				}
			}
		}					
		var iDot = sThisURL.indexOf(".", iLastSlash);	//search first Dot behind last Slash -> begin of Selector or Extention -> End of Handle 	
		if(iDot == -1) iDot = sThisURL.length;			//if no Dot found -> Selector is added to end of String
		sURL = sThisURL.substring(iFirstSingleSlash,iDot) // + "." + Base64.encode(sAnimationTypes) + "-FLCFG.xml";
		return sURL;
	}

function stWinLocHash ( value )
{
	try
	{
		// Set the hashMark through Flash.
		// Flash must accept an CallBack immediatly after Setting this value here but without any effect
		jQuery.historyLoad ( value );
	}
	catch ( error )
	{
		// alert ( 'error: ' + error );
	}
}

function HistoryManager(){
	
	var that = this;
	
	if ($.browser.msie){
		that.flashId1='embflashie';
	}
	else{
		that.flashId1='embflash';
	}
	
	function gtWinLocHash( value )
	{
		try
		{
			// Two Example-Versions of Allocating the Flash and calling a Function in the Flash.
			if ( window.document.getElementById ( that.flashId1 ) )
			{
				window.document.getElementById ( that.flashId1 ).gth ( value );
			}
		}
		catch ( error )
		{
			// alert ( 'error: ' + error );
		}
	}
	
	this.ckWinLocHash = function()
	{
		jQuery(document).ready(function(){					
			jQuery.historyInit (gtWinLocHash );
			if (!location.hash){
				gtWinLocHash();
			}
		});
		return true;
	}
}


(function() {
	var historyManager;
	// history manager is a singleton
	window.getHistoryManager = function () {
		if (!historyManager){
			historyManager = new HistoryManager();
		}
		return historyManager;
	};

})();


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"';
	strFlash	+= ' bgcolor="#FFFFFF"';
	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 {
			var flashplayerversion = "ShockwaveFlash.ShockwaveFlash." + vno;
			return ((typeof(ActiveXObject) == "function") && (typeof(new ActiveXObject(flashplayerversion)) == "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!=null && flashplugin.description) {
			flashplugindesc = parseInt(flashplugin.description.substring(flashplugin.description.indexOf(".")-2));
		}
	   	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( );
	}
}

