/*===========================================
	JavaScript Source Code,
	
	2011 - Eenda Works
===========================================*/


	/*
	Maxlength en 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 Paypal */
	function redireccionar(web, num){ 
		setTimeout("window.location = '"+web+"'", num);
	}
	
	
	/*
	inputs > Onfocus */
	function reset_onfocus(obj){
		if(obj.value == obj.defaultValue)
			obj.value = '';
	}
	
	/*
	inputs > Onblur */
	function reset_onblur(obj){
		if(obj.value=='')
			obj.value = obj.defaultValue;
	}


	$(document).ready(function(){
		
		/*
		Zona de Pageflip */
		$("#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)
		});
		
		/*
		Click en Noticias */
		$("a[class='jq_news']").click(function(){
			$("#jq_news").slideToggle(50);
		});
		
		$("*[class='submenu_bar'] a.close").click(function(){
			$(".submenu_bar").slideToggle(50);
		});
		
		
		/*
		Recordar password / Volver */
		$("a[rel='recpass']").click(function(){
			$('.iniciar_sesion').fadeOut(200, function(){
				$('.recordar_password').fadeIn();
			});
		});
		
		$("a[rel='inisess']").click(function(){
			$('.recordar_password').fadeOut(200, function(){
				$('.iniciar_sesion').fadeIn();
			});
		});
		
		
		/*
		Placeholder IE */
		jQuery(function() {
			jQuery.support.placeholder = false;
			test = document.createElement('input');
			if('placeholder' in test) jQuery.support.placeholder = true;
		});
		
		$(function() {
		   if(!$.support.placeholder) { 
			  var active = document.activeElement;
			  $(':text').focus(function () {
				 if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
					$(this).val('').removeClass('hasPlaceholder');
				 }
			  }).blur(function () {
				 if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
					$(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
				 }
			  });
			  $(':text').blur();
			  $(active).focus();
			  $('form:eq(0)').submit(function () {
				 $(':text.hasPlaceholder').val('');
			  });
		   }
		});
	
	});
