$(document).ready(function() {
	$("a[rel^=prettyPhoto]").prettyPhoto({
		social_tools: ""
	});
	
	$("a[rel=qtip]").each(function() {
		var href = $(this).attr("href");
		
		$(this).click(function() {
			return false;
		});
		$(this).qtip({
			content: $(href).html(),
			show: {
				event: "mouseover"
			},
			hide: {
				event: "mouseout"
			},
			position: {
				at: "top center",
				my: "bottom left"
			},
			style: {
				tip: true,
				classes: "ui-tooltip-cream"
			}
		});
	});
	
	$("a[rel=jquerydialog]").each(function() {
		$(this).click(function() {
			var href = $(this).attr("href");
		
			$(href).dialog({
				autoOpen: false,
				height: 500,
				width: 800,
				modal: true
			}).dialog("open");
			
			return false;
		});
	});
	
	$("input[default][default!='']").each(function() {
		if ($(this).attr("default") != '')
		{
			$(this).val( $(this).attr("default") ),
			$(this).css("color", "#aaaaaa");
			
			$(this).bind("focus", function() {
				if ($(this).val() == $(this).attr("default"))
				{
					$(this).val("");
					$(this).css("color", "black");
				}
			});
			
			$(this).bind("blur", function() {
				if ($(this).val() == "")
				{
					$(this).val( $(this).attr("default") );
					$(this).css("color", "#aaaaaa");
				}
			});
		}
	});
});

function CopyFields(fieldfrom, fieldto)
{
	$("#"+fieldto).val( $("#"+fieldfrom).val() );
	return false;
}

function CheckDisponibilitaDominio()
{
	var dominio = $("#dominio").val();
	var dominioprimolivello = $("#dominioprimolivello").val();
	
	$("#disponibilitadominio").html("<img src='img/loadingsmall.gif'> Controllo in corso...");
	$.get("pages/ajax_disponibilitadominio.php", {dominio:dominio, dominioprimolivello:dominioprimolivello}, function(data) {
		if (data == 1)
			$("#disponibilitadominio").html("<img src='img/success.jpg' style='vertical-align:middle'> <span style='font-size:12px'>dominio disponibile</span>");
		else
			$("#disponibilitadominio").html("<img src='img/error.jpg' style='vertical-align:middle'> <span style='font-size:12px'>dominio non disponibile</span>");
	});
	
	return false;
}

function ShowRegistraDominio()
{
	$("#registradominiodiv").toggle();
}
