﻿
/***************************************************************

    Created By: Asa Sherrill <asa.sherrill@definition6.com>
    Date: 12/18/2006
    
    Quantum Contact Manipulator is a dedicated set of code
    for managing the dhtml of QuantumRadiology's contact page. 
    It is designed to make use of "blocks" or divs that contain
    a link and a div which will be triggered on and off.
    
    Each div should have base "ID" which should be registered in
    arr_ContactBlocks below. Additionally, each link should be 
    labeled by the ID plus a distinct appendage which can also be
    set below. The default appendage for a link is "Link"...
    
    e.g.
    If the block's id is "Identifier" then the link to control
    the block will be called "IdentifierLink". 
    
    This same convention goes for the inner div which will be 
    opened and closed. These two values can be altered by changing
    str_LinkAppendage and str_DataAppendage below.
    
    While the data div is opened and closed, the link's class will
    be toggled as well. The two variables, str_ClosedStateLinkClass
    and str_OpenedStateLinkClass can be set to different classes
    if you so desire.
    
    ** The Main Container div is not necessary. 
    
********************************************************************/    
        
/* Add contact blocks to this array */
//var arr_ContactBlocks =  new Array(    
//   "14",
//   "15",   
//   "13",
//   "17",
//   "18"  
//);

var arr_BlockStatus = new Array ( arr_ContactBlocks.length );


var str_LinkAppendage = "Link";
var str_DataAppendage = "Data";

var str_ClosedStateLinkClass = "LocationLinkClosed";
var str_OpenedStateLinkClass = "LocationLinkOpened";

/*Initialize*/

for ( var x = 0; x < arr_ContactBlocks.length; x ++ ) {

  // debugger;
    document.getElementById ( arr_ContactBlocks[x] + str_DataAppendage ).style.display = "none";
    document.getElementById ( arr_ContactBlocks[x] + str_LinkAppendage ).className = str_ClosedStateLinkClass;
    arr_BlockStatus[x] = 0;
    
}

/********************************************************************
    requestToggleBlock()
    
    PRE: any string
    POST: if the string exists in the registered list and the 
          status is closed, the block will be opened
      
*********************************************************************/
function requestToggleBlock ( whichBlock ) {
        
    //debugger;
    // get status of block
    var int_BlockIndex = getBlockIndex ( whichBlock ); 
       
        switch ( arr_BlockStatus[int_BlockIndex] ) {
        
            case -1:
                // no op
                break;
                
            case 0:
                doOpenBlock( int_BlockIndex );
                break;
            
            case 1:
                doCloseBlock( int_BlockIndex );
                break;
        }

    
}

/********************************************************************
    getBlockIndex()
    
    PRE: any string
    POST: if the string exists in the registered list, returns
          the index number. If the string does NOT exist in the 
          array, returns -1;
      
*********************************************************************/
function getBlockIndex ( blockName ) {

    for ( var b = 0; b < arr_ContactBlocks.length; b ++ ) {
        
        if ( arr_ContactBlocks[b] == blockName ) {
            return b;
        }
        
    }
    
    return -1;

}

/********************************************************************
    getBlockStatus()
    
    PRE: 0 <= block_index < arr_BlockStatus.length
    POST: returns 0 or 1 depending on whether or not the
          block is opened or closed
      
*********************************************************************/
function getBlockStatus ( block_index ) {

    return arr_BlockStatus[block_index];
    
}

/********************************************************************
    Use the below methods to customize animation of 
    opening/closing blocks.  
*********************************************************************/

function doOpenBlock ( block_index ) {

    /***********************
       Block Animation
    *******************************************************************************/
    
    //document.getElementById ( arr_ContactBlocks[block_index] + str_DataAppendage ).style.display = 'block';  
    new Effect.BlindDown (arr_ContactBlocks[block_index] + str_DataAppendage, {duration:.5} );
    
    document.getElementById ( arr_ContactBlocks[block_index] + str_LinkAppendage ).className = str_OpenedStateLinkClass;
    
    /*****************************************************************************/
    /*  Do not modify statement */ arr_BlockStatus[block_index] = 1; /**/
   
}

function doCloseBlock ( block_index ) {

     /***********************
       Block Animation
    *******************************************************************************/
    
    //document.getElementById ( arr_ContactBlocks[block_index] + str_DataAppendage ).style.display = "none";
    new Effect.BlindUp (arr_ContactBlocks[block_index] + str_DataAppendage, {duration:.5} );
    document.getElementById ( arr_ContactBlocks[block_index] + str_LinkAppendage ).className = str_ClosedStateLinkClass;
    
     /*****************************************************************************/
     /*  Do not modify statement */ arr_BlockStatus[block_index] = 0; /**/

}
