



_jsc_package(["com","coremedia","editing"]);







(function(){

var $=com.coremedia.editing.Browser=com_coremedia_editing_Browser=function(){
};$.constructorname='com.coremedia.editing.Browser';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.Browser;

com.coremedia.editing.Browser.instance=new com.coremedia.editing.Browser();





com.coremedia.editing.Browser._preventDefault=function(){this.returnValue=false;};
com.coremedia.editing.Browser._cancelBubble=function(){this.cancelBubble=true;};




$.createPortableEventHandler=function(currentWindow,handler){
return function(event){
if(!event||typeof(event.cancelBubble)!="undefined"){

event=currentWindow.event;
if(event){
event.charCode=event.keyCode;
if(event.type=="mouseover"){
event.target=event.toElement;
event.relatedTarget=event.fromElement;
}else if(event.type=="mouseout"){
event.target=event.fromElement;
event.relatedTarget=event.toElement;
}else{
event.target=event.srcElement;
}
event.preventDefault=com.coremedia.editing.Browser._preventDefault;
event.stopPropagation=com.coremedia.editing.Browser._cancelBubble;
}
}
try{
return handler(event);
}catch(e){
alert(e.message);
}finally{
event.target=null;
event.relatedTarget=null;
event.preventDefault=null;
event.stopPropagation=null;
}
};
};


























































$.addEventListener=function(currentWindow,obj,eventName,handler,capture){
if(typeof(capture)=="undefined")
capture=false;



var bound=false;
if(eventName!="submit"){


if(obj.attachEvent){


bound=


obj.attachEvent("on"+eventName,this.createPortableEventHandler(currentWindow,handler));
}else if(!obj.attachEvent&&obj.addEventListener){
obj.addEventListener(eventName,handler,capture);
bound=true;
}
}
if(!bound){
var handlerName="on"+eventName;
obj[handlerName]=this._createLegacyEventHandler(handlerName,this.createPortableEventHandler(currentWindow,handler),obj[handlerName]);
}
};



$._createLegacyEventHandler=function(eventName,handler,oldHandler){
return function(event){
if(oldHandler){
if(false===oldHandler.call(this,event))
return false;
}
return handler(event);
};
};





$.createEvent=function(document,event){
if(typeof document.createEventObject=="function"){
return document.createEventObject(event);
}
var newEvent=new Object();
for(var member in event){
newEvent[member]=event[member];
}
return newEvent;
};

$._confirm=function(icon,msg,buttons,defaultAnswer){
return typeof(ui_Browser__makeMsgBox)!="undefined"
?com.coremedia.editing.Browser__makeMsgBox(null,msg,2,defaultAnswer?4:5,1,0)==6
:confirm(msg);
};

com.coremedia.editing.Browser._BUTTONS_OK_ONLY=0;
com.coremedia.editing.Browser._BUTTONS_OK_CANCEL=1;
com.coremedia.editing.Browser._BUTTONS_ABORT_RETRY_IGNORE=2;
com.coremedia.editing.Browser._BUTTONS_YES_NO_CANCEL=3;
com.coremedia.editing.Browser._BUTTONS_YES_NO=4;
com.coremedia.editing.Browser._BUTTONS_RETRY_CANCEL=5;

com.coremedia.editing.Browser._BUTTON_OK=1;
com.coremedia.editing.Browser._BUTTON_CANCEL=2;
com.coremedia.editing.Browser._BUTTON_ABORT=3;
com.coremedia.editing.Browser._BUTTON_RETRY=4;
com.coremedia.editing.Browser._BUTTON_IGNORE=5;
com.coremedia.editing.Browser._BUTTON_YES=6;
com.coremedia.editing.Browser._BUTTON_NO=7;

com.coremedia.editing.Browser.DIALOG_BUTTONS_OK_CANCEL=com.coremedia.editing.Browser._BUTTONS_OK_CANCEL;
com.coremedia.editing.Browser.DIALOG_BUTTONS_YES_NO=com.coremedia.editing.Browser._BUTTONS_YES_NO;
com.coremedia.editing.Browser.DIALOG_BUTTONS_RETRY_CANCEL=com.coremedia.editing.Browser._BUTTONS_RETRY_CANCEL;

com.coremedia.editing.Browser._ICON_CRITICAL=1;
com.coremedia.editing.Browser._ICON_QUESTION=2;
com.coremedia.editing.Browser._ICON_EXCLAMATION=3;
com.coremedia.editing.Browser._ICON_INFORMATION=4;

com.coremedia.editing.Browser._APPLICATION_MODAL=0;
com.coremedia.editing.Browser._SYSTEM_MODAL=1;

com.coremedia.editing.Browser._trueButtons=new Array();
com.coremedia.editing.Browser._falseButtons=new Array();

(function(){
com.coremedia.editing.Browser._trueButtons[com.coremedia.editing.Browser.DIALOG_BUTTONS_OK_CANCEL]=com.coremedia.editing.Browser._BUTTON_OK;
com.coremedia.editing.Browser._trueButtons[com.coremedia.editing.Browser.DIALOG_BUTTONS_YES_NO]=com.coremedia.editing.Browser._BUTTON_YES;
com.coremedia.editing.Browser._trueButtons[com.coremedia.editing.Browser.DIALOG_BUTTONS_RETRY_CANCEL]=com.coremedia.editing.Browser._BUTTON_RETRY;
com.coremedia.editing.Browser._falseButtons[com.coremedia.editing.Browser.DIALOG_BUTTONS_OK_CANCEL]=com.coremedia.editing.Browser._BUTTON_CANCEL;
com.coremedia.editing.Browser._falseButtons[com.coremedia.editing.Browser.DIALOG_BUTTONS_YES_NO]=com.coremedia.editing.Browser._BUTTON_NO;
com.coremedia.editing.Browser._falseButtons[com.coremedia.editing.Browser.DIALOG_BUTTONS_RETRY_CANCEL]=com.coremedia.editing.Browser._BUTTON_CANCEL;
})();

$.displayQuestionDialog=function(msg,title,dialogButtons,defaultAnswer){
return this._displayDialog(msg,title,com.coremedia.editing.Browser._ICON_QUESTION,dialogButtons,defaultAnswer?0:1);
};

$.displayInformationDialog=function(msg,title,dialogButtons,defaultAnswer){
return this._displayDialog(msg,title,com.coremedia.editing.Browser._ICON_INFORMATION,dialogButtons,defaultAnswer?0:1);
};

$.displayWarningDialog=function(msg,title,dialogButtons,defaultAnswer){
return this._displayDialog(msg,title,com.coremedia.editing.Browser._ICON_EXCLAMATION,dialogButtons,defaultAnswer?0:1);
};

$.displayErrorDialog=function(msg,title,dialogButtons,defaultAnswer){
return this._displayDialog(msg,title,com.coremedia.editing.Browser._ICON_CRITICAL,dialogButtons,defaultAnswer?0:1);
};

$._displayDialog=function(msg,title,icon,buttons,defaultButton){
com.coremedia.util.Logger.log("displayDialog("+title+", "+msg);
return typeof(ui_Browser__makeMsgBox)!="undefined"
?ui_Browser__makeMsgBox(title,msg,icon,buttons,defaultButton,com.coremedia.editing.Browser._APPLICATION_MODAL)==
com.coremedia.editing.Browser._trueButtons[buttons]
:confirm(msg);
};

















$.getMousePosition=function(e,currentWindow){
if(!currentWindow)currentWindow=window;
var left=e.clientX;
var top=e.clientY;
if(currentWindow==window){
left+=this.getScrollX(currentWindow);
top+=this.getScrollY(currentWindow);
}else if(currentWindow.frameElement){
var parentOffset=this.getElementLocation(currentWindow.frameElement,currentWindow.parent);

left+=parentOffset.left;
top+=parentOffset.top;
}
return{left:left,top:top};
};



$.getElementLocationInFrame=function(elem){
var location={left:0,top:0};
for(var currentElement=elem;currentElement!=null;currentElement=currentElement.offsetParent){
location.left+=currentElement.offsetLeft;
location.top+=currentElement.offsetTop;
}
return location;
};






$.getElementLocation=function(elem,currentWindow){
if(!currentWindow)currentWindow=window;
var location=this.getElementLocationInFrame(elem);
var frameElement=currentWindow.frameElement;
if(frameElement){


if(elem.nodeName=="FRAME"&&!document.body.ownerDocument){

}else{
var iframeLocation=this.getElementLocation(frameElement,currentWindow.parent);

location.left+=iframeLocation.left;
location.top+=iframeLocation.top;
}
}
return location;
};

$.getComputedStyle=function(elem,currentWindow){
if(!currentWindow)currentWindow=window;
return currentWindow.document.defaultView
?document.defaultView.getComputedStyle(elem,null)
:elem.currentStyle;
};

$.getStylePropertyValue=function(style,cssProperty){
if(typeof style.getPropertyValue=="function"){
return style.getPropertyValue(cssProperty);
}
var tokens=cssProperty.split("-");
for(var i=1;i<tokens.length;++i){
tokens[i]=tokens[i].charAt(0).toUpperCase()+tokens[i].substring(1);
}
var jsProperty=tokens.join("");
return style[jsProperty];
};

$.getStylePropertyValueInPixels=function(style,cssProperty){
var pixelStr=this.getStylePropertyValue(style,cssProperty);
var lastNumberIndex=pixelStr.length-2;
if(lastNumberIndex<0||pixelStr.substring(lastNumberIndex)!="px"){
throw"Style property did not return a pixel value ('nnnpx' where 'n' are digits): "+pixelStr;
}
return Number(pixelStr.substring(0,lastNumberIndex));
};







$.getWindowWidth=function(currentWindow){
if(!currentWindow)currentWindow=window;
if(typeof currentWindow.innerWidth=="number"){

return currentWindow.innerWidth;
}else{
var doc=currentWindow.document;
var docElem=doc.documentElement;
if(docElem&&docElem.clientWidth){

return docElem.clientWidth;
}else{
var body=doc.body;
if(body&&body.clientWidth){

return body.clientWidth;
}
}
}
return-1;
};








$.getWindowHeight=function(currentWindow){
if(!currentWindow)currentWindow=window;
if(typeof currentWindow.innerHeight=="number"){

return currentWindow.innerHeight;
}else{
var doc=currentWindow.document;
var docElem=doc.documentElement;
if(docElem&&docElem.clientHeight){

return docElem.clientHeight;
}else{
var body=doc.body;
if(body&&body.clientHeight){

return body.clientHeight;
}
}
}
return-1;
};






$.getScrollX=function(currentWindow){
if(!currentWindow)currentWindow=window;
return currentWindow.document.documentElement.scrollLeft?
currentWindow.document.documentElement.scrollLeft:currentWindow.pageXOffset?
currentWindow.pageXOffset:currentWindow.document.body.scrollLeft?
currentWindow.document.body.scrollLeft:0;
};






$.getScrollY=function(currentWindow){
if(!currentWindow)currentWindow=window;
return currentWindow.document.documentElement.scrollTop?
currentWindow.document.documentElement.scrollTop:currentWindow.pageYOffset?
currentWindow.pageYOffset:currentWindow.document.body.scrollTop?
currentWindow.document.body.scrollTop:0;
};

$.getContentSize=function(element){
var depth=0;
var size=new Object();
size.width=0;
size.height=0;
var currentElement=element.firstChild;
var tmp=null;
while(currentElement!=null){
if(typeof currentElement.offsetWidth!="undefined"&&currentElement.nodeName!="SCRIPT"){
size.width=Math.max(size.width,currentElement.offsetWidth);
if(com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.IE)
size.height+=currentElement.offsetHeight;
else
size.height=Math.max(size.height,currentElement.offsetHeight);
}
if(com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.IE)
currentElement=currentElement.nextSibling;
else{
tmp=currentElement.firstChild;
if(tmp==null)
tmp=currentElement.nextSibling;
else
depth++;
if(tmp==null&&depth>0){
depth--;
tmp=currentElement.parentNode.nextSibling;
}
currentElement=tmp;
}
}
if(size.width==0||size.height==0){
throw"Zero dimension for "+element.nodeName+": ("+size.width+","+size.height+")!";
}
return size;
};

$.getBrowserVersion=function(){
var browser=this.getBrowser();
if(browser==this.IE)
return this._ieversion();
if(browser==this.NETSCAPE)
if(navigator.appVersion)
return navigator.appVersion;

return this.UNKNOWN_VERSION;
};





com.coremedia.editing.Browser.getBrowser=function(){
if(navigator.appName.indexOf("Netscape")>-1){
return this.NETSCAPE;
}
else if((navigator.appName.indexOf("Microsoft")>-1)||(navigator.appName.indexOf("MSIE")>-1)){
return this.IE;
}
else if(navigator.appName.indexOf("Opera")>-1){
return this.OPERA;
}
else{
return this.UNKNOWN_BROWSER;
}
};

com.coremedia.editing.Browser.getName=function(browser){
if(browser==this.NETSCAPE)return"Netscape";
if(browser==this.IE)return"Internet Explorer";
if(browser==this.OPERA)return"Opera";
return"unknown browser";

};


com.coremedia.editing.Browser._ieversion=function(){
var ua=window.navigator.userAgent;
var ie=ua.indexOf("MSIE ");
if(ie>0)
return parseInt(ua.substring(ie+5,ua.indexOf(".",ie)));
else return 0;
};$.getversion=

function(){

};

com.coremedia.editing.Browser.getOuterHTML=function(){
var nodeName=this.nodeName.toLowerCase();
var out="<"+nodeName;
var attributes=this.attributes;
for(var a=0;a<attributes.length;++a){
var attribute=attributes[a];
out+=" "+attribute.name+"=\""+attribute.value+"\"";
}
return out+">"+this.innerHTML+"</"+nodeName+">";
};

(function(){
if(typeof HTMLElement=="function"&&typeof HTMLElement.prototype.__defineGetter__=="function"){
HTMLElement.prototype.__defineGetter__("outerHTML",com_coremedia_editing_Browser.getOuterHTML);

HTMLButtonElement.prototype.click=HTMLElement.prototype.click=function(){
var evt=this.ownerDocument.createEvent("MouseEvents");
evt.initMouseEvent("click",true,true,this.ownerDocument.defaultView,1,0,0,0,0,false,false,false,false,0,null);
this.dispatchEvent(evt);
};

window.clipboardData={
_prepare:function(){
if(!this._clipboardDocument){
var clipboardFrame=document.createElement("iframe");
clipboardFrame.style.width="1px";
clipboardFrame.style.height="1px";
clipboardFrame.style.visibility="hidden";
document.body.appendChild(clipboardFrame);
this._clipboardDocument=clipboardFrame.contentWindow.document;
this._clipboardDocument.designMode="on";
}
},
_selectBody:function(){
var selection=this._clipboardDocument.defaultView.getSelection();
selection.selectAllChildren(this._clipboardDocument.body);
return selection;
},
dispose:function(){
if(this._clipboardDocument){
document.body.removeChild(this._clipboardDocument.defaultView.frameElement);
}
},
getData:function(flavor){
var data;
if(flavor=="Text"){
this._prepare();
this._selectBody();
this._clipboardDocument.execCommand("Paste",undefined,undefined);
data=this._clipboardDocument.body.innerHTML;
this._clipboardDocument.body.innerHTML="";
}
return data;
},
setData:function(flavor,data){
if(flavor=="Text"){
this._prepare();
this._clipboardDocument.body.innerHTML=data;
this._selectBody();
this._clipboardDocument.execCommand("Copy",undefined,undefined);
this._clipboardDocument.body.innerHTML="";
}
},
clearData:function(){
this.setData("Text","");
}
};

}
})();

com.coremedia.editing.Browser.UNKNOWN_BROWSER=0;
com.coremedia.editing.Browser.NETSCAPE=10;
com.coremedia.editing.Browser.IE=200;
com.coremedia.editing.Browser.OPERA=600;

com.coremedia.editing.Browser.UNKNOWN_VERSION=-1;

})();
_jsc_package(["com","coremedia","editing"]);













(function(){

var $=com.coremedia.editing.ComponentEventType=com_coremedia_editing_ComponentEventType=function(name,isBubbling,isFrameEvent){
this._name=name;
this._isBubbling=isBubbling?true:false;
this._isFrameEvent=isFrameEvent?true:false;
this._processMethodName="process"+name.substring(0,1).toUpperCase()+name.substring(1);
com.coremedia.editing.ComponentEventType._EVENT_TYPE_MAP[name]=this;
};$.constructorname='com.coremedia.editing.ComponentEventType';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.ComponentEventType;






$.getName=function(){
return this._name;
};







$.isBubbling=function(){
return this._isBubbling;
};

$.isFrameEvent=function(){
return this._isFrameEvent;
};







$.getProcessMethodName=function(){
return this._processMethodName;
};




$.canDispatchTo=function(component){
var processMethodName=this.getProcessMethodName();
return typeof component[processMethodName]=="function";
};

$.toString=function(){
return this._name;
};

com.coremedia.editing.ComponentEventType._EVENT_TYPE_MAP=new Object();




com.coremedia.editing.ComponentEventType.CLICK=new com.coremedia.editing.ComponentEventType("click",true);
com.coremedia.editing.ComponentEventType.DBLCLICK=new com.coremedia.editing.ComponentEventType("dblclick",true);
com.coremedia.editing.ComponentEventType.CONTEXTMENU=new com.coremedia.editing.ComponentEventType("contextmenu",true);
com.coremedia.editing.ComponentEventType.MOUSEOVER=new com.coremedia.editing.ComponentEventType("mouseover",true);
com.coremedia.editing.ComponentEventType.MOUSEOUT=new com.coremedia.editing.ComponentEventType("mouseout",true);
com.coremedia.editing.ComponentEventType.MOUSEDOWN=new com.coremedia.editing.ComponentEventType("mousedown",true);
com.coremedia.editing.ComponentEventType.MOUSEUP=new com.coremedia.editing.ComponentEventType("mouseup",true);
com.coremedia.editing.ComponentEventType.MOUSEMOVE=new com.coremedia.editing.ComponentEventType("mousemove",true);
com.coremedia.editing.ComponentEventType.DRAG=new com.coremedia.editing.ComponentEventType("drag",true);
com.coremedia.editing.ComponentEventType.DRAGSTART=new com.coremedia.editing.ComponentEventType("dragstart",true);
com.coremedia.editing.ComponentEventType.DRAGEND=new com.coremedia.editing.ComponentEventType("dragend",true);
com.coremedia.editing.ComponentEventType.DROP=new com.coremedia.editing.ComponentEventType("drop",true);
com.coremedia.editing.ComponentEventType.DRAGLEAVE=new com.coremedia.editing.ComponentEventType("dragleave",true);
com.coremedia.editing.ComponentEventType.DRAGENTER=new com.coremedia.editing.ComponentEventType("dragenter",true);
com.coremedia.editing.ComponentEventType.DRAGOVER=new com.coremedia.editing.ComponentEventType("dragover",true);
com.coremedia.editing.ComponentEventType.KEYDOWN=new com.coremedia.editing.ComponentEventType("keydown",true);
com.coremedia.editing.ComponentEventType.KEYUP=new com.coremedia.editing.ComponentEventType("keyup",true);
com.coremedia.editing.ComponentEventType.KEYPRESS=new com.coremedia.editing.ComponentEventType("keypress",true);




com.coremedia.editing.ComponentEventType.FOCUS=new com.coremedia.editing.ComponentEventType("focus");
com.coremedia.editing.ComponentEventType.BLUR=new com.coremedia.editing.ComponentEventType("blur");
com.coremedia.editing.ComponentEventType.SCROLL=new com.coremedia.editing.ComponentEventType("scroll");




com.coremedia.editing.ComponentEventType.LOAD=new com.coremedia.editing.ComponentEventType("load",false,true);
com.coremedia.editing.ComponentEventType.UNLOAD=new com.coremedia.editing.ComponentEventType("unload",false,true);
com.coremedia.editing.ComponentEventType.RESIZE=new com.coremedia.editing.ComponentEventType("resize",false,true);
com.coremedia.editing.ComponentEventType.RESIZESTART=new com.coremedia.editing.ComponentEventType("resizestart",false,true);
com.coremedia.editing.ComponentEventType.SUBMIT=new com.coremedia.editing.ComponentEventType("submit",false,true);




com.coremedia.editing.ComponentEventType.ACTIVATION=new com.coremedia.editing.ComponentEventType("activation");




com.coremedia.editing.ComponentEventType.EVENT_TYPES=new Array();




com.coremedia.editing.ComponentEventType.BUBBLING_EVENT_TYPES=new Array();




com.coremedia.editing.ComponentEventType.NON_BUBBLING_EVENT_TYPES=new Array();






com.coremedia.editing.ComponentEventType.FRAME_EVENT_TYPES=new Array();

com.coremedia.editing.ComponentEventType._init=function(){
this.EVENT_TYPES=[this.CLICK,this.DBLCLICK,this.CONTEXTMENU,
this.DRAG,this.DRAGSTART,this.DRAGEND,this.DROP,
this.DRAGLEAVE,this.DRAGENTER,this.DRAGOVER,
this.MOUSEOVER,this.MOUSEOUT,this.MOUSEDOWN,this.MOUSEUP,this.MOUSEMOVE,
this.KEYDOWN,this.KEYUP,this.KEYPRESS,
this.FOCUS,this.BLUR,this.SCROLL,
this.LOAD,this.UNLOAD,this.RESIZE,this.RESIZESTART,this.SUBMIT,this.ACTIVATION];
for(var i=0;i<this.EVENT_TYPES.length;++i){
var eventType=this.EVENT_TYPES[i];
if(eventType.isBubbling()){
this.BUBBLING_EVENT_TYPES.push(eventType);
}else{
this.NON_BUBBLING_EVENT_TYPES.push(eventType);
}
if(eventType.isFrameEvent()){
this.FRAME_EVENT_TYPES.push(eventType);
}
}
};

(function(){
com.coremedia.editing.ComponentEventType._init();
})();

com.coremedia.editing.ComponentEventType.getEventTypeByName=function(name){
return this._EVENT_TYPE_MAP[name];
};





})();
_jsc_package(["com","coremedia","editing"]);








(function(){var $=com.coremedia.editing.ComponentEvent=com_coremedia_editing_ComponentEvent=












function(currentWindow,targetComponent,event,
type,target,clientX,clientY,keyCode){

if(currentWindow){
this._window=currentWindow;
this._event=event;
if(!event&&!type)throw"Undefined event and type for ComponentEvent";
this._type=com.coremedia.editing.ComponentEventType.getEventTypeByName(type?type:event.type);
if(!this._type)
throw"Unknown event type "+event.type+".";
this._propagationStopped=!this._type.isBubbling();
this._target=target?target:(event?event.target:null);
this._targetComponent=targetComponent;
this._clientX=clientX?clientX:(event?event.clientX:null);
this._clientY=clientY?clientY:(event?event.clientY:null);
this._screenX=event?event.screenX:null;
this._screenY=event?event.screenY:null;
this._keyCode=keyCode?keyCode:(event?event.keyCode:null);
}
};$.constructorname='com.coremedia.editing.ComponentEvent';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.ComponentEvent;

$.getOriginal=function(){
return this._event;
};

$.getFrame=function(){
return com.coremedia.editing.Frame.getInstance(this._window);
};

$.getWindow=function(){
return this._window;
};


$.getType=function(){
return this._type;
};

$.getTarget=function(){
return this._target;
};

$.getTargetComponent=function(){
return this._targetComponent;
};

$.getClientX=function(){
return this._clientX;
};

$.getClientY=function(){
return this._clientY;
};

$.getScreenX=function(){
return this._screenX;
};

$.getScreenY=function(){
return this._screenY;
};

$.getMousePosition=function(){
var location={left:this._clientX,top:this._clientY};
var frame=this.getFrame();
if(this._window==window){

var scrollOffset=frame.getScrollOffset();
location.left+=scrollOffset.left;
location.top+=scrollOffset.top;
}else if(frame.getFrameElement()){

var parentFrame=com.coremedia.editing.Frame.getInstance(this._window.parent);
var parentOffset=parentFrame.getElementLocation(frame.getFrameElement());

location.left+=parentOffset.left;
location.top+=parentOffset.top;
}
return location;
};

$.getKeyCode=function(){
return this._keyCode;
};

$.getCtrlKeyPressed=function(){
if(this._event&&this._event.ctrlKey)return this._event.ctrlKey;
else return false;
};

$.getAltKeyPressed=function(){
if(this._event.altKey)return this._event.altKey;
else return false;
};

$.getMetaKeyPressed=function(){
if(this._event.metaKey)return this._event.metaKey;
else return false;
};


$.getCtrlLeftPressed=function(){
if(this._event&&this._event.ctrlLeft)return this._event.ctrlLeft;
else return false;
};

$.getShiftKeyPressed=function(){
if(this._event&&this._event.shiftKey)return this._event.shiftKey;
else return false;
};

$.getShiftLeftPressed=function(){
if(this._event&&this._event.shiftLeft)return this._event.shiftLeft;
else return false;
};





$.preventDefault=function(){
if(this._event)this._event.preventDefault();
};




$.stopPropagation=function(){
if(this._event)this._event.stopPropagation();
this._propagationStopped=true;
};











$.dispatch=function(component){
if(!component)
component=this._targetComponent;
if(component){
var processMethodName=this._type.getProcessMethodName();
do{
if(this._type.canDispatchTo(component)){
var consumed=component[processMethodName](this);
if(consumed){
this.preventDefault();
this.stopPropagation();
}
if(this._propagationStopped){
break;
}
}
component=component.getParent();
}while(component);
return true;
}
return false;
};

$.toString=function(){
return"ComponentEvent [original: "+this._event+
", target: "+((this._target&&this._target.nodeName)?this._target.nodeName:this._target)+
", key: "+String.fromCharCode(this._event.keyCode)+
", keycode: "+this._keyCode+
", type: "+this._type+
", shift: "+this._event.shiftKey+
", ctrl: "+this._event.ctrlKey+
", alt: "+this._event.altKey;
};

com.coremedia.editing.ComponentEvent.VK_ENTER=13;
com.coremedia.editing.ComponentEvent.VK_BACK_SPACE=8;
com.coremedia.editing.ComponentEvent.VK_TAB=9;
com.coremedia.editing.ComponentEvent.VK_CANCEL=3;
com.coremedia.editing.ComponentEvent.VK_CLEAR=12;
com.coremedia.editing.ComponentEvent.VK_SHIFT=16;
com.coremedia.editing.ComponentEvent.VK_CONTROL=17;
com.coremedia.editing.ComponentEvent.VK_ALT=18;
com.coremedia.editing.ComponentEvent.VK_PAUSE=19;
com.coremedia.editing.ComponentEvent.VK_CAPS_LOCK=20;
com.coremedia.editing.ComponentEvent.VK_ESCAPE=27;
com.coremedia.editing.ComponentEvent.VK_SPACE=32;
com.coremedia.editing.ComponentEvent.VK_PAGE_UP=33;
com.coremedia.editing.ComponentEvent.VK_PAGE_DOWN=34;
com.coremedia.editing.ComponentEvent.VK_END=35;
com.coremedia.editing.ComponentEvent.VK_HOME=36;
com.coremedia.editing.ComponentEvent.VK_DELETE=46;













})();
_jsc_package(["com","coremedia","editing"]);
















