function changeSearchType(curr,type) {
   	   	
    current = $('typeprog').value;
    $$('a.onglet').each ( function (e) { 
            e.removeClassName('onglet_current');
            })
    Element.addClassName('search_' + type,'onglet_current');
    
    $('typeprog').value=type;
    // Si terrain : pas de nombre de pieces
    if ( type == 'terrain') {
        $$('tr.non-terrain').each ( function (e) { e.hide();})
        if (navigator.appVersion.match(/\bMSIE\b/)) {
            $$('tr.rech-terrain').each ( function (e) { e.style.display = 'block';})
        } else {
            $$('tr.rech-terrain').each ( function (e) { e.style.display = 'table-row';})
        }
        
    } else {
        if (navigator.appVersion.match(/\bMSIE\b/)) {
            $$('tr.non-terrain').each ( function (e) { e.style.display = 'block';})
        } else {
            $$('tr.non-terrain').each ( function (e) { e.style.display = 'table-row';})
        }
         $$('tr.rech-terrain').each ( function (e) { e.hide();})
    }
        
}
//recherche par la carte d'accueil
function formSubmit(reg) {
	document.forms["recherche"].elements["region"].value = reg;
	if (document.forms["recherche"].elements["region"].value != 'none') {
		document.recherche.action = 'resultat/' + document.recherche.type_prog.value + '/' + document.recherche.region.value + '/none/index.html';
		document.recherche.submit();
	}
}

//recherche de biens
function loadProg (type_prog,region,agglo) {

	var opt = {
		    method: 'post',
		    parameters: 'type_prog=' + type_prog + '&region=' + region + '&country=' + agglo, 
		    onSuccess: function(t) {
		    	$('progPTF').innerHTML = t.responseText;
		    }
		}

	new Ajax.Request('/lib/ajax/load_prog.ajax.php', opt);
}

function loadZE(region,typeprog, countrycurrent) {

	var opt = {
		    method: 'post',
		    parameters: 'region=' + region + '&type_prog=' + typeprog + '&country=' + countrycurrent, 
		    onSuccess: function(t) {
		    	$('select_country').innerHTML = t.responseText;
		    }
		}

	new Ajax.Request('/lib/ajax/load_ze.ajax.php', opt);
	
}

function loadRegion(type, regcurrent) {

	var opt = {
		    method: 'post',
		    parameters: 'type_prog=' + type + '&region=' + regcurrent, 
		    
		    onComplete: function(t) {
				ff = eval (t.responseText);
				$('select_region').innerHTML = ff[0].select;
				$('test').innerHTML = ff[0].map;
			}
		}

	new Ajax.Request('/lib/ajax/load_region.ajax.php', opt);
	
}
function majOptionTerrain(typeprog) {
    
    if(typeprog == 'terrain') {
        $('option_terrain1').hide();
        $('option_terrain2').hide();
        $('option_terrain3').hide();
    } else {
        $('option_terrain1').show();
        $('option_terrain2').show();
        $('option_terrain3').show();
    }
}
function majOption(typeprog) {
    
    if(typeprog == 'maison') {
        $('no_maison').hide();
    } else {
        $('no_maison').show();
    }
	if(typeprog == 'terrain') {
        $('option_terrain1').hide();
        $('option_terrain2').hide();
        $('option_terrain3').hide();
    } else {
        $('option_terrain1').show();
        $('option_terrain2').show();
        $('option_terrain3').show();
    }
}

//recherche a droite
function loadRegionDroite(type, reg) {
    
    var opt = {
		    method: 'post',
		    parameters: 'type_prog=' + type + '&reg=' + reg, 
		    onSuccess: function(t) {
		    	$('region_droite').innerHTML = t.responseText;
		    }
		}

	new Ajax.Request('/lib/ajax/load_region_droite.ajax.php', opt);
}

function loadZEDroite(region,typeprog,ze) {

	var opt = {
		    method: 'post',
		    parameters: 'region=' + region + '&type_prog=' + typeprog + '&ze=' + ze, 
		    onSuccess: function(t) {
		    	$('country_droite').innerHTML = t.responseText;
		    }
		}

	new Ajax.Request('/lib/ajax/load_ze_droite.ajax.php', opt);
	
}
// function qui affiche et cache le select dans la demande de brochure
function showDemande() {
    $('autredemande').style.visibility='visible';
}

function hiddeDemande() {
    $('autredemande').style.visibility='hidden';
}

//affiche le nom de la region en dessous de la carte de la page d'accueil
function afficheNomRegion(region) {
    $('nomRegion').innerHTML = region;
}
function cacheNomRegion() {
	$('nomRegion').innerHTML = '';
}

function activerProgramme(pgrid) {
    
    var opt = {
            method: 'post',
            parameters: 'pgrid=' + pgrid,
            onSuccess: function(t) {
                alert('Programme activé');
                $('activeprogramme').innerHTML = t.responseText;
            }
    }
    
    new Ajax.Request('/lib/ajax/active_prog.ajax.php', opt);
}


function selectProgNew() {
	var opt = {
		method: 'post',
		parameters: '' ,
		onSuccess: function(t) {
			$('nouveaute').innerHTML = t.responseText;
		}
	}
    
    new Ajax.Request('lib/ajax/news_prog_suiv.ajax.php', opt);
}


function gotoprom(url) {
	location.href= url;
}


function rechercheSubmit(nf)    {
    //Mise en place de l'action du formulaire.
    nf.action = 'resultat/' + nf.type_prog.value + '/' + nf.region.value + '/' + nf.country.value + '/index.html';
    //alert(nf.region.value + "/" + nf.country.value +" /" + nf.action);

    nf.submit();
}