// modules.zymase.lib.js.domainselect-fr-fr 

jQuery.fn.extend({

	ajaxLinkWithChildSelect : function(selectInput)
	{
		opt=$("option:selected", this);
		if (opt.lengt==0 || opt.val()=="")
		{
			selectInput.parent().hide();
		}
		
		$(this).change(function(){
			opt=$("option:selected", this);
			if (opt.length>0 && opt.val()!="")
			{
				var url = "index.php?module=zymase&action=Ajaxsubdomain&zymaseParam[cmpref]="+opt.val();
				//selectInput.attr("disabled", true).parent().show();
				selectInput.load(url, null, function(){
					$(this).removeAttr("disabled").trigger('change').parent().show();
					if ($("option", this).length <= 1) { $(this).parent().hide(); }					
				});

			}
			else
			{
				selectInput.parent().hide();
			}
		});
	}
	
});

$(function () {
	var s1 = $("form select[name='zymaseParam[search][domain]']");
	var s2 = $("form select[name='zymaseParam[search][subdomain]']");
	s1.ajaxLinkWithChildSelect(s2);
});





