$.extend({
	stop: function(e){
        if (e.preventDefault) e.preventDefault();
        if (e.stopPropagation) e.stopPropagation();
    }
});

var player = null;
function playerReady(thePlayer) {
	player = window.document[thePlayer.id];
}

$(function(){
	// this initialises the demo scollpanes on the page.
	$('.parrilla').jScrollPane();
});

// Funciones para aumentar  y disminiuir el tamano del texto en el contenido 


/* Crear player de video */
function createPlayer(theFile, img, start) {
	var flashvars = {
		file:theFile,
		image:img,
		repeat:"false",
		showdigits:"true",
		showdownload:"false",
		width:"316",
		height:"209",
		autostart:start
	};
	var params = {
		allowFullScreen:"true",
		base: ".",
		allowscriptaccess:"always"
	};
	var attributes = {
		id: "player1",
		name: "player1",
		onfocus: "blur();"
	};
	swfobject.embedSWF("swf/player.swf", "videoflash", "320", "213", "7.0.0", false, flashvars, params, attributes);

}
function createPlayerRight(theFile, img, start) {
	var flashvars = {
		file:theFile,
		image:img,
		repeat:"false",
		showdigits:"true",
		showdownload:"false",
		width:"316",
		height:"209",
		autostart:start
	};
	var params = {
		allowFullScreen:"true",
		base: ".",
		allowscriptaccess:"always"
	};
	var attributes = {
		id: "player1",
		name: "player1",
		onfocus: "blur();"
	};
	swfobject.embedSWF("swf/player.swf", "videoflash", "226", "158", "7.0.0", false, flashvars, params, attributes);

}

$(document).ready(function() {
	$(".js_hide").hide();
	$("#video").show();
	//createPlayer("../medios/UNIR1.flv", "../medios/A_Closer_Look_At_The_iPhone.jpg");	
	var tamano = 12;
	$(".mas").click(function(e) {
		e.preventDefault();
		//alert (tamano);
		if (tamano <= 18) {
			tamano = tamano + 3;
			$('#content').css('font-size',tamano);
		}
	});
	
	$(".menos").click(function(e) {
		e.preventDefault();
		//alert (tamano);
		if (tamano >= 9) {
			tamano = tamano - 3;
			$('#content').css('font-size',tamano);
		}
	});
	
	$(".defecto").click(function(e) {
		e.preventDefault();
		//alert (tamano);
			tamano = 12;
			$('#content').css('font-size',tamano);
	});
	
	$("#home_video .listvideos li a").click(function(e) {
		e.preventDefault();
		var ref = $(this).attr('href');
		var rel = $(this).attr('rel');
		var start = $(this).attr('rev');
		//var texto = $(this).attr('name');
		var urlArray = ref.split("$");
		var video = urlArray[1];
		var texto = urlArray[2];
		var accesible= urlArray[3];
		$(".tabs li.accesible a").attr('href', accesible);
		$(".listvideos li").removeClass('activo');									  
		$(this).parent().parent().addClass('activo');
		//player.sendEvent('STOP');
		//player.sendEvent('LOAD', ref);
		swfobject.removeSWF("player1");
		$("#video").append("<div id='videoflash'></div>");
		createPlayer(video, rel, start);
		$("#slideflash").attr('data', texto);
		$("#slideflash").attr('movie', texto);		
	});
	
	$("#video_right .listvideos li a").click(function(e) {
		e.preventDefault();
		var ref = $(this).attr('href');
		var rel = $(this).attr('rel');
		var start = $(this).attr('rev');
		//var texto = $(this).attr('name');
		var urlArray = ref.split("$");
		var video = urlArray[1];
		var texto = urlArray[2];
		var accesible= urlArray[3];
		$(".tabs li.accesible a").attr('href', accesible);
		$(".listvideos li").removeClass('activo');									  
		$(this).parent().parent().addClass('activo');
		//player.sendEvent('STOP');
		//player.sendEvent('LOAD', ref);
		swfobject.removeSWF("player1");
		$("#video").append("<div id='videoflash'></div>");
		createPlayerRight(video, rel, start);
		$("#slideflash").attr('data', texto);
		$("#slideflash").attr('movie', texto);	
	});
	
	$(".tabs li").hide();
	$(".tabs li.tab:first").show();
	$(".tabs li.tab a").click(function(e) {
		e.preventDefault();
		var href = $(this).attr('href');
		$(".tabs li").removeClass('activo');									  
		$(this).parent().addClass('activo');
		$(".js_hide").hide();
		$(href).show();
		player.sendEvent('STOP');
	});
	
	

	
	$(".conttabs").hide();
	$(".conttabs:first").show();
	$(".ul_tabs li a").click(function(e) {
		e.preventDefault();
		var href = $(this).attr('href');
		$(".ul_tabs li").removeClass('activo');									  
		$(this).parent().addClass('activo');
		$(".conttabs").hide();
		$(href).show();
	});
	
	$("form.validable").bind("submit", function(e){
		$("form.validable .error").removeClass('error');
		$(".cajaerror").hide();
		if (typeof filters == 'undefined') return;
	    $(this).find("input, textarea, select").each(function(x,el){
	        if ($(el).attr("className") != 'undefined') {
	        $.each(new String($(el).attr("className")).split(" "), function(x, klass){
	            if ($.isFunction(filters[klass]))
	                if (!filters[klass](el))
						 	var iderror = $(el).attr('id');
							$("label[for="+iderror+"]").addClass("error");
						 	//$(el).parent().parent().children('.col1').children().addClass("error");
	        });
	        }
	    });
		if ($(this).find(".error").size() > 0) {
			$.stop(e || window.event);
			$(".cajaerror").show();
			return false;
		}
	    return true;
	});
	
	

});
