/* GZIP by Raccoon Framework */

$(function() {
	/**
	 * Utileria que muestra en un input una descripcion
	 * de uso y que se quita al recibir el foco
	 * @author Alejandro Galindo twitter.com/elalecs
	 *
	 * <input class="boxinfo" data-boxinfo="Ejem." />
	 */
	$(".boxinfo").each(function() {
		var self = $(this);
		if (self.val() === "") {
			self.val(self.data("boxinfo")).addClass("boxinfo-active");
		}
	}).focus(function() {
		var self = $(this);
		if (self.val() === self.data("boxinfo")) {
			self.val("").removeClass("boxinfo-active");
		}
	}).blur(function() {
		var self = $(this);
		if (self.val() === "") {
			self.val(self.data("boxinfo")).addClass("boxinfo-active");
		}
	});
	
	
	$("img[data-media=youtube]").each(function(){
		var data = $(this).attr("rel").split("@");
		var width = /width\:\ ([0-9]{3})/.exec(data[1])[1];
		var height = /height\:\ ([0-9]{3})/.exec(data[1])[1];
		var url = "http://www.youtube.com/v/"+data[0]+"&hl=en&fs=1&rel=0";
		$(this).replaceWith(
			$('<embed type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="'+width+'" height="'+height+'" src="'+url+'" allowscriptaccess="always" /> ')
		);
	});
	$("img[data-media=vimeo]").each(function() {
		var id = $(this).attr("rel");
		var url = 'http://vimeo.com/moogaloop.swf?clip_id='+id+'&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1';
		//var obj = $('<object type="application/x-shockwave-flash" width="400" height="286" data="'+url+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="'+url+'" /></object>');
		$(this).replaceWith(
			$('<embed type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" width="400" height="286" src="'+url+'" allowscriptaccess="always" /> ')
		);
	});
});