(function(){







var $=com.coremedia.editing.ComponentController=com_coremedia_editing_ComponentController=function(currentWindow){
this.startStopWatch();
this._window=currentWindow;
currentWindow[com.coremedia.editing.ComponentController._ATTRIBUTE_NAME]=this;
this._componentMap=new Object();
this._eventTargets=new Object();
this._unregisteredEventTypes=new Object();
var BUBBLING_EVENT_TYPES=com.coremedia.editing.ComponentEventType.BUBBLING_EVENT_TYPES;
for(var i=0;i<BUBBLING_EVENT_TYPES.length;++i){
this._unregisteredEventTypes[BUBBLING_EVENT_TYPES[i].getName()]=true;
}
this._registeredEventTypes=new Array();
if(this._isLoggingEnabled())
this._log("instance created for "+currentWindow.name?currentWindow.name:currentWindow);
var self=this;
com.coremedia.editing.Browser.instance.addEventListener(currentWindow,currentWindow,"load",function(e){
self._init(e);
});
};$.constructorname='com.coremedia.editing.ComponentController';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.ComponentController;

$._init=function(e){
if(this._isLoggingEnabled())
this._log("_init()");
if(this._window.parent&&this._window.parent.document.frames){

var currentFrameElement=this._window.frameElement;
if(currentFrameElement){
var currentFrameElementName=currentFrameElement.name;
var targetFrame=currentFrameElementName=="view1"?"view2":
currentFrameElementName=="view2"?"view1":
null;
if(targetFrame){
var oldFrame=this._window.parent.document.frames[targetFrame];
if(oldFrame){
var form=this._window.document.forms[0];
if(form){
this._window.document.forms[0].target=targetFrame;
}
com.coremedia.dom.HtmlDomUtil.setClassAttribute(oldFrame.frameElement,"background");
com.coremedia.dom.HtmlDomUtil.setClassAttribute(currentFrameElement,"foreground");
oldFrame.frameElement.src="about:blank";
}
}
}
}

var frame=this.getFrame();
this._lastFrameSize=frame.getSize();
var loadEvent=new com.coremedia.editing.ComponentEvent(this._window,frame,e);
this._broadcast(loadEvent,this._eventTargets.load);
loadEvent=null;
frame=null;
delete this._eventTargets.load;

if(this._eventTargets.unload){
com.coremedia.editing.Browser.instance.addEventListener(this._window,this._window,"unload",function(e){
var unloadEvent=new com.coremedia.editing.ComponentEvent(self._window,frame,e);
self._broadcast(unloadEvent,self._eventTargets.unload);

});
}



var internalFrame=this.getFrame().getParent();
if(internalFrame&&typeof internalFrame.processContentLoad=="function"){
internalFrame.processContentLoad();
}

var browser=com.coremedia.editing.Browser.instance;
var self=this;
if(this._registeredEventTypes.length>0){

var body=this._window.document.body;
var eventListener=function(e){self.handleEvent(e);};
for(var i=0;i<this._registeredEventTypes.length;++i){
var eventType=this._registeredEventTypes[i];
browser.addEventListener(this._window,body,eventType.getName(),eventListener,this._isFirefox());
}
body=null;
eventListener=null;
}
this._unregisteredEventTypes=null;
this._registeredEventTypes=null;
for(var eventTypeName in this._eventTargets){

if(eventTypeName!="resize"&&eventTypeName!="unload"){
var eventTargets=this._eventTargets[eventTypeName];
for(var i=0;i<eventTargets.length;++i){
var eventTarget=eventTargets[i];
var element=eventTarget.getEventSourceElement();
browser.addEventListener(this._window,element,eventTypeName,
this._createNonBubblingEventListener(eventTarget.getId()),
this._isFirefox());
}
}
}
if(this._eventTargets.resize){
browser.addEventListener(this._window,this._window,"resize",function(e){self._handleResizeEvent(e);});
}
if(this._eventTargets.submit){

var form=this._eventTargets.submit[0].findEnclosingForm();
browser.addEventListener(this._window,form,"submit",self._createHandleFrameEvent());
}
browser=null;


var activate=this._getActivation();
if(activate){
var activationEvt=new com.coremedia.editing.ActivationEvent(this.getWindow(),loadEvent,activate,activate);
for(var i=0;i<activate.length;i++){
if(typeof activate[i]["processActivation"]=="function"){
activate[i].processActivation(activationEvt);

}
}
}
};

$._createHandleFrameEvent=function(){
var self=this;
return function(e){self.handleFrameEvent(e);};
};

$._createNonBubblingEventListener=function(eventTargetId){
var self=this;
return function(event){
if(self._isLoggingEnabled())
self._log("ComponentController.EventListener: event: "+event.type+", eventTarget-> "+eventTarget);
return new com.coremedia.editing.ComponentEvent(self.getWindow(),self.getComponent(eventTargetId),event).dispatch();
};
};

$._broadcast=function(event,components,parent){
if(this._isLoggingEnabled())this._log("broadcasting event "+event);
for(var i=0;i<components.length;++i){
var component=components[i];
if(!parent||parent.isTransitiveParent(component)){
event.dispatch(component);
}
}
};

$.getWindow=function(){
return this._window;
};





$.register=function(component){
if(component.getId()){

for(var eventTypeName in this._unregisteredEventTypes){
var eventType=com.coremedia.editing.ComponentEventType.getEventTypeByName(eventTypeName);
if(eventType.canDispatchTo(component)){
this._registeredEventTypes.push(eventType);
delete this._unregisteredEventTypes[eventTypeName];
}
}
this._addComponent(component);
}

var NON_BUBBLING_EVENT_TYPES=com.coremedia.editing.ComponentEventType.NON_BUBBLING_EVENT_TYPES;
for(var i=0;i<NON_BUBBLING_EVENT_TYPES.length;++i){
var eventType=NON_BUBBLING_EVENT_TYPES[i];
if(eventType.canDispatchTo(component)){
var eventTypeName=eventType.getName();
var eventTargets=this._eventTargets[eventTypeName];
if(!eventTargets){
eventTargets=new Array();
this._eventTargets[eventTypeName]=eventTargets;
}
eventTargets.push(component);
}
}
};





$.unregister=function(component){
if(component.getId()){
var NON_BUBBLING_EVENT_TYPES=com.coremedia.editing.ComponentEventType.NON_BUBBLING_EVENT_TYPES;
for(var i=0;i<NON_BUBBLING_EVENT_TYPES.length;++i){
var eventType=NON_BUBBLING_EVENT_TYPES[i];
if(eventType.canDispatchTo(component)){

}
}
if(com.coremedia.editing.ComponentEventType.RESIZE.canDispatchTo(component)){

for(var eventName in this._eventTargets){
var eventTargets=this._eventTargets[eventName];
for(var i=0;i<eventTargets.length;++i){
if(component==eventTargets[i]){
eventTargets.splice(i,1);
break;
}
}
}
}
this._removeComponent(component);
}
};





$._addComponent=function(component){
if(this._isLoggingEnabled())this._log("adding component "+component.getId());
this._componentMap[com.coremedia.editing.ComponentController._MAP_PREFIX+component.getId()]=component;
};

$._removeComponent=function(component){
if(this._isLoggingEnabled())this._log("removing component "+component.getId());
delete this._componentMap[com.coremedia.editing.ComponentController._MAP_PREFIX+component.getId()];
};






$.getComponent=function(id){
if(this._isLoggingEnabled())this._log("finding component "+id);
return(typeof(com)!="undefined")?this._componentMap[com.coremedia.editing.ComponentController._MAP_PREFIX+id]:null;
};






$.findComponent=function(element){
var id=null;
while(element!=null){
if(element.getAttribute){
id=element.getAttribute("id");
if(this._isLoggingEnabled())this._log("searching component for "+id);

var frameid=(typeof(com)!="undefined")?element.getAttribute(com.coremedia.editing.Frame.FRAME_ID_ATTRIBUTE):null;
if(frameid){
component=this.getComponent(frameid);
if(component){
return component;
}
}
if(id){
component=this.getComponent(id);
if(component){
return component;
}
}
}
element=element.parentNode;
}
if(this._isLoggingEnabled())this._log("no component found for "+id);
return null;
};




$._getParent=function(component){
return this.findComponent(component.getElement().parentNode);
};





com.coremedia.editing.ComponentController.getMouseCapture=function(){
return this._mouseCapture;
};







com.coremedia.editing.ComponentController.setMouseCapture=function(component){
var capture=!this.getMouseCapture();
if(capture){
this._mouseCapture=component;
}
return capture;
};





com.coremedia.editing.ComponentController.releaseMouseCapture=function(component){
var release=this.getMouseCapture()==component;
if(release){
this._mouseCapture=null;
}
return release;
};

















$.handleEvent=function(event){
var element=event.target;
if(element){
if(this._isLoggingEnabled())
this._log("handling event "+event);
var component=this.findComponent(element);
if(event.relatedTarget&&(event.type=="mouseover"||event.type=="mouseout")){
try{
var relatedComponent=this.findComponent(event.relatedTarget);
if(relatedComponent==component){

return;
}
}catch(e){

}
}
return this._handleEvent(event,component);
}
return false;
};







$._handleEvent=function(event,component){














if(typeof com=="undefined")return false;

var componentEvent=new com.coremedia.editing.ComponentEvent(this.getWindow(),component,event);
var mouseCapture=com.coremedia.editing.ComponentController.getMouseCapture();
var result=false;
if(mouseCapture){

if(!component||!mouseCapture.isTransitiveParent(component)){

result=componentEvent.dispatch(mouseCapture);
return result;
}
}
return componentEvent.dispatch();
};

$.requestActivation=function(component,trigger){
var oldActivationPath=this._getActivation();
var newActivationPath=(component)?component.getComponentPath():new Array();
var event=new com.coremedia.editing.ActivationEvent(this.getWindow(),trigger,oldActivationPath,newActivationPath);



var deltaIndex;
for(deltaIndex=0;
deltaIndex<oldActivationPath.length
&&deltaIndex<newActivationPath.length
&&oldActivationPath[deltaIndex]==newActivationPath[deltaIndex];
deltaIndex++);


var success=true;

for(var i=oldActivationPath.length-1;success&&i>=deltaIndex;i--){
success=(typeof oldActivationPath[i]["onBeforeDeactivation"]=="function")
?oldActivationPath[i].onBeforeDeactivation(event)
:true;

}

for(var i=deltaIndex;success&&i<newActivationPath.length;i++){
success=(typeof newActivationPath[i]["onBeforeActivation"]=="function")
?newActivationPath[i].onBeforeActivation(event)
:true;


}

if(success){
for(var i=oldActivationPath.length-1;success&&i>=deltaIndex;i--){
if(typeof oldActivationPath[i]["processDeactivation"]=="function"){
oldActivationPath[i].processDeactivation(event);

}
}
this._setActivationId((component)?component.getId():null);
for(var i=deltaIndex;success&&i<newActivationPath.length;i++){
if(typeof newActivationPath[i]["processActivation"]=="function"){
newActivationPath[i].processActivation(event);

}
}
}

return success;
};

$._getActivation=function(){
var leaf=this.getActivatedComponent();
return(leaf)?leaf.getComponentPath():new Array();
};


$.isActivated=function(component){
var activated=this.getActivatedComponent();
while(activated){
if(component==activated)return true;
activated=component.getParent();
}
return false;
};

$.getActivatedComponent=function(){
var activationId=this._getActivationId();
return(activationId==null)?null:this.getComponent(activationId);
};


$._setActivationId=function(componentId){
var field=this.getForm()["view.selectedComponent"];
if(field)field.value=(componentId==null)?"":componentId;
};


$._getActivationId=function(){
var form=this.getForm();
var field=(form)?this.getForm()["view.selectedComponent"]:null;
if(!field){
return null;
}else{
return field.value;
}
};

$._handleResizeEvent=function(event){
var newSize=this.getFrame().getSize();
if(newSize.width!=this._lastFrameSize.width||newSize.height!=this._lastFrameSize.height){
this._lastFrameSize=newSize;
this.handleFrameEvent(event);
}
};

$.handleFrameEvent=function(event,parent){
var frameEvent=new com.coremedia.editing.ComponentEvent(this.getWindow(),this.getFrame(),event);
this._broadcast(frameEvent,this._eventTargets[event.type],parent);
};




$.getFrame=function(){
var frame=this.getComponent(com.coremedia.editing.ComponentController._FRAME_ID);
if(!frame){
frame=new com.coremedia.editing.Frame(this.getWindow(),com.coremedia.editing.ComponentController._FRAME_ID);
}
return frame;
};






$._getForm=function(i){
var frame=this.getFrame();
var form;
do{
form=frame.getDocument().forms[i];
if(form)
return form;
if(!frame.getParent())return null;
frame=frame.getParent().getFrame();
}while(frame);
return null;
};

$.getForm=function(){
return this._getForm(0);
};

com.coremedia.editing.ComponentController._MAP_PREFIX="__CAP_";
com.coremedia.editing.ComponentController._ATTRIBUTE_NAME="com.coremedia.editing.ComponentController";
com.coremedia.editing.ComponentController._FRAME_ID="com_coremedia_editing_Frame";

com.coremedia.editing.ComponentController.getInstance=function(currentWindow){
if(!currentWindow||!currentWindow.com||!currentWindow.com.coremedia)return null;
var controller=currentWindow[this._ATTRIBUTE_NAME];
if(!controller){
controller=new com.coremedia.editing.ComponentController(currentWindow);
}
return controller;
};

$.startStopWatch=function(){
if(!this._stopWatch){
this._stopWatch=new com.coremedia.util.StopWatch();
}
this._stopWatch.start();
};

$.stopStopWatch=function(){
if(this._stopWatch){
this._stopWatch.stop();
}
};

$._getParentController=function(){
var frame=this.getFrame();
var parentController;
if(frame){
parentController=frame._getParentController();
}
return parentController;
};

$.startParentStopWatch=function(){
var parentController=this._getParentController();
if(parentController)parentController.startStopWatch();
};

$.logStopWatch=function(msg){
if(this._stopWatch&&(this._stopWatch.elapsed()>com.coremedia.util.Logger.MIN_LOG_TIME_SPAN)){
com.coremedia.util.Logger.log(msg+": "+this._stopWatch.elapsed());
}
};

$._isFirefox=function(){
return typeof document.createRange=="function";
};

$._log=function(msg){
com.coremedia.util.Logger.log("ComponentController "+
this._window?(this._window.name?this._window.name:this._window):""+
": "+msg);
};

$._isLoggingEnabled=function(){
if(typeof(com)=="undefined")return false;
var logger=com.coremedia.util.Logger.getInstance();
return logger&&logger.isDebugEnabled();
};











com.coremedia.editing.ComponentController._mouseCapture=undefined;

})();





_jsc_package(["com","coremedia","editing"]);




(function(){







var $=com.coremedia.editing.PropertyAware=com_coremedia_editing_PropertyAware=function(props){
if(props){
for(var prop in props){
var propSetterName="set"+prop.substring(0,1).toUpperCase()+prop.substring(1);
var propSetter=this[propSetterName];
if(typeof propSetter=="function"){
propSetter.call(this,props[prop]);
}else{
throw"Unknown property "+this.toString()+"."+prop+" set to '"+props[prop]+"'.";
}
}
}
};$.constructorname='com.coremedia.editing.PropertyAware';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.PropertyAware;


})();





_jsc_package(["com","coremedia","editing"]);
























(function(){











var $=com.coremedia.editing.Component=com_coremedia_editing_Component=function(currentWindow,id,props){
this._window=currentWindow;
this._id=id;
this.register();
this.super$com$coremedia$editing$PropertyAware(props);
};$.constructorname='com.coremedia.editing.Component';$.superconstructor=com.coremedia.editing.PropertyAware;$=$.prototype=new com.coremedia.editing.PropertyAware();$.super$com$coremedia$editing$PropertyAware=com.coremedia.editing.PropertyAware;$.constructor=com.coremedia.editing.Component;









$.register=function(){
this._getController().register(this);
};




$.unregister=function(){
this._getController().unregister(this);
};












$.getWindow=function(){
return this._window?this._window:window;
};





$.getDocument=function(){
return this.getWindow().document;
};





$.getId=function(){
return this._id;
};




$._getController=function(){
return com.coremedia.editing.ComponentController.getInstance(this.getWindow());
};





$.getParent=function(){
if(!this._parent){
this._parent=this._getController()._getParent(this);
}
return this._parent;
};

$.getComponentPath=function(){
var parent=this.getParent();
var path=(parent)?parent.getComponentPath():new Array();
path[path.length]=this;
return path;
};




$.isTransitiveParent=function(component){

var currentWindow=this.getWindow();
while(component&&component.getWindow()!=currentWindow){
component=component.getFrame().getParent();
}
while(component){
if(component==this){
return true;
}
component=component.getParent();
}
return false;
};




$.getFrame=function(){
return this._getController().getFrame();
};




$.getElement=function(){
if(!this._element){
this._element=this.getWindow().document.getElementById(this.getId());
}
return this._element;
};





$.getEventSourceElement=function(){
return this.getElement();
};

$.getFormId=function(){
return this._formId;
};

$.setFormId=function(formId){
this._formId=formId;
};




$.getStyleClass=function(){
var element=this.getElement();
return com.coremedia.dom.HtmlDomUtil.getClassAttribute(element);
};





$.setStyleClass=function(newStyleClass){
var element=this.getElement();
if(element)
com.coremedia.dom.HtmlDomUtil.setClassAttribute(element,newStyleClass);
};





$.getLocation=function(){
var browser=com.coremedia.editing.Browser.instance;
var location=browser.getElementLocation(this.getElement(),this.getWindow());
return location;
};





$.getLocationInFrame=function(){
var browser=com.coremedia.editing.Browser.instance;
var location=browser.getElementLocationInFrame(this.getElement());
return location;
};




$.getSize=function(){
var element=this.getElement();
if(element.clientWidth)
return{width:element.clientWidth,height:element.clientHeight};
else
return{width:element.offsetWidth,height:element.offsetHeight};
};

$.getPadding=function(){
var style=com.coremedia.editing.Browser.instance.getComputedStyle(this.getElement());
var getPixels=function(where){
return com.coremedia.editing.Browser.instance.getStylePropertyValueInPixels(style,"padding-"+where);
};
return{getTop:function(){return getPixels("top");},
getRight:function(){return getPixels("right");},
getBottom:function(){return getPixels("bottom");},
getLeft:function(){return getPixels("left");}
};
};

$.setMouseCapture=function(){
return com.coremedia.editing.ComponentController.setMouseCapture(this);
};

$.releaseMouseCapture=function(){
return com.coremedia.editing.ComponentController.releaseMouseCapture(this);
};

$.hasMouseCapture=function(){
return com.coremedia.editing.ComponentController.getMouseCapture()==this;
};

$.findEnclosingForm=function(){
var form=com.coremedia.dom.DomUtil.findEnclosingElement(this.getElement(),"FORM");
return form;
};

$.getForm=function(){
if(this._formId){
return this.getFrame().getDocument().forms[this._formId];
}
var form=this.findEnclosingForm();
if(form){
this._formId=form.id;
}
return form;
};






$._createInputField=function(name,value){
var input;
if(this.isIE()){
input=this.getWindow().document.createElement("<input type='hidden' name='"+name+"' ></input>");
}else{
input=this.getWindow().document.createElement("input");
input.setAttribute("type","hidden");
input.setAttribute("name",name);
}
input.setAttribute("value",value);

this.getForm().appendChild(input);
};


$.setValueForProperty=function(property,value){
var field=this.getForm()[property];
if(field)
field.value=value;
else
this._createInputField(property,value);
};




$.isActivated=function(){
return this._getController().isActivated(this);
};











$.requestActivation=function(trigger){
return this._getController().requestActivation(this,trigger);
};






























$.processUnload=function(event){
delete this._element;
};

$.submit=function(){
var form=this.getForm();
if(form.onsubmit){
form.onsubmit({type:"submit"});
}
var controller=this._getController();
if(controller)
controller.startParentStopWatch();
form.submit();
};

$.log=function(msg){
com.coremedia.util.Logger.log(msg);
};

$.logDuration=function(msg,stopWatch){
stopWatch.stop();
if(stopWatch.elapsed()>com.coremedia.util.Logger.MIN_LOG_TIME_SPAN)
this.log(msg+": "+stopWatch.elapsed());
};

$.fireResized=function(){
this._getController().handleFrameEvent({type:"resize"},this);
};

$.toString=function(){
var windowName=this.getWindow().name;
if(!windowName)
windowName="<window>";
return windowName+"."+this.getId();
};

$.isComponentSelectionEvent=function(event){
return false;
};




$.isIE=function(){
return com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.IE;
};




$.isNetscape=function(){
return com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.NETSCAPE;
};



})();
_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.Command=com_coremedia_editing_Command=function(props){
this.super$com$coremedia$editing$PropertyAware(props);
};$.constructorname='com.coremedia.editing.Command';$.superconstructor=com.coremedia.editing.PropertyAware;$=$.prototype=new com.coremedia.editing.PropertyAware();$.super$com$coremedia$editing$PropertyAware=com.coremedia.editing.PropertyAware;$.constructor=com.coremedia.editing.Command;

$.setName=function(name){
this._name=name;
};

$.getName=function(){
return this._name;
};









})();
_jsc_package(["com","coremedia","editing"]);





(function(){








var $=com.coremedia.editing.ComponentCommand=com_coremedia_editing_ComponentCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$Command(props);
this._targetWindow=targetWindow?targetWindow:window;
this._targetComponentId=targetComponentId;
};$.constructorname='com.coremedia.editing.ComponentCommand';$.superconstructor=com.coremedia.editing.Command;$=$.prototype=new com.coremedia.editing.Command();$.super$com$coremedia$editing$Command=com.coremedia.editing.Command;$.constructor=com.coremedia.editing.ComponentCommand;







$.getTargetElement=function(){
return this._targetWindow.document.getElementById(this._targetComponentId);
};







$.getTargetComponent=function(){
return com.coremedia.editing.Frame.getInstance(this._targetWindow).getComponentById(this._targetComponentId);
};





})();
_jsc_package(["com","coremedia","editing"]);

(function(){

var $=com.coremedia.editing.ToggleVisibilityCommand=com_coremedia_editing_ToggleVisibilityCommand=function(targetWindow,targetComponentId){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,{name:"toggleVisibility"});
};$.constructorname='com.coremedia.editing.ToggleVisibilityCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.ToggleVisibilityCommand;

$.execute=function(){
var target=this.getTargetElement();
target.style.display=target.style.display=="none"?"":"none";
};

})();
_jsc_package(["com","coremedia","editing"]);





(function(){






var $=com.coremedia.editing.ServerSideCommand=com_coremedia_editing_ServerSideCommand=function(targetComponent,props){
this.super$com$coremedia$editing$Command(props);
this._targetComponent=targetComponent;
};$.constructorname='com.coremedia.editing.ServerSideCommand';$.superconstructor=com.coremedia.editing.Command;$=$.prototype=new com.coremedia.editing.Command();$.super$com$coremedia$editing$Command=com.coremedia.editing.Command;$.constructor=com.coremedia.editing.ServerSideCommand;

$.execute=function(){
var target=this._targetComponent;
var form=target.getForm();
var fieldName=form.id+":_idcl";
var field=form[fieldName];
if(!field){

field=document.createElement("input");
field.setAttribute("type","hidden");
field.setAttribute("name",fieldName);
form.appendChild(field);
}
field.value=target.getId();
target.submit();
};



})();
_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.ErrorAlert=com_coremedia_editing_ErrorAlert=function(currentWindow,id,messages){
this.super$com$coremedia$editing$Component(currentWindow,id);
this._messages=messages;
};$.constructorname='com.coremedia.editing.ErrorAlert';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.ErrorAlert;

$.processLoad=function(event){
if(this._messages){
for(var i=0;i<this._messages.length;i++){
if(i<this._messages.length-1){
if(!window.confirm(this._messages[i]))return;
}else{
window.alert(this._messages[i]);
}
}
}
};



})();




_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.Transferable=com_coremedia_editing_Transferable=function(){
this._data={map:new Object(),flavors:new Array()};
};$.constructorname='com.coremedia.editing.Transferable';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.Transferable;



$.addDataFlavor=function(flavor,data){
this._data.flavors.push(flavor);
this._data.map[flavor]=data;
};

$.getDataFlavors=function(){
return this._data.flavors;
};

$.getTransferableData=function(flavor){
var data=this._data.map[flavor];
if(typeof(data)=="undefined")return null;
return data;
};

$.clear=function(){
this._data.map=new Object();
this._data.flavors=new Array();
};


})();




_jsc_package(["com","coremedia","editing"]);






(function(){

var $=com.coremedia.editing.Clipboard=com_coremedia_editing_Clipboard=function(){
this._transferable=new com.coremedia.editing.Transferable();
};$.constructorname='com.coremedia.editing.Clipboard';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.Clipboard;

com.coremedia.editing.Clipboard._TRANSFER_DATA_ID="__CAP_TRANSFER_DATA";
com.coremedia.editing.Clipboard._systemClipboard=undefined;



com.coremedia.editing.Clipboard.getSystemClipboard=function(){
return com.coremedia.editing.Clipboard._systemClipboard;
};

$._setTransferData=function(data){
this._transferable._data=data;
};

$.getContents=function(){


if(window.clipboardData&&window.clipboardData.getData){
var localText=null;
try{
localText=this._transferable.getTransferableData("text/unicode");
}catch(e){


com.coremedia.util.Logger.log("com.coremedia.editing.Clipboard.getContents(): "+
"exception while accessing clipboard object, clearing clipboard: "+e);
this._transferable.clear();
}
var text=window.clipboardData.getData("Text");
var url=window.clipboardData.getData("URL");
if(text){
if(!localText||localText!=text){
this._transferable.clear();
this._transferable.addDataFlavor("text/unicode",text);
}
}
if(url){
var localUrl=this._transferable.getTransferableData("text/uri-list");
if(!localUrl){
this._transferable.addDataFlavor("text/uri-list",[url]);
}
}
}
return this._transferable;
};

$.setContents=function(transferable){
if(window.clipboardData)
window.clipboardData.clearData();
var map=new Object();
var flavors=transferable.getDataFlavors();
var textFlavorSeen=false;
this._transferable._data.map=map;
this._transferable._data.flavors=flavors;
for(var i=0;i<flavors.length;i++){
var flavor=flavors[i];
var data=map[flavor]=transferable.getTransferableData(flavor);
com.coremedia.util.Logger.log(com.coremedia.util.Logger.LEVEL_DEBUG,"Clipboard flavor: "+flavor+", "+data);
if(flavor=="text/unicode"){
this._tryToSetIeClipboard("Text",data);
textFlavorSeen=true;
}
if(flavor=="text/uri-list"&&data.length==1){
if(!textFlavorSeen)
this._tryToSetIeClipboard("Text",data[0]);
this._tryToSetIeClipboard("URL",data[0]);
}
map[flavor]=data;
}
};

$._tryToSetIeClipboard=function(sDataFormat,value){
if(window.clipboardData&&window.clipboardData.setData){
window.clipboardData.setData(sDataFormat,value);
com.coremedia.util.Logger.log(com.coremedia.util.Logger.LEVEL_DEBUG,"set system clipboard: "+sDataFormat+", "+value);
}
};

(function(){
com.coremedia.editing.Clipboard._systemClipboard=new com.coremedia.editing.Clipboard();
var data=top[com.coremedia.editing.Clipboard._TRANSFER_DATA_ID];


if(!data){
data={flavors:[],map:{}};
}
var win=top;
win[com.coremedia.editing.Clipboard._TRANSFER_DATA_ID]=data;












com.coremedia.editing.Clipboard._systemClipboard._setTransferData(data);
})();


})();
_jsc_package(["com","coremedia","editing"]);






(function(){










var $=com.coremedia.editing.ActivationEvent=com_coremedia_editing_ActivationEvent=function(currentWindow,triggerEvent,oldActivation,newActivation){
this.super$com$coremedia$editing$ComponentEvent(currentWindow,
(newActivation&&newActivation.length>0)?newActivation[newActivation.length-1]:null,
(triggerEvent)?triggerEvent.getOriginal():null,
"activation");
this._oldActivation=oldActivation;
this._newActivation=newActivation;
this._triggerEvent=triggerEvent;
};$.constructorname='com.coremedia.editing.ActivationEvent';$.superconstructor=com.coremedia.editing.ComponentEvent;$=$.prototype=new com.coremedia.editing.ComponentEvent();$.super$com$coremedia$editing$ComponentEvent=com.coremedia.editing.ComponentEvent;$.constructor=com.coremedia.editing.ActivationEvent;




$.getTriggerEvent=function(){
return this._triggerEvent;
};




$.getOldActivation=function(){
return this._oldActivation;
};




$.getNewActivation=function(){
return this._newActivation;
};








})();
_jsc_package(["com","coremedia","editing"]);





(function(){var $=com.coremedia.editing.Frame=com_coremedia_editing_Frame=




function(currentWindow,id){
this.super$com$coremedia$editing$Component(currentWindow,id);
};$.constructorname='com.coremedia.editing.Frame';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.Frame;

$.processLoad=function(event){


this.getElement().setAttribute(com.coremedia.editing.Frame.FRAME_ID_ATTRIBUTE,this.getId());
};




$.getActivatedComponent=function(){
var activatedComponent=this._getController().getActivatedComponent();
if(!activatedComponent&&this.getParent().getFrame())
return this.getParent().getFrame().getActivatedComponent();
else return activatedComponent;
};

$.getComponentById=function(id){
return this._getController().getComponent(id);
};$.super$com$coremedia$editing$Component$getElement=$.getElement;

$.getElement=function(){
return this.getWindow().document.body;
};

$.getElementLocation=function(element){
return com.coremedia.editing.Browser.instance.getElementLocation(element,this.getWindow());
};

$.getScrollOffset=function(){
var currentWindow=this.getWindow();
var browser=com.coremedia.editing.Browser.instance;
return{left:browser.getScrollX(currentWindow),top:browser.getScrollY(currentWindow)};
};$.super$com$coremedia$editing$Component$getSize=$.getSize;




$.getSize=function(){
var currentWindow=this.getWindow();
var browser=com.coremedia.editing.Browser.instance;
return{width:browser.getWindowWidth(currentWindow),height:browser.getWindowHeight(currentWindow)};
};

$.getContentSize=function(){
var rootElement=this.getDocument().body;
return com.coremedia.editing.Browser.instance.getContentSize(rootElement);
};

$.getFrameElement=function(){
return this.getWindow().frameElement;
};





$.getFrameLocation=function(){
var browser=com.coremedia.editing.Browser.instance;
var location=browser.getElementLocation(this.getFrameElement(),this.getWindow().parent);
return location;
};

$.sizeToFit=function(maxWidth){
var iframe=this.getFrameElement();
if(!iframe){
throw"Frame.sizeToFit() only supported for iframes!";
}

var iframeStyle=iframe.style;
var oldLocation={left:iframeStyle.left,top:iframeStyle.top};
iframeStyle.visibility="hidden";
iframeStyle.left="0px";
iframeStyle.top="0px";
iframeStyle.width=maxWidth+"px";
iframeStyle.display="";
var size=this.getContentSize();
iframeStyle.display="none";
iframeStyle.visibility="";
iframeStyle.left=oldLocation.left;
iframeStyle.top=oldLocation.top;
iframeStyle.width=size.width+"px";
iframeStyle.height=size.height+"px";
return size;
};




$._getParentController=function(){
var currentWindow=this.getWindow();
if(currentWindow==currentWindow.parent)

return null;
return com.coremedia.editing.ComponentController.getInstance(currentWindow.parent);
};$.super$com$coremedia$editing$Component$getParent=$.getParent;





$.getParent=function(){
if(!this._parent){
var controller=this._getParentController();
this._parent=controller?controller.findComponent(this.getFrameElement()):null;
}
return this._parent;
};





$.getParentFrame=function(){
var controller=this._getParentController();
return controller?controller.getFrame():null;
};

$.minimize=function(){
this._hideFrame(this.getFrameElement());
};

$._getFrameSet=function(frame){
if(frame){
var frameSet=frame.parentNode;
if(frameSet&&frameSet.nodeName=="FRAMESET"){
return frameSet;
}
}
return null;
};

$._getFirstFrame=function(frameSet){
return com.coremedia.dom.DomUtil.findNextSibling(frameSet.firstChild,"FRAME|FRAMESET");
};

$._hideFrame=function(frame){
var frameSet=this._getFrameSet(frame);
if(!frameSet)
return;
var colsOrRows=frameSet.cols?"cols":"rows";
var colsOrRowsValue=frameSet[colsOrRows];
if(colsOrRowsValue=="0,*"||colsOrRowsValue=="*,0"){

if(this._getFrameSet(frameSet)){
this._hideFrame(frameSet);
return;
}
}
colsOrRowsValue=this._getFirstFrame(frameSet)==frame?"0,*":"*,0";
frameSet[colsOrRows]=colsOrRowsValue;
};

$.processResize=function(event){
if(!window.document.width){

var frame=this.getFrameElement();
if(frame&&frame.resize!="no"){
var frameSet=this._getFrameSet(frame);
if(frameSet&&frameSet.rows&&frameSet.rows!="*,0"&&frameSet.rows!="0,*"&&this._getFirstFrame(frameSet)==frame){
var height=this.getElement().clientHeight+2;
frameSet.rows=height+",*";

}
}
}
};




$.getFrames=function(){
var frames=this.getWindow().frames;
var frameComponents=new Array();
for(var i=0;i<frames.length;++i){
var frameComponent=com.coremedia.editing.Frame.getInstance(frames[i]);
frameComponents.push(frameComponent);
}
return frameComponents;
};




$.getUrl=function(){
return this.getWindow().location.href;
};

$.setUrl=function(url){
if(this.getUrl()!=url){
this.getWindow().location=url;
}
};


$.replaceFramesUrlParameter=function(paramName,paramValue){
var frameComponents=this.getFrames();
for(var i=0;i<frameComponents.length;++i){
var frameComponent=frameComponents[i];
var url=com.coremedia.editing.Frame._replaceUrlParameter(frameComponent.getUrl(),paramName,paramValue);
if(url){
frameComponent.setUrl(url);
}
}
};


com.coremedia.editing.Frame._replaceUrlParameter=function(url,paramName,paramValue){
paramName+="=";
var paramIndex=url.indexOf(paramName);
if(paramIndex>0){
var newUrl=url.substring(0,paramIndex)+paramName+paramValue;
var paramEndIndex=url.indexOf("&",paramIndex);
if(paramEndIndex>0){
newUrl+=url.substring(paramEndIndex);
}
return newUrl;
}
return null;
};

$.setUrlParameter=function(paramName,paramValue){
var url=this.getUrl();
var newUrl=com.coremedia.editing.Frame._replaceUrlParameter(url,paramName,paramValue);
if(!newUrl){
newUrl=url+(url.indexOf('?')>=0?'&':'?')+paramName+'='+paramValue;
}
this.setUrl(newUrl);
};

com.coremedia.editing.Frame.getInstance=function(window){
return com.coremedia.editing.ComponentController.getInstance(window).getFrame();
};

com.coremedia.editing.Frame.FRAME_ID_ATTRIBUTE="com_coremedia_editing_Frame";

})();
_jsc_package(["com","coremedia","editing"]);














(function(){var $=com.coremedia.editing.InternalFrame=com_coremedia_editing_InternalFrame=






function(currentWindow,id){
this.super$com$coremedia$editing$Component(currentWindow,id);
};$.constructorname='com.coremedia.editing.InternalFrame';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.InternalFrame;

$.getLocation=function(){
return this._location;
};

$.setLocation=function(location){
this._location=location;
};

$.setShowOnLoad=function(showOnLoad){
this._showOnLoad=showOnLoad;
};





$.processLoad=function(event){
if(this._showOnLoad&&(!this._element||this._element.style.display=="none")){
this.reload();
}
};





$._setVisible=function(visible){
var iframeStyle=this.getElement().style;
iframeStyle.visibility=visible?"":"hidden";
iframeStyle.display=visible?"":"none";
if(this._visibilityListener){
this._visibilityListener.visibilityChanged(visible);
}
};

$.setVisibilityListener=function(listener){
this._visibilityListener=listener;
};$.super$com$coremedia$editing$Component$getElement=$.getElement;






$.getElement=function(){
var iframeObj=this.super$com$coremedia$editing$Component$getElement();
if(!iframeObj){
iframeObj=window.document.createElement("iframe");
iframeObj.id=this.getId();
iframeObj.setAttribute("scrolling","no");
iframeObj.setAttribute("frameborder","0");
iframeObj.setAttribute("frameBorder","0");
iframeObj.setAttribute("topmargin","0");
iframeObj.setAttribute("leftmargin","0");
iframeObj.setAttribute("width","700");
iframeObj.setAttribute("border","0");
iframeObj.setAttribute("unselectable","on");
iframeObj.style.position="absolute";
com.coremedia.dom.HtmlDomUtil.setClassAttribute(iframeObj,"internalframe");
this._element=iframeObj;
this._setVisible(false);
this.reload();
window.document.body.appendChild(this._element,window.document.body);
}
return iframeObj;
};





$._disposeIframe=function(){
if(this._element){
this._element.parentNode.removeChild(this._element);
this._element=null;
}
};






$.reload=function(){
this.getElement().src=this.getUri();
};







$.show=function(event){

if(!this.getUri())return false;

var referenceComponent=this.getParent();
var allowTransparency=false;
if(referenceComponent){
if(referenceComponent.getPosition()=="mouse"){
this._location=event.getMousePosition();
}
if(typeof referenceComponent.isTransparencyAllowed=="function"){
allowTransparency=referenceComponent.isTransparencyAllowed();
}
}
this.getElement().allowTransparency=allowTransparency?"true":"";


this.reload();

this.setMouseCapture();
return true;
};




$.hide=function(){
if(this._element){
this.releaseMouseCapture();
this._setVisible(false);
this.setDialogMode(false);
}
};




$.dispose=function(){
this.hide();
this.unregister();
this._disposeIframe();
};






$.processContentLoad=function(){
var iframeWindow=this.getElement().contentWindow;
iframeWindow.name=this.getId();
var popupFrame=com.coremedia.editing.Frame.getInstance(iframeWindow);
var size=popupFrame.sizeToFit(700);
this._setIframeLocation(size);
this.setMouseCapture();
this._setVisible(true);
};

$.processClick=function(event){



if(this._dialogMode||event.getWindow()!=this.getWindow()){
event.stopPropagation();
}
return false;
};

$.processContextmenu=function(event){
return this.processClick(event);
};







$._setIframeLocation=function(size){
var iframe=this.getElement();
iframe.style.zIndex=this._calculateZIndex();

var rootFrame=com.coremedia.editing.Frame.getInstance(window);
var scrollOffset=rootFrame.getScrollOffset();
var windowSize=rootFrame.getSize();
var location;

var parent=this.getParent();
if(parent){
var position=parent.getPosition();
var offsetWidth;
var offsetHeight;
if(position=="mouse"){
location=this._location;
offsetWidth=0;
offsetHeight=0;
}else{
var referenceElement=typeof parent.getReferenceElement=="function"
?parent.getReferenceElement():parent.getElement();
location=parent.getFrame().getElementLocation(referenceElement);
offsetWidth=referenceElement.offsetWidth;
offsetHeight=referenceElement.offsetHeight;
if(position=="vertical"){
location.top+=offsetHeight;
offsetHeight=-offsetHeight;
}else{
location.left+=offsetWidth;
offsetWidth=-offsetWidth;
}
}


if(location.left+size.width-scrollOffset.left+15>=windowSize.width){
location.left+=offsetWidth-size.width;
if(location.left<scrollOffset.left){
location.left=scrollOffset.left;
}
}
if(location.top+size.height-scrollOffset.top+15>=windowSize.height){
location.top+=offsetHeight-size.height;
if(location.top<scrollOffset.top){
location.top=scrollOffset.top;
}
}
}else if(this._location){
location=this._location;
}else{

location={left:scrollOffset.left+(windowSize.width-size.width)*0.5,
top:scrollOffset.top+(windowSize.height-size.height)*0.5};
}


iframe.style.top=location.top+"px";
iframe.style.left=location.left+"px";
};$.super$com$coremedia$editing$Component$getParent=$.getParent;

$.getParent=function(){
return this._parent;
};






$.setParent=function(parent){
this._parent=parent;

};




$._calculateZIndex=function(){
var zIndex=80;
for(var popup=this;popup&&typeof popup._calculateZIndex=="function";
popup=popup.getFrame().getParent())
++zIndex;
return zIndex;
};

$.getUri=function(){
return this._uri;
};

$.setUri=function(uri){
this._uri=uri;

};

$.setDialogMode=function(dialogMode){
this._dialogMode=dialogMode;
};







com.coremedia.editing.InternalFrame.getInstance=function(currentWindow){
var internalFrame=com.coremedia.editing.Frame.getInstance(currentWindow).getComponentById(this._INTERNAL_FRAME_ID);
if(internalFrame==null){
internalFrame=new com.coremedia.editing.InternalFrame(currentWindow,this._INTERNAL_FRAME_ID);
}
return internalFrame;
};

com.coremedia.editing.InternalFrame._INTERNAL_FRAME_ID="com_coremedia_editing_InternalFrame";


})();
_jsc_package(["com","coremedia","editing"]);




