/*
Filename		: merrillLynch.js
Path			: /www/bankofamerica/data/merrill/js/
Description		: js functions used in the faq pages of the Merrill Lynch Micro Site
Original Author	 	: GDC Dev Team

Change History	:

Date			Author			SIMON WR	Description
======			==========		========	============
11/20/2008		GDC Dev Team		WR 25729	Created
*/

function toggleImage(id){
	image=document.getElementById(id);
	cur_image=image.getAttribute("src");
	if(cur_image=="images/arrow_collapsed.gif"){
		image.setAttribute("src","images/faq-level_one-over.gif")
	}
	else if((cur_image=="images/faq-level_one-over.gif")){
		image.setAttribute("src","images/arrow_collapsed.gif")
	}
	if(cur_image=="images/faq_level-two_out.gif"){
		image.setAttribute("src","images/faq_level-two_over.gif")
	}else if(cur_image=="images/faq_level-two_over.gif"){
		image.setAttribute("src","images/faq_level-two_out.gif")
	}
	return false;
}


/*function showAns(id){
	if(id.search('ans')!=-1){
		id_num=id.substring(id.length-2,id.length);
		answer='ans_'+id_num;
		object=document.getElementById(answer);
		if(object.style.display=='none'){
			object.style.display='block';
			img_id='ques_arrow_'+id_num;
			image=document.getElementById(img_id);
			image.setAttribute("src","images/faq_level-two_selected.gif");
		}else if(object.style.display=='block'){
			object.style.display='none';
			image_id='ques_arrow_'+id_num;
			image=document.getElementById(image_id);
			image.setAttribute("src","images/faq_level-two_over.gif");
		}
	}
	return false;
}*/

function toggleSection(sectionId){
	section=document.getElementById(sectionId);
	id_num=sectionId.substring(sectionId.length-2,sectionId.length);
	image='section_arrow_'+id_num;
	if(section.style.display=='none'){
		section.style.display='block';
		document.getElementById(image).setAttribute("src","images/arrow_expanded.gif");
	}
	else{
		section.style.display='none';
		document.getElementById(image).setAttribute("src","images/faq-level_one-over.gif");
	}
	return false;
}

/*function hideAns(ansId){
	document.getElementById(ansId).style.display='none';
	id_num=ansId.substring(ansId.length-2,ansId.length);
	image_id='ques_arrow_'+id_num;
	image=document.getElementById(image_id);
	image.setAttribute("src","images/faq_level-two_out.gif");
	return false;
}

function showHideAll(){
	showhide_object=document.getElementById('show_hide');
	cur_string = showhide_object.innerHTML;
	if(cur_string=="Show all"){
		showhide_object.innerHTML="Hide all";
	}else{
		showhide_object.innerHTML="Show all";
	}
	showHideAllSection();
	showHideAllAnswers();
	return false;
}

function showHideAllSection(){
	count=1;
	section="section01";
	sectionArrow="section_arrow_01";
	while(document.getElementById(section)!=null){
		if(cur_string=="Show all"){
			document.getElementById(sectionArrow).setAttribute("src","images/arrow_expanded.gif");
			document.getElementById(section).style.display='block';
		}else{
			document.getElementById(sectionArrow).setAttribute("src","images/arrow_collapsed.gif");
			document.getElementById(section).style.display='none';
		}
		count++;
		if(count<10){
			section = 'section0'+count+'';
			sectionArrow ='section_arrow_0'+count+'';
		} else {
			section = 'section'+count+'';
			sectionArrow ='section_arrow_'+count+'';
		}
	}
}

function showHideAllAnswers(){
	count=1;
	ans='ans_01';
	ans_image='ques_arrow_01';
	while(document.getElementById(ans)!=null){
		if(cur_string.match("Show all")!=null){
			document.getElementById(ans_image).setAttribute("src","images/faq_level-two_selected.gif");
			document.getElementById(ans).style.display='block';
		}else{
			document.getElementById(ans_image).setAttribute("src","images/faq_level-two_out.gif");
			document.getElementById(ans).style.display='none';
		}
		count++;
		if(count<10){
			ans = 'ans_0'+count+'';
			ans_image ='ques_arrow_0'+count+'';
		} else {
			ans = 'ans_'+count+'';
			ans_image ='ques_arrow_'+count+'';
		}
	}
}

function showHideForSection(elemid){
	elem = elemid.split("show_all_answers");
	showhide_object1=document.getElementById(elemid);
	cur_string = showhide_object1.innerHTML;
	if(cur_string=="Show all answers"){
		showhide_object1.innerHTML="Hide all answers";
	}
	else if(cur_string=="Hide all answers"){
		showhide_object1.innerHTML="Show all answers";
	}
	else if(cur_string=="Show all Deposit Customers answers"){
		showhide_object1.innerHTML="Hide all Deposit Customer answers";
	}
	else if(cur_string=="Hide all Deposit Customer answers"){
		showhide_object1.innerHTML="Show all Deposit Customers answers";
	}
	else if(cur_string=="Show all Deposit Customers&gt;CD answers"){
		showhide_object1.innerHTML="Hide all Deposit Customer>CD answers";
	}
	else if(cur_string=="Hide all Deposit Customer&gt;CD answers"){
		showhide_object1.innerHTML="Show all Deposit Customers>CD answers";
	}
	answer = elem[1].split(",");
	showHideSectionAnswers(answer,cur_string);
}

function showHideSectionAnswers(answerarray,operation){
	startans = answerarray[0];
	endans = answerarray[1];
	if(startans<10){
		ans = 'ans_0'+startans+'';
		ans_image ='ques_arrow_0'+startans+'';
	} else {
		ans = 'ans_'+startans+'';
		ans_image ='ques_arrow_'+startans+'';
	}
	while(startans<=endans){
		if(operation.match("Show all")!=null){
			document.getElementById(ans_image).setAttribute("src","images/faq_level-two_selected.gif");
			document.getElementById(ans).style.display='block';
		}else{
			document.getElementById(ans_image).setAttribute("src","images/faq_level-two_out.gif");
			document.getElementById(ans).style.display='none';
		}
		startans++;
		if(startans<10){
			ans = 'ans_0'+startans+'';
			ans_image ='ques_arrow_0'+startans+'';
		} else {
			ans = 'ans_'+startans+'';
			ans_image ='ques_arrow_'+startans+'';
		}
	}
}

function printFunction() {
	window.print();
}*/

function changeStyleSection(element){
	id = element.split('section');
	image_id = 'section_arrow_'+id[1];
	document.getElementById(element).style.display='block';
	document.getElementById(image_id).setAttribute("src","images/arrow_expanded.gif");
}

function changeStyleAns(element){
	id = element.split('ans_');
	image_id='ques_arrow_'+id[1];
	document.getElementById(element).style.display='block';
	document.getElementById(image_id).setAttribute("src","images/faq_level-two_selected.gif");
}