/**
 * @author franca02
 */
 
ClickableMap=function(){
	// intialising the dom methods from newsi
	this.dom = new newsi.HTML.DOM();
	this.ev = new newsi.Event();
	}
	
	ClickableMap.prototype.init=function(mapName, contName, contArray, defselected){	
	
		// localising the variables
		this.mapName = mapName;
		this.contName = contName;
		this.contArray = contArray;
		this.defselected = defselected;
			
		// nothing selected on init
		this.currentSel = 0;
		
				
		//remove inline anchors
		
		this.anchors = this.dom.gebtn({parent:this.dom.e_gebid("content_njs"), el:"ul"});
		
		for(var i=0; i<this.anchors.length; i++ ){
		
		
		}
				
				var i = 0 ;
				var j = this.anchors.length
				while ( i < j ) 
				{
					
					this.dom.e_gebid("id_"+i).parentNode.removeChild(this.dom.e_gebid("id_"+i));
					i++
					
		}
		
		
		this.dom.setClass({el:this.dom.e_gebid("content_njs"), className:"content"});
			
		var z = 0;
		while( z < this.contArray)
			{
				this.dom.setClass({el:this.dom.e_gebid("content_"+z), className:"hide"});
				//this.dom.setClass({el:this.dom.e_gebid("btt"), className:"hide"});
				z++
				
			}
		if (this.defselected){
			this.dom.setClass({el:this.dom.e_gebid(this.defselected), className:"show_js"});
			}
		
		
		// add listeners to the map array links	
		this.mapArray = this.dom.gebtn({parent:this.dom.e_gebid(this.mapName), el:"area"});
		
		var i = 0 ;
		while ( i < this.mapArray.length ) 
		{
			this["link_"+i] = new newsi.Event () ;
			this["link_"+i].addListener ( "onclick" , this.mapArray[i].id , this , "_changeinfo" , "false", i ) ;
			i++ ;
		}
		
		this.mapimg = this.dom.e_gebid("mapimg");
		//alert(this.mapimg.innerHTML)
	}
	ClickableMap.prototype._changeinfo = function(mapLink){
		if (this.defselected){this.dom.setClass({el:this.dom.e_gebid(this.defselected), className:"hide"});}	
	  	this.dom.setClass({el:this.dom.e_gebid("content_"+this.currentSel), className:"hide"});
		this.dom.setClass({el:this.dom.e_gebid("content_"+mapLink[0]), className:"show_js"});
		this.currentSel = mapLink[0];
		//alert(this.currentSel)
		this.mapimg.innerHTML='<img src="/sol/shared/bsp/hi/sport_relief/07/mile_map/img/'+this.currentSel+'.gif" width="412" height="400" hspace="0" vspace="0" border="0" usemap="#map" />';
 	}



