var domainfields = new Array();

function addDomainPosibility(dom_field){
	domainfields[domainfields.length] = dom_field;
}

function aleowhois_isFree(d, i){
	
	$.getJSON("/components/com_aleowhois/json.php",{do_func:"isfree", domain:d},function (json){
		tdtest = $("#domcount-"+i+"-test");
		tdorder = $("#domcount-"+i+"-order");
		tdspinner = $("#domcount-"+i+"-spinner");
		
		if(json){
			tdtest.html("Ledig");
			tdorder.html("Bestill");
			
		}
		else{
			tdtest.html("Opptatt [<a href=\"JavaScript:aleowhois_showWhois('"+d+"', "+i+");\">Vis Whois(eier info)</a>]");
			tdorder.html("Flytt til Aleo");		
			
		}
		$("#domcount-"+i+"-spinner IMG").fadeOut(300);
		//alert("test");
		//tdspinner.html("Ledig");
	});
}

function aleowhois_showWhois(d, i){
	tdwhois = $("#domcount-"+i+"-whois");
	if(tdwhois.css("display") == "none"){
		$.getJSON("/components/com_aleowhois/json.php",{do_func:"getwhoishtml", domain:d},function (json){
			
			tddiv = $("#domcount-"+i+"-whois DIV");
			tddiv.html(json);
			tdwhois.fadeIn(300);
		});
	}
	else tdwhois.fadeOut(300);
}

function doOrder(){
	form = $("#orderform");
	tmp = "";
	for(i = 0; i < domainfields.length; i ++){
		it = $("#"+domainfields[i]+":checked");
		if(it.val() != null & it.val() != "undefined"){
			if(tmp != "")tmp += ",";
			tmp += it.val();
		}
	}
	$("#orderform #domains").val(tmp);
	//alert($("#orderform #domains").val());
	form.submit();
}


