window.onload=init;

function init(){
	if(document.getElementById("contact-index")){setCD();}
	if (document.getElementById("ctl00_MainContent_newsletterheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_retailbankingheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_corpbankingheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_privatewealthheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_coresupportheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_tropsheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_fabiheadlist")) { addClick(); }
	if (document.getElementById("ctl00_MainContent_complianceheadlist")) { addClick(); }
}


function setCD(){
	src = document.getElementById("contact-index");
	var a = src.getElementsByTagName("a");
	var cDivs = src.getElementsByTagName("div");
	
	for(i=0;i<cDivs.length;i++){
		if(cDivs[i].className=="location"){cDivs[i].className="location hide"}	
	}
	

	for(i=0;i<a.length;i++){
		var divs = a[i].parentNode.getElementsByTagName("div");
		if(divs.length>0){
			a[i].onclick = function(){showDetail(this);return false;};
			a[i].onkeypress = function(){showDetail(this);return false;};
			
		}
		//if(a[i].innerHTML.indexOf("Hide")!=-1){a[i].onclick = function(){hideDetail(this);return false;};a[i].onkeypress = function(){hideDetail(this);return false;};}
	}

}



function showDetail(x){
	var divs = x.parentNode.getElementsByTagName("div");
	divs[0].className = "location";
	x.onclick = function(){hideDetail(this);return false;};
}

function hideDetail(x){
	var divs = x.parentNode.getElementsByTagName("div");
	divs[0].className = "hide";
	x.onclick = function(){showDetail(this);return false;};
}


function toggleVisibility()
{
	var check1= document.getElementById("ctl00_MainContent_newsletteroptionlist_ctl01_newsletteroptionGroup");
	var table1 = document.getElementById("ctl00_MainContent_newsletterheadlist");

	var check2= document.getElementById("ctl00_MainContent_retailbankingoptionlist_ctl01_retailbankingoptionGroup");
	var table2 = document.getElementById("ctl00_MainContent_retailbankingheadlist");

	var check3 = document.getElementById("ctl00_MainContent_corpbankingoptionlist_ctl01_corpbankingoptionGroup");
	var table3 = document.getElementById("ctl00_MainContent_corpbankingheadlist");

	var check4 = document.getElementById("ctl00_MainContent_privatewealthoptionlist_ctl01_privatewealthoptionGroup");
	var table4 = document.getElementById("ctl00_MainContent_privatewealthheadlist");

	var check5 = document.getElementById("ctl00_MainContent_coresupportoptionlist_ctl01_coresupportoptionGroup");
	var table5 = document.getElementById("ctl00_MainContent_coresupportheadlist");

	var check6 = document.getElementById("ctl00_MainContent_tropsoptionlist_ctl01_tropsoptionGroup");
	var table6 = document.getElementById("ctl00_MainContent_tropsheadlist");

	var check7 = document.getElementById("ctl00_MainContent_fabioptionlist_ctl01_fabioptionGroup");
	var table7 = document.getElementById("ctl00_MainContent_fabiheadlist");

	var check8 = document.getElementById("ctl00_MainContent_complianceoptionlist_ctl01_complianceoptionGroup");
	var table8 = document.getElementById("ctl00_MainContent_complianceheadlist");
	
	if(check1 && table1)
	{
		if (check1.checked == true)
		{
			table1.className= "";
		}
		
		else
		{
			table1.className = "hide";
		}
    }

    if (check2 && table2) 
    {
        if (check2.checked == true) {
            table2.className = "";
        }

        else {
            table2.className = "hide";
        }
    }


    if (check3 && table3) 
    {
        if (check3.checked == true) {
            table3.className = "";
        }

        else {
            table3.className = "hide";
        }
    }

    if (check4 && table4) 
    {
        if (check4.checked == true) {
            table4.className = "";
        }

        else {
            table4.className = "hide";
        }
    }

    if (check5 && table5) 
    {
        if (check5.checked == true) {
            table5.className = "";
        }

        else {
            table5.className = "hide";
        }
    }

    if (check6 && table6) 
    {
        if (check6.checked == true) {
            table6.className = "";
        }

        else {
            table6.className = "hide";
        }
    }

    if (check7 && table7) 
    {
        if (check7.checked == true) {
            table7.className = "";
        }

        else {
            table7.className = "hide";
        }
    }

    if (check8 && table8) {
        if (check8.checked == true) {
            table8.className = "";
        }

        else {
            table8.className = "hide";
        }
    }	
}

function addClick()
{
	var check1= document.getElementById("ctl00_MainContent_newsletteroptionlist_ctl01_newsletteroptionGroup");
	var table1 = document.getElementById("ctl00_MainContent_newsletterheadlist");

	var check2= document.getElementById("ctl00_MainContent_retailbankingoptionlist_ctl01_retailbankingoptionGroup");
	var table2 = document.getElementById("ctl00_MainContent_retailbankingheadlist");

	var check3= document.getElementById("ctl00_MainContent_corpbankingoptionlist_ctl01_corpbankingoptionGroup");
	var table3 = document.getElementById("ctl00_MainContent_corpbankingheadlist");

	var check4 = document.getElementById("ctl00_MainContent_privatewealthoptionlist_ctl01_privatewealthoptionGroup");
	var table4 = document.getElementById("ctl00_MainContent_privatewealthheadlist");

	var check5 = document.getElementById("ctl00_MainContent_coresupportoptionlist_ctl01_coresupportoptionGroup");
	var table5 = document.getElementById("ctl00_MainContent_coresupportheadlist");

	var check6 = document.getElementById("ctl00_MainContent_tropsoptionlist_ctl01_tropsoptionGroup");
	var table6 = document.getElementById("ctl00_MainContent_tropsheadlist");

	var check7 = document.getElementById("ctl00_MainContent_fabioptionlist_ctl01_fabioptionGroup");
	var table7 = document.getElementById("ctl00_MainContent_fabiheadlist");

	var check8 = document.getElementById("ctl00_MainContent_complianceoptionlist_ctl01_complianceoptionGroup");
	var table8 = document.getElementById("ctl00_MainContent_complianceheadlist");
	
	toggleVisibility();

	check1.onclick = function() { toggleVisibility(); }
	check2.onclick = function() { toggleVisibility(); }
	check3.onclick = function() { toggleVisibility(); }
	check4.onclick = function() { toggleVisibility(); }
	check5.onclick = function() { toggleVisibility(); }
	check6.onclick = function() { toggleVisibility(); }
	check7.onclick = function() { toggleVisibility(); }
	check8.onclick = function() { toggleVisibility(); }
}


// CLEAR FORM
function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

