/* MOOTOOLS */
window.addEvent('domready', function() {
	/* MENU DEROULANT */
	$$('#menu').getElement('ul ul').fade('hide');
	
	$$('#menu ul > li').addEvent('mouseover', function () {
		if ($(this).getElement('ul')) {
			$(this).getElement('ul').fade('in');
		}
	
	}).addEvent('mouseout', function() {
		if ($(this).getElement('ul')) {
			$(this).getElement('ul').fade('out');
		}
	});


	/* FORMULAIRES */
	$$("input[type=text], textarea").addEvent('focus', function () {
		$(this).getParent().getParent().toggleClass("active");
	});
	
	$$("input[type=text], textarea").addEvent('blur', function () {
		$(this).getParent().getParent().toggleClass("active");
	});


	/* AUCOMPLETER */
/*	if (document.getElementById("search_resto") && document.getElementById("search_resto") != null && document.getElementById("search_resto") != "undefined")
	{
		var inputResto = $('search_resto');
		new Autocompleter.Request.HTML(inputResto, '/config/custom/ajaxResto.asp', {
			'indicatorClass': 'autocompleter-loading',
			'injectChoice': function(choice) {
				var text = choice.getFirst();
				var value = text.innerHTML;
				choice.inputValue = value;
				text.set('html', this.markQueryValue(value));
				this.addChoiceEvents(choice);
				}
			});
	}
	if (document.getElementById("search_localite") && document.getElementById("search_localite") != null && document.getElementById("search_localite") != "undefined")
	{
		var inputLocalite = $('search_localite');
		new Autocompleter.Request.HTML(inputLocalite, '/config/custom/ajaxlocalite.asp', {
			'indicatorClass': 'autocompleter-loading',
			'injectChoice': function(choice) {
				var text = choice.getFirst();
				var value = text.innerHTML;
				choice.inputValue = value;
				text.set('html', this.markQueryValue(value));
				this.addChoiceEvents(choice);
				}
			});
	}
*/
});

var prevSubtype="";
function getSubtype(val,nam)
{
	if (prevSubtype==val) return;
	prevSubtype = val;

	document.getElementById("subtype").innerHTML = "<select id=\"search_subtype\" name=\"search_subtype\"></select>";

	ajaxRequest_init();

	ajaxRequest.open('GET', '/config/custom/ajaxSubtype.asp?v='+val, true);

	ajaxRequest.onreadystatechange = function() {
		if (ajaxRequest.readyState == 4) {
			if (ajaxRequest.status == 200) {
				document.getElementById(nam).innerHTML = ajaxRequest.responseText;
			}
		}
	};

	ajaxRequest.send(null);
}

