// not animated collapse/expand
function togglePannelStatus(content)
{
// Added by MK - Mozilla space characters - next.Sibling #text
var content = content.nextSibling;
if (content.nodeName == '#text') content = content.nextSibling;

    var expand = (content.style.display=="none");
    content.style.display = (expand ? "block" : "none");
    toggleChevronIcon(content);
}

// current animated collapsible panel content
var currentContent = null;

function togglePannelAnimatedStatus(content, interval, step)
{

// Added by MK - Mozilla space characters - next.Sibling #text
var content = content.nextSibling;
if (content.nodeName == '#text') {content = content.nextSibling;}

    // wait for another animated expand/collapse action to end
    if (currentContent==null)
    {
        currentContent = content;
        var expand = (content.style.display=="none");
        if (expand)
        {content.style.display = "block";}
        
		var max_height = content.offsetHeight;

        var step_height = step + (expand ? 0 : -max_height);

		toggleChevronIcon(content);
                
        // schedule first animated collapse/expand event
        content.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
}

function togglePannelAnimatingStatus(interval,
    step, max_height, step_height)
{
    var step_height_abs = Math.abs(step_height);

    // schedule next animated collapse/expand event
    if (step_height_abs>=step && step_height_abs<=(max_height-step))
    {
        step_height += step;
        currentContent.style.height = Math.abs(step_height) + "px";
        setTimeout("togglePannelAnimatingStatus("
            + interval + "," + step
            + "," + max_height + "," + step_height + ")", interval);
    }
    // animated expand/collapse done
    else
    {
        if (step_height_abs<step)
            currentContent.style.display = "none";
        currentContent.style.height = "";
        currentContent = null;
    }
}

// change chevron icon into either collapse or expand
function toggleChevronIcon(content)
{
var chevron = content.parentNode;
chevron = chevron.firstChild;
if (chevron.nodeName  == '#text') 
{
	chevron = chevron.nextSibling;
	if (chevron.nodeName  == '#text') {chevron = chevron.nextSibling;}
}

chevron = chevron.childNodes[1];

if (chevron.childNodes[0].nodeName  == '#text') 
	{
	chevron = chevron.nextSibling;
	chevron = chevron.nextSibling;
	chevron = chevron.firstChild;
	}
else chevron = chevron.childNodes[0];

var expand = (chevron.src.indexOf("panel_expand.gif")>0);
    chevron.src = chevron.src
        .split(expand ? "panel_expand.gif" : "panel_collapse.gif")
        .join(expand ? "panel_collapse.gif" : "panel_expand.gif");
}

// links with ?mortgage=type1
function init() {
var searchString = document.location.search.substring(1);
if (searchString) {
	var name_value = searchString.split("%23");
	value = name_value[0].split("=");
	var mortgageType = value[1];
	document.getElementById(mortgageType).style.display='block';
	eval('document.getElementById("showHide_'+mortgageType+'").src="../images/panel_collapse.gif"');
	}
}

window.onload = init;