(function(){






var $=com.coremedia.editing.InternalFrameTitleBar=com_coremedia_editing_InternalFrameTitleBar=function(currentWindow,id){
this.super$com$coremedia$editing$Component(currentWindow,id);
this._isNetscape=(com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.NETSCAPE);
};$.constructorname='com.coremedia.editing.InternalFrameTitleBar';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.InternalFrameTitleBar;

$.processLoad=function(event){

var element=this.getElement();
this.constructor.makeUnselectable(element);
};

com.coremedia.editing.InternalFrameTitleBar.makeUnselectable=function(element){

if(typeof element.setAttribute=="function"){
element.setAttribute("UNSELECTABLE","on");
}
var childNodes=element.childNodes;
if(childNodes){
for(var i=0;i<childNodes.length;++i){
this.makeUnselectable(childNodes[i]);
}
}
};




$.processDrag=function(event){
var iframe=this.getFrame().getFrameElement();
if(iframe){
var deltaY=this._startY-event.getScreenY();
var deltaX=this._startX-event.getScreenX();
iframe.style.left=(this._startLocation.left-deltaX)+"px";
iframe.style.top=(this._startLocation.top-deltaY)+"px";
}
return false;
};


$.processMouseup=function(event){
if(this._isNetscape)this.releaseMouseCapture();
return this.processDragend(event);
};

$.processDragend=function(event){

};

$.processMousemove=function(event){
if(this._isNetscape)
if(this.hasMouseCapture())return this.processDrag(event);
return false;
};





$.processMousedown=function(event){

if(this._isNetscape)this.setMouseCapture();
this._startY=event.getScreenY();
this._startX=event.getScreenX();
this._startLocation=this.getFrame().getFrameLocation();
this.getFrame().getFrameElement().style.position="absolute";
return false;
};







})();
_jsc_package(["com","coremedia","editing"]);















(function(){var $=com.coremedia.editing.PopupWindow=com_coremedia_editing_PopupWindow=








function(uri){
this.super$com$coremedia$editing$Component(window,com.coremedia.editing.PopupWindow._createId());
this._uri=uri;
};$.constructorname='com.coremedia.editing.PopupWindow';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.PopupWindow;

com.coremedia.editing.PopupWindow._idCounter=0;
com.coremedia.editing.PopupWindow._popupWindowsByUri=new Object();
com.coremedia.editing.PopupWindow._popupWindowsByParent=new Object();

com.coremedia.editing.PopupWindow._createId=function(){
return"__com_coremedia_editing_PopupWindow_"+(this._idCounter++);
};








com.coremedia.editing.PopupWindow.getPopupWindowFor=function(popupContainer){
var popupWindow=this._popupWindowsByParent[popupContainer.toString()];
if(!popupWindow){
var uri=popupContainer.getUri();
popupWindow=this._getPopupWindowFor(uri);

}
popupWindow.setParent(popupContainer);
return popupWindow;
};








com.coremedia.editing.PopupWindow._getPopupWindowFor=function(uri){
var popupWindow=this._popupWindowsByUri[uri];
if(popupWindow==null)
popupWindow=this._createPopupWindow(uri);
else if(popupWindow.getParent()){
throw"IllegalState: PopupWindow for uri "+uri+" already used by "+popupWindow.getParent().toString()+".";
}
return popupWindow;
};







com.coremedia.editing.PopupWindow._createPopupWindow=function(uri){
var popupWindow=new com.coremedia.editing.PopupWindow(uri);
this._popupWindowsByUri[uri]=popupWindow;
return popupWindow;
};





com.coremedia.editing.PopupWindow.releasePopupWindowFor=function(popupContainer){
var popupWindow=this._popupWindowsByParent[popupContainer.toString()];
if(popupWindow){
popupWindow.release();
}
};









$._setVisible=function(visible){
var iframeStyle=this.getElement().style;
iframeStyle.visibility=visible?"":"hidden";
iframeStyle.display=visible?"":"none";
if(this._visibilityListener){
this._visibilityListener.visibilityChanged(visible);
}
};

$.setVisibilityListener=function(listener){
this._visibilityListener=listener;
};$.super$com$coremedia$editing$Component$getWindow=$.getWindow;

$.getWindow=function(){
var parent=this.getParent();
return parent?parent.getWindow():this.super$com$coremedia$editing$Component$getWindow();
};$.super$com$coremedia$editing$Component$getElement=$.getElement;






$.getElement=function(){
if(!this._element){

var iframeObj=window.document.createElement("iframe");
iframeObj.id=this.getId();
iframeObj.setAttribute("scrolling","no");
iframeObj.setAttribute("frameborder","0");
iframeObj.setAttribute("frameBorder","0");
iframeObj.setAttribute("topmargin","0");
iframeObj.setAttribute("leftmargin","0");
iframeObj.setAttribute("width","700");
iframeObj.setAttribute("border","0");
iframeObj.setAttribute("unselectable","on");
iframeObj.style.position="absolute";
com.coremedia.dom.HtmlDomUtil.setClassAttribute(iframeObj,"popupwindow");
this._element=iframeObj;
this._setVisible(false);
this.reload();
window.document.body.appendChild(this._element,window.document.body);
}
return this._element;
};





$._disposeIframe=function(){
if(this._element){

this._element.parentNode.removeChild(this._element);
this._element=null;
}
};






$.reload=function(){
this._contentLoaded=false;
this.getElement().src=this.getUri();
};







$.show=function(event){
var stopWatch=new com.coremedia.util.StopWatch();
var controller=this._getController();
if(controller)
controller.startParentStopWatch();

if(!this.getUri())return false;

var referenceComponent=this.getParent();
if(referenceComponent.getPosition()=="mouse"){
this._location=event.getMousePosition();
this._reposition=true;
}
var allowTransparency=
typeof referenceComponent.isTransparencyAllowed!="function"||referenceComponent.isTransparencyAllowed();
this.getElement().allowTransparency=allowTransparency?"true":"";
if(this._contentLoaded){
if(this._reposition){

this._setIframeLocation();
}
this._setVisible(true);
}else{


this._showOnLoad=true;
this.reload();

}
this.logDuration("PopupWindow.show",stopWatch);
return true;
};




$.hide=function(){
if(this._element){
this._showOnLoad=false;
this._setVisible(false);
this.releaseMouseCapture();
}
};












$.release=function(){
this.hide();
if(this._parent){

delete com.coremedia.editing.PopupWindow._popupWindowsByParent[this._parent.toString()];
this._parent=null;
}
};




$.dispose=function(){
this.release();
this.unregister();
this._disposeIframe();
};






$.processContentLoad=function(){
if(this._contentLoaded==false){
var iframe=this.getElement();
iframe.contentWindow.name=this.getId();

var iframeStyle=iframe.style;
iframeStyle.width="700px";
iframeStyle.visibility="hidden";
iframeStyle.display="";
var popupFrame=com.coremedia.editing.Frame.getInstance(iframe.contentWindow);
this._size=popupFrame.getContentSize();
iframeStyle.display="none";
iframeStyle.visibility="";

iframe.style.top="0px";
iframe.style.left="0px";

iframe.style.width=this._size.width+"px";
iframe.style.height=this._size.height+"px";

this._setIframeLocation();
this._contentLoaded=true;
}

if(this._showOnLoad){
this._setVisible(true);
}
};








$._setIframeLocation=function(){
var iframe=this.getElement();
iframe.style.zIndex=this._calculateZIndex();

var parent=this.getParent();
var position=parent.getPosition();
var size=this._size;
var location;
var offsetWidth;
var offsetHeight;
if(position=="mouse"){
location=this._location;
offsetWidth=0;
offsetHeight=0;
}else{
var referenceElement=typeof parent.getReferenceElement=="function"
?parent.getReferenceElement():parent.getElement();
var location=parent.getFrame().getElementLocation(referenceElement);
offsetWidth=referenceElement.offsetWidth;
offsetHeight=referenceElement.offsetHeight;
if(position=="vertical"){
location.top+=offsetHeight;
offsetHeight=-offsetHeight;
}else{
location.left+=offsetWidth;
offsetWidth=-offsetWidth;
}
}


var rootFrame=com.coremedia.editing.Frame.getInstance(window);
var scrollOffset=rootFrame.getScrollOffset();
var windowSize=rootFrame.getSize();
if(location.left+size.width-scrollOffset.left+15>=windowSize.width){
location.left+=offsetWidth-size.width;
if(location.left<scrollOffset.left){
location.left=scrollOffset.left;
}
}
if(location.top+size.height-scrollOffset.top+15>=windowSize.height){
location.top+=offsetHeight-size.height;
if(location.top<scrollOffset.top){
location.top=scrollOffset.top;
}
}


iframe.style.top=location.top+"px";
iframe.style.left=location.left+"px";
this._reposition=false;
};$.super$com$coremedia$editing$Component$getParent=$.getParent;

$.getParent=function(){
return this._parent;
};






$.setParent=function(parent){
this._reposition=true;
this._parent=parent;
com.coremedia.editing.PopupWindow._popupWindowsByParent[parent.toString()]=this;

};




$._calculateZIndex=function(){
var zIndex=80;
for(var popup=this;popup&&typeof popup._calculateZIndex=="function";
popup=popup.getFrame().getParent())
++zIndex;
return zIndex;
};

$.getUri=function(){
return this._uri;
};









})();
_jsc_package(["com","coremedia","editing"]);






