// JavaScript Document

var clickedLinks = new Array();

function aitor(element,clickedLink)  
{  

	/* if is the first time the link is clicked it won't be stored on the array of clickedLinks, in this case
	   it stores it */
	var added = false;
	for (var i = 0; i < clickedLinks.length; i++) 
		{
		//alert ('entra1');
		if (clickedLinks[i].linkName == clickedLink) 
			{added = true;} 
		}		
	if (!added) 
		{
		newLink = new Object();
		newLink.linkName = clickedLink;
		newLink.tableId = element;
		newLink.showed = false;
		clickedLinks.push(newLink);
		}
		
	// Hides or Shows the selected menu if necessary
	for (var i = 0; i < clickedLinks.length; i++) 
		{
		// if there's other menu than the current one showed, it hides it.
		if ((clickedLinks[i].linkName != clickedLink) && (clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'none'); clickedLinks[i].showed = false; hide(clickedLinks[i]); continue;}
		// if the current menu is showed it hides it
		if ((clickedLinks[i].linkName == clickedLink) && (clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'none'); clickedLinks[i].showed = false; hide(clickedLinks[i]); continue;}
		// if the current menu is hide it shows it
		if ((clickedLinks[i].linkName == clickedLink) && (!clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'block'); clickedLinks[i].showed = true; show(clickedLinks[i]); continue;}
		}
		  
	}  
	

function change(element,clickedLink)  
{  

	/* if is the first time the link is clicked it won't be stored on the array of clickedLinks, in this case
	   it stores it */
	var added = false;
	for (var i = 0; i < clickedLinks.length; i++) 
		{
		//alert ('entra1');
		if (clickedLinks[i].linkName == clickedLink) 
			{added = true;} 
		}		
	if (!added) 
		{
		newLink = new Object();
		newLink.linkName = clickedLink;
		newLink.tableId = element;
		newLink.showed = false;
		clickedLinks.push(newLink);
		}
		
	// Hides or Shows the selected menu if necessary
	for (var i = 0; i < clickedLinks.length; i++) 
		{
		// if there's other menu than the current one showed, it hides it.
		if ((clickedLinks[i].linkName != clickedLink) && (clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'none'); clickedLinks[i].showed = false; hide(clickedLinks[i]); continue;}
		// if the current menu is showed it hides it
		if ((clickedLinks[i].linkName == clickedLink) && (clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'none'); clickedLinks[i].showed = false; hide(clickedLinks[i]); continue;}
		// if the current menu is hide it shows it
		if ((clickedLinks[i].linkName == clickedLink) && (!clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'block'); clickedLinks[i].showed = true; show(clickedLinks[i]); continue;}
		}
		  
	}  

function changeold(element,clickedLink)  
{  

	/* if is the first time the link is clicked it won't be stored on the array of clickedLinks, in this case
	   it stores it */
	var added = false;
	for (var i = 0; i < clickedLinks.length; i++) 
		{
		//alert ('entra1');
		if (clickedLinks[i].linkName == clickedLink) 
			{added = true;} 
		}		
	if (!added) 
		{
		newLink = new Object();
		newLink.linkName = clickedLink;
		newLink.tableId = element;
		newLink.showed = false;
		clickedLinks.push(newLink);
		}
		
	// Hides or Shows the selected menu if necessary
	for (var i = 0; i < clickedLinks.length; i++) 
		{
		// if there's other menu than the current one showed, it hides it.
		if ((clickedLinks[i].linkName != clickedLink) && (clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'none'); clickedLinks[i].showed = false; hide(clickedLinks[i]); continue;}
		// if the current menu is showed it hides it
		if ((clickedLinks[i].linkName == clickedLink) && (clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'none'); clickedLinks[i].showed = false; hide(clickedLinks[i]); continue;}
		// if the current menu is hide it shows it
		if ((clickedLinks[i].linkName == clickedLink) && (!clickedLinks[i].showed)) {changeDiv(clickedLinks[i].tableId,'block'); clickedLinks[i].showed = true; show(clickedLinks[i]); continue;}
		}
		  
	}  
	
function show(group)
{
	var objectId = group.linkName;
	
	element = document.getElementById(objectId);
	element.style.color='#F8C300';
	
	image = document.getElementById(objectId+'img');
	image.src='http://www.lanzarote.com/img/arrow-yd.gif';
	
	}
	
function hide(group)
{
	var objectId = group.linkName;
	
	element = document.getElementById(objectId);
	element.style.color='#FFFFFF';
	
	image = document.getElementById(objectId+'img');
	image.src='http://www.lanzarote.com/img/arrow-wr.gif';
	
	}
	
function changeDiv(the_div,the_change)   
{   
	var the_style = getStyleObject(the_div);   
	if (the_style != false)   
		{   
		the_style.display = the_change;   
		}   
		
	} // final funcio 
		
function getStyleObject(objectId)   
	{   
		if (document.getElementById && document.getElementById(objectId))   
			{return document.getElementById(objectId).style;}   
	} // final funcio   