/**
 * ViewWorld
 */
var ViewWorld = Class.create({
  /**
   * Init ViewWorld
   */	
  initialize: function() {
	this.options = Object.extend({
	  elemContent : null
	}, arguments[0] || { });		

    this.elemContentTitle = this.options.elemContent.down('.contenttitle');
    this.contentTitleFade = new EggFade({elemContent:this.elemContentTitle});
    
    this.elemImage = this.options.elemContent.down('.image');
    this.image = new EggImage(this.elemImage);
	this.elemImage.observe('eggimage:loaded', this.imageLoaded.bind(this));			    
    this.image.load();     
    
	this.arrItems = new Array();
    // locations
	var item;
    var elemItems = this.options.elemContent.select('.location');    
    for (var nItem = 0; nItem < elemItems.length; nItem++) {
      item = new ViewWorldLocation({elemContent:elemItems[nItem], nPos:nItem});
      elemItems[nItem].observe('viewworldlocation:click', this.onLocationClick.bind(this));
      this.arrItems.push(item);    	
    }    
  },

  show: function() {
	this.contentTitleFade.show();
	this.image.show();
  },

  hide: function() {
	this.contentTitleFade.hide();
	this.image.hide();
  },
    
  imageLoaded: function(evt) {
	// show locations
    for (var nItem = 0; nItem < this.arrItems.length; nItem++) {
      this.arrItems[nItem].show();
    }
  },
  
  onLocationClick: function(evt) {
    // fire event
    this.options.elemContent.fire("viewworld:clicklocation", { strName: evt.memo.strName });
  }  
  
});