(function(){







var $=com.coremedia.editing.AbstractButton=com_coremedia_editing_AbstractButton=function(currentWindow,id,props){
this.super$com$coremedia$editing$Component(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.AbstractButton';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.AbstractButton;

$.processLoad=function(event){
var elem=this.getElement();
if(elem){
while(elem.firstChild&&elem.firstChild.nodeType!=Node.TEXT_NODE){
elem=elem.firstChild;
}
elem.unselectable="on";
}
return true;
};




$.getCommand=function(){
if(!this._command){
this._command=new com.coremedia.editing.ServerSideCommand(this,{name:"ActionEvent"});
}
return this._command;
};

$.setCommand=function(command){
this._command=command;
if(typeof command.setButton=="function")
command.setButton(this);
};




$.isPressed=function(){
return this._pressed;
};

$.setPressed=function(pressed){
this._pressed=pressed;
this._updateStyleClass();
};




$.isDisabled=function(){
return this._disabled;
};

$.setDisabled=function(disabled){
this._disabled=disabled;
};





$._updateStyleClass=function(){
if(typeof this._originalStyleClass=="undefined"){
this._originalStyleClass=this.getStyleClass();
}
var styleClass=this._originalStyleClass?this._originalStyleClass:"";
var additionalClass=this._disabled?"disabled"
:this._pressed||this._pressing?"pressed":this._hover?"hover":null;
if(additionalClass){
styleClass=styleClass+" "+styleClass+additionalClass+" "+additionalClass;
}
this.setStyleClass(styleClass);
};




$.processMouseover=function(event){
if(!this._disabled&&this.isTransitiveParent(event.getTargetComponent())){
this._setHover(true);
}
return false;
};




$.processMouseout=function(event){
if(!this._disabled&&this.isTransitiveParent(event.getTargetComponent())){
this._setHover(false);
}
return false;
};

$._setHover=function(h){
this._hover=h;
this._updateStyleClass();
};




$.activate=function(){
this._pressing=true;
this._updateStyleClass();
};





$.press=function(){
this._pressing=false;
this._pressed=true;
this._updateStyleClass();
};





$.deactivate=function(){
this._pressing=false;
this._pressed=false;
this._hover=false;
this._updateStyleClass();
};








})();
_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.Button=com_coremedia_editing_Button=function(currentWindow,id,props){
this.super$com$coremedia$editing$AbstractButton(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.Button';$.superconstructor=com.coremedia.editing.AbstractButton;$=$.prototype=new com.coremedia.editing.AbstractButton();$.super$com$coremedia$editing$AbstractButton=com.coremedia.editing.AbstractButton;$.constructor=com.coremedia.editing.Button;

$.setEventSourceElementId=function(eventSourceElementId){
this._eventSourceElementId=eventSourceElementId;
};$.super$com$coremedia$editing$AbstractButton$getEventSourceElement=$.getEventSourceElement;

$.getEventSourceElement=function(){
if(!this._eventSourceElement){
var element=this.getElement();
if(this._eventSourceElementId){
element=this.getDocument().getElementById(this._eventSourceElementId);
if(!element)
throw"No such ID: "+this._eventSourceElementId;
}
this._eventSourceElement=element;
}
return this._eventSourceElement;
};




$.getBeforeSubmit=function(){
return this._beforeSubmit;
};

$.setBeforeSubmit=function(beforeSubmit){
this._beforeSubmit=beforeSubmit;
};$.super$com$coremedia$editing$AbstractButton$submit=$.submit;

$.submit=function(){
if(this._beforeSubmit&&typeof this._beforeSubmit=="function")
this._beforeSubmit();
this.super$com$coremedia$editing$AbstractButton$submit();
};

$.processKeydown=function(event){
switch(event.getKeyCode()){
case com.coremedia.editing.ComponentEvent.VK_ENTER:
case com.coremedia.editing.ComponentEvent.VK_SPACE:
this.processMousedown(event);
}
};

$.processKeyup=function(event){
var buttonContainer=this.getButtonContainer();
if(buttonContainer){
switch(event.getKeyCode()){
case com.coremedia.editing.ComponentEvent.VK_ENTER:
case com.coremedia.editing.ComponentEvent.VK_SPACE:
buttonContainer.processMouseup(event);
}
}
};

$.getButtonContainer=function(){
var buttonContainer=this.getParent();
return typeof buttonContainer.setActiveButton=="function"?buttonContainer:null;
};







$.processMousedown=function(event){

if(this.isDisabled()){
return false;
}else{
var buttonContainer=this.getButtonContainer();
if(buttonContainer){

buttonContainer.setActiveButton(this);
}
return true;
}
};

$.processClick=function(event){
if(!this.isDisabled()&&!this.getButtonContainer()){

this.getCommand().execute();
return true;
}
return false;
};





})();
_jsc_package(["com","coremedia","editing"]);













(function(){







var $=com.coremedia.editing.PopupButton=com_coremedia_editing_PopupButton=function(currentWindow,id,props){
this.super$com$coremedia$editing$AbstractButton(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.PopupButton';$.superconstructor=com.coremedia.editing.AbstractButton;$=$.prototype=new com.coremedia.editing.AbstractButton();$.super$com$coremedia$editing$AbstractButton=com.coremedia.editing.AbstractButton;$.constructor=com.coremedia.editing.PopupButton;




$.getUri=function(){
return this._uri;
};

$.setUri=function(uri){
this._uri=uri;
};




$.getPosition=function(){
return this.getParent().getPosition();
};$.super$com$coremedia$editing$AbstractButton$activate=$.activate;




$.activate=function(){
this.log("popupbutton.activate");
this.super$com$coremedia$editing$AbstractButton$activate();
com.coremedia.editing.PopupWindow.getPopupWindowFor(this).show();
};$.super$com$coremedia$editing$AbstractButton$deactivate=$.deactivate;




$.deactivate=function(){
com.coremedia.editing.PopupWindow.releasePopupWindowFor(this);
this.super$com$coremedia$editing$AbstractButton$deactivate();
};





$.processMousedown=function(event){
if(event.getTargetComponent()==this&&(this.getParent().isPopupMenu()||!this._pressed)){
var container=this.getParent();
container.setActiveButton(this);
this.press();
return true;
}else{
return false;
}
};

$.processMouseup=function(event){
return event.getTargetComponent()==this&&this._pressed;
};

$.performCommand=function(event,command){
var collectedCommand=this.getCommand();
collectedCommand+=((collectedCommand&&command)?"/":"")+command;

this.getParent().performCommand(event,collectedCommand);
};

$.setActiveButton=function(button){

this.getParent().setActiveButton(button);
};



})();
_jsc_package(["com","coremedia","editing"]);






(function(){

var $=com.coremedia.editing.Tab=com_coremedia_editing_Tab=function(currentWindow,id,props){
this.super$com$coremedia$editing$AbstractButton(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.Tab';$.superconstructor=com.coremedia.editing.AbstractButton;$=$.prototype=new com.coremedia.editing.AbstractButton();$.super$com$coremedia$editing$AbstractButton=com.coremedia.editing.AbstractButton;$.constructor=com.coremedia.editing.Tab;$.super$com$coremedia$editing$AbstractButton$activate=$.activate;







$.activate=function(){
this.super$com$coremedia$editing$AbstractButton$activate();
this.press();
};

$.processMousedown=function(event){
if(event.getTargetComponent()==this&&!this._pressed){
this.getParent().setActiveButton(this);
}
return false;
};

})();
_jsc_package(["com","coremedia","editing"]);






(function(){







var $=com.coremedia.editing.AbstractButtonContainer=com_coremedia_editing_AbstractButtonContainer=function(currentWindow,id,props){
this.super$com$coremedia$editing$Component(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.AbstractButtonContainer';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.AbstractButtonContainer;




$.isActive=function(){
return this._active;
};





$.setActive=function(active){
this._active=active?true:false;
};





$.setActiveButton=function(button){
if(button!=this._activeButton){
if(this._activeButton){
this._activeButton.deactivate();
}
this._activeButton=button;
if(button){
button.activate();
if(!this.isActive()){

this.setActive(true);
}
}
}
};




$.getActiveButton=function(){
return this._activeButton;
};




})();
_jsc_package(["com","coremedia","editing"]);





(function(){

var $=com.coremedia.editing.Toolbar=com_coremedia_editing_Toolbar=function(currentWindow,id,props){
this.super$com$coremedia$editing$AbstractButtonContainer(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.Toolbar';$.superconstructor=com.coremedia.editing.AbstractButtonContainer;$=$.prototype=new com.coremedia.editing.AbstractButtonContainer();$.super$com$coremedia$editing$AbstractButtonContainer=com.coremedia.editing.AbstractButtonContainer;$.constructor=com.coremedia.editing.Toolbar;





$.isPopupMenu=function(){
return false;
};






$.getPosition=function(){
return"vertical";
};






$.getMouseCapture=function(){
return this.getActiveButton();
};$.super$com$coremedia$editing$AbstractButtonContainer$setActive=$.setActive;

$.setActive=function(active){
this.super$com$coremedia$editing$AbstractButtonContainer$setActive(active);
var mouseCapture=this.getMouseCapture();
if(active){

mouseCapture.setMouseCapture();
}else{
this.setActiveButton(null);
if(mouseCapture){
mouseCapture.releaseMouseCapture();
}
}
};






$.processMousedown=function(event){
if(this.isActive()){
var activeButton=this.getActiveButton();
if(activeButton){
activeButton.deactivate();
}
this._deactivating=true;
return true;
}
return false;
};






$.processMouseup=function(event){
var command="";
if(this._deactivating){
this._deactivating=false;

}else{
command=typeof event.getTargetComponent().getCommand=="function"?event.getTargetComponent().getCommand():null;
}
this.performCommand(event,command);
return true;
};




$.performCommand=function(event,command){
if(command){
this.log("Toolbar: Executing command '"+command+"' on "+event.getType()+".");
command.execute();
}
this.setActive(false);
};



})();
_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.MenuBar=com_coremedia_editing_MenuBar=function(currentWindow,id,props){
this.super$com$coremedia$editing$Toolbar(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.MenuBar';$.superconstructor=com.coremedia.editing.Toolbar;$=$.prototype=new com.coremedia.editing.Toolbar();$.super$com$coremedia$editing$Toolbar=com.coremedia.editing.Toolbar;$.constructor=com.coremedia.editing.MenuBar;





$.processLoad=function(event){
var popupWindow=this.getFrame().getParent();
this._isPopupMenu=popupWindow&&typeof popupWindow.setVisibilityListener=="function";
this.log("MenuBar: ispopupmenu="+this._isPopupMenu);
if(this._isPopupMenu){
popupWindow.setVisibilityListener(this);
}
if(!this._position){
this._position=this._isPopupMenu?"horizontal":"vertical";
}
};$.super$com$coremedia$editing$Toolbar$processUnload=$.processUnload;

$.processUnload=function(event){
if(this._isPopupMenu){
var popupWindow=this.getFrame().getParent();
popupWindow.setVisibilityListener(null);
}
this.super$com$coremedia$editing$Toolbar$processUnload(event);
};$.super$com$coremedia$editing$Toolbar$isPopupMenu=$.isPopupMenu;




$.isPopupMenu=function(){
return this._isPopupMenu;
};




$.isSubmenu=function(){
return this.isPopupMenu()&&typeof this.getFrame().getParent().getParent().getCommand=="function";
};




$.visibilityChanged=function(visible){
if(!visible||!this.isSubmenu())
this.setActive(visible);
};




$.getPosition=function(){
return this._position;
};

$.setPosition=function(position){
this._position=position;
};




$.getMouseCapture=function(){
return this;
};




$.processMouseover=function(event){
if((this.isPopupMenu()||this.isActive())
&&event.getTargetComponent()
&&event.getTargetComponent().getParent()==this){
if(this.isPopupMenu()
&&typeof event.getTargetComponent().getUri=="function"){
if(this.getActiveButton()!=event.getTargetComponent()){

this.setActiveButton(null);
var MenuBar=com.coremedia.editing.MenuBar;
MenuBar._clearTimeout();
MenuBar._lastMenuBar=this;
MenuBar._lastButton=event.getTargetComponent();
MenuBar._timeoutId=window.setTimeout("com.coremedia.editing.MenuBar._activateLastButton();",300);
}
}else{
this.setActiveButton(event.getTargetComponent());
}
}
return false;
};




$.processMouseout=function(event){
if(this.isActive()
&&event.getTargetComponent()
&&event.getTargetComponent().getParent()==this
&&!(typeof event.getTargetComponent().getUri=="function")){
this.setActiveButton(null);
}
return false;
};$.super$com$coremedia$editing$Toolbar$setActiveButton=$.setActiveButton;




$.setActiveButton=function(button){
com.coremedia.editing.MenuBar._clearTimeout();
this.super$com$coremedia$editing$Toolbar$setActiveButton(button);
if(button){
button.press();
}
};




com.coremedia.editing.MenuBar._clearTimeout=function(){
if(this._timeoutId){
window.clearTimeout(this._timeoutId);
this._lastMenuBar=null;
this._lastButton=null;
}
};




com.coremedia.editing.MenuBar._activateLastButton=function(){
this._lastMenuBar.setActiveButton(this._lastButton);
};$.super$com$coremedia$editing$Toolbar$performCommand=$.performCommand;




$.performCommand=function(event,command){
if(this.isPopupMenu()){

var container=this.getFrame().getParent().getParent();
if(typeof container.performCommand=="function"){
container.performCommand(event,command);
return;
}
}
this.super$com$coremedia$editing$Toolbar$performCommand(event,command);
};



com.coremedia.editing.MenuBar._timeoutId=undefined;
com.coremedia.editing.MenuBar._lastMenuBar=undefined;
com.coremedia.editing.MenuBar._lastButton=undefined;

})();
_jsc_package(["com","coremedia","editing"]);





(function(){

var $=com.coremedia.editing.Tabs=com_coremedia_editing_Tabs=function(currentWindow,id,props){
this.super$com$coremedia$editing$AbstractButtonContainer(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.Tabs';$.superconstructor=com.coremedia.editing.AbstractButtonContainer;$=$.prototype=new com.coremedia.editing.AbstractButtonContainer();$.super$com$coremedia$editing$AbstractButtonContainer=com.coremedia.editing.AbstractButtonContainer;$.constructor=com.coremedia.editing.Tabs;

$.setFrameContainerId=function(frameContainerId){
this._frameContainerId=frameContainerId;
};$.getFrameContainer=

function(){
return this.getDocument().getElementById(this._frameContainerId);
};



})();
_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.GroupPane=com_coremedia_editing_GroupPane=function(currentWindow,id,props){
this.super$com$coremedia$editing$Component(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.GroupPane';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.GroupPane;

$.processClick=function(event){
var cell=this.getElement();
var classValue=com.coremedia.dom.HtmlDomUtil.getClassAttribute(cell);
classValue=classValue?"":"collapsed";
com.coremedia.dom.HtmlDomUtil.setClassAttribute(cell,classValue);
return true;
};


})();
_jsc_package(["com","coremedia","editing"]);







(function(){




var $=com.coremedia.editing.BrowseTableControl=com_coremedia_editing_BrowseTableControl=function(currentWindow,id,browseTableId,props){
this._browseTableId=browseTableId;
this.super$com$coremedia$editing$Toolbar(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.BrowseTableControl';$.superconstructor=com.coremedia.editing.Toolbar;$=$.prototype=new com.coremedia.editing.Toolbar();$.super$com$coremedia$editing$Toolbar=com.coremedia.editing.Toolbar;$.constructor=com.coremedia.editing.BrowseTableControl;






$.processLoad=function(event){
this._browseTable=this.getFrame().getComponentById(this._browseTableId);
delete this._browseTableId;
this._browseTable.setPageSizeListener(this);
};

$._getTextNode=function(index){
return this.getElement().getElementsByTagName("SPAN")[index].firstChild;
};

$._updateRange=function(){
var browseTable=this._browseTable;
var length=browseTable.getLength();
this._getTextNode(2).data=length;
var offset=browseTable.getOffset();
var pageSize=browseTable.getPageSize();
var loadedLength=browseTable.getLoadedLength();
this._getTextNode(0).data=offset+1;
this._getTextNode(1).data=offset+Math.min(pageSize,loadedLength);
};






$.pageSizeChanged=function(length){
this._updateRange();
};




$.changeOffset=function(delta){
var browseTable=this._browseTable;
var offset=browseTable.getOffset();
if(delta<0){
if(offset==0){

return;
}
}else{
if(offset+browseTable.getPageSize()==browseTable.getLength()){

return;
}
}
this._browseTable.setOffset(offset+delta);
};

$.gotoNextPage=function(){
this.changeOffset(+this._browseTable.getPageSize());
};

$.gotoPreviousPage=function(){
this.changeOffset(-this._browseTable.getPageSize());
};

$.performCommand=function(event,command){
if(command){

if(command.indexOf("browse-page-")==0){
this.setActive(false);
if(command=="browse-page-previous"){
this.gotoPreviousPage();
}else if(command=="browse-page-next"){
this.gotoNextPage();
}else{
alert("Unknown browse command '"+command+"'.");
}
return;
}
}
this.super$com$coremedia$editing$Toolbar$performCommand(event,command);
};




})();
_jsc_package(["com","coremedia","editing"]);













(function(){

var $=com.coremedia.editing.BrowseTable=com_coremedia_editing_BrowseTable=function(currentWindow,id,props){
this.super$com$coremedia$editing$Component(currentWindow,id,props);
this._rows=new Array();
this._selectionCount=0;
this._pageSize=-1;
this._leadSelection=null;
};$.constructorname='com.coremedia.editing.BrowseTable';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.BrowseTable;

$.setPageUpButtonId=function(pageUpButtonId){
if(pageUpButtonId)
new com.coremedia.editing.Button(this.getWindow(),pageUpButtonId,{command:"page-up"});
};

$.setPageDownButtonId=function(pageDownButtonId){
if(pageDownButtonId)
this._pageDownButton=new com.coremedia.editing.Button(this.getWindow(),pageDownButtonId,{command:"page-down"});
};

$.setLastItemIndexId=function(lastItemIndexId){
this._lastItemIndexId=lastItemIndexId;
};

$.getLastItemIndexId=function(){
return this._lastItemIndexId;
};





$.processLoad=function(event){

for(var i=0;i<this._rows.length;++i){
var row=this._rows[i];
if(row.isSelected()){
this.setSelected(row.getRowIndex(),true);
}
if(row.isLeadSelection()){
this._setLeadSelectionRow(row);
}
}

this._updateSize();
};






$.addRow=function(row){
this._rows[row.getRowIndex()]=row;
this.log("BrowseTable: added row "+row.getRowIndex()+", loadedLength: "+this.getLoadedLength());
};




$.getRow=function(index){
return this._rows[index];
};

$.getTableContainer=function(){
var outerTable=this.getElement();
var cell=outerTable.tBodies[0].rows[0].cells[1];
return com.coremedia.dom.DomUtil.findNextSibling(cell.firstChild,"DIV");
};

$.getTableElement=function(){
var div=this.getTableContainer();
return com.coremedia.dom.DomUtil.findNextSibling(div.firstChild,"TABLE");
};

$.getTBody=function(){
return this.getTableElement().tBodies[0];
};

$.getRowElement=function(index){
return this.getTBody().rows[2*index];
};

$.setLength=function(length){
this._length=Number(length);
};

$.getLength=function(){
return this._length;
};

$.getLoadedLength=function(){
return this._rows.length;
};

$.getOffset=function(){
return this._offset;
};

$.getPageSize=function(){
return this._pageSize;
};

$.setOffset=function(offset){
if(typeof this._length=="undefined"||typeof this._pageSize=="undefined"){
this._offset=offset;
return;
}
offset=Math.min(offset,this.getLength()-this.getPageSize());
offset=Math.max(offset,0);
if(offset!=this.getOffset()){
this.setValueForProperty("offset",offset);
this.submit();
}
};

$.pageUp=function(){
this.setOffset(this.getOffset()-this.getPageSize());
};

$.pageDown=function(){
this.setOffset(this.getOffset()+this.getPageSize());
};

$.getDefaultAction=function(){
return this._defaultAction;
};

$.setDefaultAction=function(defaultAction){
this._defaultAction=defaultAction;
};

$.processResize=function(event){
this._updateSize();
};

$._updateSize=function(){
var height;
var element=this.getTableContainer();
if(window.document.width){
if(this._timeoutHandle){
this.getWindow().clearTimeout(this._timeoutHandle);
this._timeoutHandle=null;
}

var frameSize=this.getFrame().getSize();
var elementLocation=this.getLocationInFrame();

height=frameSize.height-elementLocation.top;

if(height<0)height=0;

element.style.height=height+"px";
}else{

height=element.clientHeight;
}
var tBody=this.getTBody();
height-=tBody.offsetTop;
height-=tBody.parentNode.offsetTop;
var rows=tBody.rows;
var loadedLength=this.getLoadedLength();
var visibleRowCount;
if(rows.length>0){

var rowHeight=rows[0].offsetHeight+rows[1].offsetHeight;
visibleRowCount=Math.max(1,Math.floor(height/rowHeight));
}else{
visibleRowCount=0;
}
this.log("BrowseTable: height: "+height+", rowHeight: "+rowHeight+", visibleRowCount: "+visibleRowCount);
if(visibleRowCount!=this._pageSize){
if(this._pageSize<0){
this._pageSize=loadedLength;
}
var newlyVisible=visibleRowCount>this._pageSize;
var startRowIndex=newlyVisible?this._pageSize:visibleRowCount;
var endRowIndex=Math.min(loadedLength,newlyVisible?visibleRowCount:this._pageSize);
this.log("BrowseTable: "+(newlyVisible?"":"un")+"hiding from "+startRowIndex+" to "+endRowIndex);
var newStyle=newlyVisible?"":"hidden";
var leadSelectionIndex=this._leadSelection?this._leadSelection.getRowIndex()-this._offset:-1;
if(startRowIndex<=leadSelectionIndex&&leadSelectionIndex<endRowIndex){
this.log("BrowseTable: changing visibility of lead selection to '"+newStyle+"'.");
if(newlyVisible){

}else{








}
}
for(var i=startRowIndex;i<endRowIndex;++i){
rows[2*i].style.visibility=newStyle;
rows[2*i+1].style.visibility=newStyle;
}
this._pageSize=visibleRowCount;
this.setValueForProperty("pageSize",visibleRowCount);
this.pageSizeChanged();
if(this.getOffset()+loadedLength<this.getLength()&&visibleRowCount>loadedLength){
this.log("BrowseTable: loadedLength: "+loadedLength+" length: "+this.getLength());
this.timeoutHandle=this.getWindow().setTimeout("com.coremedia.editing.Frame.getInstance(window).submit();",100);
}
}
};

$.pageSizeChanged=function(){
if(this.getLastItemIndexId()){
var lastItemIndexSpan=this.getDocument().getElementById(this.getLastItemIndexId());
lastItemIndexSpan.firstChild.data=Math.min(this._offset+this._pageSize,this._length);
}
if(this._pageDownButton){
var more=this._offset+this._pageSize<this._length;
this._pageDownButton.setStyleClass("enabled--"+more);
}
};

$._getRowByElement=function(element){
var table=this.getTableElement();
var tBody=this.getTBody();
while(element&&element!=table&&element.parentNode!=tBody){
element=element.parentNode;
}
return element&&element.parentNode==tBody?this._rows[element.sectionRowIndex/2]:null;
};

$.setSelected=function(rowIndex,selected){
this._selectionCount+=selected?1:-1;
this.getRow(rowIndex).setSelected(selected);
};

$._setLeadSelectionRow=function(row){
var leadSelectionBean="";
if(this._leadSelection)
this._leadSelection.setLeadSelection(false);
if(row){
this._leadSelection=row;
this._leadSelection.setLeadSelection(true);
leadSelectionBean=row.getBean();
}else{
this._leadSelection=null;
}
this.setValueForProperty("leadSelection",leadSelectionBean);
};

$.processActivation=function(evt){
com.coremedia.dom.HtmlDomUtil.setClassAttribute(this.getTableElement(),"focus");
};

$.processDeactivation=function(evt){
com.coremedia.dom.HtmlDomUtil.setClassAttribute(this.getTableElement(),"");
};

$.processClick=function(event){
this.requestActivation(event);
var row=this._getRowByElement(event.getTarget());
if(row){
if(event.getShiftKeyPressed()){
this._selectInterval(row,event.getCtrlKeyPressed());
}else if(event.getCtrlKeyPressed()){
this._selectMultipleRows(row);
}else{
this._selectSingleRow(row);
}
}
};

$.processDblclick=function(event){
this.log("BrowseTable: "+this.getDefaultAction());
this.processClick(event);
var defaultAction=this.getDefaultAction();
if(defaultAction){
defaultAction.execute();
}
};

$._selectSingleRow=function(selectedRow){
if(selectedRow){

for(var rowIndex=0;rowIndex<this._rows.length;rowIndex++){
this.setSelected(rowIndex,(selectedRow==this._rows[rowIndex]));
}

this._setLeadSelectionRow(selectedRow);
}
};

$._selectMultipleRows=function(selectedRow){
if(selectedRow){
var newState=!selectedRow.isSelected();
this.setSelected(selectedRow.getRowIndex(),newState);
this._setLeadSelectionRow(selectedRow);
}
this._clearSelection();
};

$._selectInterval=function(selectedRow,ctrlPressed){
if(selectedRow){
var leadIndex=(this._leadSelection)?this._leadSelection.getRowIndex():0;
var first=(leadIndex<selectedRow.getRowIndex())?leadIndex:selectedRow.getRowIndex();
var last=(leadIndex>selectedRow.getRowIndex())?leadIndex:selectedRow.getRowIndex();
var start=(ctrlPressed)?first:0;
var end=(ctrlPressed)?last:this._rows.length-1;
var leadSelectionState=(this._leadSelection)?this._leadSelection.isSelected():false;
for(var rowIndex=start;rowIndex<=end;rowIndex++){
var state=(ctrlPressed)
?(leadSelectionState||rowIndex==end)
:(first<=rowIndex&&rowIndex<=last);
this.setSelected(rowIndex,state);
}

}
this._clearSelection();
};

$._clearSelection=function(){
if(this.getDocument().selection){

this.getDocument().selection.empty();
}
};




$.processContextmenu=function(event){
this.requestActivation(event);
var row=this._getRowByElement(event.getTarget());
if(row&&!row.isSelected()){
this._selectSingleRow(row);
}
com.coremedia.editing.PopupWindow.getPopupWindowFor(this).show(event);
event.preventDefault();
return true;
};

$.setActiveButton=function(button){
var command=button.getCommand();
if(command=="page-up"){
this.pageUp();
}else if(command=="page-down"){
this.pageDown();
}
};

$.performCommand=function(event,command){
com.coremedia.editing.PopupWindow.releasePopupWindowFor(this);
if(command){
if(command.indexOf("preview-resourceMenuItem/")==0){
var tabId="tab_"+command.substring("preview-resourceMenuItem/".length);
for(var i=0;i<this.getLoadedLength();++i){
if(this.getRow(i).isSelected()){
var bean=this.getRow(i).getBean();
var tab_preview=com.coremedia.editing.Frame.getInstance(window).getComponentById(tabId);
this.log("BrowseTable: Found preview tab "+tab_preview.getId());
tab_preview.replaceUrlParameter("id",bean);
tab_preview.getParent().setActiveButton(tab_preview);
return;
}
}
}else{
this.log("BrowseTable: Executing command '"+command+"' on "+event.getType()+".");
}
}
};


$.getPosition=function(){
return"mouse";
};

$._getSelectionType=function(){
return this._selectionCount==0?"none":this._selectionCount==1?"single":"multi";
};

$.setContextMenuUri=function(contextMenuUri){
this._contextMenuUri=contextMenuUri;
};

$.getContextMenuUri=function(){
return this._contextMenuUri;
};

$.getUri=function(){
var uri="prototype-popup-"+this.getContextMenuUri()+".do?selectionType="+this._getSelectionType();

return uri;
};













})();
_jsc_package(["com","coremedia","editing"]);





(function(){

var $=com.coremedia.editing.TableRow=com_coremedia_editing_TableRow=function(currentWindow,tableId,rowIndex,props){
this.super$com$coremedia$editing$Component(currentWindow,null,props);
this._table=this.getFrame().getComponentById(tableId);
this._rowIndex=rowIndex;
this._table.addRow(this);
};$.constructorname='com.coremedia.editing.TableRow';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.TableRow;




$.getTable=function(){
return this._table;
};

$.getRowIndex=function(){
return this._rowIndex;
};

$.setBean=function(bean){
this._bean=bean;
};

$.getBean=function(){
return this._bean;
};$.super$com$coremedia$editing$Component$getElement=$.getElement;

$.getElement=function(){
return this.getTable().getRowElement(this.getRowIndex());
};

$.setSelected=function(selected){
this._selected=selected;
if(!this._table)
return;
this._setSelectionStyle();
this.getDocument().getElementById("selection."+this._table.getId()+"."+this._rowIndex).checked=selected;
};

$.isSelected=function(){
return this._selected;
};

$.setLeadSelection=function(selected){
this._leadSelection=selected;
if(!this._table)
return;
this._setSelectionStyle();
};

$.isLeadSelection=function(){
return this._leadSelection;
};

$._setSelectionStyle=function(){
var style=(this._selected)?"selected":"";
if(this._leadSelection){
style=style+((this._selected)?" focus":"focus");
}
this.setStyleClass(style);
};

$.toString=function(){
return this.getTable().getId()+"["+this.getRowIndex()+"]";
};







})();
_jsc_package(["com","coremedia","editing"]);





(function(){

var $=com.coremedia.editing.TabContainer=com_coremedia_editing_TabContainer=function(currentWindow,id,props){
this.super$com$coremedia$editing$AbstractButtonContainer(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.TabContainer';$.superconstructor=com.coremedia.editing.AbstractButtonContainer;$=$.prototype=new com.coremedia.editing.AbstractButtonContainer();$.super$com$coremedia$editing$AbstractButtonContainer=com.coremedia.editing.AbstractButtonContainer;$.constructor=com.coremedia.editing.TabContainer;

$.setActiveButtonId=function(activeButtonId){
this.setActiveButton(this._getController().getComponent(activeButtonId));
};

$.processMouseup=function(event){
var command="";
if(this._deactivating){
this._deactivating=false;

}else{
command=event.getTargetComponent().getId();
}
this.performCommand(event,command);
return true;
};




$.performCommand=function(event,command){
if(command){
this.setValueForProperty("active",command);
this.submit();
}
this.setActive(false);
};

})();
_jsc_package(["com","coremedia","editing"]);





(function(){

var $=com.coremedia.editing.EditableLabel=com_coremedia_editing_EditableLabel=function(currentWindow,id,props){
this.super$com$coremedia$editing$Component(currentWindow,id,props);
com.coremedia.editing.FloatingTextField.getInstance(this.getWindow());
};$.constructorname='com.coremedia.editing.EditableLabel';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.EditableLabel;

$.setEditable=function(editable){
this._editable=editable;
};

$.isEditable=function(){
return this._editable;
};

$.setLabel=function(label){
if(this._trim(label)!=""){
this.getElement().firstChild.data=label;
this.setValueForProperty("text",label);
}
};

$._trim=function(s){

while((s.substring(0,1)==' ')||(s.substring(0,1)=='\n')||(s.substring(0,1)=='\r'))
{
s=s.substring(1,s.length);
}

while((s.substring(s.length-1,s.length)==' ')||(s.substring(s.length-1,s.length)=='\n')||(s.substring(s.length-1,s.length)=='\r'))
{
s=s.substring(0,s.length-1);
}
return s;
};

$.getLabel=function(){
return this.getElement().firstChild.data;
};

$.processClick=function(event){

if(this.isEditable()){
com.coremedia.editing.FloatingTextField.getInstance(this.getWindow()).setEditableLabel(this);
}
};



})();
_jsc_package(["com","coremedia","editing"]);


(function(){

var $=com.coremedia.editing.FloatingTextField=com_coremedia_editing_FloatingTextField=function(cWindow){
this.super$com$coremedia$editing$Component(cWindow,com.coremedia.editing.FloatingTextField._ATTRIBUTE_NAME);
};$.constructorname='com.coremedia.editing.FloatingTextField';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.FloatingTextField;



$.setEditableLabel=function(editableLabel){
this._label=editableLabel;


var size=this._label.getSize();

var labelElement=this._label.getElement();
if(labelElement.currentStyle){

this._input.style.fontFamily=labelElement.currentStyle.fontFamily;
this._input.style.fontSize=labelElement.currentStyle.fontSize;
this._input.style.fontStyle=labelElement.currentStyle.fontStyle;
this._input.style.fontVariant=labelElement.currentStyle.fontVariant;
this._input.style.fontWeight=labelElement.currentStyle.fontWeight;
this.setStyleClass("text-field");
}else{
this.setStyleClass(this._label.getStyleClass());
}
this._input.style.width=size.width+10;
this._input.style.height=size.height+6;
if(this._input.readOnly)
this._input.setAttribute("readonly","false");
if(this._input.disabled)
this._input.setAttribute("disabled","false");
this._input.value=this._label.getLabel();;

this._setPosition();
this._setVisible();
};

$._setPosition=function(){

var location=this._label.getLocation();
this._input.style.top=(location.top-2)+"px";
this._input.style.left=(location.left-2)+"px";
};


$._setVisible=function(){
this._input.style.display="";
this._input.focus();
this._input.select();
this.setMouseCapture();
};

$._isVisible=function(){
return this._input.style.display!="none"?true:false;
};


$._setHidden=function(){
this._input.style.display="none";
this.releaseMouseCapture();
};

$._confirm=function(){
if(this._isVisible()){
var changed=this._label.getLabel()!=this._input.value;
if(changed)
this._label.setLabel(this._input.value);
this._setHidden();
if(changed)
this.submit();
}
};

$.processBlur=function(event){
this._confirm();
};

$.processClick=function(event){
if(this._isVisible()&&event.getTargetComponent()!=this)
return this.processBlur(event);
else
return false;
};

$.processResize=function(event){
if(this._isVisible())
this._setPosition();
};

$.processResizestart=function(event){
this._setHidden();
};

$.processResizeend=function(event){
this._setPosition();
this._setVisible();
};

$.processKeydown=function(event){
switch(event.getKeyCode()){
case com.coremedia.editing.ComponentEvent.VK_ENTER:this._confirm();break;
case com.coremedia.editing.ComponentEvent.VK_ESCAPE:this._setHidden();break;

}
};

com.coremedia.editing.FloatingTextField.getInstance=function(window){
var frame=com.coremedia.editing.Frame.getInstance(window);
var inst=frame.getComponentById(this._ATTRIBUTE_NAME);
if(!inst)
inst=new com.coremedia.editing.FloatingTextField(window);
return inst;
};$.super$com$coremedia$editing$Component$getElement=$.getElement;

$.getElement=function(){
if(!this._input){
this._input=this.getDocument().createElement("input");
this._input.style.position="absolute";
this._input.id=this.getId();
this._setHidden();
this.getForm().appendChild(this._input);
}
return this._input;
};

$.isComponentSelectionEvent=function(event){
return("click"==event.type
||"dblclick"==event.type
||"mouseup"==event.type);
};

com.coremedia.editing.FloatingTextField._ATTRIBUTE_NAME="com.coremedia.editing.FloatingTextField";



})();
_jsc_package(["com","coremedia","editing"]);










(function(){

var $=com.coremedia.editing.TextField=com_coremedia_editing_TextField=function(currentWindow,id){
this.super$com$coremedia$editing$Component(currentWindow,id);
};$.constructorname='com.coremedia.editing.TextField';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.TextField;

$.processSubmit=function(event){
if(!this._isChanged()){
this.getElement().name="";
}
return true;
};

$.processClick=function(evt){
return this.requestActivation(evt);
};

$.processDblclick=function(evt){
return this.requestActivation(evt);
};

$.processMouseup=function(evt){
return this.requestActivation(evt);
};

$.processFocus=function(evt){
return this.requestActivation(evt);
};

$._isChanged=function(){
var element=this.getElement();
return(typeof(element.defaultValue)!="undefined"&&element.value!=element.defaultValue);
};

})();







_jsc_package(["com","coremedia","editing"]);

(function(){

var $=com.coremedia.editing.TextRange=com_coremedia_editing_TextRange=function(){
};$.constructorname='com.coremedia.editing.TextRange';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.TextRange;

$.parentElement=function(){
var parentElement=this.commonAncestorContainer;
if(parentElement.nodeType==Node.TEXT_NODE){
parentElement=parentElement.parentNode;
}else if(this.startContainer==this.endContainer&&this.endOffset==this.startOffset+1){

var imgs=parentElement.getElementsByTagName("IMG");
var imgrange=this.startContainer.ownerDocument.createRange();
try{
for(var i=0;i<imgs.length;++i){
imgrange.selectNode(imgs[i]);
if(this.compareBoundaryPoints(Range.START_TO_START,imgrange)==0&&
this.compareBoundaryPoints(Range.END_TO_END,imgrange)==0){
parentElement=imgs[i];
break;
}
}
}finally{
imgrange.detach();
}
}
return parentElement;
};

$.duplicate=function(){
return this.cloneRange();
};

$.move=function(str,units){
if(str=="character"){
var elem=this.startContainer;
return this.setStart(elem,elem.nodeType==Node.TEXT_NODE?this.startOffset+units:0);
}
return false;
};

$.moveToElementText=function(element){
this.selectNodeContents(element);
};

$.pasteHTML=function(html){
var span=this.startContainer.ownerDocument.createElement("div");
span.innerHTML=html;
span=span.firstChild;
this.deleteContents();
this.insertNode(span);
};

$.compareEndPoints=function(how,otherRange){
return-this.compareBoundaryPoints(
how=="StartToStart"?Range.START_TO_START
:how=="StartToEnd"?Range.END_TO_START
:how=="EndToStart"?Range.START_TO_END
:Range.END_TO_END,
otherRange);
};

$.setEndPoint=function(startOrEndToStartOrEnd,range){
var parts=startOrEndToStartOrEnd.split("To");
if(parts.length!=2){
throw new Error(startOrEndToStartOrEnd+" does not match (Start|End)To(Start|End).");
}
var toNode=parts[1]=="Start"?range.startContainer:range.endContainer;
var toOffset=parts[1]=="Start"?range.startOffset:range.endOffset;
this["set"+parts[0]](toNode,toOffset);
};

$.select=function(){
var selection=this.startContainer.ownerDocument.selection;
selection.removeAllRanges();
selection.addRange(this);
};

$.scrollIntoView=function(){
return this.startContainer.scrollIntoView();
};

com.coremedia.editing.TextRange.patchWindow=function(currentWindow){
if(typeof currentWindow.Range=="function"&&
typeof currentWindow.HTMLBodyElement=="function"&&
typeof currentWindow.Selection=="function"&&
typeof currentWindow.HTMLDocument=="function"){

for(var m in this.prototype){
currentWindow.Range.prototype[m]=this.prototype[m];
}
currentWindow.HTMLBodyElement.prototype.createTextRange=function(){
return this.ownerDocument.createRange();
};
currentWindow.Selection.prototype.type="Text";
currentWindow.Selection.prototype.createRange=function(){

if(this.rangeCount<2)
return this.getRangeAt(0);

else{
var result=this.getRangeAt(0).cloneRange();
var lastRange=this.getRangeAt(this.rangeCount-1);
result.setEnd(lastRange.endContainer,lastRange.endOffset);
return result;
}
};
currentWindow.HTMLDocument.prototype.__defineGetter__("selection",function(){
return this.defaultView.getSelection();
});
}
};

(function(){

com.coremedia.editing.TextRange.patchWindow(window);


})();

})();
_jsc_package(["com","coremedia","editing"]);

(function(){


var $=com.coremedia.editing.ElementSelection=com_coremedia_editing_ElementSelection=function(){};$.constructorname='com.coremedia.editing.ElementSelection';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.ElementSelection;

$._paint=function(style){
if(this.isActive()){
for(var i=0;i<this._elements.length;++i){
var element=this._elements[i];
if(element)
element.style.cssText=style;
}
}
};

$._updateElements=function(elements){
this._paint("");
this._elements=elements;
this._paint("background-color:lightblue;border-color:red;border-style:dotted;");
};

$.isActive=function(){
return typeof this._elements!="undefined";
};

$.isEmpty=function(){
return!this.isActive()||this._elements.length==0;
};

$.getElements=function(){
return this._elements;
};

$.setElements=function(elements){
if(typeof elements!="object"||typeof elements.length!="number"){
throw new Error("Argument to ElementSelection#setElements() must be an Array of Elements.");
}
this._updateElements(elements);
};

$.deactivate=function(){
this._updateElements(undefined);
};




})();
_jsc_package(["com","coremedia","editing"]);








(function(){







var $=com.coremedia.editing.Resizer=com_coremedia_editing_Resizer=function(currentWindow,resizerId,resizeContainer){
this.super$com$coremedia$editing$Component(currentWindow,resizerId);
this._resizeContainer=resizeContainer;
this._isNetscape=(com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.NETSCAPE);
};$.constructorname='com.coremedia.editing.Resizer';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.Resizer;





$.processDrag=function(event){
var newHeight=event.getClientY()-this._startY+this._originalSize.height;
var newWidth=event.getClientX()-this._startX+this._originalSize.width;
if(newHeight<10)newHeight=10;
if(newWidth<10)newWidth=10;
this._resizeContainer.setCurrentSize({width:newWidth,height:newHeight});
return true;
};


$.processMouseup=function(event){
if(this._isNetscape)this.releaseMouseCapture();
return true;
};

$.processMousemove=function(event){
if(this._isNetscape)
if(this.hasMouseCapture())return this.processDrag(event);
return false;
};





$.processMousedown=function(event){

if(this._isNetscape)this.setMouseCapture();
this._startY=event.getClientY();
this._startX=event.getClientX();
this._originalSize=this._resizeContainer.getCurrentSize();
return false;
};








})();
_jsc_package(["com","coremedia","editing"]);






(function(){









var $=com.coremedia.editing.SplitPane=com_coremedia_editing_SplitPane=function(currentWindow,id,resizerId,props){
this._orientation="horizontal";
this.super$com$coremedia$editing$Component(currentWindow,id,props);
this._menuItemMap=new Object();
new com.coremedia.editing.Resizer(currentWindow,resizerId,this);
};$.constructorname='com.coremedia.editing.SplitPane';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.SplitPane;

$.setOrientation=function(orientation){
this._orientation=orientation;
};

$.getOrientation=function(){
return this._orientation;
};

$._getSizeProperty=function(){
return this._orientation=="horizontal"?"width":"height";
};

$.getCurrentSize=function(){
var element=this._getFirstCell();
if(element.clientWidth)
return{width:element.clientWidth,height:element.clientHeight};
else
return{width:element.offsetWidth,height:element.offsetHeight};
};

$.setCurrentSize=function(size){
var element=this._getFirstCell();
var dividerLocation;
var sizeProperty=this._getSizeProperty();
var dividerLocation=size[sizeProperty]+"px";
element.style[sizeProperty]=dividerLocation;
this.setValueForProperty("dividerLocation",dividerLocation);
this.fireResized();
};

$.show=function(id){
this._menuItemMap[id].setChildVisible(true);
};

$.hide=function(id){
this._menuItemMap[id].setChildVisible(false);
};

$.registerMenuItem=function(item,childId){
this._menuItemMap[childId]=item;
};

$._getFirstCell=function(){

return this.getElement().tBodies[0].rows[0].cells[0];
};




})();





_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.ScrollPane=com_coremedia_editing_ScrollPane=function(currentWindow,id,props){
this.super$com$coremedia$editing$Component(currentWindow,id,props);
};$.constructorname='com.coremedia.editing.ScrollPane';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.ScrollPane;


















$.processLoad=function(event){
this.getDocument().documentElement.style.overflow="hidden";
var scrollPane=this.getElement();
scrollPane.scrollLeft=this._scrollLeft;
scrollPane.scrollTop=this._scrollTop;
this._resize();
};

$.processResize=function(event){
this._resize();
};

$._resize=function(){
var scrollpane=this.getElement();
var size=this.getFrame().getSize();
var availableWidth=size.width-scrollpane.offsetLeft;
var availableHeight=size.height-scrollpane.offsetTop;
var isBlockLevelElement=com.coremedia.dom.HtmlDomUtil.isBlockLevelElement;
for(var sibling=scrollpane.nextSibling;sibling;sibling=sibling.nextSibling){
if(isBlockLevelElement(sibling))
availableHeight-=sibling.offsetHeight;
}

if(availableHeight<100)
availableHeight=100;
if(availableWidth<100)
availableWidth=100;


var padding=this.getPadding();
availableWidth-=padding.getLeft()+padding.getRight();
availableHeight-=padding.getTop()+padding.getBottom();
scrollpane.style.height=availableHeight+"px";
scrollpane.style.width=availableWidth+"px";
if(scrollpane.nodeName=="TABLE"){

var cells=scrollpane.tBodies[0].rows[0].cells;
for(var i=0;i<cells.length;++i){
var cell=cells[i];
cell.style.height=availableHeight+"px";
}
}
};

















})();




_jsc_package(["com","coremedia","editing"]);








(function(){







var $=com.coremedia.editing.XHtmlEditor=com_coremedia_editing_XHtmlEditor=function(currentWindow,id,props){
this._editableDiv=null;
this.super$com$coremedia$editing$Component(currentWindow,id,props);
this._formatVariantSeparator="--";
this._allowNestedTableInsertion=true;

this._transformElementMap=new Object();
this._transformAttributeLists=new Object();
this._transformAttributeMaps=new Object();


this.transformElementOnPaste("/B","SPAN");






};$.constructorname='com.coremedia.editing.XHtmlEditor';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.XHtmlEditor;














$.isEditable=function(){
return this._editable;
};

$.setEditable=function(editable){
this._editable=editable?true:false;
};

$.setValue=function(value){
if(this._isLoggingEnabled())this._log("setValue: "+value);
var ediv=this.getElement();
ediv.innerHTML=value;
this._repairDivContent(ediv);
};

$.getValue=function(){
if(this._sourceViewActive)
this._toggleSourceView();
this._normalizeDiv(this._editableDiv);
this._updateAllImageDimensions();
var value=this.getHtmlText();
if(this._isLoggingEnabled())this._log("getValue(): "+value);
return value;
};

com.coremedia.editing.XHtmlEditor._REMOVE_RECURSIVELY_ON_PASTE={};






























$.transformElementOnPaste=function(origElementName,transformedElementName,attributes){

if(typeof transformedElementName=="undefined"){
transformedElementName=com.coremedia.editing.XHtmlEditor._REMOVE_RECURSIVELY_ON_PASTE;
}
this._transformElementMap[origElementName]=transformedElementName;
if(!attributes)
attributes=new Array();
var attributeMap=new Object();
var classGiven=false;
for(var i=0;i<attributes.length;i+=2){
var attrName=attributes[i];
var attrValue=attributes[i+1];
if(attrName=="class")
attrName="className";
classGiven|=attrName=="className";
attributeMap[attrName]=attrValue;
}
if(!classGiven){
attributes.push("className");
attributes.push(null);
attributeMap["className"]=null;
}
this._transformAttributeLists[origElementName]=attributes;
this._transformAttributeMaps[origElementName]=attributeMap;
};






















$.setStyleSelectorsConflictPredicate=function(pred){
this._styleSelectorsConflictPredicate=pred;
};




$.getStyleSelectorsConflictPredicate=function(){
return this._styleSelectorsConflictPredicate;
};

com.coremedia.editing.XHtmlEditor.STRIKE_UNDERLINE_CONFLICT_PREDICATE=function(selector1,selector2){
return selector1=="strike"&&selector2=="underline";
};

$._createEmptyElement=function(element){
var document=this.getDocument();
var newCell=document.createElement(element);
if(com.coremedia.dom.DomUtil.isElement(newCell,"DIV"))
newCell.appendChild(this._createEmptyElement("P"));
else if(this._isFirefox()&&com.coremedia.dom.DomUtil.isElement(newCell,"P|TD|LI"))
newCell.innerHTML="<br/>";
else if(com.coremedia.dom.DomUtil.isElement(newCell,"P"))
newCell.innerHTML="&nbsp";
if(this._isLoggingEnabled())
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,"#_createEmptyElement("+element+"): ",newCell);
return newCell;
};

$._repairDivContent=function(ediv){

if(this._isLoggingEnabled()&&this._detailedLoggingEnabled)
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,"before #_repairDivContent",ediv);

var child=ediv.firstChild;
var firstDiv=null;
while(child){
var nextChild=child.nextSibling;
if(firstDiv||!com.coremedia.dom.DomUtil.isElement(child,"div")){
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,
"removing superflous nodes from editable content (must be single div)",
child);
ediv.removeChild(child);
}else
firstDiv=child;
child=nextChild;
}

if(!firstDiv){
this._editableDiv=this._createEmptyElement("div");
this.getDocument().getElementById(this._id).appendChild(this._editableDiv);
}else{

var paragraphs=firstDiv.getElementsByTagName("P");
if(this._isLoggingEnabled())this._log("#_repairDivContent: checking "+paragraphs.length+" paragraphs.");
for(i=0;i<paragraphs.length;i++){
if(this._isEmpty(paragraphs[i])){
if(!this._isFirefox()){
var p=this._createEmptyElement("p");
paragraphs[i].parentNode.replaceChild(p,paragraphs[i]);
}else
paragraphs[i].innerHTML="<br/>";
}
}
this._normalizeDiv(firstDiv);
this._editableDiv=firstDiv;
}
if(this._isLoggingEnabled()&&this._detailedLoggingEnabled)
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,"after #_repairDivContent",this._editableDiv);
};

$._isEmpty=function(elem){
var children=elem.childNodes;
if(!children||children.length==0)return true;
if(children.length==1){
if(children[0].nodeType==Node.TEXT_NODE)
return this._trim(children[0].nodeValue).length==0;
if(this._isFirefox()&&com.coremedia.dom.DomUtil.isElement(elem,"TD|P|LI|DIV"))
return com.coremedia.dom.DomUtil.isElement(children[0],"BR");
}
return false;
};

$._normalizeElement=function(elem){
if(this._isFirefox()&&com.coremedia.dom.DomUtil.isElement(elem,"TD|P|LI|DIV")){
if(this._isEmpty(elem))
elem.innerHTML="<br/>";
}
};

$._trim=function(str,wh){
if(!str.replace||!str.length){return str;}
var re=(wh>0)?(/^\s+/):(wh<0)?(/\s+$/):(/^\s+|\s+$/g);
return str.replace(re,"");
};




$._setTopElementAttributes=function(){
if(!this._isFirefox()){
var ediv=this._editableDiv;
ediv.setAttribute("contentEditable","true");
ediv.setAttribute("unselectable","off");
}
};

$._removeTopElementAttributes=function(){
if(!this._isFirefox()){
var ediv=this._editableDiv;
ediv.removeAttribute("contentEditable");
ediv.removeAttribute("unselectable");
}
};

$.processContextmenu=function(event){
if(this._isLoggingEnabled())this._log("contextmenu");
this._toggleSourceView();
event.preventDefault();
event.stopPropagation();
return true;
};

$.processClick=function(event){
return this.processFocus(event);
};

$.processSubmit=function(event){
if(this._editable)
this.setValueForProperty(this.getId(),this.getValue());
};

$.processFocus=function(event){
return this.requestActivation(event);
if(this.isParent(this._editableDiv,event.getTarget())){
this._onfocus();
}
return false;
};

$.processDragstart=function(event){
return this._ondragstart(event);
};

$.processDragend=function(event){
return this._ondragend(event);
};

$.processDrop=function(event){
return this._ondrop(event);
};

$.processDragenter=function(event){
return this._ondragenter(event);
};

$.processDragover=function(event){
return this._ondragover(event);
};

$.processDragleave=function(event){
return this._ondragleave(event);
};

$.processKeydown=function(event){
return this._onkeydown(event);
};

$.processSelectionchange=function(event){
if(this._isLoggingEnabled())this._log("#processSelectionchange");
if(this._isIE()){
var spanTableModel=this._getSpanTableModel();
var cells=spanTableModel?spanTableModel.getSelectedCells():[];
this._elementSelection.setElements(cells);
}
return true;
};$.super$com$coremedia$editing$Component$processUnload=$.processUnload;

$.processUnload=function(event){
if(this._isLoggingEnabled())this._log("#processUnload");
this._editableDiv=null;
this.super$com$coremedia$editing$Component$processUnload(event);
};

$.processKeyup=function(event){
if(this._isLoggingEnabled())this._log("#processKeyup");
if(this.isParent(this._editableDiv,event.getTarget())){
this._checkSelectionForOrphans();
this._checkLists();
}
return false;
};

$.processResizestart=function(event){
if(this.isParent(this._editableDiv,event.getTarget())){
if(this._isLoggingEnabled())this._log("received onresizestart on element "+event.getTarget().nodeName);
if(com.coremedia.dom.DomUtil.isElement(event.getTarget(),"table")){
event.preventDefault();
return true;
}
}
};

$.processBlur=function(event){
if(this._isLoggingEnabled())this._log("#processBlur");
if(this.isParent(this._editableDiv,event.getTarget())){
this.unfocus();
}
};






$.isParent=function(parent,element){
if(parent!=null){
while(element!=null){
if(element===parent)return true;
element=element.parentNode;
}
}
return false;
};

$.processLoad=function(event){
var element=this.getElement();
this._repairDivContent(element);
this.setValueForProperty(this.getId(),this.getValue());
this._setTopElementAttributes();

var document=this.getDocument();
if(typeof document.createRange=="function"){

var iframe=document.createElement("IFRAME");
var editStyleClass=com.coremedia.dom.HtmlDomUtil.getClassAttribute(element);
com.coremedia.dom.HtmlDomUtil.setClassAttribute(iframe,editStyleClass);
var innerHTML=element.firstChild.innerHTML;
iframe.id=element.id;
element.parentNode.replaceChild(iframe,element);
this._element=iframe;
this._editWindow=iframe.contentWindow;
this._editWindow.name="iframe_"+this.getId();

this._editWindow.com=com;


var frameDocument=iframe.contentDocument;
frameDocument.designMode="on";
frameDocument.write("<html><head>");

var links=document.getElementsByTagName("LINK");
for(var i=0;i<links.length;++i){
if(links[i].type=="text/css"){
var richTextCssPos=links[i].href.indexOf("coremedia-richtext-1.0.css");
if(richTextCssPos>=0){
var richTextCssUrl=links[i].href;
frameDocument.write("<link rel='stylesheet' type='text/css' href='"+richTextCssUrl+"'>");
var richTextEditingCssUrl=richTextCssUrl.substring(0,richTextCssPos)+"coremedia-richtext-editing.css";
frameDocument.write("<link rel='stylesheet' type='text/css' href='"+richTextEditingCssUrl+"'>");
break;
}
}
}
var bodyId="virtual_"+this.getId();
frameDocument.write("</head><body id='"+bodyId+"' tabindex='0' class='"+editStyleClass+"' style='border:0px none;overflow-x:auto;overflow-y:hidden'>");
frameDocument.write(innerHTML);
frameDocument.write("</body></html>");
frameDocument.close();
frameDocument.designMode="on";


var bridge=new com.coremedia.editing.XHtmlEditor.FirefoxEventBridge(this._editWindow,bodyId,{editor:this});
var self=this;
this._editWindow.addEventListener("load",function(e){
bridge.processLoad(e);

if(self._isLoggingEnabled())self._log("iframe loaded:"+self.getDocument().body.innerHTML);
},false);

com.coremedia.editing.TextRange.patchWindow(this._editWindow);
iframe=links=null;
}else{
this._attachEventHandlersOnLinks(element);
}

this._elementSelection=new com.coremedia.editing.ElementSelection();

element=null;
return this;
};

$._attachEventHandlersOnLinks=function(element){
var self=this;
var links=element.getElementsByTagName("A");
for(i=0;i<links.length;i++){
com.coremedia.editing.Browser.instance.addEventListener(window,links[i],"mouseover",function(e){return self._onLinkMouseOver(e);});
com.coremedia.editing.Browser.instance.addEventListener(window,links[i],"mouseout",function(e){return self._onLinkMouseOut(e);});
}
links=null;
};

$._isAllInline=function(node){
var child=node.firstChild;
while(child){
if(child.nodeType==Node.ELEMENT_NODE&&
!com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(child))
return false;
child=child.nextSibling;
}
return true;
};

$._normalizeDiv=function(div){
var child=div.firstChild;
var accu=null;
while(child){
var nextChild=child.nextSibling;
this._normalizeElement(child);
if(!com.coremedia.dom.DomUtil.isElement(child,"p|blockquote|ol|ul|table|pre")){

if(child.nodeType==Node.TEXT_NODE&&this._isEmpty(child))
com.coremedia.dom.DomUtil.removeNode(child);
else if(com.coremedia.dom.HtmlDomUtil.isInlineLevel(child)){

if(!(this._isFirefox()&&com.coremedia.dom.DomUtil.isElement(child,"br"))){
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,
"collecting free floating inline content in new <p>",
child);
if(!accu){
accu=this.getDocument().createElement("p");
com.coremedia.dom.DomUtil.insertBefore(accu,child);
}
accu.appendChild(child);
}
}else{
if(accu){
div.insertBefore(child,accu);
accu=null;
}
if(com.coremedia.dom.HtmlDomUtil.isBlockLevelElement(child)&&this._isAllInline(child)){
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,
"converting "+child.nodeName+" to <p>",
child);
var p=this.getDocument().createElement("p");
com.coremedia.dom.DomUtil.moveChildren(child,p);
div.insertBefore(p,child);
}else if(com.coremedia.dom.DomUtil.isElement(child,"div")){
this._normalizeDiv(child);
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,
"removing nested divs from editable content",
child);
com.coremedia.dom.DomUtil.moveChildren(child,div,child.nextSibling);
}else{
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,
"removing superflous nodes from editable content (div children must be p,blockquote,ol,ul,table or pre)",
child);
}
div.removeChild(child);
}
}
child=nextChild;
}
};

$.focus=function(){
if(this._isLoggingEnabled())this._log("focus()");
if(this._editableDiv){
if(this._editWindow){
this._editWindow.focus();
}
this._editableDiv.focus();
}
};

$._isIE=function(){
return com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.IE;
};

$._isNetscape=function(){
return com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.NETSCAPE;
};

$._isFirefox=function(){
return typeof document.createRange=="function";
};

$.getHtmlText=function(){
var value;
if(this._isFirefox()){
value="<div>"+this._editableDiv.innerHTML+"</div>";
}else{
this._removeTopElementAttributes();
value=this._editableDiv.outerHTML;
this._setTopElementAttributes();
}
return value;
};

$.logHtml=function(){
if(this._isLoggingEnabled()){
this._log(this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom(0,"XHtmlEditor: ",this._editableDiv);
}
};






$._getSelectionTextRange=function(){
var range=this._getDocumentSelectionTextRange();
if(!range)return null;

var parent=range.parentElement();
if(com.coremedia.dom.DomUtil.isDescendantOf(parent,this.getElement()))
return range;
return null;
};

$._createTextRange=function(){
return this.getDocument().body.createTextRange();
};

$._getSelection=function(){
return this.getDocument().selection;
};





$.prepareSelection=function(){
if(this._getSelection().type=="Control"){
var range=this._getDocumentSelectionTextRange();
if(range){
range.select();
}
}
};

$._getDocumentSelectionTextRange=function(){
var selection=this._getSelection();
if(selection){
var range=selection.createRange();
switch(selection.type){
case"Text":
case"None":
return range;
case"Control":
var controlElement=range.item(0);
return this._getElementRange(controlElement);
}
}
return null;
};


$._execSelectionCommand=function(cmd,arg1,arg2){
var range=this._getSelectionTextRange();
if(range){
var marker=this._saveSelection();
try{
var element=range.parentElement();
if(this._execCommand(cmd,arg1,arg2)){
this._optimize(element);
return true;
}
}catch(e){this._error("Exception: "+e);}finally{
this._restoreSelection(marker);
}
}
};

$._execCommand=function(cmd,arg1,arg2){
if(this._isLoggingEnabled())this._log("_execCommand(): "+cmd+" arg1: "+arg1+" arg2: "+arg2);

var document=this.getDocument();
if(this._isFirefox()){
document.execCommand(cmd,arg1,arg2);
return true;
}
var activeElement=document.activeElement;
if(!(activeElement&&activeElement==this._editableDiv)){
if(this._isLoggingEnabled())this._log("editable div not active: canceling command");
return false;
}
if(arg1!=undefined&&arg2!=undefined)
document.execCommand(cmd,arg1,arg2);
else if(arg1!=undefined)
document.execCommand(cmd,arg1);
else
document.execCommand(cmd);
return true;
};

$._createLinkInFirefox=function(url){

var range=this._getSelectionTextRange();
if(!this.hasSelection(range))
return false;
var tmp;
var element=com.coremedia.dom.DomUtil.findEnclosingElement(range.startContainer,"A",this._editableDiv);
if(element){
tmp=com.coremedia.dom.DomUtil.findEnclosingElement(range.endContainer,"A",this._editableDiv);
if(tmp!=element)return false;
}else if(range.startContainer.nodeType!=Node.TEXT_NODE){
tmp=range.startContainer.getElementsByTagName("A");
if(tmp){
if(tmp.length>1)return false;
else if(tmp.length==1)element=tmp[1];
}
}
tmp=null;

if(element){
if(this._isLoggingEnabled())this._log("#_createLinkInFirefox: element found "+element.nodeValue?element.nodeValue:element);
if(element.nodeName=="A"){
range.selectNode(element);

tmp=element.href;
}
}
if(!url)
url=this._editWindow.prompt("URL:",tmp?tmp:"http://");
if(!url)
return false;
var resourceUri=url;
var result=true;
if(element&&element.nodeName=="A"){
if(resourceUri){
element.href=resourceUri;
this._setHref(element,url);
}else{
element.href=url;
this._setHref(element);
}
if(this._isLoggingEnabled())this._log("#_createLinkInFirefox: directly set href: "+element.href);
}else{
result=this._execCommand("CreateLink",false,resourceUri?resourceUri:url);
if(this._isLoggingEnabled())this._log("#_createLinkInFirefox: created link: "+resourceUri?resourceUri:url);
}
return result;
};

$._setHref=function(element,url){
return;
if(this._isLoggingEnabled())this._log("#_setHref: "+url);
element.removeAttribute("xlink:href");
if(typeof(url)=="string")
element.setAttribute("xlink:href",url);
};

$.pasteHtml=function(html){
var range=this._getSelectionTextRange();
if(!range){
if(this._isLoggingEnabled())this._log("no selection text range inside editable div, canceling paste");
return false;
}
if(this._isLoggingEnabled())this._log("pasting HTML: '"+html+"'");
this._log("pasting HTML: '"+html+"'");
var div=this.getDocument().createElement("div");

div.innerHTML=html;
try{
return this._pasteElementContent(div,range);
}catch(e){this._error("Exception: "+e);}finally{
com.coremedia.dom.DomUtil.removeNode(div);
}
};

$.paste=function(){
var range=this._getSelectionTextRange();
if(!range){
if(this._isLoggingEnabled())this._log("no selection text range inside editable div, canceling paste");
return;
}
var div=this.getDocument().createElement("div");

this.getDocument().body.appendChild(div);


try{
var text=this.getDocument().createTextNode(" ");
div.appendChild(text);
var divRange=this._createTextRange();
divRange.moveToElementText(div);
divRange.select();
if(typeof divRange.execCommand!="undefined"){
divRange.execCommand("Paste");
}else{
this._execCommand("Paste");
}
if(div.nextSibling){
var loggingEnabled=this._isLoggingEnabled();
while(div.nextSibling){
if(loggingEnabled)
this._log("moving trailing element after paste DIV: "+div.nextSibling.outerHTML);
div.appendChild(div.nextSibling);
}
}
}finally{
com.coremedia.dom.DomUtil.removeNode(div);
}
if(this._detailedLoggingEnabled)
this._log("paste DIV after paste: "+div.outerHTML);
this._pasteElementContent(div,range);
};




$.setEditorElementClass=function(className){
com.coremedia.dom.HtmlDomUtil.setClassAttribute(this.getElement(),className);
};

$.pasteText=function(text){
if(this._isLoggingEnabled()){
this._log("paste text: "+text);
this._log("document.selection.type="+this._getSelection().type);
}
var range=this._getSelectionTextRange();
if(range){
range.text=text;
range.select();
range.scrollIntoView();
}
};

$.cut=function(){this._execCommand("Cut");};
$.copy=function(){this._execCommand("Copy");};

$._isCutAndCopyAllowed=function(){
var sel=this._getSelection();
var range=(sel&&sel.createRange)?sel.createRange():null;
var parentElement=(range&&range.parentElement)?range.parentElement():null;
return dom_DomUtil.isDescendantOf(parentElement,this._editableDiv);
};

$.strong=function(){this.insertInlineElements("STRONG");};
$.emphasize=function(){this.insertInlineElements("EM");};
$.superScript=function(){this.insertInlineElements("SUP");};
$.subScript=function(){this.insertInlineElements("SUB");};




$.removeInlineLevelFormats=function(){
this.removeFormats("inline");
};




$.removeFormats=function(level){
if(this._isFirefox()){
this._execCommand("unlink",false,"");



return this._execCommand("removeFormat",false,"");
}
var marker=this._saveSelection();
try{
var range=this._getSelectionTextRange();
if(!range)return;
var rangeParent=range.parentElement();
if(this._isLoggingEnabled())
com.coremedia.util.Logger.getInstance().logDom(0,"removeFormats(): range parent element: ",rangeParent);
var elements=this._getFormatElements(marker,level,"SPAN",false);
if(this._isLoggingEnabled())
com.coremedia.util.Logger.getInstance().logDom(0,"removeFormats(): range parent element after getFormatElements(): ",rangeParent);
for(var i=0;i<elements.length;i++){
var element=elements[i];
if(level=="inline"||level=="flow")
this._moveOutOfInlineLevel(element);
this._removeFormats(element);
}
if(this._detailedLoggingEnabled)
com.coremedia.util.Logger.getInstance().logDom(0,"removeFormats(): range parent element after upmove & removeFormats: ",rangeParent);
this._optimize(rangeParent);
if(this._detailedLoggingEnabled)
com.coremedia.util.Logger.getInstance().logDom(0,"removeFormats(): range parent element after mergeRedundantElements(): ",rangeParent);
}finally{
this._restoreSelection(marker);
}
};

$._moveOutOfInlineLevel=function(node){
var nonInlineParent=com.coremedia.dom.HtmlDomUtil.findNonInlineParent(node);
var self=this;
if(!com.coremedia.dom.DomUtil.isDescendantOf(node,self._editableDiv))
if(this._isLoggingEnabled())this._log("#_moveOutOfInlineLevel: isDescendantOf(node, self._editableDiv) failed: "+this._getLogSummary(node));


if(nonInlineParent!=node.parentNode){
if(this._detailedLoggingEnabled)
com.coremedia.util.Logger.getInstance().logDom(0,"moving "+this._getLogSummary(node)+" out of inline level:",nonInlineParent);
var rightSubtree=this._splitSubtree(nonInlineParent,node.parentNode,node);
nonInlineParent.insertBefore(node,rightSubtree);
if(this._detailedLoggingEnabled)
com.coremedia.util.Logger.getInstance().logDom(0,"result of moving out of inline level:",nonInlineParent);
}
};

$._insertList=function(listElementName){
if(this._isFirefox()){
var cmd=listElementName=="OL"?"InsertOrderedList":"InsertUnorderedList";
return this._execCommand(cmd,false,"");
}
var marker=this._saveSelection();
try{
var nodes=this._getFormatElements(marker,"_list",null,true);

var removeList=true;
for(var i=0;i<nodes.length;i++){
var node=nodes[i];
if(!com.coremedia.dom.DomUtil.isElement(node,"li")||
!com.coremedia.dom.DomUtil.isElement(node.parentNode,listElementName)){
removeList=false;
break;
}
}
if(this._isLoggingEnabled()){
if(removeList)
this._log("converting "+nodes.length+" LI elements to P");
else
this._log("converting "+nodes.length+" nodes to LIs");
for(var i=0;i<nodes.length;i++){
this._log("  "+this._getLogSummary(nodes[i]));
}
}
for(var i=0;i<nodes.length;i++){
var node=nodes[i];
if(!node.parentNode)
continue;
if(removeList)
this._removeLi(node);
else
this._makeLi(node,listElementName);
}
}finally{
this._restoreSelection(marker);
}
};

$._removeLi=function(node){

var li=node;
var list=li.parentNode;
var listParent=list.parentNode;
var rightSubtree=this._splitSubtree(listParent,list,li);
var insertionPoint=rightSubtree?rightSubtree:list.nextSibling;
var child=li.firstChild;
var newP=null;
while(child){
var nextSibling=child.nextSibling;
if(com.coremedia.dom.HtmlDomUtil.isInlineLevel(child)){
if(!newP){
newP=this.getDocument().createElement("P");

listParent.insertBefore(newP,insertionPoint);
}
newP.appendChild(child);
}else{

listParent.insertBefore(child,insertionPoint);
newP=null;
}
child=nextSibling;
}
com.coremedia.dom.DomUtil.removeNode(li);
if(!list.firstChild)
com.coremedia.dom.DomUtil.removeNode(list);
};

$._makeLi=function(node,listElementName){
if(node.nodeType==Node.TEXT_NODE){
var nonInlineParent=com.coremedia.dom.HtmlDomUtil.findNonInlineParent(node);
var blockContentParent=com.coremedia.dom.DomUtil.findEnclosingElement(node,
com.coremedia.dom.HtmlDomUtil.blockContentElementsRegExp,this._editableDiv);
var flowLevelParent=com.coremedia.dom.DomUtil.findDirectChild(blockContentParent,node);
if(com.coremedia.dom.DomUtil.isElement(blockContentParent,"LI"))
node=blockContentParent;
else{
if(com.coremedia.dom.HtmlDomUtil.isBlockLevelElement(flowLevelParent))
node=flowLevelParent;
else{

var newP=this.getDocument().createElement("P");
blockContentParent.replaceChild(newP,flowLevelParent);
newP.appendChild(flowLevelParent);
while(com.coremedia.dom.HtmlDomUtil.isInlineLevel(newP.previousSibling))
newP.insertBefore(newP.previousSibling,newP.firstChild);
while(com.coremedia.dom.HtmlDomUtil.isInlineLevel(newP.nextSibling))
newP.appendChild(newP.nextSibling);
node=newP;
}
}
}

if(!com.coremedia.dom.DomUtil.isElement(node,"LI")){

var newLi;
if(this._isEmpty(node))
newLi=this._createEmptyElement("LI");
else{
newLi=this.getDocument().createElement("LI");
com.coremedia.dom.DomUtil.moveChildren(node,newLi);
}
var newList=this.getDocument().createElement(listElementName);
newList.appendChild(newLi);
node.parentNode.replaceChild(newList,node);
node=newLi;
}

var list=node.parentNode;

if(!com.coremedia.dom.DomUtil.isElement(list,listElementName)){
var newList=this.getDocument().createElement(listElementName);
com.coremedia.dom.DomUtil.moveChildren(list,newList);
list.parentNode.replaceChild(newList,list);
}

if(com.coremedia.dom.DomUtil.isElement(list.previousSibling,listElementName)){
com.coremedia.dom.DomUtil.moveChildren(list,list.previousSibling);
com.coremedia.dom.DomUtil.removeNode(list);
}else if(com.coremedia.dom.DomUtil.isElement(list.nextSibling,listElementName)){
com.coremedia.dom.DomUtil.moveChildren(list,list.nextSibling,list.nextSibling.firstChild);
com.coremedia.dom.DomUtil.removeNode(list);
}
};

$.indent=function(){
var marker=this._saveSelection();
try{
var nodes=this._getFormatElements(marker,"_list",null,true);
this._log("indenting "+nodes.length+" elements");
var i=0;
while(i<nodes.length){
var node=nodes[i++];
if(com.coremedia.dom.DomUtil.isElement(node,"LI")){
var li=node;
var listElement=li.parentNode;
if(!li.previousSibling&&com.coremedia.dom.DomUtil.isElement(listElement.previousSibling,"OL|UL")){
listElement.previousSibling.appendChild(li);
}
if(com.coremedia.dom.DomUtil.isElement(li.previousSibling,"LI")){
var previousLi=li.previousSibling;
if(com.coremedia.dom.DomUtil.isElement(previousLi.lastChild,"OL|UL"))
previousLi.lastChild.appendChild(li);
else{
var newListElement=this.getDocument().createElement(listElement.nodeName);
previousLi.appendChild(newListElement);
newListElement.appendChild(li);
}
}else{

while(i<nodes.length&&nodes[i].parentNode==listElement)
i++;
}
if(!listElement.firstChild)
com.coremedia.dom.DomUtil.removeNode(listElement);
}else{
this._makeLi(node,"UL");
}
}
}finally{
this._restoreSelection(marker);
}
};

$._elementsBetween=function(child,parent,elementNames){
if(!child||child==parent)
return false;
if(com.coremedia.dom.DomUtil.isElement(child.parentNode,elementNames))
return true;
return this._elementsBetween(child.parentNode,parent,elementNames);
};

$.outdent=function(){
var marker=this._saveSelection();
try{
var lis=this._getFormatElements(marker,"LI",null,true);
this._log("outdenting "+lis.length+" LI elements");
for(var i=0;i<lis.length;i++){
var li=lis[i];
var listElement=li.parentNode;
var parentListItem=com.coremedia.dom.DomUtil.findEnclosingElement(listElement,"LI");
if(parentListItem&&com.coremedia.dom.DomUtil.isDescendantOf(parentListItem,this.getElement())){
var parentList=parentListItem.parentNode;
var rightSubtree=this._splitSubtree(parentListItem,listElement,li);
parentList.insertBefore(li,parentListItem.nextSibling);
if(rightSubtree)
li.appendChild(rightSubtree);
if(!listElement.firstChild)
com.coremedia.dom.DomUtil.removeNode(listElement);


}else{
this._removeLi(li);
}
}
}finally{
this._restoreSelection(marker);
}
};

$.insertOrderedList=function(){this._insertList("OL");};
$.insertUnorderedList=function(){this._insertList("UL");};

$._repairLists=function(){
var self=this;
var range=this._getSelectionTextRange();
if(range){
var parentElement=range.parentElement();
var listElementNames="UL|OL";
var parentList=this._findEditableParentElement(range,listElementNames);
if(parentList)
this._repairLists1(parentList.parentNode,listElementNames);
}
};

$._repairLists1=function(node,listElementNames){
if(node.nodeType!=Node.ELEMENT_NODE)
return;
var nodeIsList=com.coremedia.dom.DomUtil.isElement(node,listElementNames);
var child=node.firstChild;
while(child){
var nextChild=child.nextSibling;
if(nodeIsList&&com.coremedia.dom.DomUtil.isElement(child,listElementNames)){
var li;
if(child.previousSibling&&com.coremedia.dom.DomUtil.isElement(child.previousSibling,"LI"))
li=child.previousSibling;
else{
li=this.getDocument()._createEmptyElement("LI");
node.insertBefore(li,nextChild);
}
li.appendChild(child);
}
this._repairLists1(child,listElementNames);
child=nextChild;
}
};

$.createInternalLink=function(url){
var resourceUri=url;
if(!this._execSelectionCommand("CreateLink",url?false:true,resourceUri))
return false;
var marker=this._saveSelection();
try{
if(url&&marker.parentElement&&com.coremedia.dom.DomUtil.isElement(marker.parentElement,"A")){

this._setHref(marker.parentElement,url);
}
}catch(e){this._error("Exception: "+e);}finally{
this._restoreSelection(marker);
}
return true;
};

$._convertToResourceURI=function(str){
var nonumber=/\D+/;
if(!nonumber.test(str)&&parseInt(str)>0){
if(this._isLoggingEnabled())this._log("converting to resource URI: "+str);
return"coremedia:///cap/content/"+str;
}
return str;
};

$.createLink=function(url){this._execSelectionCommand("CreateLink",url?false:true,url);};
$.insertImage=function(url){this._execSelectionCommand("InsertImage",url?false:true,url);};






$.insertLinkAtCursorPosition=function(url,text){
if(!text)text=url;
var marker=this._saveSelection();
try{
this._getRangeElements(marker);
var beginElement=marker.beginElement;
var endElement=marker.endElement;
var parentElement=marker.parentElement;
var textNode=document.createTextNode(text);
parentElement.insertBefore(textNode,endElement);
}catch(e){this._error("Exception: "+e);}finally{
this._restoreSelection(marker);
}
this.createLink(url);
};





$.hasSelection=function(range){
if(typeof(range)=="undefined")
range=this._getDocumentSelectionTextRange();
if(range){
var text=typeof range.text=="string"?range.text:
typeof range.toString=="function"?range.toString():"";
return text.length>0;
}
return false;
};




$.formatBlock=function(format){
if(format=="<p>"||format=="<pre>")
this._execSelectionCommand("formatBlock",false,format.toUpperCase());
};




$.outdentBlockQuote=function(){
var marker=this._saveSelection();
try{
var blockquotes=this._getFormatElements(marker,"BLOCKQUOTE",null,false);
for(var i=0;i<blockquotes.length;i++){
var bq=blockquotes[i];
var parent=bq.parentNode;
com.coremedia.dom.DomUtil.removeNodeKeepChildren(bq);
if(this._isLoggingEnabled())
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,"removed blockquote:",parent);
}
}finally{
this._restoreSelection(marker);
}
};




$.indentBlockQuote=function(){
var marker=this._saveSelection();
try{
var flowSiblings=this._topmostFlowSiblings(marker);

var first=flowSiblings[0];
var parent=first.parentNode;
var newElement=this.getDocument().createElement("BLOCKQUOTE");
parent.insertBefore(newElement,first);
for(var i=0;i<flowSiblings.length;i++){
var sibling=flowSiblings[i];
if(sibling.nodeType==Node.TEXT_NODE){
var p=this.getDocument().createElement("P");
while(i<flowSiblings.length&&sibling.nodeType==Node.TEXT_NODE){
p.appendChild(sibling);
sibling=flowSiblings[i++];
}
newElement.appendChild(p);
}else
newElement.appendChild(sibling);
}
if(this._isLoggingEnabled())
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,"inserted blockquote:",parent);
var range=this._createTextRange();
range.moveToElementText(newElement);
if(!this.hasSelection(range)){
com.coremedia.dom.DomUtil.removeNode(newElement);
this._log("removed empty blockquote");
}
}catch(e){this._error("Exception: "+e);}finally{
this._restoreSelection(marker);
}
return true;
};

$._topmostFlowSiblings=function(selectionMarker){
if(!selectionMarker)
return[];
this._getRangeElements(selectionMarker);
var beginElement=selectionMarker.beginElement;
var endElement=selectionMarker.endElement;
var parentElement=selectionMarker.parentElement;
while(!com.coremedia.dom.HtmlDomUtil.allowsBlockContent(parentElement))
parentElement=parentElement.parentNode;
var firstSibling=com.coremedia.dom.DomUtil.findDirectChild(parentElement,beginElement);
var lastSibling=com.coremedia.dom.DomUtil.findDirectChild(parentElement,endElement);
if(this._isLoggingEnabled()){
this._log("flow content parent: "+this._getLogSummary(parentElement));
this._log("first sibling: "+this._getLogSummary(firstSibling));
this._log("last sibling: "+this._getLogSummary(lastSibling));
}
var sibling=firstSibling;
var result=new Array();
while(true){
result.push(sibling);
if(sibling==lastSibling)
break;
sibling=sibling.nextSibling;
}
if(firstSibling!=lastSibling)
result.push(lastSibling);
return result;
};



































































$.setFormat=function(level,group,value){
var marker=this._saveSelection();
try{
var isDegeneratedGroup=typeof(value)=="boolean";
if(value=="")value=null;
var prefix=group;
if(!isDegeneratedGroup)
prefix+=this.getFormatVariantSeparator();
var newSelector=value?prefix:null;
if(!isDegeneratedGroup&&value)
newSelector+=value;
this._setFormat(marker,level,prefix,newSelector);
}finally{
this._restoreSelection(marker);
}
if(!this._editWindow){

this.getDocument().focus();
}
};

$._isSelectionInList=function(){
return this.isSelectionInsideElement("OL|UL");
};







$.isSelectionInsideElement=function(elementName){
var range=this._getDocumentSelectionTextRange();
var element=this._findEditableParentElement(range,elementName);
return element!=null;
};









$.getEditableAttributes=function(tag){
if(!tag)return null;
var elementName=tag;

var match=tag.match(/<(.+)>/);
if(match){
elementName=match[1];
}
var range=this._getDocumentSelectionTextRange();
var element=null;
if(elementName=="tr"||elementName=="td"){
var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)
return false;

var cells=spanTableModel.getSelectedCells();
if(cells){
if(elementName=="tr"){

window.__wage__selectedElements=[];
for(var i=0;i<cells.length;i++)
window.__wage__selectedElements.push(cells[i].parentNode);
}
else if(elementName=="td")
window.__wage__selectedElements=cells;
element=window.__wage__selectedElements[0];
}
}else
element=this._findEditableParentElement(range,elementName);
this._log("_findEditableParentElement(range, '"+elementName+"' = "+this._getLogSummary(element));
if(!element)return null;
if(this._getSelection().type=="Control")range.select();
return new com.coremedia.dom.DomElementAttributes(element,this._getEditableAttributeNames(elementName));
};

$._getEditableAttributeNames=function(elementName){
var result=new Array();
switch(elementName){
case"span":
case"p":
case"ul":
case"ol":
case"li":
case"pre":
case"em":
case"strong":
case"sub":
case"sup":
case"a":
case"img":
case"table":
case"tbody":
case"tr":
case"td":
case"blockquote":
result.push("class","lang","dir");
break;
case"br":
result.push("class");
break;
}
switch(elementName){
case"a":
result.push("href","xlink:role","xlink:title","xlink:show","xlink:actuate");
break;
case"table":
result.push("summary");
break;
case"img":
result.push("alt","src","height","width","xlink:role","xlink:title","xlink:show","xlink:actuate");
break;
case"blockquote":
result.push("cite");
break;
}
switch(elementName){
case"tbody":
case"tr":
case"td":
result.push("align","char","charoff","valign");
break;
}
switch(elementName){
case"td":
result.push("abbr");
break;
}
return result;
};




$.getFormatVariantSeparator=function(){
return this._formatVariantSeparator;
};







$.setFormatVariantSeparator=function(separator){
this._formatVariantSeparator=separator;
};

$._setFormat=function(selectionMarker,level,prefix,newSelector){

if(this._isLoggingEnabled())this._log(level+" "+prefix+" "+newSelector);


var rangeParent=this._getRangeParent(selectionMarker);
if(!rangeParent)
return;

var elements=this._getFormatElements(selectionMarker,level,"SPAN",false);

for(var i=0;i<elements.length;i++){
var element=elements[i];
this._mergeFormat(element,prefix,newSelector);
if(level=="inline"||level=="flow")
this._removeFormatFromChildren(element,prefix);
}
var mergeParent=elements.length==1&&com.coremedia.dom.DomUtil.isDescendantOf(rangeParent,elements[0])
?elements[0]
:rangeParent;
this._optimize(mergeParent);
};

$._getRangeParent=function(selectionMarker){
return selectionMarker?selectionMarker.parentElement:null;
};

$.insertInlineElements=function(elementName){

var marker=this._saveSelection(this._isFirefox());
if(marker)
try{
if(this._isFirefox()){
var cmd=fromName=null;
switch(elementName){
case"STRONG":
cmd="bold";
fromName="b";
break;
case"EM":
cmd="italic";
fromName="i";
break;
case"SUB":
cmd="subscript";
break;
case"SUP":
cmd="superscript";
}
if(!cmd)return false;
var result=this._execCommand(cmd,false,"");
if(result&&fromName){
var nodes=this._editableDiv.getElementsByTagName(fromName);
for(i=nodes.length-1;i>=0;i--){
var node=nodes[i];
var tmp=this.getDocument().createElement(elementName);
com.coremedia.dom.DomUtil.moveChildren(node,tmp);
node.parentNode.replaceChild(tmp,node);
}
}
return result;
}
var rangeParent=marker.parentElement;
var elements=this._getFormatElements(marker,"inline",elementName,false);
for(var i=0;i<elements.length;i++){
var element=elements[i];
if(element.nodeName!=elementName){
var newElement=this.getDocument().createElement(elementName);
element.parentNode.insertBefore(newElement,element);
newElement.appendChild(element);
element=newElement;
}
this._removeInlineElementsFromChildren(element,elementName);
}
this._optimize(rangeParent);
}finally{
this._restoreSelection(marker);
}
return false;
};

$._mayBeRedundant=function(node){

return node!=this._editableDiv&&com.coremedia.dom.DomUtil.isElement(node,"SPAN|STRONG|EM|STRIKE|U|I|B|SUB|SUP")&&
!this._isMarker(node);
};

$._isMarker=function(node){
return node&&node.id&&node.id.indexOf(com.coremedia.editing.XHtmlEditor._ID_PREFIX)==0;
};

$._optimize=function(node){
this._mergeRedundantElements(node,true);
if(node!=this._editableDiv)
this._mergeRedundantElements(node,false);
};

$._mergeRedundantElements=function(node,traversalDirectionDown){
if(this._isLoggingEnabled()){
this._log("_mergeRedundantElements(): before mergeRedundantElements():");
this.logHtml();
}
this._mergeRedundantElements0(node,traversalDirectionDown);


if(this._isLoggingEnabled()){
this._log("_mergeRedundantElements(): after mergeRedundantElements():");
this.logHtml();
}
};

$._mergeRedundantElements0=function(node,traversalDirectionDown){
this._mergeRedundantElements1(node,traversalDirectionDown,this._inElement("STRONG"),this._inElement("EM"));
};

$._mergeRedundantElements1=function(node,
traversalDirectionDown,
inStrong,
inEm){
if(!node){
if(this._isLoggingEnabled())this._log("mergeRedundantElements(): node is null?!");
return;
}



if(!node.parentNode){
if(this._isLoggingEnabled())this._log("mergeRedundantElements(): "+node.nodeName+" .parentNode is null?! "+node.innerHTML);
return;
}

if(this._isMarker(node))
return;

if(node.nodeType==Node.TEXT_NODE){
if(node.nodeValue==""&&node.parentNode)
node.parentNode.removeChild(node);
if(node.previousSibling&&node.previousSibling.nodeType==Node.TEXT_NODE){
var textNode=node.previousSibling;
if(typeof textNode.appendData=="function"){
textNode.appendData(node.nodeValue);
}else{
textNode.data+=node.nodeValue;
}
node.parentNode.removeChild(node);
}
return;
}

if(node.nodeType!=Node.ELEMENT_NODE){
node.parentNode.removeChild(node);
return;
}


var parent=node.parentNode;

if(!parent){
if(this._isLoggingEnabled())this._log("mergeRedundantElements(): node.parentNode of "+node.nodeName+" is null, halting.");
return;
}

var isStrong=com.coremedia.dom.DomUtil.isElement(node,"STRONG");
var isEm=com.coremedia.dom.DomUtil.isElement(node,"EM");
var isSpan=com.coremedia.dom.DomUtil.isElement(node,"SPAN");



var child=node.firstChild;
while(child){
var nextChild=child.nextSibling;
if(traversalDirectionDown)
this._mergeRedundantElements1(child,
traversalDirectionDown,
inStrong||isStrong,
inEm||isEm);
if(this._mayBeRedundant(child)){
this._log("checking merge of "+child.nodeName);

if(nextChild&&!this._isMarker(nextChild)&&
nextChild.previousSibling==child&&
child.nodeName==nextChild.nodeName&&
child.nodeType==Node.ELEMENT_NODE&&
nextChild.nodeType==Node.ELEMENT_NODE){
if(this._attributesEqual(child,nextChild)&&
!this._doStyleSelectorsConflict(child,nextChild)){
if(this._isLoggingEnabled()){
this._log("mergeRedundantElements(): merging 2 "+child.nodeName+" nodes:");
this._log("child="+this._getLogSummary(child));
this._log("nextChild="+this._getLogSummary(nextChild));
}
com.coremedia.dom.HtmlDomUtil.mergeAttributes(nextChild,child,this.getFormatVariantSeparator());
com.coremedia.dom.DomUtil.moveChildren(nextChild,child);
com.coremedia.dom.DomUtil.removeNode(nextChild);
nextChild=child;
}else if(this._isLoggingEnabled()){
this._log("merge of "+child.nodeName+
" failed: _attributesEqual(child, nextChild)="+
this._attributesEqual(child,nextChild)+
", this._doStyleSelectorsConflict(child, nextChild)="+
this._doStyleSelectorsConflict(child,nextChild));
}
}
}
child=nextChild;
}


if(!node.firstChild&&this._mayBeRedundant(node)&&this._hasNoOtherThanClassAttribute(node)){
if(this._isLoggingEnabled())
this._log("mergeRedundantElements(): removing "+node.nodeName);
com.coremedia.dom.DomUtil.removeNode(node);
return;
}
if(isSpan||(inStrong&&isStrong)||(inEm&&isEm)){
var className=com.coremedia.dom.HtmlDomUtil.getClassAttribute(node);
if((!className||className=="")&&
this._hasNoOtherThanClassAttribute(node)){
if(this._isLoggingEnabled())
this._log("mergeRedundantElements(): removing "+node.nodeName+", keeping children: "+this._getLogSummary(node));
com.coremedia.dom.DomUtil.removeNodeKeepChildren(node);
return;
}
}







if(this._mayBeRedundant(node)&&node.firstChild&&node.firstChild==node.lastChild){
child=node.firstChild;
if(this._isLoggingEnabled())this._log("trying to merge parent/child: "+node.nodeName+"/"+child.nodeName);
if(child.nodeType==Node.ELEMENT_NODE&&
!this._doStyleSelectorsConflict(node,child)){
if(child.nodeName==node.nodeName||
com.coremedia.dom.DomUtil.isElement(child,"SPAN")||
(com.coremedia.dom.DomUtil.isElement(node,"SUP")&&com.coremedia.dom.DomUtil.isElement(child,"SUB"))||
(com.coremedia.dom.DomUtil.isElement(node,"SUB")&&com.coremedia.dom.DomUtil.isElement(child,"SUP"))){
if(this._isLoggingEnabled())this._log("merge child into parent "+child.nodeName+"/"+node.nodeName);
com.coremedia.dom.HtmlDomUtil.mergeAttributes(child,node,this.getFormatVariantSeparator());
com.coremedia.dom.DomUtil.removeNodeKeepChildren(child);
}else if(isSpan){
if(this._isLoggingEnabled())this._log("merge parent into child "+node.nodeName+"/"+child.nodeName);
com.coremedia.dom.HtmlDomUtil.mergeAttributes(node,child,this.getFormatVariantSeparator());
com.coremedia.dom.DomUtil.removeNodeKeepChildren(node);
}
}
}
if(!traversalDirectionDown&&node!=this._editableDiv)
this._mergeRedundantElements0(parent,traversalDirectionDown);
};

$._attributesEqual=function(element1,element2){
return com.coremedia.dom.HtmlDomUtil.attributesEqual(element1,element2,this._transformAttributeLists[element1.nodeName]);
};

$._inElement=function(node,elementName){
if(!node||node==this._editableDiv)
return false;
var parent=node.parentNode;
if(!parent)return false;
if(com.coremedia.dom.DomUtil.isElement(parent,elementName))return true;
return this._inElement(parent,elementName);
};

$._removeFormats=function(node){
if(node.nodeType!=Node.ELEMENT_NODE)
return;
var child=node.firstChild;
while(child){
var nextChild=child.nextSibling;
this._removeFormats(child);
child=nextChild;
}
com.coremedia.dom.HtmlDomUtil.setClassAttribute(node,null);
if(com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(node)&&!this._isMarker(node))
com.coremedia.dom.DomUtil.removeNodeKeepChildren(node);
};









$._doStyleSelectorsConflict=function(element1,element2){
var selectors1=com.coremedia.dom.HtmlDomUtil.parseStyleSelectors(com.coremedia.dom.HtmlDomUtil.getClassAttribute(element1));
var selectors2=com.coremedia.dom.HtmlDomUtil.parseStyleSelectors(com.coremedia.dom.HtmlDomUtil.getClassAttribute(element2));
for(var i=0;i<selectors1.length;i++){
var selector1=selectors1[i];
for(var j=0;j<selectors2.length;j++){
var selector2=selectors2[j];
if(this._styleSelectorsConflict(selector1,selector2)){
return true;
}
}
}
return false;
};

$._styleSelectorsConflict=function(selector1,selector2){
var result=this._styleSelectorsConflict1(selector1,selector2);
if(this._isLoggingEnabled())this._log("styleSelectorsConflict("+selector1+", "+selector2+")="+result);
return result;
};

$._styleSelectorsConflict1=function(selector1,selector2){
if(!this._styleSelectorsConflictPredicate)
return false;
if(selector1.localeCompare(selector2)>0){
var tmp=selector1;
selector1=selector2;
selector2=tmp;
}
return this._styleSelectorsConflictPredicate.call(this,selector1,selector2);
};

$._allChildrenHaveSameElementName=function(node){
var child=node.firstChild;
while(child){
var nextSibling=child.nextSibling;
if(node.nodeName!=child.nodeName)
return false;
child=nextSibling;
}
return true;
};

$._removeFormatFromChildren=function(element,prefix){
if(element.nodeType==Node.ELEMENT_NODE){
var child=element.firstChild;
while(child){
var nextSibling=child.nextSibling;
if(child.nodeType==Node.ELEMENT_NODE){
this._removeFormatFromChildren(child,prefix);
this._mergeFormat(child,prefix,null);
}
child=nextSibling;
}
}
};

$._removeInlineElementsFromChildren=function(node,elementName){
if(node.nodeType==Node.ELEMENT_NODE){
var child=node.firstChild;
while(child){
var nextSibling=child.nextSibling;
this._removeInlineElementsFromChildren(child,elementName);
if((elementName&&elementName==child.nodeName)||
(!elementName&&com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(child))){
var selectors=com.coremedia.dom.HtmlDomUtil.parseStyleSelectors(com.coremedia.dom.HtmlDomUtil.getClassAttribute(child));
if(selectors.length>0){
var newNode=this.getDocument().createElement("SPAN");
com.coremedia.dom.DomUtil.moveChildren(child,newNode);

node.insertBefore(newNode,child);
node.removeChild(child);
}else{
com.coremedia.dom.DomUtil.removeNodeKeepChildren(child);
}
}
child=nextSibling;
}
}
};







$._mergeFormat=function(element,prefix,newSelector){
if(com.coremedia.dom.DomUtil.isElement(element,"BR"))
return;
var attrValue=com.coremedia.dom.HtmlDomUtil.getClassAttribute(element);
var selectors=com.coremedia.dom.HtmlDomUtil.parseStyleSelectors(attrValue);
var found=false;
var conflictingSelector=null;
for(var i=0;i<selectors.length;i++){
var selector=selectors[i];
if(selector.indexOf(prefix)==0){
found=true;
if(newSelector)
selectors[i]=newSelector;
else{

if(this._isLoggingEnabled())this._log("remove format "+prefix+" from "+element.nodeName);
selectors.splice(i--,1);
}
}else if(this._styleSelectorsConflict(selector,newSelector)){
conflictingSelector=selector;
}
}


if(!found)if(this._isLoggingEnabled())this._log("format "+prefix+" not found in "+element.nodeName+". class="+attrValue);
if(!found&&newSelector){
if(conflictingSelector){
if(this._isLoggingEnabled())
this._log("merging format "+newSelector+" conflicts with "+conflictingSelector+" in "+this._getLogSummary(element));
if(com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(element)){
this._log("wrapping span element");
var span=this.getDocument().createElement("span");
element.parentNode.insertBefore(span,element);
span.appendChild(element);
com.coremedia.dom.HtmlDomUtil.setClassAttribute(span,newSelector);
return;
}
}
selectors[selectors.length]=newSelector;
}
var newAttrValue=com.coremedia.dom.HtmlDomUtil.unparseStyleSelectors(selectors);
com.coremedia.dom.HtmlDomUtil.setClassAttribute(element,newAttrValue);

};

$._hasNoOtherThanClassAttribute=function(element){
var transformAttributeList=this._transformAttributeLists[element.nodeName];
if(transformAttributeList){
for(var i=0;i<transformAttributeList.length;i+=2){
var attrName=transformAttributeList[i];
if(attrName!="className"){
var value=element.getAttribute(attrName,2);
if(value)
return false;
}
}
}
return true;
};










$._getFormatElements=function(selectionMarker,level,newInlineElementName,outermostOnly){
var accu=new Array(0);
var self=this;
if(selectionMarker){
this._getRangeElements(selectionMarker);
var beginElement=selectionMarker.beginElement;
var endElement=selectionMarker.endElement;
var parentElement=selectionMarker.parentElement;
if(level=="inline"||level=="flow"){

while(beginElement.parentNode!=parentElement&&
this._noSiblingContentBefore(beginElement)&&
com.coremedia.dom.HtmlDomUtil.allowsInlineContent(beginElement.parentNode.parentNode))
beginElement.parentNode.parentNode.insertBefore(beginElement,beginElement.parentNode);
while(endElement.parentNode!=parentElement&&
this._noSiblingContentAfter(endElement)&&
com.coremedia.dom.HtmlDomUtil.allowsInlineContent(endElement.parentNode.parentNode))
endElement.parentNode.parentNode.insertBefore(endElement,endElement.parentNode.nextSibling);
}
if(parentElement!=this._editableDiv&&
parentElement==beginElement.parentNode&&
parentElement==endElement.parentNode&&
this._noSiblingContentBefore(beginElement)&&
this._noSiblingContentAfter(endElement)&&
this._isNodeInLevel(parentElement,level)&&
com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(parentElement)){
accu.push(parentElement);
}else{
this._collectFormatElements(beginElement,parentElement,endElement,level,newInlineElementName,accu,outermostOnly);
}
}
if(this._isLoggingEnabled()){
var msg="_getFormatElements(): [";
for(var i=0;i<accu.length;i++){
if(i>0)msg+=", ";
msg+=accu[i].nodeName;
}
msg+="]";
this._log(msg);
}
return accu;
};

$._getRangeElements=function(selectionMarker){
var self=this;
var beginElement=this.getDocument().getElementById(selectionMarker.beginId);
var endElement=selectionMarker.endId?this.getDocument().getElementById(selectionMarker.endId):beginElement;
var parentElement=selectionMarker.parentElement;
this._log("beginId="+selectionMarker.beginId);



var oldParentElement=parentElement;
if(this._isLoggingEnabled()&&this._detailedLoggingEnabled){
this._log("parentElement: "+this._getLogSummary(parentElement));
this._log("beginElement: "+this._getLogSummary(beginElement));
this._log("endElement: "+this._getLogSummary(endElement));
com.coremedia.util.Logger.getInstance().logDom(com.coremedia.util.Logger.LEVEL_DEBUG,"XHtmlEditor#_getRangeElements",this._editableDiv);
}



while(!com.coremedia.dom.DomUtil.isDescendantOf(beginElement,parentElement)||
!com.coremedia.dom.DomUtil.isDescendantOf(endElement,parentElement))
parentElement=parentElement.parentNode;
if(parentElement!=oldParentElement&&this._isLoggingEnabled()){
this._log("adjusted parentElement: "+this._getLogSummary(parentElement));
}


selectionMarker.beginElement=beginElement;
selectionMarker.endElement=endElement;
selectionMarker.parentElement=parentElement;
};

$._isContentNode=function(node){
switch(node.nodeType){
case Node.TEXT_NODE:
case Node.ELEMENT_NODE:
return true;
}
return false;
};

$._noSiblingContentBefore=function(node){
node=node.previousSibling;
while(node){
if(this._isContentNode(node))
return false;
node=node.previousSibling;
}
return true;
};

$._noSiblingContentAfter=function(node){
node=node.nextSibling;
while(node){
if(this._isContentNode(node))
return false;
node=node.nextSibling;
}
return true;
};

$._collectFormatElements=function(beginElement,rootElement,endElement,
level,newInlineElementName,accu,outermostOnly){
if(this._isLoggingEnabled())this._log("root element: "+this._getLogSummary(rootElement));
var currentLeft=beginElement;
var currentRight=endElement;
var count=accu.length;
var defaultIncludeAncestor=level!="inline"&&level!="flow";
var includeAncestor=defaultIncludeAncestor;
while(currentLeft.parentNode!=rootElement){
var sibling=currentLeft.nextSibling;
if(!this._tryToWrapAll(sibling,currentLeft.parentNode.lastChild,level,newInlineElementName,accu)){
while(sibling){

var nextSibling=sibling.nextSibling;
includeAncestor=!this._collectFormatElements1(sibling,level,newInlineElementName,accu,true)||includeAncestor;
sibling=nextSibling;
}
}
currentLeft=currentLeft.parentNode;
if(currentLeft!=this._editableDiv&&this._isNodeInLevel(currentLeft,level)){
if(outermostOnly)this._removeTrailingDescendants(currentRight,accu,count);
if(outermostOnly||includeAncestor)
accu.push(currentLeft);
includeAncestor=false;
}
}
includeAncestor=defaultIncludeAncestor;

var rightAccu=new Array();
while(currentRight.parentNode!=rootElement){
var sibling=currentRight.previousSibling;
if(!this._tryToWrapAll(currentRight.parentNode.firstChild,sibling,level,newInlineElementName,rightAccu)){
while(sibling){
var nextSibling=sibling.previousSibling;
includeAncestor=!this._collectFormatElements1(sibling,level,newInlineElementName,rightAccu,false)||includeAncestor;
sibling=nextSibling;
}
}
currentRight=currentRight.parentNode;
if(currentRight!=currentLeft&&currentRight!=this._editableDiv&&this._isNodeInLevel(currentRight,level)){
if(outermostOnly)this._removeTrailingDescendants(currentRight,rightAccu,count);
if(outermostOnly||includeAncestor)
rightAccu.push(currentRight);
includeAncestor=false;
}
}
includeAncestor=false;
if(currentLeft!=currentRight){
var current=currentLeft.nextSibling;
if(!this._tryToWrapAll(current,currentRight.previousSibling,level,newInlineElementName,accu)){
while(current&&current!=currentRight){
var sibling=current.nextSibling;
this._collectFormatElements1(current,level,newInlineElementName,accu,true);
includeAncestor=includeAncestor||
(this._isContentNode(current)&&!this._isNodeInLevel(current,level));
current=sibling;
}
}
}
for(var i=0;i<rightAccu.length;i++){
accu.push(rightAccu[i]);
}
if(level!="inline"&&level!="flow"&&(includeAncestor||accu.length==count)){
var matchingAncestor=this._findMatchingAncestor(rootElement,this._editableDiv,level);
if(matchingAncestor&&matchingAncestor!=this._editableDiv){
if(outermostOnly)this._removeTrailingDescendants(rootElement,accu,count);
accu.push(matchingAncestor);
}
}
};

$._removeTrailingDescendants=function(element,accu,stop){
while(accu.length>stop&&com.coremedia.dom.DomUtil.isDescendantOf(accu[accu.length-1],element))
accu.pop();
};

$._tryToWrapAll=function(firstSibling,lastSibling,
level,newInlineElementName,accu){
var sibling=firstSibling;
if((level!="inline"&&level!="flow")||!sibling)
return false;
while(true){
if(!com.coremedia.dom.HtmlDomUtil.isInlineLevel(sibling))
return false;
if(sibling==lastSibling)
break;
sibling=sibling.nextSibling;
};
var newElement=this.getDocument().createElement(newInlineElementName);
var parent=firstSibling.parentNode;
parent.insertBefore(newElement,firstSibling);
sibling=firstSibling;
while(true){
var nextSibling=sibling.nextSibling;
newElement.appendChild(sibling);
if(sibling==lastSibling)
break;
sibling=nextSibling;
}
accu.push(newElement);
return true;
};

$._findMatchingAncestor=function(node,root,level){
var result=null;
if(!result&&this._isNodeInLevel(node,level))
result=node;
if(!result&&node!=root)
result=this._findMatchingAncestor(node.parentNode,root,level);
return result;
};



$._collectFormatElements1=function(node,level,newInlineElementName,accu,direction){
var self=this;
var inLevel=this._isNodeInLevel(node,level);
if(inLevel&&(level=="inline"||level=="flow")&&newInlineElementName&&this._isNodeInLevel(node,"inline")){
var previouslyCollected=accu.length>0?accu[accu.length-1]:null;
if(direction&&previouslyCollected&&previouslyCollected.nextSibling==node&&previouslyCollected.nodeName==newInlineElementName){
previouslyCollected.appendChild(node);
return true;
}else if(!direction&&previouslyCollected&&previouslyCollected.previousSibling==node&&previouslyCollected.nodeName==newInlineElementName){
previouslyCollected.insertBefore(node,previouslyCollected.firstChild);
return true;
}
}
switch(node.nodeType){
case Node.TEXT_NODE:
if(inLevel){
if(newInlineElementName){
var newElement=this.getDocument().createElement(newInlineElementName);
node.parentNode.insertBefore(newElement,node);
newElement.appendChild(node);

accu.push(newElement);
}else{
accu.push(node);
}
return true;
}else
return false;
case Node.ELEMENT_NODE:
if(inLevel){
if(!com.coremedia.dom.DomUtil.isDescendantOf(node,self._editableDiv))
this._log("### _collectFormatElements1(): isDescendantOf(node, self._editableDiv) failed: "+this._getLogSummary(node));

accu.push(node);
return true;
}
var result=true;
var child=node.firstChild;
while(child){
var nextSibling=child.nextSibling;
result=result&&this._collectFormatElements1(child,level,newInlineElementName,accu,true);
child=nextSibling;
}
return result;
}
return false;
};

$._isEmptyRange=function(range){
return range.compareEndPoints("StartToEnd",range)==0;
};

$._getElementRange=function(element){
var range=this._createTextRange();
range.moveToElementText(element);
return range;
};

$._rangesIntersect=function(range1,range2){
return!(range1.compareEndPoints("StartToEnd",range2)>=0||
range1.compareEndPoints("EndToStart",range2)<=0);
};

$._rangeContains=function(range1,range2){
return range1.compareEndPoints("StartToStart",range2)<=0&&
range1.compareEndPoints("EndToEnd",range2)>=0;
};

$.insertTable=function(rows,cols){
if(typeof(rows)=="undefined")rows=3;
if(typeof(cols)=="undefined")cols=4;
if(this._isLoggingEnabled())this._log("insertTable("+rows+","+cols+")");

var cellHtml=this._isFirefox()?"<td><br/></td>":"<td></td>";
var html="<table>";
for(var r=0;r<rows;r++){
html+="<tr>";
for(var c=0;c<cols;c++){
html+=cellHtml;
}
html+="</tr>";
}
html+="</table>";
return this.pasteHtml(html);
};

$._getSpanTableModel=function(){
var range=this._getSelectionTextRange();
if(!range)
return null;
return com.coremedia.editing.SpanTableModel.fromTextRange(range,this.getElement());
};

$.insertTableRows=function(before,rowsToInsert){
if(rowsToInsert==undefined)rowsToInsert=1;

if(this._isLoggingEnabled())this._log("insertTableRows()");

var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)return;

var table=spanTableModel.getTable();
var currentCell=before
?spanTableModel.getFirstSelectedCell()
:spanTableModel.getLastSelectedCell();

if(currentCell){
var nCols=spanTableModel.getColumnCount();
var y=before
?spanTableModel.getCoordinates(currentCell).y
:spanTableModel.getLowerRightEdge(currentCell).y;
for(var r=0;r<rowsToInsert;r++){
var newRow=this.getDocument().createElement("tr");
var x=0;
while(x<nCols){
var cell=spanTableModel.getCell(x,y);
var upperLeftEdge=spanTableModel.getUpperLeftEdge(cell);
var lowerRightEdge=spanTableModel.getLowerRightEdge(cell);
if(before
?upperLeftEdge.y<y&&lowerRightEdge.y>=y
:upperLeftEdge.y<=y&&lowerRightEdge.y>y){

cell.rowSpan++;
x+=cell.colSpan;




}else{
var newCell=this._createEmptyElement("td");
com.coremedia.dom.HtmlDomUtil.setColSpan(newCell,cell.colSpan);
newRow.appendChild(newCell);
x+=newCell.colSpan;
}
}
var row=table.rows[y];
row.parentNode.insertBefore(newRow,before?row:row.nextSibling);
}
}else{

if(this._isLoggingEnabled())this._log("insertTableRows(): no parent table row element found");
}
};

$.insertTableColumns=function(before,columnsToInsert){
if(columnsToInsert==undefined)columnsToInsert=1;
if(this._isLoggingEnabled())this._log("insertTableColumns()");
var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)return;

var table=spanTableModel.getTable();
var nRows=spanTableModel.getRowCount();
var currentCell=before
?spanTableModel.getFirstSelectedCell()
:spanTableModel.getLastSelectedCell();
if(currentCell){
var nCols=spanTableModel.getColumnCount();
var x=before
?spanTableModel.getCoordinates(currentCell).x
:spanTableModel.getLowerRightEdge(currentCell).x;
for(var i=0;i<columnsToInsert;i++){
var y=0;
while(y<nRows){
var cell=spanTableModel.getCell(x,y);
var upperLeftEdge=spanTableModel.getUpperLeftEdge(cell);
var lowerRightEdge=spanTableModel.getLowerRightEdge(cell);
if(before
?upperLeftEdge.x<x&&lowerRightEdge.x>=x
:upperLeftEdge.x<=x&&lowerRightEdge.x>x){

cell.colSpan++;
y+=cell.rowSpan;





}else{
var newCell=this._createEmptyElement("td");
com.coremedia.dom.HtmlDomUtil.setRowSpan(newCell,cell.rowSpan);
var nextSibling=this._findInsertionPoint(spanTableModel,x+(before?0:1),y);
var row=table.rows[y];
row.insertBefore(newCell,nextSibling);
y+=newCell.rowSpan;
}
}
}
}else{

if(this._isLoggingEnabled())this._log("insertTableColumns(): no parent table row element found");
}
};





$._findInsertionPoint=function(spanTableModel,destX,destY){
var row=spanTableModel.getRow(destY);
var x=0;
var nextSibling=null;
if(row.cells.length>0){
nextSibling=row.cells[0];
while(nextSibling&&x<destX){

var underlyingCell=spanTableModel.getCell(x,destY);
x+=underlyingCell.colSpan;
if(underlyingCell==nextSibling){
nextSibling=nextSibling.nextSibling;
}
}
}
return nextSibling;
};

$.joinTableCells=function(){
var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)
return;
var rect=spanTableModel.getSelectedRectangle();

if(rect){
var cells=spanTableModel.getSelectedCells();
if(cells.length>1){
var targetCell=cells[0];
for(var i=1;i<cells.length;i++){
var cell=cells[i];

while(cell.childNodes.length>0)
targetCell.appendChild(cell.childNodes[0]);
cell.parentNode.removeChild(cell);
}
if(rect.height>1)
targetCell.rowSpan=rect.height;
if(rect.width>1)
targetCell.colSpan=rect.width;
}
}
};





$.splitTableCells=function(horizontally){
if(this._isLoggingEnabled())this._log("com.coremedia.editing.XHtmlEditor#splitTableCells");
var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)
return;
var cells=spanTableModel.getSelectedCells();
if(cells.length>0){
if(this._isLoggingEnabled())this._log("trying to split "+cells.length+" cells");
for(var i=0;i<cells.length;i++){
var cell=cells[i];
if((horizontally&&cell.colSpan>1)||(!horizontally&&cell.rowSpan>1)){
var newCell=this._createEmptyElement("td");
var upperLeftEdge=spanTableModel.getUpperLeftEdge(cell);
var row;
var nextSibling;
if(horizontally&&cell.colSpan>1){

var oldCellColSpan=Math.floor(cell.colSpan/2);
var newCellColSpan=Math.ceil(cell.colSpan/2);

com.coremedia.dom.HtmlDomUtil.setRowSpan(newCell,cell.rowSpan);
com.coremedia.dom.HtmlDomUtil.setColSpan(newCell,newCellColSpan);
com.coremedia.dom.HtmlDomUtil.setColSpan(cell,oldCellColSpan);
if(this._isLoggingEnabled())this._log("colSpan split: "+oldCellColSpan+"/"+newCellColSpan);
row=spanTableModel.getRow(upperLeftEdge.y);

nextSibling=cell.nextSibling;
}else if(!horizontally&&cell.rowSpan>1){
var oldCellRowSpan=Math.floor(cell.rowSpan/2);
var newCellRowSpan=Math.ceil(cell.rowSpan/2);

com.coremedia.dom.HtmlDomUtil.setColSpan(newCell,cell.colSpan);
com.coremedia.dom.HtmlDomUtil.setRowSpan(newCell,newCellRowSpan);
com.coremedia.dom.HtmlDomUtil.setRowSpan(cell,oldCellRowSpan);
if(this._isLoggingEnabled())this._log("rowSpan split: "+oldCellRowSpan+"/"+newCellRowSpan);


var splitY=upperLeftEdge.y+oldCellRowSpan;
nextSibling=this._findInsertionPoint(spanTableModel,upperLeftEdge.x,splitY);
row=spanTableModel.getRow(splitY);
}
if(this._isLoggingEnabled())this._log("inserting cell at row "+row.rowIndex
+(nextSibling
?" before cell #"+nextSibling.cellIndex
:"at end of row"));
row.insertBefore(newCell,nextSibling);
}else
if(this._isLoggingEnabled())this._log("cannot split cell "
+(horizontally?"horizont":"vertic")
+"ally (rowSpan="+cell.rowSpan
+",colSpan="+cell.colSpan+"), ignored");
}
}
};

$.removeTableRows=function(){
var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)
return;
var rect=spanTableModel.getSelectedRectangle();
if(rect){
var table=spanTableModel.getTable();
var nDeletedRows=rect.height;
var nCols=spanTableModel.getColumnCount();
if(nDeletedRows==spanTableModel.getRowCount()){

table.parentNode.removeChild(table);
}else{

if(rect.y>0){
var x=0;
while(x<nCols){
var cell=spanTableModel.getCell(x,rect.y-1);
var bottom=spanTableModel.getLowerRightEdge(cell).y;
var ule=spanTableModel.getUpperLeftEdge(cell);
if(bottom>=rect.y){
var newRowSpan=cell.rowSpan-Math.min(bottom-rect.y+1,nDeletedRows);
if(this._isLoggingEnabled())this._log("adjusting cell "+ule.x+","+" rowSpan="+cell.rowSpan+" to "+newRowSpan);
com.coremedia.dom.HtmlDomUtil.setRowSpan(cell,newRowSpan);
}else{
if(this._isLoggingEnabled())this._log("did not adjust cell "+ule.x+","+ule.y+" rowSpan="+cell.rowSpan);
}
x+=cell.colSpan;
}

}




var rowBelowDeletedRows=rect.y+rect.height;
if(rowBelowDeletedRows<table.rows.length){
var row=table.rows[rowBelowDeletedRows];
var x=0;
var c=0;
var insertionPoint=c<row.cells.length?row.cells[c++]:null;
while(x<nCols){
var cell=spanTableModel.getCell(x,rowBelowDeletedRows);
if(cell==insertionPoint)
insertionPoint=c<row.cells.length?row.cells[c++]:null;
else{
var y=spanTableModel.getUpperLeftEdge(cell).y;
if(y>=rect.y&&y<rowBelowDeletedRows){

com.coremedia.dom.HtmlDomUtil.setRowSpan(cell,y+cell.rowSpan-(rect.y+rect.height));

row.insertBefore(cell,insertionPoint);
}
}
x+=cell.colSpan;
}

}

for(var i=0;i<nDeletedRows;i++){
var row=table.rows[rect.y];
com.coremedia.dom.DomUtil.removeNode(row);
}
}
}
};

$.removeTableColumns=function(){
var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)
return;
var rect=spanTableModel.getSelectedRectangle();
if(rect){
var table=spanTableModel.getTable();
var nColumns=rect.width;
if(nColumns==spanTableModel.getColumnCount()){

table.parentNode.removeChild(spanTableModel.getTable());
}else{
var nRows=table.rows.length;

for(var x=rect.x;x<rect.x+rect.width;x++){

var y=0;
while(y<nRows){
var row=spanTableModel.getRow(y);
var cell=spanTableModel.getCell(x,y);
y+=cell.rowSpan;
if(cell.colSpan==1)
com.coremedia.dom.DomUtil.removeNode(cell);
else
com.coremedia.dom.HtmlDomUtil.setColSpan(cell,cell.colSpan-1);
}
}
}
}
};






