$(function(){	

	$('img[@src$=.png], .png, #fondo_web, #lista_curri h3, #centro_intro').ifixpng();	//png transparentes en IE.  
	
	$('#enviar_contacto').click(function(){
		error = "";
		if ($('#nombre').val().length<3){error += $('#nombre').attr('error')+"\n";}
		if ( $('#email').val().length<3 || !validar_mail($('#email')) ){ error += $('#email').attr('error')+"\n"; }
		if ($('#comentarios').val().length<10){error += $('#comentarios').attr('error')+"\n";}
		if ($('#field_codigo').val().length != 5){error += $('#field_codigo').attr('error')+"\n";}
		if (error != ""){
			alert(error); return;
		} else {
			$('#form_contacto').submit();
		}
	});

	$('#cerrar_mensaje').click(function(){
		$('.bloque_mensajes').slideToggle("slow");								
	});	
	
	if ($('.editor').length){
		$('.editor').wysiwyg({
			controls : {
				separator04 : { visible : true },
				insertOrderedList : { visible : true },
				insertUnorderedList : { visible : true },
				separator01 : { visible : true },
				indent  : { visible : true },
				outdent : { visible : true },
				separator02 : { visible : true },
				subscript   : { visible : true },
				superscript : { visible : true },
				separator00 : { visible : true },
				justifyLeft   : { visible : true },
				justifyCenter : { visible : true },
				justifyRight  : { visible : true },
				justifyFull   : { visible : true },
				separator06 : { separator : false },
				insertImage : { visible : false },
				h1mozilla : { visible : false },
				h2mozilla : { visible : false },
				h3mozilla : { visible : false },
				h1 : { visible : false },
				h2 : { visible : false },
				h3 : { visible : false },
				separator08 : { visible : false },
				increaseFontSize : { visible : false },
				decreaseFontSize : { visible : false }
			}
		});
	}

	$('#enviar_carta').click(function(){
		$('#send_carta').submit();							  
	});

	if ($('div.contiene_video').length){
		$('div.contiene_video').each(function(){
			$video = $('p', this).html();
			Objectclass = 'reproduce_video';
			WIDTH = 475;
			HEIGHT = 356;
			MOVIE = base_url+'mediaplayer.swf';
			VALORES = 'file='+$video;
			$flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" class="' + Objectclass + '" width="' + WIDTH + '" height="' + HEIGHT +'"><param name="movie" value="' + MOVIE +'"><param name="quality" value="high"><PARAM NAME="wmode" VALUE="transparent"><param name="FlashVars" value="' + VALORES +'"><embed src="' + MOVIE +'" quality="high" wmode="transparent" FlashVars="' + VALORES +'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + WIDTH + '" height="' + HEIGHT +'"></embed></object>';
			$(this).html($flash);
		});
	}
});

$(window).bind("load", function() { 
	$('.bloque_mensajes').slideToggle("slow");
});
function validar_mail(objeto){
	reg=/(\S+\@\S+(\.\S+)+)|(^[ \t]*$)/;
	if (! reg.exec(objeto.val())){ return false; }
	return true;
}

function FlashTransparente(DivID,ObjectID,WIDTH,HEIGHT,MOVIE,VALORES){
	document.getElementById(DivID).innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" id="' + ObjectID + '" width="' + WIDTH + '" height="' + HEIGHT +'"><param name="movie" value="' + MOVIE +'"><param name="quality" value="high"><PARAM NAME="wmode" VALUE="transparent"><param name="FlashVars" value="' + VALORES +'"><embed src="' + MOVIE +'" quality="high" wmode="transparent" FlashVars="' + VALORES +'" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + WIDTH + '" height="' + HEIGHT +'"></embed></object>';
}

