﻿// Common JScript File

// Common tab functions for vertical tabs
// generic function to create a 'array list' and add properties of the base 'class' to the array list to give a custom collection object. 
  function CreateCollection(ClassName)    
{
    var obj=new Array();
   // create the base class object 
    eval("var t=new "+ClassName+"()");
   // assign base class object property/method to tehnew object created  
    for(_item in t)
        {
            eval("obj."+_item+"=t."+_item);
        }
    return obj;
}
    // individual tab oject. Holds client ids of the tab and related tab content
    function TabObject(pTabButtonClientID,pTabContentClentID) 
    {
  
       // Tab button client id  
       this.TabButtonClientID = pTabButtonClientID;
      // Tab content client id 
       this.TabContentClientID = pTabContentClentID;
      //Disabled property
    
        this.Disabled = function()
        {
            if(this.TabButtonClientID != null)
                return  (document.getElementById(this.TabButtonClientID).className );
            else
                return(this.TabButtonClientID) ;
         } 
                                 
      // Hide a tab method 
       this.Hide = function()
                           {
                               var obj= document.getElementById(this.TabButtonClientID);
                              if(obj != null) obj.className=null;
                               var obj= document.getElementById(this.TabContentClientID);
                              if(obj != null) obj.style.display='none';
                           }
       // set style attributs for a tab to 'cuurent tab' method                           
       this.Show = function()
                           {
                                var obj= document.getElementById(this.TabButtonClientID);
                                if(obj != null) obj.className='selectedtabitem';
                                var obj= document.getElementById(this.TabContentClientID);
                                obj.style.display='block';       
                           }
    }  
  // Collection of tab objects 
   function TabObjectList()
   {
   // Hidden field to record value of current tab - used on serverside to reshow teh last tab teh user was on prior to a postback
     this.CurrentTab = null;
     // Add a tab to teh tabs collection
      this.Add = function(pTabName,pTabObject)
                        {
                            this[pTabName] = pTabObject;
                        }
       // Move to another tab
       this.ShowTab = function(pTabToShow)
                                {
                                    if(pTabToShow != null)
                                    {          
                                       if(this[pTabToShow].Disabled() != "selectedtabitem")
                                       {
                                            for(x in this)
                                            {
                                                 if(this[x] != null && this[x].Hide != null) this[x].Hide();
                                            } 
                                            this[pTabToShow].Show();
                                             
                                            if(this.CurrentTab != null) document.getElementById(this.CurrentTab).value = pTabToShow;
                                       }
                                    }
                                 }    
   } 
   // end of vertical tab functions

    // Used by FrameBreakoutURL to enable the page to detect and breakout from a frame if required
    function FrameBreakout(url)
    {
       if (window.top!=window.self) 
        {
                // In Frame, set top window to url
            window.top.location.href = url;  
        }
    }
    
    function MessagePageContinueAction(url)
    {
        window.top.location.href = url;  
    }