﻿var lastAnswer = null;

function TogglePanel(index, arrow)
{
var divPanelContainer = GetObject('divPanelContainer');
var panel_items = divPanelContainer.getElementsByTagName('div');
    
var arrow_img_set = new Array();
arrow_img_set[0] = '../images/clinicalstudies/arrow_rt.jpg';
arrow_img_set[1] = '../images/clinicalstudies/arrow_dwn2.jpg';
arrow_img_set[2] = '../images/blue_arrow_rt3.jpg';
arrow_img_set[3] = '../images/blue_arrow_down4.jpg';
    
var cntr = 0;

if (parseInt(panel_items.length) > 0)
{
for (var i = 0; i < parseInt(panel_items.length); i++)
{
if (panel_items[i].className.toLowerCase().indexOf('panel_title') != -1)
{
var arrow_img = panel_items[i].getElementsByTagName('img')[0];
var p = panel_items[i].getElementsByTagName('p')[0];
//var a = panel_items[i].getElementsByTagName('a')[0];
var smallQuote = panel_items[i].getElementsByTagName('div')[0];
}
            
if (panel_items[i].className.toLowerCase().indexOf('panel_list') != -1)
{
if (cntr == index)
{
if (panel_items[i].className.toLowerCase().indexOf('hide') != -1)
{
panel_items[i].className = 'panel_list show';
                        
arrow_img.src = arrow_img_set[arrow+1];
arrow_img.alt = 'Collapse';
arrow_img.title = 'Collapse';
                        
if (p)
{
p.innerHTML = 'click to collapse';
p.title = 'click to collapse';
}
                        
//a.title = 'click to collapse';
                        
if (smallQuote)
smallQuote.className = smallQuote.className.replace("show", "hide");
                        

if (lastAnswer != null)
lastAnswer.className = lastAnswer.className.replace('show', 'hide');
}
else
{
panel_items[i].className = 'panel_list hide';
                        
arrow_img.src = arrow_img_set[arrow];
arrow_img.alt = 'Expand';
arrow_img.title = 'Expand';
                        
if (p)
{
p.innerHTML = 'click to expand';
p.title = 'click to expand';
}
                        
//a.title = 'click to expand';
                        
if (smallQuote)
smallQuote.className = smallQuote.className.replace("hide", "show");
}
}
else
{
// comment the following lines of code if you wish to keep the panel lists open between clicks
panel_items[i].className = 'panel_list hide';
                    
arrow_img.src = arrow_img_set[arrow];
arrow_img.alt = 'Expand';
arrow_img.title = 'Expand';
                    
if (p)
{
p.innerHTML = 'click to expand';
p.title = 'click to expand';
}
                    
//a.title = 'click to expand';
                    
if (smallQuote)
smallQuote.className = smallQuote.className.replace("hide", "show");
}
                
cntr++;
}
}
}
_ie732Bit_layoutfix();
}

/**
* on the Systemic Links Page, IE 7 (32 Bit) will fail to refresh the bottom part of the left nav.
* For some reason, IE7 32 Bit forgets what the bottom setting is.  Developer toolbar shows the correct 
* setting, and when the setting is re-applied via developer toolbar, the layout corrects itself. 
* This function merely uses the bottom style setting and resets it for a handful of elements.
* For some reason, the orginal style needs to be inline. 
*/ 
function _ie732Bit_layoutfix() {
    var els_to_refresh = ['left_bottom_bg', 'icon_wrap', 'visit_container'];

    for (var i = 0; i < els_to_refresh.length; i++) {
        var _el = document.getElementById(els_to_refresh[i]);
        var _bottom_style = _el.style.bottom
        _el.style.bottom = "";
        _el.style.bottom = _bottom_style;
    }
}


function ToggleAnswer(questionSetIndex, answerIndex)
{
	var questionSet = GetObject('divQuestionSet' + questionSetIndex.toString());
	var answer = questionSet.getElementsByTagName('div');
	var cntr = 0;

	for (var a = 0; a < answer.length; a++)
	{
	    if (answer[a].className.indexOf('answer') != -1) {
	        if (cntr == answerIndex) {
	            if (answer[a].className.indexOf('hide') != -1) {
	                answer[a].className = answer[a].className.replace('hide', 'show');

	                lastAnswer = answer[a];
	            }
	            else {
	                answer[a].className = answer[a].className.replace('show', 'hide');
	            }
	        }
	        else {
	            // comment the following lines of code if you wish to keep the answers open between clicks
	            answer[a].className = answer[a].className.replace('show', 'hide');
	        }

	        cntr++;
	    }
	}

	return;
}


// --- HELPER METHODS --- //
function GetObject(obj)
{
    return ((typeof(obj) != 'object') ? document.getElementById(obj) : obj);
}