$._findEditableParentElement=function(range,elementName){
if(!range)
return null;
var parentElement;
if(range.parentElement)
parentElement=range.parentElement();
if(!parentElement&&range.length==1){
parentElement=range.item(0);
this._log("control range");
}
this._log("parentElement: "+this._getLogSummary(parentElement));
var element=com.coremedia.dom.DomUtil.findEnclosingElement(parentElement,elementName);
this._log("findEnclosingElement(parentElement, '"+elementName+"')="+this._getLogSummary(element));
if(!com.coremedia.dom.DomUtil.isDescendantOf(element,this.getElement()))
return null;
return element;
};

$._saveToplevelSiblings=function(targetElement){


var toplevelElement=null;
if(targetElement!=this._editableDiv){
toplevelElement=targetElement;
while(toplevelElement&&toplevelElement.parentNode!=this._editableDiv){
toplevelElement=toplevelElement.parentNode;
}
}
var previousToplevelSibling=toplevelElement?toplevelElement.previousSibling:null;
var nextToplevelSibling=toplevelElement?toplevelElement.nextSibling:null;
return{previous:previousToplevelSibling,next:nextToplevelSibling};
};

$._getDomPath=function(node,root){
if(!root)root=this._editableDiv;
if(node==root)return node.nodeName;
if(!node)return"";
return this._getDomPath(node.parentNode,root)+"."+node.nodeName;
};

