/*
 * flexEditIntegration
 * Copyright(c) 2007, DMX Zone.
 * $Rev: 240 $
 * $Date: 2007-02-01 18:08:28 +0100 (do, 01 feb 2007) $
 */


var cFlashTextArea=function()
{var bDebug=true;var bWindowConsole=window.console;bWindowConsole=bWindowConsole!=undefined;var isIE=(window.ActiveXObject);var CS_FLASH_OBJECT_FILE="dmxFlashHTMLEdit.swf";var CS_ATTRIBUTE="flashedit";var CS_IDPREFIX="flashtextarea";var CS_TAIDPREFIX="flashtextarea_textarea";var CS_CONTAINER_IDPREFIX="flashtextareacontainer";var CA_ATTRIBUTES=["toolbar","toolbarBgColor","iconBgColor","iconBgColorEnd","iconBorderColor","iconRadius","areaTextColor","areaBgColor","iconOverColor","uploadPath","uploadFolder","typeOutput"];var nIdCounter=0;var aTextAreas=[];var printDebugMessage=function(sMessage)
{if(bDebug&&bWindowConsole)
{window.console.log(sMessage);}};var cWaitException=function()
{this.description='will wait a little...';};var generateTAId=function()
{return CS_TAIDPREFIX+nIdCounter;};var generateEditorId=function()
{return CS_IDPREFIX+nIdCounter;};var generateContainerId=function()
{return CS_CONTAINER_IDPREFIX+nIdCounter;};var selectTextAreas=function()
{var aTAS=document.getElementsByTagName("textarea");for(var nI=0;nI<aTAS.length;nI++)
{if(aTAS[nI].getAttribute(CS_ATTRIBUTE)&&aTAS[nI].getAttribute(CS_ATTRIBUTE)!="")
{if(!aTAS[nI].id)
{aTAS[nI].id=generateTAId();}
aTextAreas.push(aTAS[nI].id);var sDmxFlashEditorId=generateEditorId();var sDmxContainerId=generateContainerId();if(aTAS[nI].getAttribute("dmxFlashEditorId")&&document.getElementById(aTAS[nI].getAttribute("dmxFlashEditorId")))
{}
else
{aTAS[nI].setAttribute("dmxFlashEditorId",sDmxFlashEditorId);}
if(aTAS[nI].getAttribute("dmxContainerId")&&document.getElementById(aTAS[nI].getAttribute("dmxContainerId")))
{}
else
{aTAS[nI].setAttribute("dmxContainerId",sDmxContainerId);}
createFlashEnvelope(aTAS[nI],sDmxContainerId);nIdCounter++;}}};var processTextAreas=function()
{var hContainer,hSO,hTA,hFTA,hDiv,hO,nWidth,nHeight,sDmxFlashEditorId,sId,sCId,sTAId;for(var nI=0;nI<aTextAreas.length;nI++)
{sTAId=aTextAreas[nI];hTA=document.getElementById(sTAId);nWidth=getStyle(hTA,'width');nWidth=(nWidth=='auto')?hTA.offsetWidth:nWidth;nHeight=getStyle(hTA,'height');nHeight=(nHeight=='auto')?hTA.offsetHeight:nHeight;sDmxFlashEditorId=hTA.getAttribute("dmxFlashEditorId");hSO=new SWFObject(CS_FLASH_OBJECT_FILE,sDmxFlashEditorId,nWidth,nHeight,"9.0.22");hSO.addVariable("textareaId",sTAId+"&"+createConfigVar(hTA));hSO.addParam("allowScriptAccess","always");sCId=hTA.getAttribute("dmxContainerId");sId=sDmxFlashEditorId;hContainer=document.getElementById(sCId);try
{if(isIE)
{hSO.write(hContainer.id);}
else
{hFTA=hSO.buildObject();hContainer.appendChild(hFTA);}}
catch(hE)
{printDebugMessage('On create problem: '+hE.description);}
hTA._originalWidth=nWidth;hTA.style.width='0px';hTA._originalHeight=nWidth;hTA.style.height='0px';hTA.style.position='absolute';hTA.style.left='0';hTA.style.top='0';hTA.style.padding='0';hTA.style.margin='0';hTA.style.borderWidth='0';hTA.style.visibility='hidden';hTA.className='invisibleTA';attachToOnSubmit(hTA);}
deconcept.SWFObject.fixFlex();};var initValue=function(sTAid)
{try
{var hTA=document.getElementById(sTAid);var sDmxFlashEditorId=hTA.getAttribute("dmxFlashEditorId");var hFE=document.getElementById(sDmxFlashEditorId);if(isIE&&!hFE.flexfixed)
{throw(new cWaitException());}
var sValue=hTA.value;hFE.setFlashContent(sValue);}
catch(hE)
{printDebugMessage('On init problem: '+sTAid);window.setTimeout(function(){initValue(sTAid)},100);}};var createFlashEnvelope=function(hTA,sId)
{var hDiv=document.createElement('div');hTA.parentNode.insertBefore(hDiv,hTA);hDiv.id=sId;return hDiv;};var attachToOnSubmit=function(hTA)
{if(hTA.form)
{if(hTA.form.addEventListener)
{hTA.form.addEventListener('submit',function(){cFlashTextArea.onFormSubmit.call(hTA.form)},false)}
else if(hTA.form.attachEvent)
{hTA.form.attachEvent('onsubmit',function(){cFlashTextArea.onFormSubmit.call(hTA.form)})}}};var createConfigVar=function(hTA)
{var aConfig=[];for(var nI=0;nI<CA_ATTRIBUTES.length;nI++)
{if(hTA.getAttribute(CA_ATTRIBUTES[nI]))
{if(aConfig.length>0)
{aConfig.push("&");}
aConfig.push(CA_ATTRIBUTES[nI]);aConfig.push("=");aConfig.push(hTA.getAttribute(CA_ATTRIBUTES[nI]));}}
if(bDebug)
{printDebugMessage(aConfig.join(''));}
return aConfig.join('');};var prepareForSubmission=function(hForm)
{for(var nI=0;nI<hForm.elements.length;nI++)
{if(hForm.elements[nI].getAttribute('dmxFlashEditorId'))
{var hDmxFlashEditor=document.getElementById(hForm.elements[nI].getAttribute('dmxFlashEditorId'));if(hDmxFlashEditor)
{try
{var sValue=hDmxFlashEditor.getFlashContent();if(!sValue)
{sValue="";}
hForm.elements[nI].value=sValue;}
catch(hE)
{printDebugMessage('On submit problem: '+hE.description);}}}}};var toCamelCase=function(sString)
{sString=sString.replace(/[\-\.]/g,' ');var aStr=sString.split(' ');for(var nI=0;nI<aStr.length;nI++)
{aStr[nI].replace(/^\s+|\s+$/,'');if(nI>0)
{aStr[nI]=aStr[nI].charAt(0).toUpperCase()+aStr[nI].substr(1);}}
return aStr.join('');};var getStyle;if(document.defaultView&&document.defaultView.getComputedStyle)
{getStyle=function(hEl,sStyle)
{sStyle=toCamelCase(sStyle);var hStyle=document.defaultView.getComputedStyle(hEl,null);if(hStyle)
{return hEl.style[sStyle]||hStyle[sStyle];}}}
else if(document.documentElement.currentStyle&&isIE)
{getStyle=function(hEl,sStyle)
{sStyle=toCamelCase(sStyle);if(sStyle.toLowerCase()=='opacity')
{var nOpacity=100;try
{nOpacity=hEl.filters['DXImageTransform.Microsoft.Alpha'].opacity;}
catch(e)
{try
{nOpacity=hEl.filters('alpha').opacity;}
catch(e)
{}}
return nOpacity/100;}
else
{var hStyle=hEl.currentStyle;if(hStyle)
{return hEl.style[sStyle]||hStyle[sStyle];}}}}
else
{getStyle=function(hEl,sStyle)
{return hEl.style[MO.Util.toCamelCase(sStyle)];}}
return{init:function()
{selectTextAreas();processTextAreas();},attachToOnLoad:function()
{if(window.addEventListener)
{window.addEventListener('load',cFlashTextArea.init,false)}
else if(window.attachEvent)
{window.attachEvent('onload',cFlashTextArea.init)}},getTextAreaValue:function(sId)
{if(document.getElementById(sId))
{return document.getElementById(sId).value;}
else
{return"";}},setTextAreaValue:function(sId,sValue)
{if(document.getElementById(sId))
{document.getElementById(sId).value=sValue;}
else
{return false;}},onFlashTextAreaCreated:function(sId)
{initValue(sId);},onFormSubmit:function()
{prepareForSubmission(this);}};}();cFlashTextArea.attachToOnLoad();

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(swf,id,w,h,ver,c,useExpressInstall,quality,xiRedirectUrl,redirectUrl,detectKey){if(!document.getElementById){return;}
this.DETECT_KEY=detectKey?detectKey:'detectflash';this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(swf){this.setAttribute('swf',swf);}
if(id){this.setAttribute('id',id);}
if(w){this.setAttribute('width',w);}
if(h){this.setAttribute('height',h);}
if(ver){this.setAttribute('version',new deconcept.PlayerVersion(ver.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(c){this.addParam('bgcolor',c);}
var q=quality?quality:'high';this.addParam('quality',q);this.setAttribute('useExpressInstall',useExpressInstall);this.setAttribute('doExpressInstall',false);var xir=(xiRedirectUrl)?xiRedirectUrl:window.location;this.setAttribute('xiRedirectUrl',xir);this.setAttribute('redirectUrl','');if(redirectUrl){this.setAttribute('redirectUrl',redirectUrl);}}
deconcept.SWFObject.bOnLoadActivated=false;deconcept.SWFObject.nTime=300;deconcept.SWFObject.nRepeat=10;deconcept.SWFObject.aElementsToFix={};deconcept.SWFObject.activateOnLoad=function(sId)
{deconcept.SWFObject.aElementsToFix[sId]={id:sId,bFixed:false};if(deconcept.SWFObject.bOnLoadActivated)
{return;}
else
{window.attachEvent('onload',deconcept.SWFObject.fixFlex);deconcept.SWFObject.bOnLoadActivated=true;}}
deconcept.SWFObject.fixFlex=function()
{deconcept.SWFObject.bOnLoadActivated=true;var hFakeMovie,hRealMovie,hTA,hMethod;var bRunAgain=false;for(var hI in deconcept.SWFObject.aElementsToFix)
{if(deconcept.SWFObject.aElementsToFix[hI].bFixed)
{continue;}
sId=deconcept.SWFObject.aElementsToFix[hI].id;hFakeMovie=window[sId];hRealMovie=document.getElementById(sId);try
{for(hMethod in hFakeMovie)
{hRealMovie[hMethod]=function(){flashFunction="<invoke name=\""+hMethod+"\" returntype=\"javascript\">"+__flash__argumentsToXML(arguments,0)+"</invoke>";return this.CallFunction(flashFunction);};}
window[sId]=hRealMovie;hRealMovie.flexfixed=true;deconcept.SWFObject.aElementsToFix[sId].bFixed=true;}
catch(hE)
{bRunAgain=true;}}
if(bRunAgain)
{deconcept.SWFObject.nRepeat--;if(deconcept.SWFObject.nRepeat<=0)
{alert('IE Error: failed to initilize properly the objects');return;}
window.setTimeout(function(){deconcept.SWFObject.fixFlex(sId)},deconcept.SWFObject.nTime);}}
deconcept.SWFObject.getUniqueId=function()
{var sPrefix='antiiecache_';var hDate=new Date();return sPrefix+hDate.getTime();}
deconcept.SWFObjectUtil.UA=function()
{var ua=navigator.userAgent.toLowerCase();return{isOpera:(ua.indexOf('opera')>-1),isSafari:(ua.indexOf('safari')>-1),isGecko:isMozilla=(ua.indexOf('gecko')>-1),isFirefox:(ua.indexOf('firefox')>-1),isIE:(window.ActiveXObject),isIE7:this.isIE&&(ua.indexOf('msie 7')>=0)}}();deconcept.SWFObjectUtil.CS_NAMESPACEURI="http://www.w3.org/1999/xhtml";deconcept.SWFObjectUtil.createElement=function(sTagName)
{if(document.createElementNS)
{return document.createElementNS(deconcept.SWFObjectUtil.CS_NAMESPACEURI,sTagName);}
else
{return document.createElement(sTagName);}};deconcept.SWFObjectUtil.addParamNode=function(hObjectEl,sParamName,sParamValue)
{var hParam=deconcept.SWFObjectUtil.createElement("param");if(hParam)
{hParam.setAttribute(sParamName,sParamValue);hObjectEl.appendChild(hParam);}
else
{return null;}}
deconcept.SWFObject.prototype={setAttribute:function(name,value){this.attributes[name]=value;},getAttribute:function(name){return this.attributes[name];},addParam:function(name,value){this.params[name]=value;},getParams:function(){return this.params;},addVariable:function(name,value){this.variables[name]=value;},getVariable:function(name){return this.variables[name];},getVariables:function(){return this.variables;},getVariablePairs:function(){var variablePairs=new Array();var key;var variables=this.getVariables();for(key in variables){variablePairs.push(key+"="+variables[key]);}
return variablePairs;},getSWFHTML:function(){var swfNode="";var ieSuffix="";ieSuffix="?antiie="+deconcept.SWFObject.getUniqueId();if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
swfNode='<embed type="application/x-shockwave-flash" src="'+this.getAttribute('swf')+ieSuffix+'" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'"';swfNode+=' id="'+this.getAttribute('id')+'" name="'+this.getAttribute('id')+'" ';var params=this.getParams();for(var key in params){swfNode+=[key]+'="'+params[key]+'" ';}
var pairs=this.getVariablePairs().join("&");if(pairs.length>0){swfNode+='flashvars="'+pairs+'"';}
swfNode+='/>';}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
swfNode='<object id="'+this.getAttribute('id')+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+this.getAttribute('width')+'" height="'+this.getAttribute('height')+'">';swfNode+='<param name="movie" value="'+this.getAttribute('swf')+ieSuffix+'" />';var params=this.getParams();for(var key in params){swfNode+='<param name="'+key+'" value="'+params[key]+'" />';}
var pairs=this.getVariablePairs().join("&");if(pairs.length>0){swfNode+='<param name="flashvars" value="'+pairs+'" />';}
swfNode+="</object>";}
return swfNode;},write:function(elementId){this.skipDetect=true;var n,sId;if(this.getAttribute('useExpressInstall')){var expressInstallReqVer=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(expressInstallReqVer)&&!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'))){if(deconcept.SWFObjectUtil.UA.isIE)
{sId=this.getAttribute('id');window[sId]=new Object();}
n=(typeof elementId=='string')?document.getElementById(elementId):elementId;n.innerHTML=this.getSWFHTML();if(deconcept.SWFObjectUtil.UA.isIE)
{deconcept.SWFObject.activateOnLoad(sId);}
return true;}else{if(this.getAttribute('redirectUrl')!=""){document.location.replace(this.getAttribute('redirectUrl'));}}
return false;},buildObject:function()
{var hFlashNode=null;var pairs=this.getVariablePairs().join("&");var params=this.getParams();var paramKey;var swfSuffix="";ieSuffix="?antiie="+deconcept.SWFObject.getUniqueId();if(deconcept.SWFObjectUtil.UA.isOpera)
{hFlashNode=deconcept.SWFObjectUtil.createElement('object');hFlashNode.setAttribute('data',this.getAttribute('swf')+ieSuffix);deconcept.SWFObjectUtil.addParamNode(hFlashNode,'movie',this.getAttribute('swf')+ieSuffix);deconcept.SWFObjectUtil.addParamNode(hFlashNode,'quality','best');deconcept.SWFObjectUtil.addParamNode(hFlashNode,'wmode','transparent');deconcept.SWFObjectUtil.addParamNode(hFlashNode,'bgcolor','transparent');if(pairs.length>0)
{deconcept.SWFObjectUtil.addParamNode(hFlashNode,'flashvars',pairs);}
for(paramKey in params)
{deconcept.SWFObjectUtil.addParamNode(hFlashNode,paramKey,params[paramKey]);}}
else
{hFlashNode=deconcept.SWFObjectUtil.createElement('embed');if(pairs.length>0)
{hFlashNode.setAttribute('flashvars',pairs);}
for(paramKey in params)
{hFlashNode.setAttribute(paramKey,params[paramKey]);}
hFlashNode.setAttribute('src',this.getAttribute('swf'));}
hFlashNode.setAttribute('width',this.getAttribute('width'));hFlashNode.setAttribute('height',this.getAttribute('height'));hFlashNode.setAttribute('id',this.getAttribute('id'));hFlashNode.setAttribute('name',this.getAttribute('id'));return hFlashNode;}}
deconcept.SWFObjectUtil.getPlayerVersion=function(){var PlayerVersion=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){PlayerVersion=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");PlayerVersion=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(PlayerVersion.major==6){return PlayerVersion;}}
try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}
if(axo!=null){PlayerVersion=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return PlayerVersion;}
deconcept.PlayerVersion=function(arrVersion){this.major=arrVersion[0]!=null?parseInt(arrVersion[0]):0;this.minor=arrVersion[1]!=null?parseInt(arrVersion[1]):0;this.rev=arrVersion[2]!=null?parseInt(arrVersion[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(param){var q=document.location.search||document.location.hash;if(q){var pairs=q.substring(1).split("&");for(var i=0;i<pairs.length;i++){if(pairs[i].substring(0,pairs[i].indexOf("="))==param){return pairs[i].substring((pairs[i].indexOf("=")+1));}}}
return"";}}
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all)return;var objects=document.getElementsByTagName("OBJECT");for(var i=0;i<objects.length;i++){objects[i].style.display='none';for(var x in objects[i]){if(typeof objects[i][x]=='function'){objects[i][x]=function(){};}}}}
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);}
if(window.attachEvent)
{window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);}
if(Array.prototype.push==null){Array.prototype.push=function(item){this[this.length]=item;return this.length;}}
var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
