// momentum media design v4 theme scripts 


// mailpress
//var mp_url = '/wp-content/plugins/mailpress/mp-includes/action.php';

// jquery
jQuery(document).ready( function($) {
	
	// **** Precarga de imágenes *************************************
	
	$.preloadImages = function()
	{
		for(var i = 0; i<arguments.length; i++) {
			$("<img>").attr("src", arguments[i]);
	  	}
	}
	
	rt = "/wp-content/themes/mmd4/img/common/";
	$.preloadImages(rt+"submenu_agencia_on.gif", rt+"submenu_contacto_on.gif", rt+"mainmenu_servicios.png", rt+"mainmenu_produccion.png", rt+"mainmenu_portafolio.png");
	$('.mp-loading').css("opacity", "0");
	
	
	// **** Formularios **********************************************
	
	$("#s").focus( function() {
	
		if ($(this).attr("value") == "Escribe tu búsqueda") {
			$(this).attr("value", "");
		}
	
	});
	
	$(".MailPressFormEmail").focus( function() {
	
		if ($(this).attr("value") == "escribe tu correo") {
			$(this).attr("value", "");
		}
	
	});
	
	$("#ref-li").hide();
	$("#ref-select").change( function() {
	
		if($(this).val() == "Otro") {
			$("#ref-li").show();
		} else {
			$("#ref-li").hide();
		}
	
	});
	
	
	// **** Portafolio ***********************************************
	
	$("#pictBox").text('');
	$("#pictBox").html('<div class="picWorkBox"></div>');
	$(".picWorkBox").width(300);
	$(".picWorkBox").height(300);
	
	
	src = $('a.imageLink:first-child').attr('href');
	alt = $('a.imageLink:first-child').attr('alt');
	
	img = new Image();
		
	$(img).load( function() {
		
		w = img.width;
		h = img.height;
		
		$(".picWorkBox")
			.text('')
			.append(img)
			.animate({ width: w, height: h }, 500, 'swing', function() { $(".workPict").fadeIn(1000);  } );
		
		$(img)
			.addClass('workPict')
			.hide()
		
	})
		
	$(img).attr('src', src);
	$(img).attr('alt', alt);
	
	
	// cambio de imagen
	$('a.imageLink').click( function(event) {		
		
		$("img.workPict").remove();
		
		img = new Image();
		
		$(img)
			.load( function() {

				w = img.width;
				h = img.height;
				
				$(".picWorkBox")
					.append(img)
					.animate({ width: w, height: h }, 500, 'swing', function() { $(".workPict").fadeIn(1000); });
				
				$(img)
					.addClass('workPict')
					.hide()
				
			})
			
			.attr('src', this.href)
			.attr('alt', $(this).children("img").attr("alt"));
		
		return false;
	
	});
	
	$("#currency_code").change(function () {
		
		var cur = $("select option:selected").attr("value");
		$("#labelAmount").text("Cantidad a pagar ("+cur+")");
		
	})
	.change();

	
	
	// ie6 :(
	if($.browser.msie && parseInt($.browser.version) <= 6) {
	 
		$("th[scope=col]").addClass("scopeCol");
		$("th[scope=row]").addClass("scopeRow");
	
	}
	
	//Disponibilidad de dominios******************************************************************************
	var valor;
	var datos; 
	var ban=0;
	$("#submitBtn").click(function(event)
		{
      		valor=$("#domain").attr("value");
			datos = 'domain='+valor;
			if($("#top_com").attr("checked"))
			{
				datos+='&top_com='+$("#top_com").attr("checked");
				ban=1;
			}
			if($("#top_net").attr("checked"))
			{
				datos+='&top_net='+$("#top_net").attr("checked");
				ban=1;
			}
			if($("#top_org").attr("checked"))
			{
				datos+='&top_org='+$("#top_org").attr("checked");
				ban=1;
			}
			if($("#top_info").attr("checked"))
			{
				datos+='&top_info='+$("#top_info").attr("checked");
				ban=1;
			}
			if(ban==0)
			{
				alert('Selecciona algún tipo de dominio');
			}
			else
			{
			$.ajax({
		    	type: 'POST',
		        url: "resultado.php",
				data: datos,
				success: function(data) {
					$('#informacion').html(data);
				}
			});
		}       
	});
	
	// Termina funcion Disponibilidad de dominios***************************************************************
	
	
	
	
	
});
