
	$.fx.speeds._default = 1000;
	
	

$(function(){

				// Accordion
				$("#accordion, #accordion2, #accordion3, #accordion4, #accordion5, #accordion14").accordion({ header: "h3", collapsible: true, autoHeight: false});
				$("#accordion6, #accordion7, #accordion8, #accordion9, #accordion13,#slidingTopWrap, #logeo").accordion({ header: "h3", collapsible: true, autoHeight: false});
				$("#accordion10, #accordion11, #accordion12, #compras").accordion({ header: "h3", collapsible: true, autoHeight: false});
				
				
				
				$("#mail").toggle (
			function() {
				$("#accordion12").animate({width: 270}, 1000);
				var selectedEffect = "blind";
				$("#mailfull").show();

			},
			function() {
				$("#accordion12").animate({width: 253}, 1000);
				$("#mailfull, #msnfull, #skypefull, #telfull").hide();
			}
		
		);
		$("#msn").toggle (
			function() {
				$("#accordion12").animate({width: 270}, 1000);
				var selectedEffect = "blind";
				$("#msnfull").show();
			},
			function() {
				$("#accordion12").animate({width: 191}, 1000);
				$("#mailfull, #msnfull, #skypefull, #telfull").hide();
			}
		
		);
		$("#skype").toggle (
			function() {
				$("#accordion12").animate({width: 270}, 1000);
				var selectedEffect = "blind";
				$("#skypefull").show();
			},
			function() {
				$("#accordion12").animate({width: 191}, 1000);
				$("#mailfull, #msnfull, #skypefull, #telfull").hide();
			}
		
		);
		$("#tel").toggle (
			function() {
				$("#accordion12").animate({width: 270}, 1000);
				var selectedEffect = "blind";
				$("#telfull").show();
			},
			function() {
				$("#accordion12").animate({width: 191}, 1000);
				$("#mailfull, #msnfull, #skypefull, #telfull").hide();
			}
		
		);


				// Tabs
				$('#tabs').tabs();
				
				// Dialog Link

				$('#dialog_link,#registro, #ingresar, #registrar, #ver, #ver2, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);

				
				$('#mail, #msn, #skype, #datos, #seguir, #tel').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
				
				
				function runEffect(){
			//get effect type from 
			
			
			
			var selectedEffect = "blind";
			
			//most effect types need no options passed by default
			var options = {};
			//check if it's scale, transfer, or size - they need options explicitly set
		
			//run the effect
			

			
			
		};
		
		//callback function to bring a hidden box back

		
		//set effect from select menu value
		$("#registro, #registro2").toggle(
		 function() {
			$("#effect").show('slow').animate({width: 270}, 1000);
     		},
	     function() {
			$("#effect").hide('slow');
			return false;
			}
		);
		
				
		$("#effect").hide();
		$("#logeo").hide();
		$("#mailfull").hide();
		$("#msnfull").hide();
		$("#skypefull").hide();
		$("#telfull").hide();
		$("#cargando").hide();
		
		//$("#slidingTopWrap").draggable({handle: 'p'} );
	});




//////////////////////---------------------------------CHEQUEO DE REGISTRO------------------------------/////////////////////////////
	$().ready(function() {
	// validate the comment form when it is submitted
	$("#commentForm").validate();
	
	// validate signup form on keyup and submit
	$("#signupForm").validate({
		rules: {
			firstname: "required",
			lastname: "required",
			username: {
				required: true,
				minlength: 2
			},
			password: {
				required: true,
				minlength: 5
			},
			confirm_password: {
				required: true,
				minlength: 5,
				equalTo: "#password"
			},
			email: {
				required: true,
				email: true
			},
			topic: {
				required: "#newsletter:checked",
				minlength: 2
			},
			agree: "required"
		},
		messages: {
			firstname: "<img src=images/unchecked.gif >",
			lastname: "<img src=images/unchecked.gif >",
			username: {
				required: "<img src=images/unchecked.gif >",
				minlength: "<img src=images/unchecked.gif >"
			},
			password: {
				required: "<img src=images/unchecked.gif >",
				minlength: "<img src=images/unchecked.gif >"
			},
			confirm_password: {
				required: "<img src=images/unchecked.gif >",
				minlength: "<img src=images/unchecked.gif >",
				equalTo: "<img src=images/unchecked.gif >"
			},
			email: "<img src=images/unchecked.gif >",
			agree: "<img src=images/unchecked.gif >"
		}
	});
	
	// propose username by combining first- and lastname
	$("#username").focus(function() {
		var firstname = $("#firstname").val();
		var lastname = $("#lastname").val();
		if(firstname && lastname && !this.value) {
			this.value = firstname + "." + lastname;
		}
	});
	
	//code to hide topic selection, disable for demo
	var newsletter = $("#newsletter");
	// newsletter topics are optional, hide at first
	var inital = newsletter.is(":checked");
	var topics = $("#newsletter_topics")[inital ? "removeClass" : "addClass"]("gray");
	var topicInputs = topics.find("input").attr("disabled", !inital);
	// show when newsletter is checked
	newsletter.click(function() {
		topics[this.checked ? "removeClass" : "addClass"]("gray");
		topicInputs.attr("disabled", !this.checked);
	});
});
	
//////////////////////---------------------------------VALIDADOR REGISTRO------------------------------/////////////////////////////	
	$.validator.setDefaults({
	submitHandler: function() {
		$("#cargando").ajaxStart(function() { $(this).show() });
		
		$.get('reg.php',{ usuario:$('#username').val(),password:$('#password').val(), email:$('#email').val(),nombre:$('#firstname').val() },function(datos) {
		if(datos=="yes" ){
			$("#cargando").ajaxStop(function() { $(this).hide() });
			$("#effect").hide('clip',1000);
			$("#accordion7").hide('explode',1000);
			$("#logeo").show('fold',1000);
			$("#usuario0").html($('#username').val());
		}else{
			$("#cargando").html('');
			if(datos=="usuario"){
				$("#cargando").html('<span style="background:#ff0000"><font color=white>Usuario ya registrado</font></span>');
				$("#cargando").ajaxStop(function() { $(this).delay(3000).hide('slide',1000) });
			}else if(datos=="correo"){
				$("#cargando").html('<span style="background:#ff0000"><font color=white>Correo ya registrado</font></span>');
				$("#cargando").ajaxStop(function() { $(this).delay(3000).hide('slide',1000) });
			}
			else{
				$("#cargando").html('<span style="background:#ff0000"><font color=white>Error al registro</font></span>');
				$("#cargando").ajaxStop(function() { $(this).delay(3000).hide('slide',1000) }); 
			}
		}		
		});
	}
});
	
//////////////////////---------------------------------    LOGEO    -----------------------------/////////////////////////////
	
	$(document).ready(function()
{
	$("#login_form").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#msgbox").removeClass().addClass('messagebox').text('Validando....').fadeIn(1000);
		//check the username exists or not from ajax
		$.post("ajax_login.php",{ user_name:$('#user_name').val(),password:$('#pass').val(),rand:Math.random() } ,function(data)
        {
		  if(data!='no') //if correct login detail
		  {
		  	$("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  $(this).html('Entrando.....').addClass('messageboxok').fadeTo(900,1,
              function()
			  { 
			  
				  $("#accordion7").hide('explode',1000);
				  $("#logeo").show('fold',1000);
				  $("#usuario0").html(data);
			  	 //redirect to secure page
				 //document.location='secure.php';
			  });
			  

			  
			});
		  }
		  else 
		  {
		  	$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
			{ 
			  //add message and change the class of the box and start fading
			  
			 	$(this).html('Usuario o Contrase&ntilde;a incorrectos...').addClass('messageboxerror').fadeTo(1900,1);
				$(this).html('Usuario o Contrase&ntilde;a incorrectos...').addClass('messageboxerror').fadeTo(1200,0);
				
			});		
          }
				
        });
 		return false; //not to post the  form physically
	});
	//now call the ajax also focus move from 
	$("#pass").blur(function()
	{
		$("#login_form").trigger('submit');
	});
});
	
		$(document).ready(function(){	
	$("#slider").easySlider({
		auto: true,
		continuous: true,
		numeric: true
	});
	
});
		

