$(function(){
	$('img[@src$=.png], .png, h1, .menu_directores a, .menu_directores li').ifixpng();	//png transparentes en IE.

	$('img.director').mouseover(function() {
		$(this).parent().css('zIndex', 100); 
		$(this).parent().children(".describe").animate({opacity: 'toggle'});
	});
	$('img.director').mouseout(function() {
		$(this).parent().css('zIndex', 1); 
		$(this).parent().children(".describe").hide();
	});
	
	if ($(".requerido").length>0){
		$('.requerido input, .requerido textarea').each(function(){												 
			if($(this).attr("value") == undefined){
				$(this).attr("value",$(this).attr("title"));
			}
		}); 
	}
	
	$('#videos').jqm();
	$('.abre_video1').click(function(){
		$('#videos .iframe').html('<iframe frameborder="0" width="630" height="385" src="'+ base_url +'compartir.php?video=iLAnuRUIS2k"></iframe>');
	});
	$('.abre_video2').click(function(){
		$('#videos .iframe').html('<iframe frameborder="0" width="630" height="385" src="'+ base_url +'compartir.php?video=APSpyo7eo80"></iframe>');	
	});
	$('.abre_video3').click(function(){
		$('#videos .iframe').html('<iframe frameborder="0" width="630" height="385" src="'+ base_url +'compartir.php?video=c4DWZbz7dJQ"></iframe>');	
	});
	$('.abre_video4').click(function(){
		$('#videos .iframe').html('<iframe frameborder="0" width="630" height="385" src="'+ base_url +'compartir.php?video=DF6jhxtFgGA"></iframe>');	
	});
	
	$('.requerido input').focus(function(){
		if ($(this).attr("value") == $(this).attr("title")){
			$(this).attr("value","");
		}
	});
	
	$('.requerido textarea').focus(function(){
		if ($(this).val() == $(this).attr("title")){
			$(this).val('');
		}
	});
	
	$('.requerido textarea').blur(function(){
		if($(this).val() == ''){
			$(this).val($(this).attr("title")); 	
		}
	});
	
	$('.requerido input').blur(function() {
		if (!$(this).attr("value")){
			$(this).attr("value",$(this).attr("title"));
			if($(this).attr("class") == "correo"){
				$(this).attr("style","");
			}
		} else {
			if($(this).attr("class") == "correo"){
				$tipo = $(this).parent().attr("id");
				switch ($tipo){
					case 'datos_compartelo':
						$color = '#532f6f'; $width = '255'; $borde = '#2F2E67';
					break;
					
					default:
						$color = '#772A25'; $width = '416'; $borde = '#E0B4B4';
					break;
				}
				if (!validar_mail($(this))){
					$(this).attr("style","background:" + $color + " url(../images/form_error.gif) no-repeat center right;border:1px solid " + $borde + ";padding-right:30px;width:" + $width + "px;color:#fff;");
				} else {
					$(this).attr("style","");
				}
			}
		}
	});
});

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>';
}
