var TutorialClass = function()
{
	this.panelTutorial = null;
	
	this.Expand = function(tutorialCategoryId)
	{
		if ($$("tc_" + tutorialCategoryId).style.display == 'none')
		{
			$$("tc_" + tutorialCategoryId).style.display = 'block';
			
			var anim = new YAHOO.util.Anim( "tc_" + tutorialCategoryId , { opacity : {from: 0, to: 1 } }, 0.3);
			anim.animate();		
			
			
			$$("tcarrow_" + tutorialCategoryId).style.background = 'transparent url(/static/images/layout/tutorial_arrow_down.png) no-repeat scroll 0 0';
		}
		else
		{
			var doHide = function() { $$("tc_" + tutorialCategoryId).style.display = 'none'; }
			
			var anim = new YAHOO.util.Anim( "tc_" + tutorialCategoryId , { opacity: {from: 1, to: 0 } }, 0.3);
			anim.onComplete.subscribe(doHide);
			anim.animate();			
			
			$$("tcarrow_" + tutorialCategoryId).style.background = 'transparent url(/static/images/layout/tutorial_arrow_right.png) no-repeat scroll 0 0';
		}
	}
	
	this.Show = function(tutorial)
	{
		var thisClass = this;
		
		this.panelTutorial = new YAHOO.widget.Panel("modalTutorial", {
		    width: "800px", 
		    fixedcenter: false, 
		    constraintoviewport: true, 
		    underlay: "none", 
		    close: true,
		    modal: true,  
		    visible: false,
		    draggable: false
		});
		
		this.panelTutorial.setHeader(tutorial.title);
		
		var video 	= '<div class="video">';
				
		if(tutorial.type  == 'FLV')
		{
			video 	+= '<object id="playerTutorial" ';
			video 	+= 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9.0.115" ';
			video 	+= 'width="720" height="564">';
			video 	+= '<param name="movie" value="/static/player/player.swf"> ';
	        video 	+= '<param name="allowfullscreen" value="true"> ';
	        video 	+= '<param name="allowscriptaccess" value="always"> ';
	        video 	+= '<param name="flashvars" value="file=/upload/tutorials/' + tutorial.id + '.flv' + '&image=/static/images/previewVideo.png"> ';
			video 	+= '	<embed ';
      video   += '    id="embedplayerTutorial" ';
			video 	+= '		name="embedplayerTutorial" ';
			video 	+= '		src="/static/player/player.swf" ';
			video 	+= '		width="720" ';
			video 	+= '		height="564" ';
			video 	+= '		flashvars="file=/upload/tutorials/' + tutorial.id + '.flv' + '&image=/static/images/previewVideo.png" ';
			video 	+= '		allowfullscreen="true" ';
			video 	+= '		allowscriptaccess="always" ';
			video 	+= '		quality="high" ';
			video 	+= '		type="application/x-shockwave-flash" ';
			video 	+= '	/>';
			video 	+= '</object>';
		}
		else
		{
			video 	+= '<embed ';
			video 	+= '	type="application/x-shockwave-flash" ';
			video 	+= '	id="embed" ';
			video 	+= '	name="embed" ';
			video 	+= '	src="/upload/tutorials/'+ tutorial.id +'" '; 
			video 	+= '	width="720" ';
			video 	+= '	height="540" ';
			video 	+= '	quality="high" ';
			video 	+= '/> ';
		}
		
		video 	+= '</div> ';
		
		var text = '<div class="text">';
		
		text	+= tutorial.description; 
		text	+= '</div>';
		var body  = video + text; 
			
		this.panelTutorial.setBody(body);
		this.panelTutorial.render();
		
		this.panelTutorial.show();
		
		this.panelTutorial.hideEvent.subscribe( thisClass.Close )
		
	};
	
	this.Close = function()
	{
/* funca solo para firefox
    var a = document.getElementById('embedplayerTutorial');
    a.sendEvent("STOP");
*/
    var a = document.getElementById('modalTutorial');
    a.innerHTML ='';
	};

	
	
}



var Tutorial;
YAHOO.util.Event.onDOMReady(
		
		function()
		{				
			Tutorial = new TutorialClass()			
		}
); 


var player = null;
function playerReady(thePlayer) {
	player = document.getElementById(thePlayer.id);
}

