// JavaScript Document
$(document).ready(function() {
    // put all your jQuery goodness in here.

	$('#footer').css("opacity",0.7); 
	function sendEvent ( event, params ) {
		jQuery(document).trigger( event, params )
	}

			$('#slideHome').loopedSlider({
			/*autoStart: 7000,*/
			slidespeed: 800,
			autoHeight: 500
			});
			
			
// Form Promociones Content01
	
/*	$('#content01Ampli').click(function(){
	$('#content01').animate({opacity: 0}, 400, function(){
			$('#content01').css("display","none");
			$('#content01Form').css("display","block");
			$('#content01Form').css("opacity",0);
			$('#content01Form').animate({opacity: 1, display: "block"},400);
			});								   	
		*/

	$('#content01Form').submit(function() {
		
		var nombre = $('#nombre01').val();
		var mail = $('#mail01').val();
		var peticion = $('#peticion01').val();
		
		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) {
			
			$('#mail01').css("color","red");
			$('#mail01').attr('value', 'Indica tu Email');
			return false;
		
		} else if (nombre == "") {
			
			$('#nombre01').css("color","red");
			$('#nombre01').attr('value', 'Indique un Nombre');
			return false;
			
		} else {

		$('#content01Form').animate({opacity: 0});
		$.ajax({
			type: 'POST',
			url: "/wp-content/themes/default/includes/peticion.php",
			data: "mail01=" + mail + "& nombre01=" + nombre + "& peticion01=" + peticion,
			success: function(data) {
				$('#content01Form').animate({opacity: 1});
				$('#content01Form').html(data);
			}
		})
		return false;
		}
	});
	// Fin Form
	
	//})
    // Fin click
	
	
	
	
	$('#content02Form').submit(function() {
		
		var nombre = $('#nombre02').val();
		var mail = $('#mail02').val();
		var telefono = $('#telefono02').val();
		var consulta = $('#consulta02').val();
		var empresa = $('#empresa02').val();
		
		if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail)) {
			
			alert("test");
			$('#mail02').css("color","red");
			$('#mail02').attr('value', 'Indica tu Email');
			return false;
		
		} else if (nombre == "") {
			
			$('#nombre02').css("color","red");
			$('#nombre02').attr('value', 'Indique un Nombre');
			return false;
			
		} else {

		$('#content01Form').animate({opacity: 0});
		$.ajax({
			type: 'POST',
			url: "/wp-content/themes/default/includes/contacto.php",
			data: "mail02=" + mail + "& nombre02=" + nombre + "& telefono02=" + telefono + "& consulta02=" + consulta + "& empresa02=" + empresa ,
			success: function(data) {
				$('#content02Form').animate({opacity: 1});
				$('#content02Form').html(data);
			}
		})
		return false;
		}
	});
	// Fin Form
		
	
});


var currentPlayer=null;
var currentFile;
var currentImage;

function stopPlayer() {
		var player = document.getElementById('playerID');
		if(player){player.sendEvent('STOP');}
		}

function removeOldPlayer() {	
	if (currentPlayer!=null) {
		var player = document.getElementById('playerID');
		if(player){player.sendEvent('STOP');}
		document.getElementById(currentPlayer).innerHTML = '&nbsp';
		}
}
 
function createPlayer(thePlace, theFile, theImage, go) {
	if (currentPlayer!=null) { removeOldPlayer(); }
	currentPlayer = thePlace;
	
	var s = new SWFObject("/wp-content/themes/default/media/player.swf","playerID","414","263","7", "#1b1818");
	s.addParam("allowfullscreen","true");
	s.addVariable("file",encodeURIComponent(theFile));
	s.addVariable("skin","/wp-content/themes/default/media/skin.swf");
	s.addVariable("image",theImage);
	//s.addVariable("id","player");
	if (go) { s.addVariable("autostart","true"); }
	s.write(thePlace);
	}
	
function createPlayerSingle(thePlace, theFile,  go) {
	
	if (currentPlayer!=null) { removeOldPlayer(); }
	currentPlayer = thePlace;
	
	var s = new SWFObject("/wp-content/themes/default/media/player.swf","playerID","572","341","7", "#1b1818");
	s.addParam("allowfullscreen","true");
	s.addVariable("file",encodeURIComponent(theFile));
	s.addVariable("skin","/wp-content/themes/default/media/skin.swf");
	//s.addVariable("image",theImage);
	if (go) { s.addVariable("autostart","true"); }
	s.write(thePlace);
	}
	
function createPlayerMundo(thePlace, theFile, theImage, go) {
	if (currentPlayer!=null) { removeOldPlayer(); }
	currentPlayer = thePlace;
	
	var s = new SWFObject("/wp-content/themes/default/media/player.swf","playerID","456","316","7", "#1b1818");
	s.addParam("allowfullscreen","true");
	s.addVariable("file",encodeURIComponent(theFile));
	s.addVariable("skin","/wp-content/themes/default/media/skin.swf");
	s.addVariable("image",theImage);
	if (go) { s.addVariable("autostart","true"); }
	s.write(thePlace);
	}

