﻿// JScript File
var g_AJAXUrl
var g_isIE = false
if (window.ActiveXObject)
{
    g_isIE = true
}

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}

function fncAssignXMLText(objNode)
{
    if (window.ActiveXObject)
    {
        return objNode.text
    }
    // code for Mozilla, Firefox, Opera, etc.
    else
    {
        return objNode.textContent
    }
}

function HTMLDecode(str)
{
    return str.replace(/&gt;/g, ">").replace(/&lt;/g,"<").replace(/&nbsp;/g, " ").replace(/&quot;/g, " ");
}

function dropMenu(index)
{
    if (g_isIE)
    {
        $('lilhsChildMenu' + index.toString() ).style.display = "block"
    }    
    $('lhsChildMenu' + index.toString()).style.display = "block"
}

function loadSecondNav(index, nodeID, bAjax)
{
    dropMenu(index)
    loadPage(nodeID, bAjax)
}

function loadPage(nodeID, bAjax)
{
    var objMenu, varName

    //remove highlight from all nav start
    $('ctl00_holderLHS_ctlLHSMenu_lnkSubParent').className = ''
    
    for (index = 0; index < 5;index++)
    {
        switch (index)
        {
            case 0:
                varName = 'lhsChildMenu'
                break;
            case 1:
                varName = 'lhsChildMenu0'
                break;
            case 2:
                varName = 'lhsChildMenu1'
                break;
            case 3:
                varName = 'ctl00_holderLHS_ctlLHSMenu_lhsSubMenu1'
                break;
            case 4:
                varName = 'ctl00_holderLHS_ctlLHSMenu_lhsSubMenu2'
                break;    

        }
        
        if ($(varName)!= null)
        {
        
            for (j=0; j<$(varName).childNodes.length; j++)
            {
                if ($(varName).childNodes[j].tagName == 'UL')
                {
                    objUL = $(varName).childNodes[j];
                    
                    for (k=0; k<objUL.childNodes.length;k++)
                    {
                        if (objUL.childNodes[k].tagName == 'LI')
                        {
                            objLI = objUL.childNodes[k];
                        
                            for (l=0; l<objLI.childNodes.length;l++)
                            {
                                if (objLI.childNodes[l].tagName == 'A')
                                {
                                    objLI.childNodes[l].className = ""
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    //remove highlight from all nav end


    if ($('nav_' + nodeID.toString()) != null)
    {
        $('nav_' + nodeID.toString()).className = "current"
    }else
    {
        $('ctl00_holderLHS_ctlLHSMenu_lnkSubParent').className = "current"
    }
            
    
    
    if (bAjax)
    {
        $('spanBody').innerHTML = "Loading..."
    
        var url = g_AJAXUrl + '?nodeid=' + nodeID.toString()

        var myAjax = new Ajax.Request(url, { onComplete: function(transport)
                                            {
                                            
                                                // code for IE
                                                if (window.ActiveXObject)
                                                {
                                                    var doc=new ActiveXObject("Microsoft.XMLDOM");
                                                    doc.async="false";
                                                    doc.loadXML(transport.responseText);
                                                }
                                                // code for Mozilla, Firefox, Opera, etc.
                                                else
                                                {
                                                    var parser=new DOMParser();
                                                    var doc=parser.parseFromString(transport.responseText,"text/xml");
                                                }

                                                var root=doc.documentElement;
                                            
                                                $('divBreadCrumb').innerHTML = HTMLDecode(fncAssignXMLText(root.childNodes[0]));
                                                $('spanBody').innerHTML = ""
                                                $('spanBody').innerHTML = fncAssignXMLText(root.childNodes[1]);
                                                $('divPuff').innerHTML = ""
                                                $('divPuff').innerHTML = fncAssignXMLText(root.childNodes[2]);
                                                dhtmlHistory.add(nodeID.toString(), nodeID.toString())
                                            
                                            }
                                        });
    }else
    {
        if ($('lhsChildMenu0') != null)
        {
            if (g_isIE)
            {
                $('lilhsChildMenu0').style.display = "none"
            }    
            $('lhsChildMenu0').style.display = "none"
        }
        
        if ($('lhsChildMenu1') != null)
        {
            if (g_isIE)
            {
                $('lilhsChildMenu1').style.display = "none"
            }
            $('lhsChildMenu1').style.display = "none"
        }
        
        if ($('nav_' + nodeID.toString()) != null)
        {
            objLI = $('nav_' + nodeID.toString()).parentNode
        
            objUL = objLI.parentNode
            objParent = objUL.parentNode;
            
            objParent.style.display = "block"
            $('li' + objParent.id).style.display = "block"
            
            if (objParent.id == 'lhsChildMenu0' || objParent.id == 'lhsChildMenu1')
            {
                if (g_isIE)
                {
                    $('lilhsChildMenu').style.display = "none"
                }    
                $('lhsChildMenu').style.display = "none"
            }
        }
            
            
    }
}

function arrowClick(spanID)
{
    if ($(spanID).style.display == 'none')
    {
        if (g_isIE)
        {
            $('li' + spanID).style.display = 'block'
        }
        $(spanID).style.display = 'block'
    }else
    {
        if (g_isIE)
        {
            $('li' + spanID).style.display = 'none'
        }    
        $(spanID).style.display = 'none'
    }
}

function writeBannerURL(refr,banner,w,h) {
	sLink="http://www.membersequity.com.au/";	
	if (banner.indexOf('.swf') !=-1) {	
		sURL="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\""+w+"\" height=\""+h+"\">";
		sURL=sURL+"<param name=\"movie\" value=\""+sLink+banner+"?url="+sLink+refr+"\"/>";
		sURL=sURL+"<param name=\"quality\" value=\"high\" />";
		sURL=sURL+"<embed src=\""+sLink+banner+"?url="+sLink+refr+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\" /></object>";
   } else {
		sBanner="<img border=\"0\" src=\""+sLink+banner + "\"    onclick=\"window.alert('The Trustee is not responsible for and does not accept liability for the products or services or actions of Members Equity Bank. You should use your own judgement before taking up any product or services offered by Members Equity Bank.') \" >";
		sURL="<a target=\"_blank\" href=\""+sLink+refr+"\">"+sBanner+"</a>";
	}
	document.writeln(sURL);	
	if (refr.indexOf('-TEST') !=-1) {
		document.writeln("<br>Javscript generated code:<br><textarea cols='120' rows='8'>"+sURL+"</textarea>");
	}
}

function toggleFAQ(index)
{
    var divName = 'divAns' + index.toString();
    
    if ($(divName).style.display == 'none')
    {
        $(divName).style.display = 'block'
    }else
    {
        $(divName).style.display = 'none'
    }
    
}