




function wxApplication(){ 
  this.m_name = "WebXOffice 2005";
  this.m_menu_count = 0;
}

var _ImplementApp = new wxApplication()

function GetApp(){
  return _ImplementApp
}

function wxMenuBar(){
  this.m_menus = new Array();
  function wxMenuBar.prototype.Show(the_html){
  
    var buffer = new String()
    
    buffer ='<table ID="sbMenuBar" align="left" width="100%" class="menu_bar_border" cellpadding="0" cellspacing="0" unselectable="on">'
    var i
    for(i=0;i<this.m_menus.length;i++){
      buffer  += '<td>'
      buffer  += this.m_menus[i].Show()
      buffer  +='</td>'
    }
    buffer +='<td width="100%" align="right" title="" unselectable="on" style="cursor:default" ></td></table>'
    
    the_html.innerHTML = buffer
  }    
  

  
  function wxMenuBar.prototype.AppendSeperator(){
    this.Append(new wxMenuBarSeperator())
  }

  function wxMenuBar.prototype.AppendHTML(html){
    this.Append(new wxMenuItemHTML(html))
  }


  function wxMenuBar.prototype.Append(item){
    ArrayPush(this.m_menus,item)
  }
}

function wxMenu(name){
  this.m_menus_items = new Array();
  this.m_name        = name
  
  this.m_menu_id     = GetApp().m_menu_count++
  
  function wxMenu.prototype.Show(){
    var buffer = new String()
    if(this.m_menus_items.length){
      
      buffer +='<b id="idMenuTitle'+this.m_menu_id+'" class="clsMenuTitle" onMouseOver="doHover(this)" onMouseOut="unHover(this)" unselectable="on">'+this.m_name+'</b><br>'
      buffer +='<span ID="idMenu'+this.m_menu_id+'" class="clsMenu">'
      var i
      for(i=0;i<this.m_menus_items.length;i++){
        buffer += this.m_menus_items[i].Show()
      }
      buffer +='</span>'
    } else {
      buffer +='<b onClick="return false" class="clsDeadMenuTitle" title="Actions not available">'+this.m_name+'</b><br>'
    }
    
    return buffer
  }
  
  function wxMenu.prototype.AppendMenuSeperator(){
    this.Append(new wxMenuSeperator())
  }
  function wxMenu.prototype.AppendMenuGroup(head){
    this.Append(new wxMenuGroup(head))
  }

  function wxMenu.prototype.AppendMenuItemHTML(html){
    this.Append(new wxMenuItemHTML(html))
  }
  
  function wxMenu.prototype.AppendMenuItem(name,callback,title,disabled){
    this.Append(new wxMenuItem(name,callback,title,disabled))
  }
  
  function wxMenu.prototype.Append(item){
    ArrayPush(this.m_menus_items,item)
  }
  

}

function wxMenuSeperator(){
  function wxMenuSeperator.prototype.Show(){
		return '<hr>'
  }
}    

function wxMenuGroup(head){
	this.m_head=head;
  function wxMenuGroup.prototype.Show(){
    return '<table cellpadding="0" cellspacing="0" height="20">'
	+ '<td nowrap style="font-size:9px;color:blue">&nbsp;'+this.m_head+'</td>'
	+ '<td width="100%">'
	+'<table cellpadding="0" cellspacing="0" width="100%">'
	+'<TR><TD height=10px><img height=10px></TD></TR>'
	+'<TR><TD style="height:2px;border-top:2px groove;" width="100%"><img height=10px></td></TR>'
	+'</TABLE></td>'
	+'</table>'
	//'<hr>'
  }
}    

function wxMenuItemHTML(html){
  this.m_html = html
  function wxMenuItemHTML.prototype.Show(buffer){
    return this.m_html
  }
}  

function wxMenuBarSeperator(){
  function wxMenuBarSeperator.prototype.Show(buffer){
  	return '<table cellpadding="0" cellspacing="0" height="20" width="2">'
    + '<td bgcolor="buttonshadow"><img src="null.gif" width=1></td>'
    + '<td bgcolor="buttonhighlight"><img src="null.gif" width=1></td>'
	  + '</table>'
  }
}


function wxButton(image,callback,title,disabled){
  this.m_image       = image
  this.m_callback   = callback
  this.m_disabled   = disabled
  this.m_title      = title
  
  function wxButton.prototype.Show(buffer){
    if(this.m_title){
	 return '<td style="height:26px;text-indent:22px;'
	 		+'background-image:url(components/ev3/images/'+this.m_image+'); background-repeat:no-repeat;"'
	 		+'onMouseUp="simpleHover(this,1);'+this.m_callback+'"'
		   +'onMouseDown="simpleHover(this,-1);" onMouseOver="simpleHover(this,1)"'
		   +'onMouseOut="simpleHover(this,0)"'
			+'>'+this.m_title
			+'&nbsp;</td>'
	}
	else
      return '<img onMouseUp="simpleHover(this,1);'+this.m_callback+'"'
       +'onMouseDown="simpleHover(this,-1);" onMouseOver="simpleHover(this,1)"'
       +'onMouseOut="simpleHover(this,0)"'
       +'src="components/ev3/images/'+this.m_image+'"'
       +'border=0 class="button" title="">'

      
  }
}



function wxMenuItem(name,callback,title,disabled,javascript,new_window){
  this.m_name       = name
  this.m_callback   = callback
  this.m_disabled   = disabled
  this.m_title      = title
  this.m_javascript = 0
  
  if(typeof javascript == "undefined")
    this.m_javascript = 1
  else
    this.m_javascript = javascript
    
  this.m_new_window = new_window
  
  
  
  function wxMenuItem.prototype.Show(buffer){
    var style
    if(this.m_disabled)
      style = 'style="color:999"'
    
    if(this.m_new_window)
      style += ' target="_BLANK"'
    
    var the_link = ""
    
    if(this.m_javascript)  
      the_link = 'javascript:'
      
    the_link += this.m_callback
    
    return '<a '+style+' href="' + the_link + '">' + this.m_name + '</a><br>'
  }

}    

function wxMenuFactory(){

}



function wxTree(){

}

function wxTreeItem(){

}
