/************************************************************************************************************
Ajax chained select
Copyright (C) 2006  DTHMLGoodies.com, Alf Magne Kalleland

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

Dhtmlgoodies.com., hereby disclaims all copyright interest in this script
written by Alf Magne Kalleland.

Alf Magne Kalleland, 2006
Owner of DHTMLgoodies.com


************************************************************************************************************/	
var ajax = new Array();

//******	EACH WORK IN THE TEXT ( OMEKA ITEM ) ON MOUSEOVER

function getItemInfo(Item)
{

	document.getElementById('item-tip').innerHTML ="";   //initialize the field that contains the tip-info for the item 
	//window.location = 'http://www.sciencetweets.eu/test/portal/exhibits/medical-imaging/';
	
	if ( Item.id.length > 20 )
		document.getElementById('title').innerHTML = Item.id.substr(0,19)+'...';  //the first 20 characters
	else
		document.getElementById('title').innerHTML = 'Learn more about '+Item.id;			// replace the 'Did you know'   tabTitle with the name of the item
		
	
	if ( navigator.appName == "Microsoft Internet Explorer"){
		document.getElementById('title').setAttribute("className", "title_sel");
	}
	else{
		document.getElementById('title').setAttribute("class", "title_sel");
	}
	
	
		


//	    document.getElementById('updatedLink').href=Item.href +"?len="+ajax.length;	
//		var itemId = Item.id;					//Attribute Id of the Trigger Link :  Name_TypeId
//		var itemName  = itemId.substring(0,itemId.indexOf("_"))		//Name
//		var itemTypeId = itemId.substring(itemId.indexOf("_")+1)		//TypeId
		
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item.id+'&field=Tip';
		//portal/themes/eknownetv2
		ajax[index].onCompletion = function(){ showItemInfo(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
		getItemImages(Item.id);
		getItemLinks(Item.id);
		getItemVideo(Item.id);
		getItemGames(Item.id);
		getItemInteractives(Item.id);

}

function showItemInfo(index)
{
	var obj = document.getElementById('item-tip');
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
																//eval() evaluates a string and executes it as if it was script code
	
}

// ***** FUNCTION THAT RETURNS THE TERM DEFINITION **********//
function getItemDef(Item)
{
	// Clear content in other divs
	document.getElementById('image-resources').innerHTML ="";
	document.getElementById('links-resources').innerHTML ="";
	document.getElementById('links-games').innerHTML ="";
	document.getElementById('video-resources').innerHTML ="";
	document.getElementById('item-tip').innerHTML ="";   //initialize the field that contains the tip-info for the item 
	//window.location = 'http://www.sciencetweets.eu/test/portal/exhibits/medical-imaging/';
	
	if ( Item.id.length > 20 )
		document.getElementById('title').innerHTML = Item.id.substr(0,29)+'...';  //the first 30 characters
	else
		document.getElementById('title').innerHTML = 'Learn more about '+Item.id;			// replace the 'Did you know'   tabTitle with the name of the item
		
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item.id+'&field=Definition';
		//portal/themes/eknownetv2
		ajax[index].onCompletion = function(){ showItemInfo(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
		
		
}


//******	TAB IMAGES ON CLICK

function getItemImages(Item)
{
		document.getElementById('image-resources').innerHTML ="";		
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item+'&field=Image';      
		ajax[index].onCompletion = function(){ showItemImages(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function

}


function showItemImages(index)
{
	var obj = document.getElementById('image-resources');	
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
																//eval() evaluates a string and executes it as if it was script code
}


//******	TAB LINKS ON CLICK

function getItemLinks(Item)
{
		document.getElementById('links-resources').innerHTML ="";
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item+'&field=Links';      
		ajax[index].onCompletion = function(){ showItemLinks(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function

}


function showItemLinks(index)
{
	var obj = document.getElementById('links-resources');	
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
															//eval() evaluates a string and executes it as if it was script code
}

//******	TAB GAMES ON CLICK

function getItemGames(Item)
{
		document.getElementById('links-games').innerHTML ="";
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item+'&field=Games/Activities';      
		ajax[index].onCompletion = function(){ showItemGames(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function

}


function showItemGames(index)
{
	var obj = document.getElementById('links-games');	
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
															//eval() evaluates a string and executes it as if it was script code
}


//******	TAB VIDEO ON CLICK

function getItemVideo(Item)
{
		
		document.getElementById('video-resources').innerHTML ="";
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item+'&field=Video';      
		ajax[index].onCompletion = function(){ showItemVideo(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function

}


function showItemVideo(index)
{
	var obj = document.getElementById('video-resources');	
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
															//eval() evaluates a string and executes it as if it was script code
}

//******	TAB INTERACTIVES ON CLICK

function getItemInteractives(Item)
{
		document.getElementById('links-resources').innerHTML ="";
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemInfo.php?item='+Item+'&field=Interactives';      
		ajax[index].onCompletion = function(){ showItemInteractives(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function

}


function showItemInteractives(index)
{
	var obj = document.getElementById('links-resources');	
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
															//eval() evaluates a string and executes it as if it was script code
}

function showRights(Item)
{
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = 'http://'+top.location.host+'/photochemistry/custom/tips/getItemRights.php?item='+Item.name+'';      
		ajax[index].onCompletion = function(){ showItemInteractives(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
}

// Function that clears the Resources div
function clearItemInfo()
{
	document.getElementById('image-resources').innerHTML ="";
	document.getElementById('links-resources').innerHTML ="";
	document.getElementById('links-games').innerHTML ="";
	document.getElementById('video-resources').innerHTML ="";
	document.getElementById('item-tip').innerHTML ="Click on a keyword or a term of the exhibit and learn more by exploring:";
	document.getElementById('title').innerHTML = "Further Resources";
}

// SHOW each section of the exhibit
function getSection(Section)
{
		var index = ajax.length;
		ajax[index] = new sack();
		ajax[index].requestFile = '../../showSection';      
		ajax[index].onCompletion = function(){ showSection(index) };	// Specify function that will be executed after file has been found
		ajax[index].runAJAX();		// Execute AJAX function
}
function showSection(index)
{
	var obj = document.getElementById('section');	
	eval(ajax[index].response);									// Executing the response from Ajax as Javascript code	!!!!!!!!!
															//eval() evaluates a string and executes it as if it was script code
}

function loadXMLDoc(url,sectionnum)
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
		if(sectionnum!="keywords"){
			
				
				document.getElementById(sectionnum).style.display = "block";
    document.getElementById(sectionnum).innerHTML='<a style="right:10px; position:absolute;" href="javascript:void(0);" onClick="document.getElementById(&quot;'+sectionnum+'&quot;).style.display =&quot;none&quot;">Close &nbsp;<img src="http://www.sciencetweets.eu/photochemistry/themes/eknownetv3/images/close.png" width="15" height="15"></a><br>'+xmlhttp.responseText;
			
			} else{
			
			
			
		}
    }
  }
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
