
var TIMEOUT_TO_HIDE_SUBMENU=500;
function SKMenuItem(sMenuId,oMIProps,iMIIndex){
this.menuId=sMenuId;
this.menuItemIndex=iMIIndex;
this.slideContentObj=null;
this.props=oMIProps;
this.isOpen=false;
this.timeoutHandler=0;
this.subItems=new Array();
 this.subItemsCount=0;
this.addSubItem=function(oSIProps){
 this.subItemsCount++;
 this.subItems[oSIProps.id]=new SKMenuItem(this.menuId,oSIProps,this.subItemsCount);
}
this.getSubMenuItemById=function(sID){
 return this.subItems[sID];
}
this.showSubMenu=function(){
if(typeof SKMenus=='undefined')return;
 SKMenus[this.menuId].hideSubMenus();
 this.isOpen=true;
 this.updateCurrentState();
 if(this.subItemsCount==0){
 return;
}
 this.setSubMenuPosition();
 SKLayerShow(SK_SUBMENU_CONTAINER_PREF+this.props.id);
 this.playAnimation(0);
}
this.hideSubMenu=function(){
 this.isOpen=false;
 SKLayerHide(SK_SUBMENU_CONTAINER_PREF+this.props.id);
 if(!isUndefined(this.props.subMenuOpacity)){
 this.props.subMenuOpacity=0;
 this.opacityChange(0);
}
 this.updateCurrentState();
}
this.playAnimation=function(direction){
if(direction!=0){
 this.hideSubMenu();
}
}
this.setSubMenuPosition=function(){
}
this.updateCurrentState=function(){
}
this.opacityChange=function(iOpacity){
this.props.subMenuOpacity=iOpacity;
var oSubMenuLayer=document.getElementById(SK_SUBMENU_CONTAINER_PREF+this.props.id);
if(this.props.subMenuOpacity < 0){
 this.props.subMenuOpacity=0;
 this.hideSubMenu();
}
if(this.props.subMenuOpacity > SK_SUBMENU_MAX_OPACITY){
 this.props.subMenuOpacity=SK_SUBMENU_MAX_OPACITY;
 if(document.all){
 oSubMenuLayer.style.filter='';
}else{
 oSubMenuLayer.style.MozOpacity=99/100;
}
 return;
}
if(document.all){
 oSubMenuLayer.style.filter='alpha(opacity='+this.props.subMenuOpacity+')';
}else{
 oSubMenuLayer.style.MozOpacity=this.props.subMenuOpacity/100;
}
}
this.getHTML=function(){
var sSubItemsHTML='';
 for(var i in this.subItems){
 sSubItemsHTML+=this.subItems[i].getHTML();
}
var sLayoutType=this.props.default_layout;
 var oLayout=this.props.layouts[sLayoutType];
if(sLayoutType==SKM_CONST.FLASH_LAYOUT&&
 isDefined(oLayout.alternative_layout)&&
 isDefined(oLayout.required_version)){
var iRequiredFlashVersion=oLayout.required_version;
 if(iRequiredFlashVersion > INSTALLED_FLASH_VERSION){
oLayout=this.props.layouts[oLayout.alternative_layout];
 sLayoutType=oLayout.alternative_layout;
}
}
if(sLayoutType==SKM_CONST.FLASH_LAYOUT){
 if(!oLayout.template_props){
 oLayout.template_props={};
}
oLayout.template_props['flash_code']=ComposeFlashCode(oLayout);
}else if(sLayoutType==SKM_CONST.TEXT_LAYOUT){
var sCutSuffix='...';
 if(oLayout.cut_suffix){
 sCutSuffix=oLayout.cut_suffix;
}
if(oLayout.max_chars&&oLayout.text.length > oLayout.max_chars){
 oLayout.text=oLayout.text.substr(0,oLayout.max_chars-sCutSuffix.length);
 oLayout.text+=sCutSuffix;
}
if(oLayout.wrap_chars){
var iMaxTextChunkLength=oLayout.wrap_chars;
 var sMIText='';
var arrSITextChunks=oLayout.text.split(' ');
 for(var i=0;i < arrSITextChunks.length;i++){
var sTextChunk=arrSITextChunks[i];
if(sTextChunk.toString().length > iMaxTextChunkLength){
var sModifiedTextChunk='';
 function _add_new_lines(sText){
 return sText.substr(0,iMaxTextChunkLength)+'<br>';
}
var j=0;
 var sRemainingText='';
 do{
var sStartText=_add_new_lines(sTextChunk.substr(j*iMaxTextChunkLength,(j+1)*iMaxTextChunkLength));
 j++;
sRemainingText=sTextChunk.substr(j*iMaxTextChunkLength,(j+1)*iMaxTextChunkLength);
 sModifiedTextChunk+=sStartText;
}while(sRemainingText.length > iMaxTextChunkLength);
sTextChunk=sModifiedTextChunk+sRemainingText;
}
sMIText+=sTextChunk+' ';
}
oLayout.text=sMIText.replace(/ $/,'');
}
var re=/{/g;
 oLayout.text=oLayout.text.replace(re, "&#123;");
 re=/}/g;
 oLayout.text=oLayout.text.replace(re, "&#125;");
if(!oLayout.template_props){
 oLayout.template_props={};
}
 oLayout.template_props['menuitem_text']=oLayout.text;
}else if(sLayoutType==SKM_CONST.IMAGEN_LAYOUT){
}
if(this.props.slide_content){
 this.slideContentObj=SlideContent_Create(this.props.slide_content_props);
 ONLOAD_FUNCTIONS.push('SlideContent_GetById("' + this.slideContentObj.id + '").init()');
}
var sMenuItemTmpl=oLayout.template;
 var sWceIconCode=SKGetIconHTML(this.props.id);
var oCommonProps={
 menuitem_obj_id : this.props.id,
 menu_obj_id : this.menuId,
menuitem_td_id : SK_MENUITEM_TD_PREFIX+this.props.id,
 menuitem_mouseover : "if( typeof SKMenus != 'undefined' ) { SKMenus["+this.menuId+"].getMenuItemById('"+this.props.id+"').onmouseover(); }",
 menuitem_mouseout : "if( typeof SKMenus != 'undefined' ) { SKMenus["+this.menuId+"].getMenuItemById('"+this.props.id+"').onmouseout(); }",
 menuitem_id : SK_MENUITEM_LINK_PREFIX+this.props.id,
 menuitem_href : this.props.href,
 menuitem_target : this.props.target,
menuitem_wce_icon : sWceIconCode,
 subitems_container_id : SK_SUBMENU_CONTAINER_PREF+this.props.id,
 subitem_block_mouseover : "if( typeof SKMenus != 'undefined' ) { SKMenus["+this.menuId+"].getMenuItemById('"+this.props.id+"').onmouseover(); }",
 subitem_block_mouseout : "if( typeof SKMenus != 'undefined' ) { SKMenus["+this.menuId+"].getMenuItemById('"+this.props.id+"').onmouseout(); }",
 subitems : sSubItemsHTML
}
if(this.slideContentObj!=null){
 oCommonProps['slide_content_start']=this.slideContentObj.getStartHtml();
 oCommonProps['slide_content_end']=this.slideContentObj.getEndHtml();
}
if(oLayout.template_props){
 for(var i in oLayout.template_props){
 oCommonProps[i]=oLayout.template_props[i];
}
}
 var sMenuitemHTML=sMenuItemTmpl.supplant(oCommonProps);
return sMenuitemHTML;
}
this.onmouseover=function(){
 if(this.slideContentObj!=null){
 this.slideContentObj.forward();
}
if(this.subItemsCount > 0){
 window.clearInterval(this.timeoutHandler);
 this.timeoutHandler=0;
 if(!this.isOpen){
 this.showSubMenu();
}
}
}
this.onmouseout=function(){
if(this.slideContentObj!=null){
 this.slideContentObj.backward();
}
if(this.subItemsCount > 0){
if(this.timeoutHandler==0){
 this.timeoutHandler=window.setTimeout('if( typeof SKMenus != "undefined" ) { SKMenus['+this.menuId+'].getMenuItemById('+this.props.id+').playAnimation(1); }',TIMEOUT_TO_HIDE_SUBMENU);
}
}
}
this.onMenuPrint=function(){
}
function ComposeFlashCode(oProps){
var sHtml=''+
 '<OBJECT classid  = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
 'codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '+
 'WIDTH    = "' + oProps.flash_width + '" '+
 'HEIGHT   = "' + oProps.flash_height + '" '+
 '>'+
'<PARAM NAME = "FlashVars" VALUE = "' + oProps.flash_vars + '">'+
 '<PARAM NAME = "movie"     VALUE = "' + oProps.flash_src + '">'+
 '<PARAM NAME = "quality"   VALUE = "high">';
if(oProps.flash_is_transparent){
 sHtml+='<PARAM NAME = "wmode"   VALUE = "transparent">';
}
if(oProps.flash_bg_color){
 sHtml+='<PARAM NAME = "bgcolor" VALUE = "' + oProps.flash_bg_color + '">';
}
sHtml+='<EMBED src         = "' + oProps.flash_src + '" '+
 'quality     = "high" '+
 'width       = "' + oProps.flash_width + '" '+
 'height      = "' + oProps.flash_height + '" '+
 'type        = "application/x-shockwave-flash" '+
 'pluginspage = "http://www.macromedia.com/go/getflashplayer" '+
 'FlashVars   = "' + oProps.flash_vars + '" ';
if(oProps.flash_bg_color){
 sHtml+='bgcolor = "' + oProps.flash_bg_color + '" ';
}
 sHtml+='></EMBED>'+
 '</OBJECT>';
return sHtml;
}
var self=this;
}