/*
	1/14/08 - currently only works on banner modules
*/

/* Example CSS code for title and content box
.pop_out .bannermodtitle{
	background-color:#7493c2;
	background-image:url('/uploaded/images/right_arrow.gif');
	background-repeat:no-repeat;
	background-position:8px 6px;
	color:#005596;
	padding:2px 8px 2px 20px;
	font-weight:bold;
	text-align:right;
	cursor:pointer;
}

.pop_out .bannermodcontent{
	visibility:hidden;
	position:absolute;
	background-color:#005596;
	border:1px solid #67addf;
	padding:10px;
	width:317px; *width:339px;
	margin-left:-156px;
}
*/

var box_container = "rightbanner"; //where to look for the content boxes
var box_class = "pop_out"; //class name of the content boxes

var backgroundImage = "uploaded/images/right_arrow.gif"; //path of background image (arrow/bullet)
var backgroundImageOn = "uploaded/images/right_arrow_on.gif"; //path to activated background image (arrow/bullet)

var boxes = new Array();

function getBoxes(){
	if(document.getElementById(box_container)){
		var tables = document.getElementById(box_container).getElementsByTagName('div');
		for(i=0;i<tables.length;i++){
			if(tables[i].className == box_class){							//if the mod is a pop_out
				var tds = tables[i].getElementsByTagName('div'); 			//get all tds
				for(j=0;j<tds.length;j++){ 									//loop through tds
					if(tds[j].className == 'bannermodtitle'){           	//if it's a title
						boxes[i] = tables[i].id;							//and grab the table id
						tds[j].n = i;
						tds[j].id = ('title'+i);
						tds[j].onclick = function (){ showBox(this.n) }		//set the click function
					}
				}
			}
		}	
	}
}

function showBox(n){

	var tn = 'title'+n;

	//check if it's on already
	if( document.getElementById(tn).on != true ){
		//close everything first
		for(i=0;i<boxes.length;i++){
			if(boxes[i]){
			var ti = 'title'+i;
			document.getElementById(ti).style.backgroundImage = 'url('+ backgroundImage +')';
			document.getElementById(ti).on = false;
				divs_off = document.getElementById(boxes[i]).getElementsByTagName('div');
				for(j=0;j<divs_off.length;j++){
					if(divs_off[j].className == 'bannermodcontent'){
						divs_off[j].style.visibility = 'hidden';
					}
				}
			}
		}
		
		//now turn on the one clicked
		divs = document.getElementById(boxes[n]).getElementsByTagName('div');
		for(j=0;j<divs.length;j++){
			if(divs[j].className == 'bannermodcontent'){
				divs[j].style.visibility = 'visible';
				document.getElementById(tn).style.backgroundImage = 'url('+ backgroundImageOn +')';
				document.getElementById(tn).on = true;
			}
		}
	}else{ //turn off the one clicked if it was on already
		divs = document.getElementById(boxes[n]).getElementsByTagName('div');
		for(j=0;j<divs.length;j++){
			if(divs[j].className == 'bannermodcontent'){
				divs[j].style.visibility = 'hidden';
				document.getElementById(tn).style.backgroundImage = 'url('+ backgroundImage +')';
				document.getElementById(tn).on = false;
			}
		}
	}
}