$._getLogSummary=function(node){
if(!node)return""+node;
return this._getDomPath(node,this._editableDiv)+" "+this._getLogSummary1(node);
};

$._getLogSummary1=function(node){
var self=this;
if(!node.nodeType)return"undefined node type, nodeName is: "+node.nodeName;
var result="";
switch(node.nodeType){
case Node.ELEMENT_NODE:
var element=node;
result=!element?(""+element):element.outerHTML?element.outerHTML:element.nodeValue;
break;
case Node.COMMENT_NODE:
result="#comment "+node.nodeValue;
break;
case Node.TEXT_NODE:
result="'"+node.nodeValue+"'";
break;
case Node.ATTRIBUTE_NODE:
result="#attribute "+node.nodeValue;
break;
case Node.DOCUMENT_NODE:
result="#document "+node.nodeValue;
break;
case Node.DOCUMENT_FRAGMENT_NODE:
result="#documentfragment "+node.nodeValue;
break;
}
return result.length>60
?result.substr(0,60)+"..."
:result;
};

$._checkSelectionForOrphans=function(){
this._log("checkSelectionForOrphans()");
var range=this._getSelectionTextRange();
if(range&&this._isEmptyRange(range)){
var parent=range.parentElement();
if(parent==this._editableDiv){
var i=0;
var children=this._editableDiv.childNodes;
while(i<children.length){
var child=children[i];
if(child.nodeType==Node.TEXT_NODE){
var nChars=child.nodeValue.length;

this._checkNode(child);

range.moveToElementText(children[i]);
range.collapse(true);
range.move("character",nChars);
range.select();
}else if(children[i]==child)
i++;
}
}
}
};



$._checkLists=function(){
if(this._isLoggingEnabled())this._log("_checkLists");
var range=this._getSelectionTextRange();
var doc=this.getDocument();
if(range&&this._isEmptyRange(range)){
var element=range.parentElement();
while(element!=this._editableDiv){
if(com.coremedia.dom.DomUtil.isElement(element,"OL|UL")){
var child=element.firstChild;
while(child){
var next=child.nextSibling;
if(com.coremedia.dom.DomUtil.isElement(child,"LI")){
if(this._isFirefox()&&!child.firstChild){

if(!child.nextSibling||com.coremedia.dom.DomUtil.isElement(child.nextSibling,"LI"))
child.appendChild(doc.createElement("BR"));
}
}else{
var marker=this._saveSelection();
try{
if(com.coremedia.dom.DomUtil.isElement(child.previousSibling,"LI")){
this._log("reparing list: moving non-LI child of "+element.nodeName+" into previous sibling LI: "+this._getLogSummary(element));
child.previousSibling.appendChild(child);
}else{
this._log("reparing list: wrapping non-LI child of "+element.nodeName+" into new LI: "+this._getLogSummary(element));
var newLi=doc.createElement("LI");
element.insertBefore(newLi,child);
newLi.appendChild(child);
}
if(this._isLoggingEnabled())this._log("result list: "+this._getLogSummary(element));
}finally{
this._restoreSelection(marker);
}
}
child=next;
}
}
element=element.parentNode;
}
}
};

$._selectRowOrColumn=function(selectRow){
if(this._isLoggingEnabled())this._log("_selectRowOrColumn("+selectRow+")");
var self=this;

var spanTableModel=this._getSpanTableModel();
if(!spanTableModel)
return false;

var table=spanTableModel.getTable();
var currentCell=spanTableModel.getFirstSelectedCell();

if(currentCell){

spanTableModel._getCellRange=function(x,y){
var range=self._createTextRange();
var node=table.firstChild.rows[y].cells[x];
if(self._isFirefox())
range.selectNode(node);
else
range.moveToElementText(node);
return range;
};

var coords=spanTableModel.getCoordinates(currentCell);
var rowIndex=selectRow?coords.y:0;
var colIndex=selectRow?0:coords.x;
var endIndex=selectRow?spanTableModel.getColumnCount()-1:spanTableModel.getRowCount()-1;

if(this._isFirefox()){
var selection=this._getSelection();
selection.removeAllRanges();
for(i=0;i<=endIndex;i++)
selection.addRange(spanTableModel._getCellRange(selectRow?i:colIndex,selectRow?rowIndex:i));
}else{
var range=spanTableModel._getCellRange(colIndex,rowIndex);
range.setEndPoint("EndToEnd",spanTableModel._getCellRange(
selectRow?endIndex:colIndex,
selectRow?rowIndex:endIndex));
range.select();
}
spanTableModel._getCellRange=null;
return true;
}else{
if(this._isLoggingEnabled())this._log("_selectRowOrColumn(): no cells selected");
return false;
}
};

$.selectTableColumn=function(){
return this._selectRowOrColumn(false);
};

$.selectTableRow=function(){
return this._selectRowOrColumn(true);
};

$._onfocus=function(event){
this._checkSelectionForOrphans();
return true;
};

$.processDblclick=function(event){
if(this._isLoggingEnabled())this._log("#processDblClick");
var e=event.getOriginal();
if(com.coremedia.dom.DomUtil.isElement(e.target,"A|IMG")){

var element=e.target;
var url;
var target="_blank";
if(com.coremedia.dom.DomUtil.isElement(element,"A")){
if(element.target)
target=element.target;
url=element.href;
}else if(com.coremedia.dom.DomUtil.isElement(element,"IMG")){
var src=element.src;
if(src){
var tmp=src.split("?");
url=tmp[0].replace(/blob.do/gi,"showDocumentWindow.do");
var arr=tmp[1].split("&");
for(i=0;i<arr.length;i++){
tmp=arr[i];
if(tmp.indexOf("resource")==0){
url=url+"?"+tmp;
break;
}
}
}
}else{
this._log("unable to open link for "+element);
}
window.open(url,target,com.coremedia.editing.Browser.WINDOW_PARAMETERS).focus();
return false;
}else{

if(typeof wage_AttributeEditor!="undefined"){
wage.AttributeEditor.openAttributeEditor(this,true);
return false;
}
}
return true;
};

$._onkeydown=function(e){
if(this._isLoggingEnabled()&&this._detailedLoggingEnabled){
this._log("onkeydown received event "+e);
}
var stopPropagation=false;
if(e.ctrlKey&&!e.metaKey&&!e.shiftKey&&!e.altKey){

switch(String.fromCharCode(e.getKeyCode())){
case"V":
e.preventDefault();
stopPropagation=true;
com.coremedia.editing.XHtmlClipboardHelper.paste(this);
break;
case"T":
e.preventDefault();
stopPropagation=true;
var clipboard=com.coremedia.editing.Clipboard.getSystemClipboard();
var transferable=clipboard.getContents();
var text=transferable.getTransferableData("text/unicode");
if(typeof(text)!="string")
text="";
this.pasteHtml(text);
break;
case"Z":
case"Y":

e.preventDefault();
stopPropagation=true;
break;

}
}else if(!e.getCtrlKeyPressed()&&!e.getMetaKeyPressed()&&e.getShiftKeyPressed()&&!e.getAltKeyPressed()){
switch(e.getKeyCode()){
case 45:
e.preventDefault();
stopPropagation=true;
com.coremedia.editing.XHtmlClipboardHelper.paste(this);
break;
}
}
return stopPropagation;
};

