	
	function email_check(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);

		if ((str.indexOf(at)==-1) ||
		((str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)) ||
		((str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)) ||
		(str.indexOf(at,(lat+1))!=-1) ||
		((str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)) ||
		(str.indexOf(dot,(lat+2))==-1) ||
		(str.indexOf(" ")!=-1)) {
			return false;
		} else {
			return true;
		};
	};
	
	var carrousel = new Class({

		options: {
			nombre: null,
			clonar: 0,
			segundos: 4000,
			direccion: 1,
			velocidad: 500,
			controles: 0,
			controlesLeftFuncionMOv: null,
			controlesLeftFuncionMOu: null,
			controlesRightFuncionMOv: null,
			controlesRightFuncionMOu: null,
			controlesLeftFuncionClick: null,
			controlesRightFuncionClick: null,
			wrapperMOv: null,
			wrapperMOu: null
		},

		initialize: function(options){

			if (options.nombre) { this.options.nombre = options.nombre; };
			if (options.clonar) { this.options.clonar = options.clonar; };
			if (options.segundos) { this.options.segundos = options.segundos; };
			if (options.direccion) { this.options.direccion = options.direccion; };
			if (options.velocidad) { this.options.velocidad = options.velocidad; };
			if (options.controles) { this.options.controles = options.controles; };
			if (options.controlesLeftFuncionMOv) { this.options.controlesLeftFuncionMOv = options.controlesLeftFuncionMOv; };
			if (options.controlesLeftFuncionMOu) { this.options.controlesLeftFuncionMOu = options.controlesLeftFuncionMOu; };
			if (options.controlesRightFuncionMOv) { this.options.controlesRightFuncionMOv = options.controlesRightFuncionMOv; };
			if (options.controlesRightFuncionMOu) { this.options.controlesRightFuncionMOu = options.controlesRightFuncionMOu; };
			if (options.controlesLeftFuncionClick) { this.options.controlesLeftFuncionClick = options.controlesLeftFuncionClick; };
			if (options.controlesRightFuncionClick) { this.options.controlesRightFuncionClick = options.controlesRightFuncionClick; };
			if (options.wrapperMOv) { this.options.wrapperMOv = options.wrapperMOv; };
			if (options.wrapperMOu) { this.options.wrapperMOu = options.wrapperMOu; };
			
			this.wrapper = $('wrap-'+options.nombre);
			this.carousel = $(options.nombre);
			this.items = $$('#'+options.nombre+' li');

			this.item_width = parseInt(this.items[0].getStyle('width'));
			this.max_margin = (this.items.length * this.item_width);

			if (this.options.clonar > 0) {

				for (x = 0; x < this.options.clonar; x++) {

					var itemid = (this.options.clonar)-(x+1);

					if (this.items[itemid]) {

						var nuevoelemento = this.items[itemid].clone().cloneEvents(this.items[itemid]);
						nuevoelemento.id = this.items[itemid].id+'clon';
						nuevoelemento.inject(this.items[this.items.length-1],'after');

					};
			
				};

				this.items = $$('#'+options.nombre+' li');
				
			};

			this.animation = new Fx.Tween(this.carousel, {duration: this.options.velocidad});

			this.pausa = 0;
			this.empezar(this.options);
			
			var pausea = (function() { this.pausa = 1; }).bind(this);
			var despausea = (function() { this.pausa = 0; }).bind(this);
						
			this.wrapper.addEvent('mouseover', pausea);
			this.wrapper.addEvent('mouseout', despausea);

			if (this.options.wrapperMOv) {

				var wrapper_mouseover = (function() { this.options.wrapperMOv(this); }).bind(this);
				this.wrapper.addEvent('mouseover', wrapper_mouseover);
				
			};

			if (this.options.wrapperMOu) {

				var wrapper_mouseout = (function() { this.options.wrapperMOu(this); }).bind(this);
				this.wrapper.addEvent('mouseout', wrapper_mouseout);
				
			};
			
			if (this.options.controles==1) {
			
				var control_left = new Element('a', {
				    href: '#',
				    html: '<img src="img/flecha-izquierda.png" width="50" height="50">',
				    styles: {
				        display: 'block',
				        width: '50px',
				        height: '50px',
				        position: 'absolute',
				        top: '55px',
				        left: '10px',
				        opacity: '.0'
				    }
				});

				var control_right = new Element('a', {
				    href: '#',
				    html: '<img src="img/flecha-derecha.png" width="50" height="50">',
				    styles: {
				        display: 'block',
				        width: '50px',
				        height: '50px',
				        position: 'absolute',
				        top: '55px',
				        right: '10px',
				        opacity: '.0'
				    }
				});

				control_left.inject(this.wrapper);			
				control_right.inject(this.wrapper);			

				var control_left_evento = (function() {
					this.derecha( parseInt(this.carousel.getStyle('left')) , 0);
					return false;
				}).bind(this);

				var control_right_evento = (function() {
					this.izquierda( parseInt(this.carousel.getStyle('left')) , 0);
					return false;
				}).bind(this);
							
				control_left.addEvent('click', control_left_evento);
				control_right.addEvent('click', control_right_evento);

				if (this.options.controlesLeftFuncionClick) {

					var control_left_click = (function() { this.options.controlesLeftFuncionClick(this); }).bind(this);
					control_left.addEvent('click', control_left_click);
				
				};

				if (this.options.controlesRightFuncionClick) {

					var control_right_click = (function() { this.options.controlesRightFuncionClick(this); }).bind(this);
					control_right.addEvent('click', control_right_click);
				
				};

				var efectocontroles = new Fx();
				var efectocontroles2 = new Fx();

				this.wrapper.addEvent('mouseover', function() {
		
					efectocontroles.cancel();
					efectocontroles2.cancel();
				
					efectocontroles = new Fx.Tween(control_left, {property:'opacity', duration: 500}).start(1);
					efectocontroles2 = new Fx.Tween(control_right, {property:'opacity', duration: 500}).start(1);
					
				});
				this.wrapper.addEvent('mouseout', function() {
		
					efectocontroles.cancel();
					efectocontroles2.cancel();
							
					efectocontroles = new Fx.Tween(control_left, {property:'opacity', duration: 500}).start(0);
					efectocontroles2 = new Fx.Tween(control_right, {property:'opacity', duration: 500}).start(0);
					
				});

				if (this.options.controlesLeftFuncionMOv) {

					var control_left_mouseover = (function(event) { this.options.controlesLeftFuncionMOv(event,'left',this); }).bind(this);
					control_left.addEvent('mouseover', control_left_mouseover);
					
				};
				
				if (this.options.controlesLeftFuncionMOu) {

					var control_left_mouseout = (function(event) { this.options.controlesLeftFuncionMOu(event,'left',this); }).bind(this);
					control_left.addEvent('mouseout', control_left_mouseout);

				};

				if (this.options.controlesRightFuncionMOv) {

					var control_right_mouseover = (function(event) { this.options.controlesRightFuncionMOv(event,'right',this); }).bind(this);
					control_right.addEvent('mouseover', control_right_mouseover);

				};
				
				if (this.options.controlesRightFuncionMOu) {

					var control_right_mouseout = (function(event) { this.options.controlesRightFuncionMOu(event,'right',this); }).bind(this);
					control_right.addEvent('mouseout', control_right_mouseout);

				};
						
			};
						
			return this;
			
		},

		derecha: function(posicion,pausa) {

			if (pausa!=1) {

				if ( posicion == -(this.max_margin) ) {
	
					this.carousel.style.left = 0;
					posicion = 0;
	
				};
	
				this.animation.start('left', (posicion - this.item_width) );

			};

		},

		izquierda: function(posicion,pausa) {

			if (pausa!=1) {

				if (posicion == 0){
		
					this.carousel.style.left = -(this.max_margin)+'px';
					posicion = -(this.max_margin);
		
				};
		
				this.animation.start('left', (posicion + this.item_width) );

			};

		},

		rotar: function(direccion) {

			if (direccion==1) {

				this.derecha( parseInt(this.carousel.getStyle('left')) , this.pausa);
				
			} else {

				this.izquierda( parseInt(this.carousel.getStyle('left')) , this.pausa);
			
			};
		
		},
		
		empezar: function(options) {

			this.rotador = (function() { this.rotar(options.direccion); }).periodical(options.segundos,this);
			this.status = 1;
		
		}
	
	});
	
	function funcion_controles(event,direccion,objeto) {
		
		var left_actual = parseInt(objeto.carousel.getStyle('left'));
		var posicion_actual = ((left_actual*(-1))/220);

		if (direccion!='left') {

			posicion_actual = posicion_actual+(objeto.options.clonar-1);

		};

		if (parseInt(posicion_actual) != posicion_actual) {

			if (direccion!='left') {

				posicion_actual = Math.ceil(posicion_actual);
			
			} else {

				posicion_actual = Math.floor(posicion_actual);
			
			};
		
		};

		if (objeto.items[posicion_actual]) {

			if (event.type=='mouseover') {

				muestrasocalo(objeto.items[posicion_actual].id);
				
			} else {

				sacasocalo(objeto.items[posicion_actual].id);
			
			};
			
		};

	};

	function hace_muestrasocalo() {
	
		muestrasocalo(this.id);
	
	};
	
	function muestrasocalo(elid) {

		if (!esie && !esie7 && !esie8) { $(elid).getElementsByTagName('img')[0].set('opacity','1'); };
		$$('#'+elid+' .socalo')[0].style.display = 'block';
											
	};

	function hace_sacasocalo() {
	
		sacasocalo(this.id);
	
	}

	function sacasocalo(elid) {

		if (!esie && !esie7 && !esie8) { $(elid).getElementsByTagName('img')[0].set('opacity','0.5'); };
		$$('#'+elid+' .socalo')[0].style.display = 'none';

	}

	function ocultar_todos_los_socalos(objeto) {

		$$('#'+objeto.options.nombre+' li').each(function(el){

			sacasocalo(el.id);
		
		});
	
	};
	
	function videos(videos_id) {

		if (esie) {

			$('home-video-content').innerHTML = '';
			
			(function() { $('home-video-content').innerHTML = '<iframe width="640" height="390" src="http://www.youtube.com/embed/'+videos_id+'?rel=0&autoplay=1&hd=1&wmode=transparent" frameborder="0" allowfullscreen></iframe>'; }).delay(500);

		} else {

			$('home-video-content').innerHTML = '<iframe width="640" height="390" src="http://www.youtube.com/embed/'+videos_id+'?rel=0&autoplay=1&hd=1&wmode=transparent" frameborder="0" allowfullscreen></iframe>';
		
		};
	
	};

