 /**
 * DivTitolPresentation
 * @description: Titol BC En Directe
 */
var DivTitolPresentation = Class.create(ComponentPresentation, {
 pinta: function($super, data){
	this.data= data;
	//var vTitle='<a href="#/restoreMainContent" onclick="startRefreshMainContent(); return false;" >'+this.data["titol"]+'</a>';
	var vTitle= this.data["titol"];
	InterfaceAgent.doFadeOutIn(this.html.id, vTitle);
	if (!vRefreshMainContent){
		InterfaceAgent.glowLiveBar(true, this.data["thumb"]);
	}
 }
});

 /**
 * LastPlayedPresentation
 * @description: Llistat de BCs emesos
 */
var DivLastPlayedPresentation = Class.create(ComponentPresentation, {
 pinta: function($super, data){
  this.data= data;
	var iTitle= vdivLlistaUc.data["titol"];
	var op= HTML('HeaderLastPlayed',iTitle);
	$(this.id).innerHTML=op;
 }
});

/**
 * DivMenuUCPresentation
 * @description: Llistat UCs
 */
var DivLlistaUCPresentation = Class.create(ComponentPresentation, {
 pinta: function($super, data){
  this.data= data;

  var UCTit  = this.data["titol"];
  InterfaceAgent.showUCInterface(UCTit,this.data["ucMenuTitle"]);
 }

});

/**
 * DivLoginFormPresentation
 * if loged -> paint Logout link
 * else -> paint login form
 */
var DivLoginFormPresentation = Class.create(ComponentPresentation, {

 pinta: function($super,data){
  this.data= data;
  if (vLoged == true){
  	InterfaceAgent.showLoggedUserInterface(this.data["nom"]);
  }
  else{
	InterfaceAgent.enableLoginInterface();
  }
 }

});


/**
 * PostitPresentation
 * Generic postit
 */
var PostitPresentation = Class.create(ComponentPresentation, {
 pinta: function(data){

  this.data= data;
  this.minimized = false;
  this.container = "postitInstance" + vpostitLayer.postit_zindexCount; //divContainer
  this.pId = vpostitLayer.postit_zindexCount;
  this.zindex = vpostitLayer.postit_zindexCount + vpostitLayer.postit_zindexBase;
  var bType = undefined;


  //var my_div = document.createElement('div');//No funciona en IE
  var my_div = new Element('div');
  my_div.writeAttribute("id",this.container);
  my_div.writeAttribute("style","z-index:"+this.zindex);


  $(vpostitLayer.postit_container).appendChild(my_div);

  //SWITCH per tipus de postit....
  trace(this.data["type"]);

  var postitContent = '';
  switch (this.data["type"]){
   case "text":
	    if(this.data["image"] != '' ){
			postitContent += '<div><img src="'+this.data["image"]+'" ';
			//if( data["text"] != '' ) postitContent += 'alt="'+this.data["text"]+'" ';
			postitContent += ' /></div>';
		}
		if( this.data["text"] != '' ) postitContent += '<p>'+this.data["text"]+'</p>';
   	 	break;
		
   case "webcam":
	   	// NOU CAS WEBCAM AMB SÓ
		if(	this.data["so"] == "SI"){			
			postitContent = InterfaceAgent.getWebcamAmbSo( this.data["text"], this.data["url"] );
			bType = "salmo";
		}else{			
			postitContent = InterfaceAgent.getWebcam( this.data["text"], this.data["url"] );		
			}
    	break;  
   case "enquesta":

		var answers = new Array();
		for ( var c = 0 ; c < this.data["options"].length ; c++ ) {
			answers[c] = new Hash();
			answers[c]["value"] = this.data["values"][c]; //1
			answers[c]["label"] = this.data["options"][c];
		}
		postitContent = '<p>'+ InterfaceAgent.getPoll(data["text"], answers, data["idServei"] , 'results_'+data["id"] ) +'</p>';

    	break;
	case "links":
		var links = new Array();
		for ( var c = 0 ; c < this.data["itemsText"].length ; c++ ) {
			links[c] = new Hash();
			links[c]["title"] = 		this.data["itemsText"][c];
			links[c]["url"] = 			this.data["itemsUrl"][c];
			links[c]["target"] = 		'_blank';
			links[c]["description"] = 	this.data["itemsComment"][c];
		}
		postitContent = InterfaceAgent.getLinks(this.data["text"], links);
		break;
  }

	vpostitLayer.attachPostItWindow(this.container,this.data.titol,postitContent,bType);

  my_div.style.top = ( vpostitLayer.postit_zindexCount*20 + vpostitLayer.postit_startY )+'px';
  my_div.style.left = ( vpostitLayer.postit_zindexCount*20 + vpostitLayer.postit_startX)+'px';

 },
 
 repinta: function(data){
	var postitContent = '';
	switch (this.data["type"]){
	case "webcam":
		postitContent = InterfaceAgent.getWebcam( this.data["text"], this.data["url"] );
		break;
	}
	$('content_'+this.container).innerHTML= postitContent;	
 },
 
 minimize: function(){
  //vpostitLayer.minimize();
 }

});

 /**
 * DivOpinaPresentation
 * @description: Opina BC En Directe
 */
var DivOpinaPresentation = Class.create(ComponentPresentation, {
 pinta: function($super, data){
  this.data= data;

	var op='';
	var vNumOpinions= this.data["type"].length;
	var splittedTimeStamp;
	for(var i=0; i<vNumOpinions; i++){
		splittedTimeStamp = this.data["hora"][i].split(" ");
		op += InterfaceAgent.getCommentRow((this.data["totalComments"] -i),this.data["type"][i],splittedTimeStamp[1],this.data["user"][i],this.data["localitat"][i],this.data["text"][i], this.data["multimedia"][i]);
	}
	InterfaceAgent.updateCommentRows(op);
 }
});

 /**
 * MoscaPresentation
 * @description: Mosca
 */
var MoscaPresentation = Class.create(ComponentPresentation, {
 pinta: function($super, data){
  this.data= data;
  if (this.data["text"]==""){
  	InterfaceAgent.moscaCloseWin()
  }
  else{
  	InterfaceAgent.mosca('', this.data["text"]);
  }
 }
});

 /**
 * ProgramaPresentation
 * @description: Programa's related (Skin, header)
 */
var ProgramaPresentation = Class.create(ComponentPresentation, {
 pinta: function($super, data){
	this.data= data;

	InterfaceAgent.swapSkin(this.data["colorRef"]);
	//InterfaceAgent.updateMainHeader(this.data["titol"],this.data["image_cap"]);
	InterfaceAgent.updateMainHeader('&nbsp;',this.data["image_cap"]);
	try{ $('divTitolDebat').innerHTML= this.data["debat"];}
	catch(error){trace(error);}
 }
});
