
jQuery(document).ready(function($) {

	if($('#contacto-form').length){ //el formulario de contacto
		$('#bt_enviar').click(function() {
			var valid;
			var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if(!$.trim($('#nombre').val()).length) { $('#infoNombre').html('<span class="red">No puede quedar en blanco</span>'); validA=false; } else { $('#infoNombre').html(""); validA=true; };
			if(!$.trim($('#mensaje').val()).length) { $('#infoMensaje').html('<span class="red">No puede quedar en blanco</span>'); validB=false; } else { $('#infoMensaje').html("lo que quieras decir, comentar o preguntar"); validB=true; };
			if (!regex.test($('#correo').val())) { $('#infoCorreo').html('<span class="red">ingresa una dirección de correo válida</span>'); validC=false; } else { $('#infoCorreo').html(""); validC=true; };
			if ($('#spam').val()!=cha) { $('#infoSpam').html('<span class="red">o vamos, es aritmética de primaria</span>'); validD=false; } else { $('#infoSpam').html("anti-spam"); validD=true; };

		  // are all fields valid
		  valid = validA && validB && validC && validD;
		  if(valid){
				$('.buttons').html('<p class="blue align-center">Gracias por escribirnos, te responderemos lo más pronto posible.</>');
				$.post("../_contacto-post.php", $("#contacto-form").serialize());
		  }
		});
	}

	//hosting - feature info
	if($('#hosting-plan').length){ //el listado
		$('table .feat .info').css('display','none');
		$('table .feat img.toggle').click(function () {
			$(this).parent().find('.info').slideToggle("slow");
		});
	}

	//hosting email - screenshots
	if($('#hosting-plan .email').length){
		$("a.mimail").fancybox({'transitionIn':'elastic','titlePosition':'over'});
	}




	//servicios
	if($('#servicios').length){

		//sidebar
		var divTipos = $("#servicios div.tipos");
		$("#servicios div.tipos a.comercio").hover(function () {divTipos.addClass("comercio");},function () {divTipos.removeClass("comercio");});
		$("#servicios div.tipos a.hosting").hover(function () {divTipos.addClass("hosting");},function () {divTipos.removeClass("hosting");});
		$("#servicios div.tipos a.publicidad").hover(function () {divTipos.addClass("publicidad");},function () {divTipos.removeClass("publicidad");});
		$("#servicios div.tipos a.desarrollo").hover(function () {divTipos.addClass("desarrollo");},function () {divTipos.removeClass("desarrollo");});

		//animacion en la home
		if($('#servicios div.content.home').length){
			//hide submenu
			$('#servicios .header .showcase').css('height','138px');
			//clic que inicia las animaciones
			$('#servicios div.tipos a').click(function (e) {
				e.preventDefault(); //prevent default y captura el href
				var rel = $(this).attr('rel');
				var reqContent = $('#reqContent');
				var divContent = $('#servicios div.content')

				divTipos.animate({marginLeft:-1000},"slow"); //quita el menu
				divContent.html('<div style="margin:100px auto;width:32px;"><img src="../img/loading.gif" width="32"></div>');
				divContent.animate({width:'100%'},"slow"); //amplia content
					$('#servicios .header .showcase').animate({height:174},"slow",function(){ //crece showcase
						$('#servicios .header .showcase .submenu').show("slow",function(){ //aparece submenu
							$('#servicios .header .showcase .submenu ._home').removeClass("selected")
							$('#servicios .header .showcase .submenu .'+rel).addClass("selected")
							//$('#home-h2').css('display','none');
							reqContent.css('opacity',0);
							reqContent.load('/servicios/'+rel+'.php'); //carga el url original del href
							reqContent.animate({opacity:1},"slow");
						});
					});
			});
		}

		//animacion en las internas
		if(!$('#servicios div.content.home').length){

		}

	}

	//footer
	if($('#footer').length){
		$("#footer dl dd.sociales ul li a img").css('opacity',0);
		$("#footer dl dd.sociales ul li a.facebook img").hover(function(){$(this).animate({'opacity':1},"fast");},function () {$(this).animate({opacity:0},"fast");});
		$("#footer dl dd.sociales ul li a.skype img").hover(function(){$(this).animate({'opacity':1},"fast");},function () {$(this).animate({opacity:0},"fast");});
		$("#footer dl dd.sociales ul li a.rss img").hover(function(){$(this).animate({'opacity':1},"fast");},function () {$(this).animate({opacity:0},"fast");});
	}


});

