/**
 * @author Nikolay Borisov (nikolay@borisov.me | http://nikolay.borisov.me/)
 * @copyright Notamedia (http://notamedia.ru/)
 * @version 0.3
 * @required jQuery
 * @date 2009-11-12
 */

var EnvaseClass = function() {

	var self = this;

	var $libroFlash = $('#libroFlash');
	var $libroPuntos = $('#tileDerecha .puntos');

	var libroAbrir;
	var libroFlashLoaded = false;

	var flashHTML = function() {
		var tm = new Date();
		
		var id = 'libroFlashContent',
			url = '/static/swf/preloader.swf?'+tm.valueOf(),
			width = '880',
			height = '560',
			wmode = 'transparent',
			flashVars = 'swf=/static/swf/girar.swf';

		var html =
			'<object id="' + id + '" type="application/x-shockwave-flash" data="' + url + '" width="' + width + '" height="' + height + '">' +
				'<param name="wmode" value="' + wmode + '" />' +
				'<param name="movie" value="' + url + '" />' +
				'<param name="quality" value="high" />' +
				'<param name="menu" value="false" />' +
				'<param name="allowScriptAccess" value="always" />' +
				'<param name="flashvars" value="' + flashVars + '" />' +
			'</object>';

		return html;
	};

	var showLibroPuntos = function() {
		$libroPuntos.show();
	}

	var hideLibroPuntos = function() {
		$libroPuntos.hide();
	}

	$.Libro = {};

	$.Libro.startDragging = function(){
		hideLibroPuntos();
	}

	$.Libro.stopDragging = function(){
		showLibroPuntos();
	}

	$.Libro.abrirElLibro = function(){
		hideLibroPuntos();
	}

	$.Libro.cerrarElLibro = function(){
		setTimeout(showLibroPuntos, 800);
	}

	$.Libro.complete = function(){
		showLibroPuntos();
	}


	this.load = function(){
		$libroFlash.show();
		$libroFlash.html(flashHTML());
	}

	this.unload = function(){
		$libroFlash.html('');
		$libroPuntos.hide();
	}

};

