 
/*********************************************************************************************************************
 * IE PNG Alpha Fix v1.0 RC4 - http://www.twinhelix.com                          									 *
 *********************************************************************************************************************/

    /* This applys an IE filter to correct the transparency of PNG images */
    if (document.all && document.styleSheets && document.styleSheets[0] && document.styleSheets[0].addRule)
    {
        // Apply the fix to img's
        //document.styleSheets[0].addRule('img', 'behavior: url(/shared/js/iepngfix.htc)');
        // Apply the fix to div's
         //document.styleSheets[0].addRule('div', 'behavior: url(/shared/js/iepngfix.htc)');
    }

/*********************************************************************************************************************
 * CONTENT-SPECIFIC FUNCTIONS                       																 *
 *********************************************************************************************************************/
 
     /* Custom Drop Down List */
     function selectOption(selectedText, selectedValue){
     
        var selectedTextSpan;
        var selectedValueSpan;
        
        selectedTextSpan = document.getElementById('selectedOption');
        selectedValueSpan = document.getElementById('selectedValue');
        
        if (selectedTextSpan){
            selectedTextSpan.innerHTML = selectedText;
        }
        if (selectedValueSpan){
            selectedValueSpan.value = selectedValue;
        }
        
        changeClass('optionList','off');
    }
    function redirect(){
        var selectedValueSpan;
        var url;
        selectedValueSpan = document.getElementById('selectedValue');
        url = selectedValueSpan.value;
        if (url == ''){
            alert('Please choose a site');
        }
        else {
            window.location = url;
        }
    }
 
    /* Open popup */
    function popup(){
        // Open the window
        newPopup = window.open('Popup.htm','popupWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=624,height=767');
        return false;
    }
    function openPopup(){
        // Open the window
        newPopup = window.open('/shared/templates/modules/productpopup.htm','popupWindow','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=500');
        //alert('hello');
    }
    
    /* This wires up the popup windows */
    /* I found this sillliness at: http://www.accessify.com/features/tutorials/the-perfect-popup/ */
    window.onload = function() {
        // check to see that the browser supports the getElementsByTagName method	
        // if not, exit the loop 	
        if (!document.getElementsByTagName){
            return false;
        }
        // create an array of objects of each link in the document 	
        var popuplinks = document.getElementsByTagName("a");	
        // loop through each of these links (anchor tags) 		
        for (var i=0; i < popuplinks.length; i++){			
            // if the link has a rel of "popup"...			
            if (popuplinks[i].rel.indexOf("popup")!=-1){

                // add an onclick event on the fly to pass the href attribute				
                // of the link to our second function, openPopUp 				
                popuplinks[i].onclick = function() {				
                    openPopup('/shared/templates/modules/productpopup.htm');				
                    return false;
                }
            }
        }
    } 

    /* Change the selected product detail tab */
	function selectProductTab(elementId){
	    
	    var i=0;
	    var maxlen=121;
	    var ArrTab=new Array(maxlen)

	    for (i=0;i<maxlen; i++) 
	    {
			ArrTab[i]=new Array(3);
		}
		
		var str;
		//Define all the tab names here
	    ArrTab[0][0] = "rates";
	    ArrTab[1][0] = "requirements";
	    ArrTab[2][0] = "free";
	    ArrTab[3][0] = "related";
	    ArrTab[4][0] = "account";
	    ArrTab[5][0] = "learning";
	    ArrTab[6][0] = "addInfo";
	    ArrTab[7][0] = "online";
	    ArrTab[8][0] = "becSup";
	    ArrTab[9][0]= "cerRen";
	    ArrTab[10][0] = "comLis";
	    ArrTab[11][0] = "polOve";
	    ArrTab[12][0] = "guidenlines";
	    ArrTab[13][0] = "subReq";
	    ArrTab[14][0] = "feaBen";
	    ArrTab[15][0] = "terCon";
	    ArrTab[16][0] = "feeOpt";
	    ArrTab[17][0] = "bulOrd";
	    ArrTab[18][0] = "points";
	    ArrTab[19][0] = "features";
	    ArrTab[20][0] = "relProSer";
	    ArrTab[21][0] = "accFea";
	    ArrTab[22][0] = "fees";
	    ArrTab[23][0] = "tour";	    
	    ArrTab[24][0] = "corOpe";
	    ArrTab[25][0] = "loaSer";
	    ArrTab[26][0] = "infSer";
		ArrTab[27][0] = "comRelFinSer";
		ArrTab[28][0] = "capMar";
		ArrTab[29][0] = "finance";
		ArrTab[30][0] = "boaDir";
		ArrTab[31][0] = "officers";
		ArrTab[32][0] = "corDoc";
		ArrTab[33][0] = "proFea";
		ArrTab[34][0] = "ratFee";		
		ArrTab[35][0] = "relPro";
		ArrTab[36][0] = "redMil";	
		ArrTab[37][0] = "freOnlPayBil";
		ArrTab[38][0] = "touDem";
		ArrTab[39][0] = "onlBan";
		ArrTab[40][0] = "onlBilPay";
		ArrTab[41][0] = "tips";
		ArrTab[42][0] = "plaAccTyp";
		ArrTab[43][0] = "benefits";
		ArrTab[44][0] = "accSer";
		ArrTab[45][0] = "feaAdv";
		ArrTab[46][0] = "feeConLim";
		ArrTab[47][0] = "funOpt";
		ArrTab[48][0] = "tab1Wait";
		ArrTab[49][0] = "tab2Wait";
		ArrTab[50][0] = "tab3Wait";
		ArrTab[51][0] = "tab4Wait";	
		ArrTab[52][0] = "taxCod";	
		ArrTab[53][0] = "solPro";
		ArrTab[54][0] = "leaPro";
		ArrTab[55][0] = "busBen"; 
		ArrTab[56][0] = "empBen";  
		ArrTab[57][0] = "forms";  
		ArrTab[58][0] = "enroll";  
		ArrTab[59][0] = "help";  
		ArrTab[60][0] = "meePro";  
		ArrTab[61][0] = "casYouVot";  		
		ArrTab[62][0] = "plans";
		ArrTab[63][0] = "proDet";
		ArrTab[64][0] = "visBusOpt";	
		ArrTab[65][0] = "rate";
		ArrTab[66][0] = "tecReq";
		ArrTab[67][0] = "relationships";
		ArrTab[68][0] = "industries";
		ArrTab[69][0] = "results";
		ArrTab[70][0] = "achPosPay";
		ArrTab[71][0] = "webAch";
		ArrTab[72][0] = "robRep";
		ArrTab[73][0] = "advantages";
		ArrTab[74][0] = "solutions";
		ArrTab[75][0] = "relSol";
		ArrTab[76][0] = "contacts";
		ArrTab[77][0] = "expertise";
		ArrTab[78][0] = "relSer";	
		ArrTab[79][0] = "experience";	
		ArrTab[80][0] = "whyNatCitBan";
		ArrTab[81][0] = "options";	
		ArrTab[82][0] = "rewBen";
		ArrTab[83][0] = "details";
		ArrTab[84][0] = "rules";
		ArrTab[85][0] = "rotTra";
		ArrTab[86][0] = "stocks";
		ArrTab[87][0] = "bonds";
		ArrTab[88][0] = "spInvAcct";
	    ArrTab[89][0] = "compare";
	    ArrTab[90][0] = "ageIncomeCont";
	    ArrTab[91][0] = "ageIncomeRest";
	    ArrTab[92][0] = "contributionLimits";
	    ArrTab[93][0] = "conLim";
	    ArrTab[94][0] = "security";
	    ArrTab[95][0] = "Implementation";
	    ArrTab[96][0] = "onlDem";
	    ArrTab[97][0] = "rateFee";
	    ArrTab[98][0] = "traIra";
	    ArrTab[99][0] = "busServc";
	    ArrTab[100][0] = "secFea";
	    ArrTab[101][0] = "demo";
	    ArrTab[102][0] = "benLea";
	    ArrTab[103][0] = "aboLea";
        ArrTab[104][0] = "written";
        ArrTab[105][0] = "implied";
	    ArrTab[106][0] = "nccFea";
	    ArrTab[107][0] = "impNcc";
	    ArrTab[108][0] = "ncsFea";
	    ArrTab[109][0] = "impNcs";
	    ArrTab[110][0] = "written";
	    ArrTab[111][0] = "implied";        
	    ArrTab[112][0] = "steps";  
	    ArrTab[113][0] = "ncsFeaImp";  
        ArrTab[114][0] = "nccFeaImp";  
        ArrTab[115][0] = "sbaLoaGua";  
        ArrTab[116][0] = "cerDevCom";  
        ArrTab[117][0] = "sbaLoaGua";  
        ArrTab[118][0] = "cerDevCom";  
        ArrTab[119][0] = "cardUsg";

	    for (i=0; i<ArrTab.length; i++) 
	    {	    
			// CSS class Name with "Tab"
			ArrTab[i][1] = ArrTab[i][0] + "Tab";

			// Get Element
			ArrTab[i][2] = document.getElementById(ArrTab[i][1]);

			//Reset all the tabs
			if (ArrTab[i][2]) 
			{ 				
				// Handle the class and mouseouts
				if (elementId == ArrTab[i][0]) 
				{ 					
				    ArrTab[i][2].className = 'selected';					
					ArrTab[i][2].onmouseout = function(){this.className = 'selected';} ;					
					
					// Show the selected body
					changeClass(elementId,'selected');
				}
				else
				{	
				    ArrTab[i][2].className = '';
				    ArrTab[i][2].onmouseout = function(){this.className = '';} ;
				    
					// Hide all the bodies
					changeClass(ArrTab[i][0], '');					
				}
			}			
		}
	}
	/* Hover a product detail tab */
	function mouseOverProductTab(elementId){
        // Get a reference to the element
        element = document.getElementById(elementId);
        // Make sure it is not selected already
        if (element.className != 'selected'){
			// Hover the list item
			element.className = 'hover';
		}
	}

    /* The advanced search options */
    function toggleSearch(){
        // Toggle the advanced search menu off/on
        toggleClass('advancedSearch', 'off', 'on');

    }
    function toggleSearchMaskLogin(){
        // Mask the windowed select object (IE6)
        toggleClass('loginSelect', 'unmasked', 'masked');
        // Toggle the advanced search menu off/on
        toggleSearch();

    }
    
    /* The Open/Close link  */
    function toggleLogin(){
        // Toggle the icon next to the Open/Close link
        toggleClass('toggleLogin','down','up');
        // Toggle the link text Open/Close
        toggleText('toggleLogin','Open','Close');
        // Toggle the secure login area
        toggleClass('frmLogin','on','off');
    }

    /* The Open/Close link in the Secure Login Module */
    function toggleSecureLogin(isEnglish){
        // Toggle the icon next to the Open/Close link
        toggleClass('toggleLogin','down','up');
        // Toggle the link text Open/Close
        if (isEnglish)
        {
            toggleText('toggleLogin','Open','Close');
        }
        else
        {
            toggleText('toggleLogin','',''); // TODO:
        }
        // Toggle the secure login area
        toggleClass('frmLogin','on','off');
    }

    function selectOption(linkName, linkUrl){
        window.location = linkUrl;
    }    
    
    /* Hide an element and fill the space it took up */
    function hide(elementId){
        changeClass(elementId, 'off');

    }
    function show(elementId){
        changeClass(elementId, 'on');

    }
    
    /* Hide an element and preserve the space it took up */
    function mask(elementId){
        changeClass(elementId, 'masked');

    }
    function unmask(elementId){
        changeClass(elementId, 'unmasked');

    }
    
    /* Foo */
    function select(elementId){
        changeClass(elementId, 'selected');
    }
    function deselect(elementId){
        changeClass(elementId, '');
    }

