var tiempo;
var foto = 1;
function cambia_principal(total){
	flash_nuevo = galeria[foto];
	enlace_nuevo = enlace[foto];
	$('#foto_flash').fadeOut("slow", function(){
		$('#foto_flash').attr({src: flash_nuevo});
		$('#foto_flash').css("position", 'relative');
		$('#foto_flash').css("z-index", '1');
		$('#enlace_flash').attr({href: enlace_nuevo});
		$('#enlace_flash').css("position", 'relative');
		$('#enlace_flash').css("z-index", '1');
	});
	$('#foto_flash').fadeIn("slow");
	
	foto = parseInt(foto)+1;
	if(foto == total){
		foto = 0;
	}
}

function loop(total){
	tiempo = setInterval("cambia_principal("+total+")",15000);
}

function newsletterSubmit(value){
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
	$('#enlaceNewsletter').attr('href', 'includes/newsletter/newsletter.php?email='+value);

	Shadowbox.init();

	$('#enlaceNewsletter').click();

	if (filter.test(value)) {

		$('#email').val('');

	}

	$('#email').focus();
}

	
function playYoutube(codigo){
		$('#reproduccion_actual').html('<object height="265" width="339"><param value="http://www.youtube.com/v/'+codigo+'?f=videos&amp;app=youtube_gdata&amp;autoplay=0" name="movie"/><param value="transparent" name="wmode"/><embed height="265" width="339" wmode="transparent" type="application/x-shockwave-flash" src="http://www.youtube.com/v/'+codigo+'?f=videos&amp;app=youtube_gdata&amp;autoplay=0&amp;rel=0"/></object>');

}
