﻿Menu.prototype.ImagesDir='';
Menu.prototype.BannerElement='imgHeader';
Menu.prototype.Banners=["banner.jpg"];

Menu.prototype.newImage=function(imageName) 
{
    /// <summary>Creates and returns new HTML Image Object from the imageName</summary>
    if (document.images) {
        var rslt = new Image();
        rslt.src =this.ImagesDir + imageName;
        return rslt;        
    }
}

function Menu()
{
    /// <summary>Menu Class</summary>        
    
}

Menu.prototype.setImagesDir=function(imagesDir)
{
    //Sets Image Directory to use for loading images
    this.ImagesDir=imagesDir;    
}

Menu.prototype.setBanner=function()
{
    /// <summary>Assigns random banner to BannerElment(header)</summary>
    var totalBanners=this.Banners.length;
    var randomBanner=this.Banners[Math.floor(Math.random()*totalBanners)];
    var bannerImage=this.newImage(randomBanner);
    document.getElementById(this.BannerElement).src=bannerImage.src;
}

Menu.prototype.preloadImages=function(imageArray)
{    
    /// <summary>PreLoads Images</summary>
    /// <param name="ImageArray">Array Of Image names, relative to ImageDir variable 
    //  defined by the MasterPage or explicitly set using setImagesDir function
    /// </param>
    var i;
    var _tempArray=new Array;            
    
    if (document.images)
    {
        for(i=0;i<imageArray.length;i++)
        {                       
            _tempArray[i]=new Image();
            _tempArray[i].src=this.ImagesDir + imageArray[i];            
        }
    }
    return _tempArray;    
}

Menu.prototype.updateTextBar=function(selectedMenu)
{    
    /// <summary>Sets corrosponding text for the selectedMenu in textbar</summary>
    /// <param name="selectedMenu">Name of menu in the form nav_<MenuName></param>
    var fieldTextBar=document.getElementById('tdTextBar');
        
    var barText=''
    var texAlign=''            
    var selMenu=selectedMenu.toLowerCase();

    //Remove _sec suffix from selectedMenu name
    var secIndex = selMenu.indexOf('_sec');    
    if(secIndex>=0)
        selMenu=selMenu.substr(0,secIndex);
        
       // alert(selMenu);
    switch(selMenu)
    {
        case 'nav_broadcaster':
            barText='I am a broadcaster or production company. How will VenueMgr.com benefit my organization?';                    
            break;
        
        case 'nav_industry':
            barText='How is VenueMgr.com changing the industry and what are the benefits that it brings?';                    
            break;
        
        case 'nav_venues':
            barText='What defines a venue and what information is contained in VenueMgr.com?';
            break;
        
        case 'nav_franchises':
            barText='How does VenueMgr.com store franchise information and how is it used?';
            break;
        
        case 'nav_resources':
            barText='How does VenueMgr.com store resource information and how is it used?';
            break;
        
        case 'nav_company':
            barText='Who is the driving force behind VenueMgr.com and how did it get started?';                    
            break;                
        
        case 'nav_login':
            barText='If you have a user account, click here to log-in.';                    
            break;
                
        case 'nav_home':
            barText='Use this button to return to the home page.';
            break;
            
        case 'nav_registernow':
            barText='Apply for user access and begin exploring all the benefits of VenueMgr.com.';
            break;

    }
    
    texAlign='center';    
    fieldTextBar.innerHTML=barText;
    fieldTextBar.style.textAlign=texAlign;     
}
      
Menu.prototype.changeImagesArray= function(array) 
{  
    //Prefix imageDir before image name
    array[1]=this.ImagesDir + array[1].toString();
    
    var d = document; var img;
    for (var i=0; i<array.length; i+=2) 
    {
        img = null; var n = array[i];
        if (d.images) {img = d.images[n];}
        if (!img && d.getElementById) {img = d.getElementById(n);}
        if (img) {img.src = array[i+1];}
    }
}

Menu.prototype.changeImages=function() 
{  
    /// <summary></summary>     
    this.changeImagesArray(this.changeImages.arguments);
}

