/**************************************************************

	enelnombredelARTE.com

**************************************************************/

	/*
	Bloqueo el botón derecho del ratón */
	//window.oncontextmenu = function(){return false;}
	
	/*
	Impongo un límte a los textarea */
	window.onload = function(){
		var selects = document.getElementsByTagName("textarea");
		for (var i = 0; i < selects.length; i++) { 
			if(selects[i].getAttribute("maxlength") > 0){
				selects[i].onkeydown = function(){
					if (this.value.length > this.getAttribute("maxlength")) 
						this.value = this.value.substring(0, this.getAttribute("maxlength"));
				}
				selects[i].onblur = function(){
					if (this.value.length > this.getAttribute("maxlength")) 
						this.value = this.value.substring(0, this.getAttribute("maxlength"));
				}
			}
		}
	}

	
	/*
	Redireccionar / Recargar página */
	function redir(){ 
		window.location='./';
	}
	
	function setredir(num){
		setTimeout("redir()", num);
	}
	
	function setredir_descarga(num, web){
		setTimeout("window.location='"+web+"'", num);
		setTimeout("window.location='http://www.photoclick.es'", 3000);
	}
	
	function setreload(num){
		setTimeout("location.reload()", num);
	}
	



$(document).ready(function(){


	/********************************************
	* Ejecuto el plugin prettyPhoto
	********************************************/
	jQuery('#partners').jcarousel({
        auto: 2,
        wrap: 'circular',
		scroll: 1
    });



	/********************************************
	* Ejecuto el plugin prettyPhoto
	********************************************/
	$("a[rel^='zoom']").prettyPhoto({
		theme:'facebook'
	});




	/********************************************
	* Default value para los formularios
	********************************************/
	$("input[type='text'][alt='jq'], textarea[alt='jq'], input[type='password'][alt='jq']").focus(function(){
		$(this).prev().css("opacity", "0.2");
	})
	
	$("input[type='text'][alt='jq'], textarea[alt='jq'], input[type='password'][alt='jq']").blur(function(){
		var thisValue = $(this).val();
		
		if(thisValue == ""){
			$(this).prev().fadeIn(100, function(){
				$(this).css("opacity", "1");
			});
		}else{
			$(this).prev().fadeOut(100);
		}
	});




	/********************************************
	* Acceso clientes > Recordar password
	********************************************/
	$("a[rel='recordar_password']").click(function(){
		$('#form_login').fadeOut(300, function(){
			$('#form_remindpass').fadeIn(300);
		});
	});
	
	$("a[rel='volver']").click(function(){
		$('#form_remindpass').fadeOut(300, function(){
			$('#form_login').fadeIn(300);
		});
	});
	
	
	/********************************************
	* Acceso clientes > Express login
	********************************************/
	$("a[rel='recordar_password_express']").click(function(){
		$('#form_login_express').fadeOut(300, function(){
			$('#form_remindpass_express').fadeIn(300);
		});
	});
	
	$("a[rel='volver_express']").click(function(){
		$('#form_remindpass_express').fadeOut(300, function(){
			$('#form_login_express').fadeIn(300);
		});
	});




	/********************************************
	* Función para agregar campos al formulario
	********************************************/
	function addImagefile(index){
    	$(this).each(function(){
			if(index < 3){
				$("#elements").append('<input type="file" name="email_'+index+'" size="25" />');
				index ++;
			}else{
				alert('Ha alcanzado el límite de imágenes'); return false;
			}
		});
	}
	
	
	
	/*
	Ejecuto la función de adición de campo */
	$("a[rel='addElement']").click(function(){
		addImagefile(2);
	});
	
	
	
	$("#pageflip").hover(function(){
		$("#pageflip img , .msg_block").stop()
			.animate({ //Animate and expand the image and the msg_block (Width + height)
				width: '300px',
				height: '300px'
			}, 500);
		} , function() {
		$("#pageflip img").stop() //On hover out, go back to original size 50x52
			.animate({
				width: '50px',
				height: '52px'
			}, 220);
		$(".msg_block").stop() //On hover out, go back to original size 50x50
			.animate({
				width: '50px',
				height: '50px'
			}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
	});




	/********************************************
	* Sponsors Flip
	********************************************/
	$('.sponsorFlip').bind("click",function(){
		var elem = $(this);
		
		if(elem.data('flipped')){
			elem.revertFlip();
			elem.data('flipped',false)
		}else{
			
			elem.flip({
				direction:'lr',
				speed: 350,
				onBefore: function(){
					elem.html(elem.siblings('.sponsorData').html());
				}
			});
			
			elem.data('flipped',true);
		}
	});


		
	
		
		


}); // close document.ready();
