﻿isc.defineClass("ValicomMenu","Canvas").addProperties({
  width:200,
  height:300,
  neckWidth:80,
  top:200,
  left:200,
  neckHeight:6,
  padding:0,
  margin:0,
  mouseOut:function()
    {          
      var mY = this.getOffsetY();
      var mX = this.getOffsetX();
      if(mX < 3)
        {
          this.hide();
        }
      else if(mX > this.getWidth())
        {
          this.hide();
        }      
      else if(mY > this.getHeight())
        {            
          this.hide();
        }    
      else if(mX > this.neckWidth && mY < 10)
        {
          this.hide();
        }
    },
  initWidget: function()
    {
      this.Super("initWidget",arguments);
      
      this.addChild(
        isc.Canvas.create({
          left:1,
          top:0,
          width:this.neckWidth,
          className:"menuNeck",
          height:this.neckHeight
        })
      );
      
      this.addChild(
        isc.Canvas.create({
          left:0,
          height:9,
          top:this.neckHeight,
          width:this.neckWidth,
          className:"menuNeckFiller"
        })
      );
      
      this.addChild(
        isc.Img.create({
          top:this.neckHeight,
          height: this.height - (13 + this.neckHeight),
          width:13,
          imageType:"stretch",
          src:"http://www.valicomcorp.com/images/menu/left.png"
        })
      );
      
      this.addChild(
        isc.Img.create({
          height: 13,
          width:13,
          top: this.height - 13,
          left:0,
          src:"http://www.valicomcorp.com/images/menu/leftBottom.png"
        })
      ); 
      
      this.addChild(
        isc.Img.create({
          height: 13,
          width:this.width - 26,
          top: this.height - 13,
          left:13,
          imageType:"stretch",
          src:"http://www.valicomcorp.com/images/menu/bottom.png"
        })
      );     
      
      this.addChild(
        isc.Img.create({
          height: 13,
          width:13,
          top: this.height - 13,
          left:this.width - 13,
          src:"http://www.valicomcorp.com/images/menu/rightBottom.png"
        })
      );  
      
      this.addChild(
        isc.Img.create({
          height: this.height - (22 + this.neckHeight),
          width:13,
          top:9 + this.neckHeight,
          left:this.width - 13,
          imageType:"stretch",
          src:"http://www.valicomcorp.com/images/menu/right.png"
        })
      );
      
      this.addChild(
        isc.Img.create({
          height:9,
          width:13,
          top:this.neckHeight,
          left:this.width - 13,
          src:"http://www.valicomcorp.com/images/menu/rightTop.png"
        })
      ); 
      
      this.addChild(
        isc.Img.create({
          height:9,
          width:this.width - (this.neckWidth + 13),
          top:this.neckHeight,
          left:this.neckWidth,
          imageType:"stretch",
          src:"http://www.valicomcorp.com/images/menu/top.png"
        })
      );
      
      this.addChild(
        isc.Canvas.create({
          className:"valicomMenu",
          width:this.width - 26,
          height:this.height - (22 + this.neckHeight),
          top:9 + this.neckHeight,
          left:13,
          children:[
            isc.VLayout.create({ 
              top:5,
              left:8,                   
              height:this.height - (36 + this.neckHeight),                                       
              menuItems: this.menuItems,
              initWidget:function()
                {
                  this.Super("initWidget",arguments);
                  
                  for(var i=0; i<= this.menuItems.length - 1; i++)
                    {
                      this.addMember(                          
                        isc.DropDownMenuItem.create({
                          title: this.menuItems[i].title,
                          click: "window.location = 'http://www.valicomcorp.com" +  this.menuItems[i].link + "';"
                        })
                      );
                      this.addMember(                          
                        isc.LayoutSpacer.create({
                          height:4
                        })
                      );
                    }
                }
            })
          ]
        })
      );
      
    }
});

isc.defineClass("ValicomMenuButton","Button").addProperties({
  baseStyle:"menuButton",
  showDown:false,
  showFocused:false,
  autoFit:true,
  mouseOver:function()
    {
      this.Super("mouseOver",arguments);
      if(this.dropDownMenu)
        {
          this.dropDownMenu.moveTo(this.getPageLeft()-2,this.getPageTop()+15);
          this.dropDownMenu.show();
          //alert(this.div.getPageLeft());
          //alert(this.getPageLeft());
        }          
    },
  mouseOut:function()
    {        
      this.Super("mouseOut",arguments);
      if(this.dropDownMenu)
        {
          if(this.getOffsetY() < 15)
            {
              this.dropDownMenu.hide();                          
            } 
        }                               
    }   
});

isc.defineClass("ValicomSubMenuButton","Button").addProperties({
  baseStyle:"subMenuButton",
  showDown:false,
  showFocused:false,
  autoFit:true
});

isc.defineClass("SubMenuDivider","Img").addProperties({
  className:"subMenuDivider",                  
  margin:0,
  padding:0,
  width:180,
  height:3,
  src:"http://www.valicomcorp.com/images/subMenuDivider.png"
});
            
isc.defineClass("MenuDivider","Img").addProperties({
  src:"http://www.valicomcorp.com/images/menu/divider.jpg",                  
  margin:0,
  padding:0,
  width:1,
  height:15,
  className:"menuDivider"
}); 

isc.defineClass("DropDownMenuItem", "Button").addProperties({
  baseStyle:"valicomMenuItem",
  showDown:false,
  showFocused:false,
  autoFit:true
});

isc.defineClass("CaaSDemo", "Window").addProperties({
  isModal:true,
  showModalMask:true,
  autoCenter:true,
  showHeaderIcon:false,
  title:"Clearview Demo",
  width:815,
  height:600,
  src:"http://www.valicomcorp.com/demo.aspx",
  closeClick: function()
    {
      this.destroy();
    }
});

var mainMenuItems = [
  isc.LayoutSpacer.create({
    width:290
  })
]; 

for(var i=0;i<=mainMenu.length - 1; i++)
  {
    var ddMenu;
    var divider;
    if(mainMenu[i].dropDownItems.length > 0)
      {
        ddMenu = isc.ValicomMenu.create({
          autoDraw:false,
          width:mainMenu[i].dropDownWidth,
          height:mainMenu[i].dropDownHeight,
          neckWidth:mainMenu[i].dropDownNeckWidth,
          menuItems: mainMenu[i].dropDownItems
        });
        
      }
    if(i > 0)
      {            
        divider = isc.MenuDivider.create({ID:"divider_" + i});
        mainMenuItems.push(divider);
      }
    if(mainMenu[i].link=="")
      {
        mainMenuItems.push(
          isc.ValicomMenuButton.create({
            autoDraw:false,
            title: "&nbsp;&nbsp;&nbsp;" + mainMenu[i].title + "&nbsp;&nbsp;&nbsp;",
            dropDownMenu: ddMenu,
            div: divider
          })
        );
      }
    else
      {
        mainMenuItems.push(
          isc.ValicomMenuButton.create({
            autoDraw:false,
            title:"&nbsp;&nbsp;&nbsp;" + mainMenu[i].title + "&nbsp;&nbsp;&nbsp;",
            dropDownMenu: ddMenu,
            click:"window.location = 'http://www.valicomcorp.com" + mainMenu[i].link + "';",
            div: divider
          })
        );
      }           
    ddMenu = null;     
    divider = null;        
  }  
mainMenuItems.push(
  isc.LayoutSpacer.create({
    width:135
  })
);