$.processPaste=function(e){
e.preventDefault();
e.stopPropagation();
com.coremedia.editing.XHtmlClipboardHelper.paste(this);
return true;
};

com.coremedia.editing.XHtmlEditor._ID_PREFIX="_CoreMedia_XHtmlEditor_ID_";

$._generateId=function(){
var n=this._idCounter;
if(!n)n=1;
while(true){
var id=com.coremedia.editing.XHtmlEditor._ID_PREFIX+n++;
if(!this.getDocument().getElementById(id)){
this._idCounter=n;
return id;
}
n++;
}
};

$._pasteElementContent=function(element,range){
this._errors=false;
var self=this;
if(this._isLoggingEnabled())
this._log("pasting content of: "+element.outerHTML);
if(this._detailedLoggingEnabled){
this._log("ediv before paste: "+this._editableDiv.outerHTML);
}
if(!range){
this._log("_pasteElementContent(): no selection text range inside editable div, canceling paste");
return false;
}
var id=self._generateId();
range.pasteHTML("<span id="+id+" />");
if(this._detailedLoggingEnabled){
this._log("contenteditable DIV after paste of SPAN: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV after paste of SPAN: ",this._editableDiv);
}
var span=this.getDocument().getElementById(id);


try{
var nonInlineParent=com.coremedia.dom.HtmlDomUtil.findNonInlineParent(span);

if(nonInlineParent!=span.parentNode){
var rightSubtree=this._splitSubtree(nonInlineParent,span.parentNode,span);
if(this._detailedLoggingEnabled){
this._log("contenteditable DIV after split at helper SPAN, before moving helper SPAN: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV after split at helper SPAN, before moving helper SPAN: ",this._editableDiv);
}
nonInlineParent.insertBefore(span,rightSubtree);
if(this._detailedLoggingEnabled){
this._log("contenteditable DIV after split at helper SPAN, after moving helper SPAN: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV after split at helper SPAN, after moving helper SPAN: ",this._editableDiv);
}
this._mergeRedundantElements(nonInlineParent,true);
}
if(this._detailedLoggingEnabled){
this._log("contenteditable DIV before children movement: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV before children movement: ",this._editableDiv);
}
self._transformChildren(element,span.parentNode,span);
}finally{

var nodeToRemove=span;
while(nodeToRemove.parentNode!=this._editableDiv&&nodeToRemove.parentNode.childNodes.length==1)
nodeToRemove=nodeToRemove.parentNode;
range.moveToElementText(span);
range.collapse(false);
range.select();
range.scrollIntoView();
com.coremedia.dom.DomUtil.removeNode(nodeToRemove);
}
if(this._detailedLoggingEnabled){
this._log("contenteditable DIV after children movement: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV after children movement: ",this._editableDiv);
}
if(this._errors)
this._log("### There where errors during paste.");
};

$._insertElementContent=function(element,target,insertionPoint){
this._errors=false;
var self=this;
if(this._detailedLoggingEnabled){
this._log("inserting content of: "+element.outerHTML);
this._log("ediv before insert: "+this._editableDiv.outerHTML);
this._log("contenteditable DIV before children movement: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV before children movement: ",this._editableDiv);
}
self._transformChildren(element,target,insertionPoint);
if(this._detailedLoggingEnabled){
this._log("contenteditable DIV after children movement: "+this._editableDiv.outerHTML);
com.coremedia.util.Logger.getInstance().logDom("DOM of contenteditable DIV after children movement: ",this._editableDiv);
}
if(this._errors)
this._log("### There where errors during insert");
};

$._ondragstart=function(event){
_CAP_inDnD=true;
return false;
};

$._ondragend=function(event){
_CAP_inDnD=false;
return false;
};

$._ondragover=function(event){
var original=event.getOriginal();
var isUrl=original.dataTransfer&&original.dataTransfer.getData("URL");
if(isUrl){
if(this.hasSelection()){
event.preventDefault();
return true;
}
}
return false;
};

$._ondragleave=function(event){
if(this._isLoggingEnabled())this._log("ondragleave: "+event.getType());
return false;
};

$._ondragenter=function(event){
if(this._isLoggingEnabled())this._log("ondragenter: "+event.getType());
return false;
};

$._ondrop=function(event){
var url=event.getOriginal().dataTransfer.getData("URL");
var stopPropagation=false;
if(url){
if(this.hasSelection()){
event.preventDefault();
stopPropagation=true;
this._execSelectionCommand("CreateLink",false,url);
}
}else if(!_CAP_inDnD){
var text=event.getOriginal().dataTransfer.getData("Text");
var marker=this._saveSelection();
try{
this.pasteText(text);
}finally{
this._restoreSelection(marker);
}
event.preventDefault();
stopPropagation=true;
}else{
var self=this;
var done=false;

if(this._isLoggingEnabled()&&this._detailedLoggingEnabled){
var srcElement=event.getTarget();
this._log("received ondrop event on "+srcElement.nodeName);
this._log("ondrop component: "+srcElement.nodeName);

}


var iid=window.setInterval(function(){
if(!done){
done=true;
var affected=new Array();
var selection=self._getSelection();
var range=selection.createRange();
switch(selection.type){
case"Text":
case"None":
self._collectTouchedChildren(self._editableDiv,range,affected);
break;
case"Control":

var selectedElement=range.item(0);
var edivChild=com.coremedia.dom.DomUtil.findDirectChild(self._editableDiv,selectedElement);

affected.push(edivChild);
break;
}
var marker=self._saveSelection();
try{

self._log(affected.length+" drop affected children of ediv");
var container=self.getDocument().createElement("div");

document.body.appendChild(container);
try{
var insertionPoint=affected[affected.length-1].nextSibling;
for(var i=0;i<affected.length;i++)
container.appendChild(affected[i]);
self._insertElementContent(container,self._editableDiv,insertionPoint);
}catch(e){self._error("Exception: "+e);}finally{
com.coremedia.dom.DomUtil.removeNode(container);
}
}catch(e){self._error("Exception: "+e);}finally{
self._restoreSelection(marker);
}
}
window.clearInterval(iid);
},1);
}
return stopPropagation;
};

$._collectTouchedChildren=function(element,range,accu){
var child=element.firstChild;
while(child){
if(child.nodeType==Node.TEXT_NODE)
accu.push(child);
else if(child.nodeType==Node.ELEMENT_NODE){
var childRange=this._getElementRange(child);
if(this._rangesIntersect(range,childRange))
accu.push(child);
}
child=child.nextSibling;
}
};








$._pasteHtml=function(range,html,forward,elem){
var offset=forward?0:10000;
if(!html.nodeType){
div=this.getDocument().createElement("div");
div.innerHTML=html;

if(com.coremedia.dom.HtmlDomUtil.isAllowedIn(div.firstChild,range.parentElement())){
range.pasteHTML(html);
return true;
}
html=div.firstChild;
offset=forward?range.startOffset:range.endOffset;
delete div;
}
if(!elem){
elem=forward?range.startContainer:range.endContainer;

if(!elem&&com.coremedia.dom.DomUtil.isElement(range.parentElement(),"IMG"))
elem=range.parentElement().parentNode;
}
if(com.coremedia.dom.HtmlDomUtil.isAllowedIn(html,elem)||com.coremedia.dom.DomUtil.isElement(elem,"BODY|BLOCKQUOTE"))
return com.coremedia.dom.DomUtil.insertAtIndex(html,elem,offset);
else{
var children=elem.childNodes;
if(children.length>offset)
elem=children[offset];
else if(!forward)
elem=elem.lastChild;
else{this._error("prevent stack overflow");
elem=null;}
if(elem!=null)
return this._pasteHtml(range,html,forward,elem);
}

return false;
};

$._saveSelection=function(careful){

if(this._isLoggingEnabled())this._log("saving selection");
var range=this._getSelectionTextRange();
if(range){
var selection=this._getSelection();
var beginId=this._generateId();
var endId=null;
var parentElement=range.parentElement();
if(this._isLoggingEnabled()&&!com.coremedia.dom.DomUtil.isDescendantOf(parentElement,this._editableDiv)){
this._log("## selection parent is not descendant of editable div: "+
this._getLogSummary(parentElement)+", editable div is: "+
this._getLogSummary(this._editableDiv));
this._log("parent == editable div: "+(parentElement.parentNode==this._editableDiv));
}
switch(selection.type){
case"Control":
range=selection.createRange();
if(range.length!=1)
return null;
var element=range.item(0);
element.setAttribute("id",beginId);
break;
case"None":
case"Text":
var begin=selection.createRange().duplicate();

var isImage=com.coremedia.dom.DomUtil.isElement(parentElement,"IMG");
if(isImage||(typeof begin.text=="string"?begin.text.length>0:!begin.collapsed)){
careful|=isImage;
endId=this._generateId();
var end=begin.duplicate();
begin.collapse(true);
end.collapse(false);
if(careful)
this._pasteHtml(end,"<span id="+endId+" />",false);
else
end.pasteHTML("<span id="+endId+" />");
}else{
endId=beginId;
}
if(careful)
this._pasteHtml(begin,"<span id="+beginId+" />",true);
else
begin.pasteHTML("<span id="+beginId+" />");
break;
}
var marker={beginId:beginId,endId:endId,parentElement:parentElement};
if(this._isLoggingEnabled())this._log("selection saved");
return marker;
}
if(this._isLoggingEnabled())this._log("saveSelection(): returning null");
return null;
};

$._restoreSelection=function(marker){
if(!marker){
this._log("restoreSelection(): null");
return;
}
var beginMark=marker.beginId?this.getDocument().getElementById(marker.beginId):null;
var endMark=marker.endId?this.getDocument().getElementById(marker.endId):null;
if(beginMark&&!endMark){
var range=this.getDocument().body.createControlRange();
range.add(beginMark);
beginMark.removeAttribute("id");
range.select();
range.scrollIntoView();
}else{
if(!beginMark)
beginMark=endMark;
if(beginMark&&endMark){
var begin=this._createTextRange();
var end=this._createTextRange();
begin.moveToElementText(beginMark);
end.moveToElementText(endMark);
if(begin.compareEndPoints("EndToEnd",end)>0)
begin.setEndPoint("EndToEnd",end);
else if(begin.compareEndPoints("StartToStart",end)<0)
begin.setEndPoint("StartToStart",end);
begin.select();
begin.scrollIntoView();
com.coremedia.dom.DomUtil.removeNode(beginMark);
if(beginMark!=endMark)
com.coremedia.dom.DomUtil.removeNode(endMark);
}
}
if(this._isLoggingEnabled()){
this._log("selection restored");
com.coremedia.util.Logger.getInstance().logDom(0,"XHtmlEditor after restoring selection: ",this._editableDiv);
}
};










$.findText=function(text,fromCurrentSelection){
var range=this._findText(text,fromCurrentSelection);
if(range){
range.select();
range.scrollIntoView();
return true;
}
return false;
};

$._findText=function(text,fromCurrentSelection){
var wholeEditableDiv=this._createTextRange();
wholeEditableDiv.moveToElementText(this._editableDiv);
var selectionRange=this._getDocumentSelectionTextRange();
var range;
if(!fromCurrentSelection||!selectionRange||!wholeEditableDiv.inRange(selectionRange)){
if(this._isLoggingEnabled())this._log("searching for text '"+text+"' in whole editable div range");
range=wholeEditableDiv.duplicate();
range.collapse(true);
}else{
if(this._isLoggingEnabled())this._log("searching for text '"+text+"' in selection range");
range=selectionRange;
range.collapse(false);
}
if(range.findText(text)&&wholeEditableDiv.inRange(range)){
if(this._isLoggingEnabled())this._log("text '"+text+"' found");
return range;
}
return null;
};

$._doWithChildren=function(node,
siblingToStartAfter,
siblingToStopBefore,
logPrefix,
fun){
var child=siblingToStartAfter?siblingToStartAfter.nextSibling:node.firstChild;
while(child&&child!=siblingToStopBefore){
var previousSibling=child.previousSibling;
if(logPrefix&&this._detailedLoggingEnabled)
this._log(logPrefix+" "+(child.outerHTML?child.outerHTML:this._getLogSummary(child)));
fun(child);
if(logPrefix&&this._isLoggingEnabled())
if(this._detailedLoggingEnabled)
this._log("after "+logPrefix+" "+
(child.parentNode?(child.outerHTML?child.outerHTML:this._getLogSummary(child))
:" node removed"));

if((previousSibling&&previousSibling.nextSibling==child)||
(!previousSibling&&node.firstChild==child))
child=child.nextSibling;
else if(previousSibling)
child=previousSibling.nextSibling;
else
child=siblingToStartAfter?siblingToStartAfter.nextSibling:node.firstChild;
}
};

$._transformChildren=function(node,target,insertionPoint){
this._transformChildren1(node,target,insertionPoint,0);
};

$._transformChildren1=function(node,target,insertionPoint,level){
var result=null;
var child=node.firstChild;
if(!target){
target=node.parentNode;
insertionPoint=node;
}
if(this._detailedLoggingEnabled){
this._log("transforming children of "+this._getDomPath(node)+" to "+this._getDomPath(target)+
", "+this._getDomPath(insertionPoint));
com.coremedia.util.Logger.getInstance().logDom("source element is: ",node);
}






var currentTarget=target;
var currentInsertionPoint=insertionPoint;
var i=0;
while(child){
if(this._detailedLoggingEnabled)
this._log("child #"+i+" of "+this._getDomPath(node));
var insertedNode=this._transform(child,
currentTarget,
currentInsertionPoint,
level+1);
if(insertedNode){


currentTarget=insertedNode.parentNode;
currentInsertionPoint=insertedNode.nextSibling;
result=insertedNode;


}
child=child.nextSibling;
i++;
}
return result;
};

$._transform=function(node,
target,insertionPoint,level){
var self=this;

var newNode;

switch(node.nodeType){
case Node.ELEMENT_NODE:
var isMarker=this._isMarker(node);
var name=node.nodeName;

if(name.length==0||name[0]=="/"){
if(this._detailedLoggingEnabled)this._log(""+level+" removing unexpected element "+name);
return null;
}

var transformedName=isMarker&&name=="SPAN"?name:this._transformElementMap[name];

if(typeof transformedName=="undefined"){

if(!com.coremedia.dom.HtmlDomUtil.isFlowLevelElement(name)){


transformedName=null;
}else{
if(this._detailedLoggingEnabled)this._log(""+level+" removing html element "+name);
return null;
}
}

if(transformedName==null){
if(this._detailedLoggingEnabled)this._log(""+level+" removing element "+name+", keeping children");
return this._transformChildren1(node,target,insertionPoint,level);
}

if(transformedName===com.coremedia.editing.XHtmlEditor._REMOVE_RECURSIVELY_ON_PASTE){
if(this._detailedLoggingEnabled)this._log(""+level+" removing element "+name);
return null;
}

if(transformedName!=name){
if(this._detailedLoggingEnabled)
this._log(""+level+
" creating new element "+transformedName+" replacing "+this._getLogSummary(node));
}
if(name=="IMG"){

if(!node.getAttribute("src")){
if(this._detailedLoggingEnabled)this._log(""+level+" removing img element without src attribute");
return null;
}
var clone=this.getDocument().createElement("IMG");
if(this._isFirefox())
clone=this._flatCopyEditableElement(node);
else
clone.mergeAttributes(node,false);
node=clone;
}
newNode=this.getDocument().createElement(transformedName);

var transformAttributeList=this._transformAttributeLists[name];
if(transformAttributeList){
for(var i=0;i<transformAttributeList.length;i+=2){
var attrName=transformAttributeList[i];
var attrValue=transformAttributeList[i+1];
this._copyAttribute(node,newNode,attrName,attrValue);
}
}
if(isMarker)
newNode.id=node.id;
break;
case Node.TEXT_NODE:
newNode=this.getDocument().createTextNode(node.nodeValue);
break;
default:
return null;
}
if(this._isLoggingEnabled()&&this._detailedLoggingEnabled)
this._log("looking for legal parent for "+newNode+" in "+target);
var legalParent=com.coremedia.dom.HtmlDomUtil.findInnermostLegalParent(newNode,target,insertionPoint);
if(this._isLoggingEnabled()){
if(!com.coremedia.dom.DomUtil.isDescendantOf(target,self._editableDiv)){
this._error("_transform: com.coremedia.dom.DomUtil.isDescendantOf(target, self._editableDiv)");
return null;
}
}
if(!legalParent){
if(this._detailedLoggingEnabled)
this._log("removing node, no legal parent found for "+node.nodeName+
" in "+(target?target.nodeName:target));
return this._transformChildren1(node,target,insertionPoint,level);
}
if(this._isLoggingEnabled())

if(this._detailedLoggingEnabled){
this._log("moving node "+this._getDomPath(node)+
" to "+this._getDomPath(legalParent)+
", splitting at "+this._getDomPath(target)+", "+this._getDomPath(insertionPoint));
this._log("  transformed node is: "+this._getLogSummary(newNode));
this._log("  target is: "+this._getLogSummary(target));
this._log("  insertion point is: "+this._getLogSummary(insertionPoint));
}
var newInsertionPoint=this._splitSubtree(legalParent,target,insertionPoint);
if(this._detailedLoggingEnabled){
this._log("  new parent is: "+this._getLogSummary(legalParent));
this._log("  new insertion point is: "+this._getLogSummary(newInsertionPoint));
}
legalParent.insertBefore(newNode,newInsertionPoint);
if(target!=legalParent)
this._mergeStyles(legalParent,target,newNode);
var lastInsertedChild=this._transformChildren1(node,newNode,null,level);

var result=lastInsertedChild&&lastInsertedChild.parentNode!=newNode?lastInsertedChild:newNode;
this._checkNode(newNode);



if(!newNode.firstChild&&this._mayBeRedundant(newNode)){
if(this._detailedLoggingEnabled)
this._log("removing empty "+node.nodeName);
if(!result||result==newNode)
result=newNode.nextSibling;
com.coremedia.dom.DomUtil.removeNode(newNode);
}
return result;
};

$._flatCopyEditableElement=function(element){
var name=element.nodeName;
var clone=this.getDocument().createElement(name);
if(clone.mergeAttributes)
clone.mergeAttributes(element);
else{
var transformAttributeList=this._transformAttributeLists[name];
if(transformAttributeList){
for(var i=0;i<transformAttributeList.length;i+=2)
this._copyAttribute(element,clone,transformAttributeList[i]);
}
}
return clone;
};

$._checkNode=function(node){
if(com.coremedia.dom.DomUtil.isElement(node,"TABLE")){
new com.coremedia.editing.SpanTableModel(node);
}else if(com.coremedia.dom.DomUtil.isElement(node,"TBODY")){
if(com.coremedia.dom.DomUtil.isElement(node.previousSibling,"TBODY")){
var otherTBody=node.previousSibling;
this._log("merging adjacent tbody elements");
com.coremedia.dom.DomUtil.moveChildren(otherTBody);
com.coremedia.dom.DomUtil.removeNode(otherTBody);
}
}else if(node.parentNode==this._editableDiv&&
(node.nodeType==Node.TEXT_NODE||
com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(node))){

if(com.coremedia.dom.DomUtil.isElement(node.previousSibling,"P")){
if(this._detailedLoggingEnabled)
this._log("moving toplevel inline content into previous paragraph: "+this._getLogSummary(node));
node.previousSibling.appendChild(node);
}else{
if(this._detailedLoggingEnabled)
this._log("wrapping toplevel inline content into new paragraph: "+this._getLogSummary(node));
var p=this.getDocument().createElement("P");
this._editableDiv.replaceChild(p,node);
p.appendChild(node);
}
}
};

$._mergeStyles=function(root,node,newNode){

if(node!=root){

if(node.nodeName==newNode.nodeName)
com.coremedia.dom.HtmlDomUtil.mergeClassAttribute(node,newNode,false,this.getFormatVariantSeparator());
this._mergeStyles(root,node.parentNode,newNode);
}
};











$._splitSubtree=function(root,node,insertionPoint){

if(root==node)
return insertionPoint;
var rightSubtree=null;
var previous=insertionPoint;
var current=node;
while(true){

var newRightSubtree=null;
if(rightSubtree){
newRightSubtree=this._flatCopyEditableElement(current);
newRightSubtree.appendChild(rightSubtree);
}
if(previous){


previous=previous.nextSibling;
while(previous){
if(!newRightSubtree)
newRightSubtree=this._flatCopyEditableElement(current);
var next=previous.nextSibling;
newRightSubtree.appendChild(previous);
previous=next;
}
}
rightSubtree=newRightSubtree?newRightSubtree:current.nextSibling;
var newParent=current.parentNode;
if(newParent==root)
break;
previous=current;
current=newParent;
}
if(rightSubtree&&rightSubtree!=current.nextSibling){
root.insertBefore(rightSubtree,current.nextSibling);
}

return rightSubtree;
};

$._log=function(msg){
com.coremedia.util.Logger.log("XHtmlEditor "+msg);
};

$._isLoggingEnabled=function(){
var logger=com.coremedia.util.Logger.getInstance();
return logger&&logger.isDebugEnabled();
};

$._isBlockLevel=function(level){
return level.search(new RegExp("^(block|<"+com.coremedia.editing.XHtmlEditor.blockLevelElementsRegExp+">)$","i"))==0;
};

$._isInlineLevel=function(level){
return level.search(new RegExp("^(inline|<"+com.coremedia.editing.XHtmlEditor.inlineLevelElementsRegExp+">)$","i"))==0;
};

$._isNodeInLevel=function(node,level){
var result=this._isNodeInLevel1(node,level);
if(this._isLoggingEnabled())
this._log("element "+(result?"":"not ")+"in level:"+this._getLogSummary(node));
return result;
};

$._isNodeInLevel1=function(node,level){
if(!node)
return false;
if(level=="_list")
return node.nodeType==Node.TEXT_NODE||com.coremedia.dom.DomUtil.isElement(node,"li|p");
if(node.nodeType==Node.TEXT_NODE)
return level=="inline"||level=="flow";
if(!node.nodeType==Node.ELEMENT_NODE)
return false;
if(level=="block")
return com.coremedia.dom.HtmlDomUtil.isBlockLevelElement(node);
if(level=="inline")
return com.coremedia.dom.HtmlDomUtil.isInlineLevelElement(node);
if(level=="flow")
return com.coremedia.dom.HtmlDomUtil.isFlowLevelElement(node);

var m=level.match(/^<(.+)>$/);
if(m==null)
return level.toUpperCase()==node.nodeName.toUpperCase();
else
return m[1].toUpperCase()==node.nodeName.toUpperCase();
};

$._error=function(msg){
this._errors=true;
this._log("##### "+msg);
};

$._copyAttribute=function(sourceElement,targetElement,
name,value){
if(name=="class"||name=="className")
com.coremedia.dom.HtmlDomUtil.setClassAttribute(targetElement,
value?value:com.coremedia.dom.HtmlDomUtil.getClassAttribute(sourceElement));
else{
if(!value){
try{
value=sourceElement.getAttribute(name);
}catch(e){


}
}
if(value)
targetElement.setAttribute(name,value);
}
};

$._toggleSourceView=function(){
if(!this._sourceViewEnabled)return;
var document=this.getDocument();
var html;
if(this._isFirefox()){
if(!this._sourceViewActive){
html=document.createTextNode(this._editableDiv.innerHTML);
this._editableDiv.innerHTML="";
this._editableDiv.appendChild(html);
this._sourceViewActive=true;
}else{
html=document.createRange();
html.selectNodeContents(this._editableDiv);
this._editableDiv.innerHTML=html.toString();
this._sourceViewActive=false;
}
}else if(this._isIE()){
if(!this._sourceViewActive){
this._editableDiv.innerText=this._editableDiv.innerHTML;
this._sourceViewActive=true;
}else{
this._editableDiv.innerHTML=this._editableDiv.innerText;
this._sourceViewActive=false;
}
}
};

$._updateAllImageDimensions=function(element){
var imgs=this._editableDiv.getElementsByTagName("IMG");
for(var i=0;i<imgs.length;++i){
this._updateImageDimensions(imgs[i]);
}
};

$._updateImageDimensions=function(element){
if(element&&com.coremedia.dom.DomUtil.isElement(element,"IMG")&&element.style){
var width=element.style.width;
var height=element.style.height;
if(width){
if(typeof width=="string")width=width.split("px")[0];
element.width=width;
if(typeof element.style.removeAttribute=="function"){
element.style.removeAttribute("width");
}else{
element.style.width="";
}
}
if(height){
if(typeof height=="string")height=height.split("px")[0];
element.height=height;
if(typeof element.style.removeAttribute=="function"){
element.style.removeAttribute("height");
}else{
element.style.height="";
}
}
}
};

$._onclick=function(e){
if(this._isLoggingEnabled())this._log("#_onclick "+e);
if(e.button==2){

e.preventDefault();
e.stopPropagation();
}
};

$._onLinkMouseOver=function(e){
if(this._isLoggingEnabled())this._log("#_onLinkMouseOver "+e);
var target=e.getTarget?e.getTarget():e.target;
if(target){
var uri=this._getLinkUri(target);
if(uri)window.top.status=uri;
}
return false;
};

$._onLinkMouseOut=function(e){
if(this._isLoggingEnabled())this._log("#_onLinkMouseOut "+e);
var target=e.getTarget?e.getTarget():e.target;
if(target){
window.top.status="";
}
return false;
};

$._getLinkUri=function(element){
var uri=com.coremedia.dom.DomUtil.isElement(element,"A")?
element.href:
com.coremedia.dom.DomUtil.isElement(element,"IMG")?
element.src:
element.getAttribute("xlink:href");
if(!uri){
if(this._isLoggingEnabled())this._log("#_getLinkUri: looking for 'href' attribute.");
uri=element.getAttribute("href");
}
if(this._isLoggingEnabled())this._log("#_getLinkUri returns "+uri);
return uri;
};


})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.RemoveFormatsCommand=com_coremedia_editing_XHtmlEditor_RemoveFormatsCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.RemoveFormatsCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.RemoveFormatsCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.removeFormats("flow");
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TagAsLinkCommand=com_coremedia_editing_XHtmlEditor_TagAsLinkCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TagAsLinkCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TagAsLinkCommand;

$.execute=function(){
var xhtmlEditor=this.getTargetComponent();
if(this._isFirefox())
return xhtmlEditor._createLinkInFirefox();
return xhtmlEditor._execSelectionCommand("CreateLink",true);
};

$._isFirefox=function(){
return typeof document.createRange=="function";
};


})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TagAsLinkFromClipboardCommand=com_coremedia_editing_XHtmlEditor_TagAsLinkFromClipboardCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TagAsLinkFromClipboardCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TagAsLinkFromClipboardCommand;

$.execute=function(){
var target=this.getTargetComponent();
return com.coremedia.editing.XHtmlClipboardHelper.paste(target);
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.InsertInternalLinkFromClipboardCommand=com_coremedia_editing_XHtmlEditor_InsertInternalLinkFromClipboardCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.InsertInternalLinkFromClipboardCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.InsertInternalLinkFromClipboardCommand;

$.execute=function(){
var target=this.getTargetComponent();
return com.coremedia.editing.XHtmlClipboardHelper.insertInternalLinkFromClipboard(target);
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.InsertImageFromClipboardCommand=com_coremedia_editing_XHtmlEditor_InsertImageFromClipboardCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.InsertImageFromClipboardCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.InsertImageFromClipboardCommand;

$.execute=function(){
var target=this.getTargetComponent();
com.coremedia.editing.XHtmlClipboardHelper.insertImageFromClipboard(target);
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.MultiToggleOrderedItemCommand=com_coremedia_editing_XHtmlEditor_MultiToggleOrderedItemCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.MultiToggleOrderedItemCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.MultiToggleOrderedItemCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.insertOrderedList();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.MultiToggleUnorderedItemCommand=com_coremedia_editing_XHtmlEditor_MultiToggleUnorderedItemCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.MultiToggleUnorderedItemCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.MultiToggleUnorderedItemCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.insertUnorderedList();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.ToggleIndentTextCommand=com_coremedia_editing_XHtmlEditor_ToggleIndentTextCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.ToggleIndentTextCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.ToggleIndentTextCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.indent();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.ToggleOutdentTextCommand=com_coremedia_editing_XHtmlEditor_ToggleOutdentTextCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.ToggleOutdentTextCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.ToggleOutdentTextCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.outdent();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TagAsBlockquoteCommand=com_coremedia_editing_XHtmlEditor_TagAsBlockquoteCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TagAsBlockquoteCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TagAsBlockquoteCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.indentBlockQuote();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TagAsBlockunquoteCommand=com_coremedia_editing_XHtmlEditor_TagAsBlockunquoteCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TagAsBlockunquoteCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TagAsBlockunquoteCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.outdentBlockQuote();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.InsertTableCommand=com_coremedia_editing_XHtmlEditor_InsertTableCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
if(typeof(this._rows)=="undefined")this._rows=3;
if(typeof(this._cols)=="undefined")this._cols=4;
};$.constructorname='com.coremedia.editing.XHtmlEditor.InsertTableCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.InsertTableCommand;

$.execute=function(){
var target=this.getTargetComponent();

var cellHtml=typeof document.createRange=="function"?"<td><br/></td>":"<td></td>";
var html="<table>";
for(var r=0;r<this._rows;r++){
html+="<tr>";
for(var c=0;c<this._cols;c++){
html+=cellHtml;
}
html+="</tr>";
}
html+="</table>";
target.pasteHtml(html);
};

$.setRows=function(rows){
this._rows=rows;
};

$.setCols=function(cols){
this._cols=cols;
};




})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableDeleteRowCommand=com_coremedia_editing_XHtmlEditor_TableDeleteRowCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableDeleteRowCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableDeleteRowCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.removeTableRows();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableDeleteColumnCommand=com_coremedia_editing_XHtmlEditor_TableDeleteColumnCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableDeleteColumnCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableDeleteColumnCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.removeTableColumns();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableSelectRowCommand=com_coremedia_editing_XHtmlEditor_TableSelectRowCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableSelectRowCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableSelectRowCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.selectTableRow();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableSelectColumnCommand=com_coremedia_editing_XHtmlEditor_TableSelectColumnCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableSelectColumnCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableSelectColumnCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.selectTableColumn();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableMergeCellsCommand=com_coremedia_editing_XHtmlEditor_TableMergeCellsCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableMergeCellsCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableMergeCellsCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.joinTableCells();
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableSplitCellsHorizontalCommand=com_coremedia_editing_XHtmlEditor_TableSplitCellsHorizontalCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableSplitCellsHorizontalCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableSplitCellsHorizontalCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.splitTableCells(true);
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableSplitCellsVerticalCommand=com_coremedia_editing_XHtmlEditor_TableSplitCellsVerticalCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableSplitCellsVerticalCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableSplitCellsVerticalCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.splitTableCells(false);
};

})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.SetFormatCommand=com_coremedia_editing_XHtmlEditor_SetFormatCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.SetFormatCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.SetFormatCommand;

$.setLevel=function(level){
this._level=level;
};

$.getLevel=function(){
return this._level;
};

$.setGroup=function(group){
this._group=group;
};

$.getGroup=function(){
return this._group;
};

$.setValue=function(value){
this._value=value;
};

$.getValue=function(){
return this._value;
};

$.execute=function(){
var target=this.getTargetComponent();
if("true"==this._value){
target.setFormat(this._level,this._group,true);
}else if("false"==this._value){
target.setFormat(this._level,this._group,false);
}else{
target.setFormat(this._level,this._group,this._value);
}
};






})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.AttributeEditorCommand=com_coremedia_editing_XHtmlEditor_AttributeEditorCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.AttributeEditorCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.AttributeEditorCommand;

$.execute=function(){
var xhtmleditor=this.getTargetComponent();
var tag=this.getFormattableTag(xhtmleditor);

var templateId="attributes";

if(tag.length>0&&templateId){
var parameters=this.uriParamFromStringArray(tag);



window.wage_propertyEditor=xhtmleditor;
var documentType="RichText";
var propertyName="RichText";
var template="templateId="+documentType+"."+propertyName+"%23"+templateId;
var tmpUri="/editor/generator/index,"+template+","+parameters+".html";
var editorWindow=window.open(tmpUri,"attributeEditor","height=520,width=600,menubar=no,location=no,toolbar=no,status=no,scrollbars=no,resizable=yes");
editorWindow.focus();
return editorWindow;
}else{
return null;
}
};




$.uriParamFromStringArray=function(tags){
var result="";
for(var i=0;i<tags.length;i++){
if(i>0)result+=",";
result+="tag="+tags[i];
}
return result;
};







$.getFormattableTag=function(editor){
var tags=this.getFormattableTableTag(editor);
var pseudoPath=["blockquote","ol","ul","li","p","span","a","img"];
for(var i=0;i<pseudoPath.length;++i){
var attributes=editor.getEditableAttributes(pseudoPath[i]);
if(attributes){
tags.push(pseudoPath[i]);
}
}
return tags;
};





