﻿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:"/images/menu/left.png"
        })
      );
      
      this.addChild(
        isc.Img.create({
          height: 13,
          width:13,
          top: this.height - 13,
          left:0,
          src:"/images/menu/leftBottom.png"
        })
      ); 
      
      this.addChild(
        isc.Img.create({
          height: 13,
          width:this.width - 26,
          top: this.height - 13,
          left:13,
          imageType:"stretch",
          src:"/images/menu/bottom.png"
        })
      );     
      
      this.addChild(
        isc.Img.create({
          height: 13,
          width:13,
          top: this.height - 13,
          left:this.width - 13,
          src:"/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:"/images/menu/right.png"
        })
      );
      
      this.addChild(
        isc.Img.create({
          height:9,
          width:13,
          top:this.neckHeight,
          left:this.width - 13,
          src:"/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:"/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 = '" +  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)
        {
          for(var i=0; i<=mainMenuItems.length - 1; i++)
            {
              if(isA.ValicomMenuButton(mainMenuItems[i]))
                {
                  if(mainMenuItems[i].dropDownMenu)
                    {
                      mainMenuItems[i].dropDownMenu.hide();
                    }
                }
            } 
          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:"images/subMenuDivider.png"
});
            
isc.defineClass("MenuDivider","Img").addProperties({
  src:"/images/menu/divider.png",                  
  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:"../demo.aspx",
  closeClick: function()
    {
      this.destroy();
    }
});

isc.defineClass("Webinar", "Window").addProperties({
  isModal:true,
  showModalMask:true,
  autoCenter:true,
  showHeaderIcon:false,
  title:"Webinar",
  width:798,
  height:693,
  src:"/Knowledge/webinar_stream.aspx",
  closeClick: function()
    {
      this.destroy();
    }
});

isc.defineClass("RegisterWindow","Window").addProperties({
  isModal:true,
  showModalMask:true,
  autoCenter:true,
  showHeaderIcon:false,
  title:"Register",
  showMinimizeButton:false,
  canDragReposition:false,
  canDragResize:false,
  showCloseButton:false,
  autoSize:true,
  initWidget: function()
    {
      this.Super("initWidget",arguments);
      
      this.addItem(
        isc.VLayout.create({
          layoutMargin:20,
          members:[
            isc.HTMLFlow.create({
              width:570,
              contents:"Already Registered?  Just enter your email address and click submit.  If you haven't registered with us before, please fill out the form below and click register."      
            }),
            isc.HTMLFlow.create({              
              width:570,
              className:"formHeader",
              contents:"<br><br>Existing Users"
            }),
            isc.DynamicForm.create({
              ID:"ExistingRegForm",
              className:"contactForm",
              numCols:3,
              width:570,
              colWidths:[189,220,100],
              fields:[
                {name:"email", title:"Email", required:true, width:220, validators:[{type:"regexp", expression:"^([a-zA-Z0-9_.\\-+])+@(([a-zA-Z0-9\\-])+\\.)+[a-zA-Z0-9]{2,4}$", errorMessage:"Invalid email format"}]},
                {name:"submit", title:"Submit", endRow:false, width:100, type:"button", startRow:false,
                  click: function(form, item)
                    {
                      form.clearErrors(true);
                      if(form.validate())
                        {
                          PostBackCall("checkRegister|" + form.getValue("email"),"checkRegister");
                        }                       
                    }
                }
              ]
            }),
            isc.HTMLFlow.create({
              width:570,
              className:"formHeader",
              contents:"<br><br>New Users"
            }),
            isc.DynamicForm.create({
              ID:"RegistrationForm",
              className:"contactForm",
              action:"https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8",
              method:"POST",
              width:570,
              numCols:3,
              colWidths:[189,220,100],
              fields:[ 
                {name:"oid", defaultValue:"00D700000009tlI", type:"hidden"},
                //{name:"retURL", defaultValue:"http://www.valicomcorp.com/knowledge/whitepapers_download.aspx", type:"hidden"},
                {name:"00N70000002qknt", defaultValue:leadSource, type:"hidden"},                           
                {name:"first_name", title:"Name", required:true},
                {name:"company", title:"Company", required:true},
                {name:"title", title:"Title", required:true},
                {name:"email", title:"Email", required:true, width:220, validators:[{type:"regexp", expression:"^([a-zA-Z0-9_.\\-+])+@(([a-zA-Z0-9\\-])+\\.)+[a-zA-Z0-9]{2,4}$", errorMessage:"Invalid email format"}]}                ,
                {name:"00N70000002qgl9", title:"How did you find us?", type:"select", width:160, required:true, valueMap: {
                    "Aberdeen Webinar":"Aberdeen Webinar",
                    "Email":"Email",
                    "LinkedIn":"LinkedIn",
                    "Other":"Other",
                    "Press Release":"Press Release",
                    "Referral":"Referral",
                    "Search Engine":"Search Engine",
                    "Twitter":"Twitter",
                    "Valicom Blog":"Valicom Blog",
                    "Wikipedia":"Wikipedia"
                }},
                {type:"spacer"},
                {type:"spacer"},
                {type:"spacer"},
                {name:"register", title:"Register", endRow:false, width:100, type:"button", startRow:false,
                  click: function(form, item)
                    {
                      form.clearErrors(true);
                      if(form.validate())
                        {                          
                          PostBackCall("addRegister|" + form.getValue("email"),"addRegister");
                        }
                    }
                }
              ]
            })
          ]
        })        
      ); 
    },
  closeClick: function()
    {
      this.destroy();
    }
});

isc.defineClass("HomePageWidget", "Canvas").addProperties({
  ID:"HPWCanvas",
  width:650,
  height:330,
  className:"hpwCanvas",
  animateTime:1000,
  position:"relative",
  cancelChange:false,
  changeImage: function()
    {
      if(!this.cancelChange)
        {
          if(hpwImgOne.opacity==100||hpwImgOne.opacity==null)
            {
              if(hpwImgOne.opacity==100||hpwImgOne.opacity==null)
                {
                  hpwImgOne.animateFade(0);
                  hpqThumb1.animateMove(20,278);
                }
              if(hpwImgThree.opacity==100||hpwImgThree.opacity==null)
                {
                  hpwImgThree.animateFade(0);
                  hpqThumb3.animateMove(438,278);
                }
              if(hpwImgTwo.opacity==0)
                {
                  hpwImgTwo.animateFade(100);
                  hpwImgOne.sendToBack();
                  hpwImgThree.sendToBack();
                  hpqThumb2.animateMove(234,260);
                }  
            }
          if(hpwImgTwo.opacity==100||hpwImgTwo.opacity==null)
            {
              if(hpwImgTwo.opacity==100||hpwImgTwo.opacity==null)
                {
                  hpwImgTwo.animateFade(0);
                  hpqThumb2.animateMove(234,278);
                }
              if(hpwImgOne.opacity==100||hpwImgOne.opacity==null)
                {
                  hpwImgOne.animateFade(0);
                  hpqThumb1.animateMove(20,278);
                }
              if(hpwImgThree.opacity==0)
                {
                  hpwImgThree.animateFade(100);
                  hpwImgTwo.sendToBack();
                  hpwImgOne.sendToBack();
                  hpqThumb3.animateMove(438,260);
                }       
            }
          if(hpwImgThree.opacity==100||hpwImgThree.opacity==null)
            {
              if(hpwImgTwo.opacity==100||hpwImgTwo.opacity==null)
                {
                  hpwImgTwo.animateFade(0);
                  hpqThumb2.animateMove(234,278);
                }
              if(hpwImgThree.opacity==100||hpwImgThree.opacity==null)
                {
                  hpwImgThree.animateFade(0);
                  hpqThumb3.animateMove(438,278);
                }
              if(hpwImgOne.opacity==0)
                {
                  hpwImgOne.animateFade(100);
                  hpwImgTwo.sendToBack();
                  hpwImgThree.sendToBack();
                  hpqThumb1.animateMove(20,260);                  
                } 
            }
          setTimeout("HPWCanvas.changeImage();",6000);
        }
    },
  initWidget: function()
    {
      this.Super("initWidget",arguments);      
      
      HPWCanvas.addChild(
        isc.Img.create({
          ID:"hpwImgTwo",
          className:"hpwImage",
          cursor:"hand",
          width:650,
          height:330,
          opacity:0,
          link: this.linkTwo, 
          src:"/images/homepageWidget/2.jpg",
          click: function()
            {
              window.location = this.link;
            }
        })
      );
      HPWCanvas.addChild(
        isc.Img.create({
          ID:"hpwImgThree",
          className:"hpwImage",
          cursor:"hand",
          width:650,
          height:330,
          opacity:0,
          link: this.linkThree, 
          src:"/images/homepageWidget/3.jpg",
          click: function()
            {
              window.location = this.link;
            }
        })
      );
      HPWCanvas.addChild(
        isc.Img.create({
          ID:"hpwImgOne",
          className:"hpwImage",
          cursor:"hand",
          width:650,
          height:330,
          link: this.linkOne,      
          src:"/images/homepageWidget/1.jpg",
          click: function()
            {
              window.location = this.link;
            }
        })
      );
      HPWCanvas.addChild(
        isc.Img.create({
          width:650,
          height:60,
          top:270,
          className:"thumbStrip",
          src:"/images/homepageWidget/thumbStrip.png"
        })
      );
      HPWCanvas.addChild(
        isc.Img.create({
          ID:"hpqThumb1",
          width:74,
          height:44,
          top:260,
          left:20,
          className:"hpwThumb",
          showShadow:true,
          src:"/images/homepageWidget/1thumb.jpg",
          mouseOver: function()
            {            
              if(hpwImgTwo.opacity==100||hpwImgTwo.opacity==null)
                {
                  hpwImgTwo.animateFade(0);
                  hpqThumb2.animateMove(234,278);
                }
              if(hpwImgThree.opacity==100||hpwImgThree.opacity==null)
                {
                  hpwImgThree.animateFade(0);
                  hpqThumb3.animateMove(438,278);
                }
              if(hpwImgOne.opacity==0)
                {
                  hpwImgOne.animateFade(100);
                  hpwImgTwo.sendToBack();
                  hpwImgThree.sendToBack();
                  hpqThumb1.animateMove(20,260);                  
                } 
              HPWCanvas.cancelChange = true;            
            }
        })
      );
      HPWCanvas.addChild(
        isc.VLayout.create({
          top:270,
          height:60,
          left:104,
          members:[
            isc.LayoutSpacer.create({
              height:"*"
            }),
            isc.HTMLFlow.create({ 
              height:1,
              width:110,
              className:"hpwText",
              contents: this.thumbOneText
            }),
            isc.LayoutSpacer.create({
              height:"*"
            })
          ]
        })      
      );
      HPWCanvas.addChild(
        isc.Img.create({
          ID:"hpqThumb2",
          width:74,
          height:44,
          top:278,
          left:234,
          className:"hpwThumb",
          showShadow:true,
          src:"/images/homepageWidget/2thumb.jpg",
          mouseOver: function()
            {
              if(hpwImgOne.opacity==100||hpwImgOne.opacity==null)
                {
                  hpwImgOne.animateFade(0);
                  hpqThumb1.animateMove(20,278);
                }
              if(hpwImgThree.opacity==100||hpwImgThree.opacity==null)
                {
                  hpwImgThree.animateFade(0);
                  hpqThumb3.animateMove(438,278);
                }
              if(hpwImgTwo.opacity==0)
                {
                  hpwImgTwo.animateFade(100);
                  hpwImgOne.sendToBack();
                  hpwImgThree.sendToBack();
                  hpqThumb2.animateMove(234,260);
                } 
              HPWCanvas.cancelChange = true;                
            }
        })
      );
      HPWCanvas.addChild(
        isc.VLayout.create({
          top:270,
          height:60,
          left:318,
          members:[
            isc.LayoutSpacer.create({
              height:"*"
            }),
            isc.HTMLFlow.create({ 
              height:1,
              width:110,
              className:"hpwText",
              contents: this.thumbTwoText
            }),
            isc.LayoutSpacer.create({
              height:"*"
            })
          ]
        })      
      );
      HPWCanvas.addChild(
        isc.Img.create({
          ID:"hpqThumb3",
          width:74,
          height:44,
          top:280,
          left:438,
          className:"hpwThumb",
          showShadow:true,
          src:"/images/homepageWidget/3thumb.jpg",
          mouseOver: function()
            {
              if(hpwImgTwo.opacity==100||hpwImgTwo.opacity==null)
                {
                  hpwImgTwo.animateFade(0);
                  hpqThumb2.animateMove(234,278);
                }
              if(hpwImgOne.opacity==100||hpwImgOne.opacity==null)
                {
                  hpwImgOne.animateFade(0);
                  hpqThumb1.animateMove(20,278);
                }
              if(hpwImgThree.opacity==0)
                {
                  hpwImgThree.animateFade(100);
                  hpwImgTwo.sendToBack();
                  hpwImgOne.sendToBack();
                  hpqThumb3.animateMove(438,260);
                }  
              HPWCanvas.cancelChange = true;               
            }
        })
      );
      HPWCanvas.addChild(
        isc.VLayout.create({
          top:270,
          height:60,
          left:522,
          members:[
            isc.LayoutSpacer.create({
              height:"*"
            }),
            isc.HTMLFlow.create({ 
              height:1,
              width:110,
              className:"hpwText",
              contents: this.thumbThreeText
            }),
            isc.LayoutSpacer.create({
              height:"*"
            })
          ]
        })      
      );
    }
});