/*********************************************************************************************************************
 * UTILITY FUNCTIONS    																							 *
 *********************************************************************************************************************/
 
    /***********************************************************************
     * toggleText           											   *
     ***********************************************************************
     * Switches the innerHTML value of an element between off and on       *
     * Parameters:          											   *
     *   - elementId: The id of the element to switch                      *
     *   - offText: The text for the off state                             *
     *   - onText: The text for the on state                               *
     * Results:             											   *
     *   - If the element was on, it will be off                           *
     *   - If the element was off, it will be on                           *
     ***********************************************************************/
    function toggleText(elementId, offText, onText){
        // Get a reference to the element
        element = document.getElementById(elementId);
        // Make sure the element was on the page
        if (element) {
			// If the element's text is "On"
			if(element.innerHTML == offText){
			    // Turn it "Off"
			    element.innerHTML = onText;
			}
			// If the element's text is "Off"
			else if(element.innerHTML  == onText){
			    // Turn it "On"
			    element.innerHTML = offText;
			}
		}
    }
    
    /***********************************************************************
     * toggleClass          											   *
     ***********************************************************************
     * Switches the className value of an element between off and on       *
     * Parameters:          											   *
     *   - elementId: The id of the element to switch                      *
     *   - offClassName: The class for the off state                       *
     *   - onClassName: The class for the on state                         *
     * Results:             											   *
     *   - If the element was on, it will be off                           *
     *   - If the element was off, it will be on                           *
     ***********************************************************************/
    function toggleClass(elementId, offClassName, onClassName){
        // Get a reference to the element
        element = document.getElementById(elementId);
        // Make sure the element was on the page
        if (element) {
			// If the element's class is "Off"
			if(element.className == offClassName){
			    // Turn it "On"
			    element.className = onClassName;
			}
			// If the element's class is "On"
			else if(element.className == onClassName){
			    // Turn it "Off"
			    element.className = offClassName;
			}
		}
    }
    
    /***********************************************************************
     * changeClass          											   *
     ***********************************************************************
     * Switches the className value of an element                          *
     * Parameters:          											   *
     *   - elementId: The id of the element to switch                      *
     *   - className: The class to set the element to                      *
     * Results:             											   *
     *   - The element will be set to the given class                      *
     ***********************************************************************/
    function changeClass(elementId, className){
        // Get a reference to the element
        element = document.getElementById(elementId);
        // Make sure the element was on the page
        if (element) {
			// Update the element's className property
			element.className = className;
        }
    }
    
    function changeText(elementId, text){
        // Get a reference to the element
        element = document.getElementById(elementId);
        // Make sure the element was found
        if (element) {
			// Update the element's className property
			element.innerHTML = text;
        }
    }
    
    function changeImage(elementId, img) {
        // Get a reference to the element
        element = document.getElementById(elementId)
        // Make sure the element was found
        if (element) {
            // Update the element's path
            element.src = img
        }
    }
    function newImage(arg) {
	    if (document.images) {
		    rslt = new Image();
		    rslt.src = arg;
		    return rslt;
	    }
    }
