﻿// JScript File  JScriptUtilities 
/************************************************************************************* 
-  JScriptUtilities  This file contains JavaScript functions and objects that 
-       are common in nature AND NOT BROWSER SPECIFIC.
**************************************************************************************/
/************************************************************************************* 
-  Related Jscript files   
-        
**************************************************************************************/
/*Commom Page Functions *************************************************************/ 
/* *********************************************************************************** 
-  Commom Page Functions - Function: ChangeLanguage   
-  Purpose:  Change Language Indicator via an AJAX call.
-  Parameters: langType - The numeric representation of the language.  
-  Date:  11/06/2006
-  Mods:
-     
************************************************************************************ */
function ChangeLanguage(langType)
{     
    AjaxProxy.ClientSetLanguage(langType);
}
/*Image Swap Classes *****************************************************************/
/* *********************************************************************************** 
/* ImgSwap Class                                                                     */
/* *********************************************************************************** 
-  Class: ImgSwap
-  Purpose: Detects and swaps images for navigation.
-  Date:  6/12/2006
-  Mods:
-    
************************************************************************************ */
function ImgSwap(thisForm)
{
// Constructor /////////////////////////////////////////
    this.curForm = thisForm;
////////////////////////////////////////////////////////


// Public Function Declarations ////////////////////////
    this.replaceImage = replaceImage;
////////////////////////////////////////////////////////

// Public Functions ////////////////////////////////////
/* *********************************************************************************** 
-  Public  Functions:  replaceImage()
-  Parameters: String of pagename,target element Id,replacement image. 
-  Purpose: Iterate thru a list of pages and associated images and replace the image
-           if it is found.  The imageList is in the form:
-           pagename,target element Id,replacement image|pagename,target element Id,replacement image......  
-  Date:  6/12/2006
-  Mods:
-     
************************************************************************************ */    
    function replaceImage(imageList)
        {  
            //Find the page, split the page/id/image tag string on the pipe delimiter
            var splitImage = imageList.split("|");
            var imgEle;
            var imgEleArr;
            
            //Go thru the array and pick out all entries for this page, then 
            //substitute the image.
            for(var i = 0; i < splitImage.length; i++)
            {
                //Go locate the page
                if(locatePage(this.curForm,splitImage[i]))
                    {
                        imgEleArr = splitImage[i].split(",");
                        imgEle = document.getElementById(imgEleArr[1]);
                        if(imgEle)
                            {   
                                //This is a bit kludgy we do this because the < and > tags
                                //can't be in the web config entry where the imageList currently
                                //resides.  We can remove this when the data lives in a database.  
                                imgEleArr[2] = imgEleArr[2].replace("@","<");
                                imgEleArr[2] = imgEleArr[2].replace("*",">");
                                imgEle.innerHTML = imgEleArr[2];
                            }
                    
                    }
            
            }
          
        }  
// Private Functions        ////////////////////////        
/* *********************************************************************************** 
-  Private  Functions:  locatePage()
-  Parameters: pageName - Name of the current page
-              imageRow - Current row in imageList in the form pagename,target element Id,replacement image   
-  Purpose: Find a match in the string passed to the current page name. 
-  Date:  6/12/2006
-  Mods:
-     
************************************************************************************ */          
    function locatePage(pageName, imageRow)
        { 
            //Find out if images on this page should be swapped 

            var imgRSplit = imageRow.split(",");   
                        
            if(pageName == imgRSplit[0])
                {
                    return true; 
                
                }
            else
                {
                    return false;
                }    
                
        }        


} 
/*End Image Swap Classes *************************************************************/ 
