var ids=new Array('tab_1','tab_2','tab_3');
var idsFourTabs=new Array('tab_1','tab_2','tab_3','tab_4');

function check_querystring(){

	var search = location.search;
	search = search.replace(/\?/,'');
	var searchAttributes = search.split('&');
	var searchequal = search.indexOf('=');

	if (searchequal>-1){
	
		for(var no=0;no<searchAttributes.length;no++){
			var items = searchAttributes[no].split('=');
			eval("var "+items[0]+" = '"+items[1]+"';");
		}

			if(tabId){
				switchid(tabId)
			}
				} else {

					switchid('tab_1')

		}  
}

function setScroll(){
	
	count = 0;
	
	if(document.getElementById('scroll_text').offsetHeight < 130){
			document.getElementById('scroll_buttons').style.display = 'none';
		} else {
				document.getElementById('scroll_buttons').style.display = 'block';
			}
	if(document.getElementById('scroll_text_2').offsetHeight < 130){
			document.getElementById('scroll_buttons_2').style.display = 'none';
		} else {
				document.getElementById('scroll_buttons_2').style.display = 'block';
			}
	if(document.getElementById('scroll_text_3').offsetHeight < 130){
			document.getElementById('scroll_buttons_3').style.display = 'none';
		} else {
				document.getElementById('scroll_buttons_3').style.display = 'block';
			}
}

//==============================================

function switchid(id){
	var id_print_advisor = id.substring(4,5) - 1;
	//alert(id_print_advisor);
	document.getElementById('link_print').innerHTML = "<a href=\"javascript:openPrintWin(\'advisorPrintAction.do?topicId="+id_print_advisor+"\',\'660\',\'500\',\'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=no\');\">Print it</a>";
	//document.getElementById('tabId').value = id.substring(4,5);
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';

	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}



function switchid4(id){
	
	hideallids4();
	showdiv4(id);
}

function hideallids4(){
	//loop through the array and hide each element by id
	for (var i=0;i<idsFourTabs.length;i++){
		hidediv(idsFourTabs[i]);
	}		  
}

function hidediv4(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv4(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';

	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
		setScroll();
}


function showQuestion(pId){

elem = document.getElementsByTagName("P");
			for(i=0;i<elem.length;i++){
				if (elem[i].className == "answer_"+i)
					elem[i].style.display = 'none';
					elem[pId].style.display = 'block';
					//document.getElementById("li_"+i).style.listStyleImage = "url(images/illustrations/arrow_questions_r.gif)";
					//document.getElementById("li_"+pId).style.listStyleImage = "url(images/illustrations/arrow_questions_b.gif)";
			}
}

function showAnswer(pId){

	elem = document.getElementById("answer_" + pId);

	if ((elem.style.display == 'none') || (elem.style.display == '')) {
		elem.style.display = 'block';			
		//document.getElementById("li_" + pId).style.listStyleImage = "url(images/illustrations/arrow_questions_b.gif)";
		document.getElementById("li_" + pId).style.backgroundImage="url(images/illustrations/arrow_questions_b.gif)";
		document.getElementById("li_" + pId).style.backgroundRepeat = "no-repeat";
		document.getElementById("li_" + pId).style.backgroundPosition = "0px 5px";
	} 
	else {
		elem.style.display = 'none';				
		//document.getElementById("li_" + pId).style.listStyleImage = "url(images/illustrations/arrow_questions_r.gif)";					
		document.getElementById("li_" + pId).style.backgroundImage="url(images/illustrations/arrow_questions_r.gif)";
		document.getElementById("li_" + pId).style.backgroundRepeat = "no-repeat";
		document.getElementById("li_" + pId).style.backgroundPosition = "0px 5px";
	}
					
}