$.getFormattableTableTag=function(editor){
var tags=new Array();
var tableAttributes=editor.getEditableAttributes("<table>");
if(tableAttributes){
tags.push("table");
var tbodyAttributes=editor.getEditableAttributes("<tbody>");
var trAttributes=editor.getEditableAttributes("<tr>");
if(trAttributes&&
(tbodyAttributes&&tbodyAttributes.isElementChildOf(tableAttributes)&&trAttributes.isElementChildOf(tbodyAttributes)||
!tbodyAttributes&&trAttributes.isElementChildOf(tableAttributes))){
tags.push("tr");
var tdAttributes=editor.getEditableAttributes("<td>");
if(tdAttributes&&tdAttributes.isElementChildOf(trAttributes)){
tags.push("td");
}
}
}
return tags;
};

$.getTemplateForTag=function(tag){
return"attributes";
};


})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.InsertInlineElementCommand=com_coremedia_editing_XHtmlEditor_InsertInlineElementCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.InsertInlineElementCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.InsertInlineElementCommand;

$.execute=function(){
var target=this.getTargetComponent();
target.insertInlineElements(this._inlineElementName);
};

$.setInlineElementName=function(name){
this._inlineElementName=name;
};



})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);

(function(){

var $=com.coremedia.editing.XHtmlEditor.TableEditItemCommand=com_coremedia_editing_XHtmlEditor_TableEditItemCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.XHtmlEditor.TableEditItemCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.XHtmlEditor.TableEditItemCommand;

$.execute=function(){
var target=this.getTargetComponent();
if(this._isColumn){
target.insertTableColumns(this._before);
}else{
target.insertTableRows(this._before);
}
};

$.setBefore=function(before){
this._before=before;
};

$.setIsColumn=function(isColumn){
this._isColumn=isColumn;
};




})();
_jsc_package(["com","coremedia","editing","XHtmlEditor"]);




(function(){

var $=com.coremedia.editing.XHtmlEditor.FirefoxEventBridge=com_coremedia_editing_XHtmlEditor_FirefoxEventBridge=function(currentWindow,id,props){
this._window=currentWindow?currentWindow:window;
if(typeof(this._window.com)=="undefined")
this._window.com=com;
this._id=id;
this.super$com$coremedia$editing$PropertyAware(props);
if(this._isLoggingEnabled())this._log("initialized: "+id);
};$.constructorname='com.coremedia.editing.XHtmlEditor.FirefoxEventBridge';$.superconstructor=com.coremedia.editing.PropertyAware;$=$.prototype=new com.coremedia.editing.PropertyAware();$.super$com$coremedia$editing$PropertyAware=com.coremedia.editing.PropertyAware;$.constructor=com.coremedia.editing.XHtmlEditor.FirefoxEventBridge;

$.getId=function(){
return this._id;
};

$.processLoad=function(event){
if(this._isLoggingEnabled())this._log("process load: "+this.getId());
var self=this;
var editor=this._editor;
editor._editWindow.HTMLElement.prototype.__defineGetter__("outerHTML",parent.com_coremedia_editing_Browser.getOuterHTML);
editor.getDocument=function(){return editor._editWindow.document;};
editor._element=editor._editWindow.document.body;
editor._editableDiv=editor._element;
editor.findEnclosingForm=function(){
var frameElement=editor._editWindow.frameElement;
var form=com.coremedia.dom.DomUtil.findEnclosingElement(frameElement,"FORM");
return form;
};





editor._editWindow.frameElement.style.height=editor._editWindow.document.body.offsetHeight+"px";
window.setInterval(function(){
editor._editWindow.frameElement.style.height=Math.max(22,editor._editWindow.document.body.offsetHeight)+"px";
},200);
editor._execCommand("styleWithCSS",false,false);

var win=editor._editWindow;
var editableElement=editor._editableDiv;
var browser=com.coremedia.editing.Browser.instance;

var links=editableElement.getElementsByTagName("A");
for(i=0;i<links.length;i++){
browser.addEventListener(win,links[i],"mouseover",function(e){return editor._onLinkMouseOver(e);});
browser.addEventListener(win,links[i],"mouseout",function(e){return editor._onLinkMouseOut(e);});
}
links=null;

browser.addEventListener(win,editableElement,"focus",function(e){editor.processFocus(self._convert(e));},true);
browser.addEventListener(win,editableElement,"click",function(e){editor._onclick(self._convert(e));},true);
browser.addEventListener(win,editableElement,"dblclick",function(e){editor.processDblclick(self._convert(e));});
browser.addEventListener(win,editableElement,"contextmenu",function(e){editor.processContextmenu(self._convert(e));});

browser.addEventListener(win,editableElement,"dragstart",function(e){editor._ondragstart(self._convert(e));});
browser.addEventListener(win,editableElement,"dragend",function(e){editor._ondragend(self._convert(e));});
browser.addEventListener(win,editableElement,"drop",function(e){editor._ondrop(self._convert(e));});
browser.addEventListener(win,editableElement,"dragenter",function(e){editor._ondragenter(self._convert(e));});
browser.addEventListener(win,editableElement,"dragover",function(e){editor._ondragover(self._convert(e));});
browser.addEventListener(win,editableElement,"dragleave",function(e){editor._ondragleave(self._convert(e));});
browser.addEventListener(win,editableElement,"paste",function(e){editor._onpaste(self._convert(e));});

browser.addEventListener(win,win,"keypress",function(e){self.processKeypress(e);},true);
browser.addEventListener(win,win,"keyup",function(e){editor.processKeyup(self._convert(e));},true);
browser.addEventListener(win,win,"keydown",function(e){editor.processKeydown(self._convert(e));},true);

browser.addEventListener(win,win,"unload",function(e){
self._log("#unload");
editor._editableDiv=null;
editor._elementSelection.setElements([]);
editor._elementSelection=null;
});

if(this._isLoggingEnabled())this._log("Event handlers for xhtml editor attached to "+editableElement.nodeName+"("+editableElement.id+")");
editableElement=null;

};

$.processKeypress=function(e){

if(this._isLoggingEnabled())this._log("#processKeypress");
var self=this;
if(!this._cleanUpBrsInProgress){
this._cleanUpBrsInProgress=true;
window.setTimeout(function(){
if(self._isLoggingEnabled())self._log("cleanUpBrsInFirefox");
var brs=self._editor._editableDiv.getElementsByTagName("BR");
for(var i=0;i<brs.length;i++){
var br=brs[i];
if(i==0&&com.coremedia.dom.DomUtil.isElement(br.parentNode,"BODY"))continue;
if(com.coremedia.dom.DomUtil.isElement(br.parentNode,"BODY|BLOCKQUOTE|A")||
com.coremedia.dom.DomUtil.isElement(br.previousSibling,"P")||
com.coremedia.dom.DomUtil.isElement(br.nextSibling,"P"))
com.coremedia.dom.DomUtil.removeNode(br);
}
delete self._cleanUpBrsInProgress;
},1);
}

if(e.ctrlKey&&e.charCode==118
||!e.ctrlKey&&e.shiftKey&&e.keyCode==e.DOM_VK_INSERT){
this._editor.processPaste(this._convert(e));
return false;
}

var result=true;
var key=e.key||e.keyCode;
var editor=this._editor;


if(key==13&&!e.shiftKey){
var editNode=editor._editableDiv;
var document=editor.getDocument();
var selection=editor._getSelection();
var range=editor._getSelectionTextRange();
if(range){
var marker=editor._saveSelection();
editor._getRangeElements(marker);
var beginElement=marker.beginElement;
var endElement=marker.endElement;
com.coremedia.util.Logger.getInstance().logDom("before handling key pressed: ",document);
try{

if(!range.collapsed){
range.deleteContents();
}

var block=this._getBlockAncestor(range.endContainer,editNode);
this._log("found block ancestor "+block.blockNode+(block.blockNode?": "+block.blockNode.nodeName:""));
if(com.coremedia.dom.DomUtil.isElement(block.blockNode,"LI"))
return true;


if(!block.blockNode){
document.execCommand("formatblock",false,"P");
this._log("P inserted using formatblock");

block={blockNode:com.coremedia.dom.DomUtil.findEnclosingElement(beginElement,"P",editNode)};
if(block.blockNode){
if(this._trim(this._textContent(block.blockNode)).length==0){
this._removeTrailingBr(block.blockNode);
return false;
}
}else{
block.blockNode=editNode;
}
this._removeTrailingBr(block.blockNode);
}
var newblock=editor._createEmptyElement("P");
this._removeTrailingBr(range.startContainer);
if(this._atEndOfContainer(block.blockNode||block.blockContainer,endElement,range.endOffset)){
if(block.blockNode===block.blockContainer){
block.blockNode.appendChild(newblock);
}else{
com.coremedia.dom.DomUtil.insertAfter(newblock,block.blockNode);
}

var newrange=editor._createTextRange();
newrange.setStart(newblock,0);

selection.removeAllRanges();
selection.addRange(newrange);
}else if(this._atBeginningOfContainer(block.blockNode||block.blockContainer,
range.startContainer,range.startOffset)){
if(block.blockNode===block.blockContainer){
com.coremedia.dom.DomUtil.prependChild(newblock,block.blockNode);
}else if(block.blockNode!=editNode){
com.coremedia.dom.DomUtil.insertBefore(newblock,block.blockNode);
}

block.blockNode.scrollIntoView();
}
result=false;
}catch(e){editor._error("Exception: "+e);}finally{
editor._restoreSelection(marker);
}
com.coremedia.util.Logger.getInstance().logDom("after handling key pressed: ",document);
}
}
return result;
};

$._atBeginningOfContainer=function(container,node,offset){
var atBeginning=false;
var offsetAtBeginning=(offset==0);
if(!offsetAtBeginning&&node.nodeType==3){
if(this._trim(node.nodeValue.substr(0,offset)).length==0){
offsetAtBeginning=true;
}
}
if(offsetAtBeginning){
var cnode=node;
atBeginning=true;
while(cnode&&cnode!==container){
if(cnode.previousSibling){
atBeginning=false;
break;
}
cnode=cnode.parentNode;
}
}
return atBeginning;
};

$._atEndOfContainer=function(container,node,offset){
var atEnd=false;
var offsetAtEnd=(offset==(node.length||node.childNodes.length));
if(!offsetAtEnd&&node.nodeType==3){
if(this._trim(node.nodeValue.substr(offset)).lenth==0){
offsetAtEnd=true;
}
}
if(offsetAtEnd){
var cnode=node;
atEnd=true;
while(cnode&&cnode!==container){
if(cnode.nextSibling){
atEnd=false;
break;
}
cnode=cnode.parentNode;
}
}
return atEnd;
};

$._getBlockAncestor=function(node,root){
root=root||node.ownerDocument.body;
var regex=/^(?:P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|DT|DE)$/;
var block=null;
var blockContainer=null;
while(node&&node!==root){
var name=node.nodeName.toUpperCase();
if(!block&&regex.test(name)){
block=node;
}
if(!blockContainer&&(/^(?:BODY|TD|TH|CAPTION)$/).test(name)){
blockContainer=node;
}

node=node.parentNode;
}
return{blockNode:block,blockContainer:blockContainer||node.ownerDocument.body};
};

$._textContent=function(node){
if(this._isLoggingEnabled())this._log("#_textContent");
if(node.textContent!=undefined){
return node.textContent;
}
var_result="";
if(node==null){return_result;}
for(var i=0;i<node.childNodes.length;i++){
switch(node.childNodes[i].nodeType){
case 1:
case 5:
_result+=this._textContent(node.childNodes[i]);
break;
case 3:
case 2:
case 4:
_result+=node.childNodes[i].nodeValue;
break;
default:
break;
}
}
return_result;
};

$._removeTrailingBr=function(container){
if(this._isLoggingEnabled())this._log("#_removeTrailingBr");
var para;
if(/P|DIV|LI/i.test(container.tagName)){
para=container;
}else{
para=com.coremedia.dom.DomUtil.findEnclosingElement(container,"P|DIV|LI",this._editableDiv);
}
if(para&&para.lastChild){
if(para.childNodes.length>1&&para.lastChild.nodeType==3&&this._trim(para.lastChild.nodeValue).length==0){
com.coremedia.dom.DomUtil.removeNode(para.lastChild);
}
if(para.childNodes.length>0&&para.lastChild.tagName=="BR"){
com.coremedia.dom.DomUtil.removeNode(para.lastChild);
if(para.childNodes.length==0){
para.appendChild(para.ownerDocument.createTextNode(' '));
}
}
}
};

$.setEditor=function(editor){
this._editor=editor;
};

$._trim=function(string){
return this._editor._trim(string);
};

$._log=function(msg){
com.coremedia.util.Logger.getInstance().log("FirefoxEventBridge: ");
};

$._convert=function(event){
return new com.coremedia.editing.ComponentEvent(window,this._editor,event);
};

$._isLoggingEnabled=function(){
if(typeof(com)=="undefined")return false;
var logger=com.coremedia.util.Logger.getInstance();
return logger&&logger.isDebugEnabled();
};




})();
_jsc_package(["com","coremedia","editing","BlobEditor"]);

(function(){

var $=com.coremedia.editing.BlobEditor.CopyBlobUrlCommand=com_coremedia_editing_BlobEditor_CopyBlobUrlCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.BlobEditor.CopyBlobUrlCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.BlobEditor.CopyBlobUrlCommand;

$.execute=function(){
var a=this.getTargetElement();
var url=a.href;
var transferable=new com.coremedia.editing.Transferable();
transferable.addDataFlavor("text/unicode","{type: 'contentBlob', url: '"+url+"'}");
com.coremedia.editing.Clipboard.getSystemClipboard().setContents(transferable);
window.status="Copied BLOB URL '"+url+"'.";
};

})();




_jsc_package(["com","coremedia","editing"]);






(function(){

var $=com.coremedia.editing.SpanTableModel=com_coremedia_editing_SpanTableModel=function(table,begin,end){
this._clazz="com.coremedia.editing.SpanTableModel";
this._lineToColumnToCellMapMap=new Array();
this._table=table;
this._begin=begin;
this._end=end;
this._init();
};$.constructorname='com.coremedia.editing.SpanTableModel';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.SpanTableModel;

com.coremedia.editing.SpanTableModel._COORDINATE_PROPERTY="com.coremedia.editing.SpanTableModel.COORDINATES";





com.coremedia.editing.SpanTableModel.fromTextRange=function(textRange,topElement){
var begin=textRange.duplicate();
var end=textRange.duplicate();
begin.collapse(true);
end.collapse(false);
var parent1=begin.parentElement();
var parent2=end.parentElement();
var table1=com.coremedia.dom.DomUtil.findEnclosingElement(parent1,"table");
var table2=com.coremedia.dom.DomUtil.findEnclosingElement(parent2,"table");
if(!table1||!table2)
return null;
var table=table1;
if(com.coremedia.dom.DomUtil.isDescendantOf(table1,table2))
table=table2;
if(!com.coremedia.dom.DomUtil.isDescendantOf(table,topElement)||table==topElement)
return null;

var result=new com.coremedia.editing.SpanTableModel(table,begin,end);
if(com.coremedia.editing.Browser.getBrowser()==com.coremedia.editing.Browser.IE
||!com.coremedia.dom.DomUtil.isElement(textRange.parentElement(),"TBODY|TR")){
result._firstSelectedCell=result.getCellFromTextRange(begin);
result._lastSelectedCell=result.getCellFromTextRange(end);
}else{
result._firstSelectedCell=textRange.startContainer.childNodes[textRange.startOffset];
result._lastSelectedCell=textRange.endContainer.childNodes[textRange.endOffset-1];
}
if(result._firstSelectedCell&&!result._lastSelectedCell)
result._lastSelectedCell=result._firstSelectedCell;
return result;
};

$.getSelectedCells=function(){
return this.getCellsFromArea(this.getSelectedRectangle());
};

$.getCellsFromArea=function(area){
var result=new Array();
var cell=null;
if(area){
for(var y=area.y;y<area.y+area.height;y++){
var x=area.x;
while(x<area.x+area.width){
cell=this.getCell(x,y);
if(y==area.y||this.getCell(x,y-1)!=cell){

result[result.length]=cell;
}
x+=cell.colSpan;
}
}
}




return result;
};

$.getCellFromTextRange=function(textRange){
var table=this.getTable();

var element=com.coremedia.dom.DomUtil.findEnclosingElement(textRange.parentElement(),"td");



while(element&&element.parentNode.parentNode.parentNode!=table){
element=com.coremedia.dom.DomUtil.findEnclosingElement(element.parentNode,"td");
}

return element;
};

$.getFirstSelectedCell=function(){
return this._firstSelectedCell;
};

$.getLastSelectedCell=function(){
return this._lastSelectedCell;
};

$.getBeginRange=function(){
return this._begin;
};

$.getEndRange=function(){
return this._end;
};

$.getSelectedRectangle=function(){
var first=this.getFirstSelectedCell();
if(!first){
return null;
}

var last=this.getLastSelectedCell();


var topLeft=this.getUpperLeftEdge(first);
var lowerRight=this.getLowerRightEdge(last);
var area={x:topLeft.x,y:topLeft.y,width:lowerRight.x-topLeft.x+1,height:lowerRight.y-topLeft.y+1};
var bottom=area.y+area.height;
var right=area.x+area.width;

for(var y=area.y;y<bottom;y++){
var x=area.x;
while(x<right){
var cell=this.getCell(x,y);
var cellArea=this.getArea(cell);
if(!this._rectIncludes(area,cellArea))
return null;
x+=cell.colSpan;
}
}
return area;
};

$._rectIncludes=function(rect1,rect2){
return rect1.x<=rect2.x&&rect1.y<=rect2.y&&
rect1.x+rect1.width>=rect2.x+rect2.width&&rect1.y+rect1.height>=rect2.y+rect2.height;
};

$._init=function(){
var table=this._table;
if(!table)return;
var rows=table.rows;
if(!rows)return;
var nRows=rows.length;
var nColumns=0;



var columns=new Array(nRows);
for(var y=0;y<nRows;++y){
columns[y]=0;
}
var inconsistent=false;
for(var r=0;r<rows.length;++r){
var cells=rows[r].cells;
var nc=0;
for(var i=0;i<cells.length;++i){
var cell=cells[i];

for(var spannedRow=0;spannedRow<cell.rowSpan&&r+spannedRow<nRows;spannedRow++){
columns[r+spannedRow]+=cell.colSpan;
}
}
if(columns[r]!=nColumns){
inconsistent|=nColumns>0;
nColumns=Math.max(columns[r],nColumns);
}
}

if(inconsistent)
logging.Logger.log("TABLE: inconsistent column count, cells should be inserted later on");

var rowSpan=new Array(nColumns);
var rowSpanElement=new Array(nColumns);
for(var x=0;x<nColumns;++x){
rowSpan[x]=0;
rowSpanElement[x]=null;
}

for(var y=0;y<nRows;++y){
var i=0;
var colSpan=0;
var cell=null;
for(var x=0;x<nColumns;++x){


if(rowSpan[x]==0){
var row=table.rows[y];
if(colSpan==0){

cell=row.cells[i++];
if(!cell){
logging.Logger.log("TABLE: cell at "+x+","+y+" missing, inserting emtpy cell");
cell=document.createElement("td");
row.appendChild(cell);
}
this._setCoordinates(cell,x,y);
colSpan=cell.colSpan;
rowSpan[x]=cell.rowSpan;
rowSpanElement[x]=cell;

}
}else{


cell=rowSpanElement[x];
if(cell==null)throw new Error("cell "+x+","+y+" is null!");
colSpan=cell.colSpan;
}
if(colSpan>0)
colSpan--;
if(rowSpan[x]>0)
rowSpan[x]--;
this._setCell(x,y,cell);
}
}


for(var x=1;x<nColumns;++x){
if(rowSpan[x]!=0){
logging.Logger.log("TABLE: column "+x+" is too long, adjusting");
com.coremedia.dom.HtmlDomUtil.setRowSpan(rowSpanElement[x],rowSpanElement[x].rowSpan-rowSpan[x]);
}
}

this._nColumns=nColumns;
this._nRows=nRows;
};




$.getTable=function(){
return this._table;
};

$.getColumnCount=function(){
return this._nColumns;
};

$.getRowCount=function(){
return this._nRows;
};

$.getUpperLeftEdge=function(cell){
return this.getCoordinates(cell);
};

$.getLowerRightEdge=function(cell){
var area=this.getArea(cell);
return{x:area.x+area.width-1,y:area.y+area.height-1};
};

$._setCoordinates=function(cell,x,y){
cell[com.coremedia.editing.SpanTableModel._COORDINATE_PROPERTY]={x:x,y:y};
};

$._setCell=function(x,y,cell){
var columnToCellMap=this._lineToColumnToCellMapMap[y];
if(!columnToCellMap){
columnToCellMap=new Array();
this._lineToColumnToCellMapMap[y]=columnToCellMap;
}
columnToCellMap[x]=cell;
};





$.getRow=function(y){
var result=this._table.rows[y];
return result?result:null;
};





$.getCell=function(x,y){
var columnToCellMap=this._lineToColumnToCellMapMap[y];
if(!columnToCellMap)return null;
var result=columnToCellMap[x];
return result?result:null;
};





$.getCoordinates=function(cell){
var result=cell[com.coremedia.editing.SpanTableModel._COORDINATE_PROPERTY];
if(!result)
throw new Error("table cell not mapped: "+cell.nodeName);
return result;
};




$.getArea=function(cell){
var coords=this.getCoordinates(cell);
return{x:coords.x,y:coords.y,width:cell.colSpan,height:cell.rowSpan};
};





$.getAreaFromCoordinates=function(x,y){
var cell=this.getCell(x,y);
return cell?this.getArea(cell):null;
};


})();



_jsc_package(["com","coremedia","editing"]);




(function(){

var $=com.coremedia.editing.XHtmlClipboardHelper=com_coremedia_editing_XHtmlClipboardHelper=function(){
};$.constructorname='com.coremedia.editing.XHtmlClipboardHelper';$.superconstructor=Object;$=$.prototype=new Object();$.super$Object=Object;$.constructor=com.coremedia.editing.XHtmlClipboardHelper;

com.coremedia.editing.XHtmlClipboardHelper.paste=function(editor){

var clipboard=com.coremedia.editing.Clipboard.getSystemClipboard();
var transferable=clipboard.getContents();
var uris=transferable.getTransferableData("text/uri-list");
if(editor.hasSelection&&editor.hasSelection()&&uris&&uris.length==1){
com.coremedia.util.Logger.log("Exactly one uri in clipboard");
editor.createLink(uris[0]);
}else{
var text=transferable.getTransferableData("text/unicode");
var match1=null;
var match2=null;
var uric="[;/?:@&=+$,A-Za-z0-9%\\-_\\.!~*'()]";
var regexp1="^"+uric+"+$";
var regexp2="^([^:/?#]+://[^/?#]*)/[^?#]*(\\?([^#]*))?(#(.*))?$";
if(text&&text.length<=1024*4){
match1=text.match(regexp1);
match2=text.match(regexp2);
}

var isUrl=match1!=null&&match1[0].length==text.length
&&match2!=null&&match2[0].length==text.length;
if(editor.hasSelection&&isUrl&&editor.hasSelection()){
com.coremedia.util.Logger.log("Text in clipboard matched url regexp: '"+text+"'");
editor.createLink(text);
}else{
if(text&&text.length>4*1024)
com.coremedia.util.Logger.log("Text in clipboard is greater than 4k");
else
com.coremedia.util.Logger.log("Text in clipboard did not match url regexp: '"+text+"'");
com.coremedia.util.Logger.log("XHtmlEditor#paste() start");
editor.paste();
}
}

};

com.coremedia.editing.XHtmlClipboardHelper.insertImageFromClipboard=function(editor){
var clipboard=com.coremedia.editing.Clipboard.getSystemClipboard();
var transferable=clipboard.getContents();
var text=transferable.getTransferableData("text/unicode");
try{
var blob=eval("("+text+")");
if(blob&&blob.type&&blob.type=="contentBlob"){
editor.insertImage(blob.url);
return;
}
}catch(e){
}
var ex=new Object();
ex.message="Clipboard does not contain a content blob property";
ex.key="exception.no-content-blob-property-in-clipboard";
throw ex;
};

com.coremedia.editing.XHtmlClipboardHelper.insertInternalLinkFromClipboard=function(editor){
var clipboard=com.coremedia.editing.Clipboard.getSystemClipboard();
var transferable=clipboard.getContents();
var text=transferable.getTransferableData("text/unicode");
if(text){
try{
var obj=eval("("+text+")");
if(obj&&obj.type){
if(obj.type=="contentList"&&obj.contents&&obj.contents.length>0){
var firstDocument=null;
for(var i=0;i<obj.contents.length;i++){
firstDocument=obj.contents[i];
if(firstDocument.type=="content"&&firstDocument.url&&!firstDocument.isFolder)break;
}
obj=firstDocument;
}
if(obj.type=="content"&&obj.url&&!obj.isFolder){
editor.createLink(obj.url);
return;
}
}
}catch(e){
}
}
var ex=new Object();
ex.message="Clipboard does not contain a content object";
ex.key="exception.no-document-in-clipboard";
throw ex;
};


})();




_jsc_package(["com","coremedia","editing"]);

(function(){

var $=com.coremedia.editing.IncrementDecrementCommand=com_coremedia_editing_IncrementDecrementCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.IncrementDecrementCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.IncrementDecrementCommand;

$.execute=function(){
var target=this.getTargetElement();
if(target){
if(target.value)
target.value=this._incrementOrDecrement(target.value);
else if(target.firstChild)
target.firstChild.data=this._incrementOrDecrement(target.firstChild.data);
}
};

$._incrementOrDecrement=function(str){
var value=Number(str);
var decrement=this._decrement;
if(decrement&&value>this.getMinOrMax())
return value-1;
else if(!decrement&&value<this.getMinOrMax())
return value+1;
return value;
};

$.setDecrement=function(decrement){
this._decrement=decrement;
};

$.getMinOrMax=function(){
return this._minOrMax;
};

$.setMinOrMax=function(val){
this._minOrMax=Number(val);
};




})();




_jsc_package(["com","coremedia","editing"]);












(function(){

















var $=com.coremedia.editing.Overlay=com_coremedia_editing_Overlay=function(currentWindow,id,sourceElemId,targetPosElemId,optionalParentElemId,width,height,stylesheetRef){
this.super$com$coremedia$editing$Component(currentWindow,id);
this._sourceElemId=sourceElemId;
this._targetPosElemId=targetPosElemId;
this._targetParentElemId=optionalParentElemId;
this._width=width;
this._height=height;
this._stylesheetRef=stylesheetRef;


};$.constructorname='com.coremedia.editing.Overlay';$.superconstructor=com.coremedia.editing.Component;$=$.prototype=new com.coremedia.editing.Component();$.super$com$coremedia$editing$Component=com.coremedia.editing.Component;$.constructor=com.coremedia.editing.Overlay;

















$.processLoad=function(event){



var sourceContentHolder=this.getWindow().document.getElementById(this._sourceElemId);


var targetPosElem=this.getWindow().document.getElementById(this._targetPosElemId);


var targetLocation={left:0,top:0};
if(targetPosElem){
var browser=com.coremedia.editing.Browser.instance;
targetLocation=browser.getElementLocation(targetPosElem,this.getWindow());

}




var layoutParent=this.getWindow().document.body;



if(this._targetParentElemId){

var targetParentElem=this.getWindow().document.getElementById(this._targetParentElemId);
if(targetParentElem){
layoutParent=targetParentElem;


}
}



this.renderOverlay(targetLocation.left,targetLocation.top,this._width,this._height,layoutParent,sourceContentHolder);




};





$.renderOverlay=function(pos_x,pos_y,width,height,layoutParent,sourceContentHolder){
this._renderOverlayAsDIV(pos_x,pos_y,width,height,layoutParent,sourceContentHolder);



};





$._renderOverlayAsDIV=function(pos_x,pos_y,width,height,layoutParent,sourceContentHolder){

this._moveContentHolder(pos_x,pos_y,width,height,sourceContentHolder);
};


$._moveContentHolder=function(pos_x,pos_y,width,height,sourceContentHolder){

var divObj=sourceContentHolder;

divObj.setAttribute("scrolling","no");
divObj.setAttribute("frameborder","0");
divObj.setAttribute("topmargin","0");
divObj.setAttribute("leftmargin","0");
divObj.setAttribute("border","0");


divObj.style.position="absolute";
divObj.style.top=pos_y+"px";
divObj.style.left=pos_x+"px";

divObj.style.visibility="visible";
divObj.style.display="block";

return divObj;
};



$._createDIVElem=function(pos_x,pos_y,width,height){

var divObj=this.getWindow().document.createElement("div");


divObj.id=this.getId();

divObj.setAttribute("scrolling","no");
divObj.setAttribute("frameborder","0");
divObj.setAttribute("topmargin","0");
divObj.setAttribute("leftmargin","0");
divObj.setAttribute("border","0");


divObj.style.position="absolute";
divObj.style.top=pos_y+"px";
divObj.style.left=pos_x+"px";

return divObj;
};



$._writeContentToDIV_innerHTML=function(sourceContentHolder,destElem){



var content=sourceContentHolder.innerHTML;


var parentElem=sourceContentHolder.parentNode;


parentElem.removeChild(sourceContentHolder);


destElem.innerHTML=content;

};


$._writeContentToDIV_cloneNode=function(sourceContentHolder,destElem){

var contents=sourceContentHolder.getElementsByTagName("div");

if(contents){
var content=contents[0].cloneNode(true);

if(content){
var parentElem=sourceContentHolder.parentNode;


parentElem.removeChild(sourceContentHolder);


destElem.appendChild(content);
}
}
};









$._renderOverlayAsIFrame=function(pos_x,pos_y,width,height,layoutParent,sourceContentHolder){

var iframeElem=this._createIFrameElem(pos_x,pos_y,width,height);


layoutParent.appendChild(iframeElem,layoutParent);


var frameWindow=iframeElem.contentWindow;


this._writeContentToIFrame(sourceContentHolder,frameWindow);

};

$._createIFrameElem=function(pos_x,pos_y,width,height){
var iframeObj=this.getWindow().document.createElement("iframe");
iframeObj.id=this.getId();
iframeObj.setAttribute("scrolling","no");
iframeObj.setAttribute("frameborder","0");
iframeObj.setAttribute("topmargin","0");
iframeObj.setAttribute("leftmargin","0");
iframeObj.setAttribute("width",width);
iframeObj.setAttribute("height",height);
iframeObj.setAttribute("border","0");
iframeObj.setAttribute("unselectable","on");
iframeObj.style.position="absolute";
iframeObj.style.top=pos_y;
iframeObj.style.left=pos_x;

return iframeObj;
};

$._writeContentToIFrame=function(sourceContentHolder,destFrame){
destFrame.document.write("<html scroll='no'>");
destFrame.document.write("<head>");
destFrame.document.write("<link rel='stylesheet' type='text/css' href='"+this._stylesheetRef+"'></link>");
destFrame.document.write("</head>");
destFrame.document.write("<body scroll='no'>");
destFrame.document.write(sourceContentHolder.innerHTML);
destFrame.document.write("</body>");
destFrame.document.write("</html>");
};

})();
_jsc_package(["com","coremedia","editing"]);

(function(){

var $=com.coremedia.editing.WindowOpenCommand=com_coremedia_editing_WindowOpenCommand=function(props){
this.super$com$coremedia$editing$Command(props);
};$.constructorname='com.coremedia.editing.WindowOpenCommand';$.superconstructor=com.coremedia.editing.Command;$=$.prototype=new com.coremedia.editing.Command();$.super$com$coremedia$editing$Command=com.coremedia.editing.Command;$.constructor=com.coremedia.editing.WindowOpenCommand;

$.setUrl=function(url){
this._url=url;
};

$.getUrl=function(){
return this._url;
};

$.setWindowName=function(windowName){
this._windowName=windowName;
};

$.getWindowName=function(){
return this._windowName;
};

$.setWindowFeatures=function(windowFeatures){
this._windowFeatures=windowFeatures;
};

$.getWindowFeatures=function(){
return this._windowFeatures;
};

$.execute=function(){
var win=window.open(this._url,this._windowName,this._windowFeatures);
if(win){
win.focus();
}else{
alert("Please disable your popup blocker for this server!");
}
};






})();
_jsc_package(["com","coremedia","editing","query"]);

(function(){

var $=com.coremedia.editing.query.OpenWebEditorResourceChooserCommand=com_coremedia_editing_query_OpenWebEditorResourceChooserCommand=function(targetWindow,targetComponentId,props){
this.super$com$coremedia$editing$ComponentCommand(targetWindow,targetComponentId,props);
};$.constructorname='com.coremedia.editing.query.OpenWebEditorResourceChooserCommand';$.superconstructor=com.coremedia.editing.ComponentCommand;$=$.prototype=new com.coremedia.editing.ComponentCommand();$.super$com$coremedia$editing$ComponentCommand=com.coremedia.editing.ComponentCommand;$.constructor=com.coremedia.editing.query.OpenWebEditorResourceChooserCommand;

$.setAllowedResourceTypeName=function(allowedResourceTypeName){
this._allowedResourceTypeName=allowedResourceTypeName;
};

$.execute=function(){
var target=this.getTargetElement();
var startResourceId=target.value;
var CONTENT_ID_PREFIX="coremedia:///cap/content/";
if(!startResourceId){
startResourceId="1";
}else if(startResourceId.substring(0,CONTENT_ID_PREFIX.length)==CONTENT_ID_PREFIX){
startResourceId=startResourceId.substring(CONTENT_ID_PREFIX.length);
}
var allowedResourceTypeName=this._allowedResourceTypeName?this._allowedResourceTypeName:"Resource_";
window.wage_propertyEditor={
setResource:function(id){
target.value="coremedia:///cap/content/"+id;
target.form.submit();
}
};
window.open("/editor/showChooser.do"
+"?resource="+startResourceId
+"&tableAction=chooserResourceList"
+"&allowedResourceType="+allowedResourceTypeName
+"&allowMultiSelection=false"
+"&imageMode=false",
"chooser",
"height=400,width=700,menubar=no,location=no,toolbar=no,status=no,resizable=yes");
};



})();