// JavaScript Document


	// function change the height of the div
function changeDivHeight(DivID,itemcount) {
	if (itemcount > 6)
	{
	document.getElementById(DivID).style.height=340;
	}
	else{
	document.getElementById(DivID).style.height=178;
	
	}
	}
	
	
	
//used to remove highlighted cells
function cleartablestyle(table) {
   rows=document.getElementById(table).getElementsByTagName("TR");
   for (var j=0; j<rows.length; j++)  {
    //if (j==2) {
    cells=rows[j].getElementsByTagName("TD");
    for (var i=0; i<cells.length; i++)  {
      
	  //cells[i].style.backgroundImage="url('graphics/item_selected.jpeg')";
	  cells[i].style.backgroundColor='';
	  cells[i].setAttribute("class", ""); 
	  cells[i].setAttribute("className", ""); 

    //} 
   }
  }
} 

function setRadioValue(theObj,theObjValue) {
for (var i=0; i<theObj.length; i++) {
if (theObj[i].value==theObjValue) { 
theObj[i].checked = true;
}
}
}


var MyNavigate = function(DivUrl,DivID,DivClass,SelectedCell,tableID,itemcount){

//hide divs
document.getElementById('Div1').style.visibility = 'visible'; 
document.getElementById('Div2').style.visibility = 'hidden'; 

	// add content to div
	document.getElementById(DivID).style.visibility = 'visible'; 
	 ColdFusion.navigate(DivUrl,DivID);
	 // the divs class get set here
	document.getElementById(DivID).className = DivClass; 
	
	//clear previous selectetions
	cleartablestyle(tableID);
	
	thecell = document.getElementById(SelectedCell);
	thecell.style.background = '#FFFFFF';

	
	
	
	// thecell.style.backgroundImage="url('graphics/item_selected_on.jpeg')";
	//change the height of the div
	changeDivHeight(DivID,itemcount);
	
	
}


// get url vars
function getURLVar(urlVarName) {
//divide the URL in half at the '?' 
var urlHalves = String(document.location).split('?');
var urlVarValue = '';
if(urlHalves[1]){
//load all the name/value pairs into an array 
var urlVars = urlHalves[1].split('&');
//loop over the list, and find the specified url variable 
for(i=0; i<=(urlVars.length); i++){
if(urlVars[i]){
//load the name/value pair into an array 
var urlVarPair = urlVars[i].split('=');
if (urlVarPair[0] && urlVarPair[0] == urlVarName) {
//I found a variable that matches, load it's value into the return variable 
urlVarValue = urlVarPair[1];
}
}
}
}
return urlVarValue;   
}

resizeDiv = function(divId,height) {
document.getElementById(divId).style.height=height;
}


showdetail = function(myurl,series,mytitle,selectedCell)
{
	
	//clear previous selections
	cleartablestyle('series_table');
	
	// change background color of selected cell / radio
	thecell = document.getElementById(selectedCell);
	thecell.style.background = '#FFFFFF';
	

//http://prototype-window.xilinus.com/documentation.html
var win = new Window({className: "alphacube", title: mytitle, resizable: "false",  destroyOnClose: "true",
opacity: 1,minimizable: "false", maximizable: "false",
                      top:200, left:200, width:550, height:450, 
                      url: myurl, showEffectOptions: {duration:1.5}})

win.show();
}


initDiv = function(divId,height) {
    resizeDiv(divId,height);
	
	
}


ajaxjumpmenu = function(DivUrl,DivID)
{
	//alert(DivUrl.options[DivUrl.selectedIndex].value);
	ColdFusion.navigate(DivUrl.options[DivUrl.selectedIndex].value,DivID);
  if (restore) DivUrl.selectedIndex=0;
  
}