/**
 * @author Raymond Brostowiez
 * 
 */



/****Plant Loader vars****/
var toggled = 0;
/**END Plant Loader vars**/

/****Viewer Menu vars****/
var mToggled = 0;
var currentList;
var activeItems = 0;


/**END Viewer Menu vars**/



/****Plant Loader****/
function load(plantId)
{
	
	if (toggled != 0){
		toggled.style.backgroundColor="";
		toggled.style.color="";
	 }
	toggled = document.getElementById('li' + plantId);
	toggled.style.backgroundColor="#70D070";
	toggled.style.color="#FFFFFF";
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      var divItem = document.getElementById('Item');
	  divItem.innerHTML=xmlHttp.responseText;
	  
      }
    }
  if (!toggled) {
  	toggled.style.backgroundColor="inherit";
  }
  toggled = document.getElementById('li' + plantId);
  toggled.style.backgroundColor="#70D070";
  xmlHttp.open("GET", "getplant.php?p="+plantId ,true);
  xmlHttp.send(null);
 }
/**END Plant Loader**/
 
 
  
/******Menu Loader******/
function menu(menuId)
{
	
if (mToggled != 0){
	mToggled.style.backgroundColor="";
}
mToggled = document.getElementById("m" + menuId);
mToggled.style.backgroundColor="#70D070";
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      var divItem = document.getElementById('menuList');
	  divItem.innerHTML=xmlHttp.responseText;
	  
      }
    }
  if (!mToggled) {
  	mToggled.style.backgroundColor="inherit";
  }
  mToggled = document.getElementById('m' + menuId);
  mToggled.style.backgroundColor="#70D070";
  xmlHttp.open("GET", "getmenu.php?m="+menuId ,true);
  xmlHttp.send(null);
  
  
 }

/******END Menu Loader******/
 
 
 
  
 /****Viewer Menu****/


function menuChange(itemNum){
	if (activeItems != 0) {
		for (i = 0; i < 13; i++) {
			activeItems[i].style.display = "none";
		}
	}
	activeItems = new Array(13);
	
	var j = 0;
	for(i = itemNum - 6; i <= itemNum + 6;i++){
		var tempId = "li" + i;
		
		activeItems[j++] = document.getElementById(tempId);
		
	}
	
	for(i = 0; i<13;i++){
		activeItems[i].style.display="block";
	}
	
	
	
	
}


function genusToggle(genus){
	var tempList = document.getElementById(genus);
	if(tempList.style.display=="none"){
		tempList.style.display="block";
	}
	else {
		tempList.style.display="none";
	}
	
	
}

/**END Viewer Menu**/
 
 
/***Image Loader***/

function changeImage(plant, image){
	tempImage = document.getElementById("image_"+plant);
	tempImage.src="images/"+plant+"/"+image;
}


/***END Image Loader***/
