function getAllItems(store, montype) {
	var itemsList = "";
	var liste = dojo.byId("listeI");
	var themesStore = new dojo.data.ItemFileReadStore({url: store });
	var listeStore = themesStore;
	pageSize = 10;
	var totalItems = 0;
	var request = null;
	var listerch = null;
	var currentStart = 0;
	var searchObj= {};
	var recherche='';
	var tri = { attribute : "ZONE_100_3"};
	var sel = {};
	var sort = {};
    var filteringSelect = null;
    var regionStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'REGION', items:[]}});
    var stationStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'SITE', items:[]}});
    var typeStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'TYPE', items:[]}});
    var type = {
    0 : 'Mer',
    1 : 'Montagne',
    2 : 'Campagne',
    3 : 'Ville' };
    var geoloc = new Array();
    var nom;
    var urlIMGE1 = "http://images.locatour.fr"; 
    var urlIMGH1 = "http://images.snotour.fr"; 
    
    function selsai() {
		if (dojo.byId('ETE').checked && dojo.byId('HIVER').checked) sel['SAISON'] = '*';
		else if (!dojo.byId('ETE').checked && dojo.byId('HIVER').checked) sel['SAISON'] = 'H1';
		else if (dojo.byId('ETE').checked && !dojo.byId('HIVER').checked) sel['SAISON'] = 'E1';
		request.query = sel;
		request.start=0;
		request= themesStore.fetch(request);
		maCarte();
	}
    function selmmcv() {
    	sel['MERMONCAMP']=dijit.byId('MMCV').attr('value');
    	request.query = sel;
    	request.start=0;
    	request= themesStore.fetch(request);
    	maCarte();
    }
    function selreg() {
    	if (montype=='TH') {
    		sel['CODREG']=dijit.byId('LSTREG').attr('value');
    		sel['CODPRO']='*';
    	} else {
    		sel['REGION']=dijit.byId('LSTREG').attr('value');
	    	sel['SITE']='*';
    	}
    	listerch = themesStore.fetch( {query: sel,start: 0, onComplete: traitementStation, onError : gotError });
    	request = themesStore.fetch( {query: sel, onBegin : clearOldList , onComplete : gotItems, start: 0, count: pageSize, queryOptions: { }, sort: {} } );
    	maCarte();
	}
    function selsta() {
    	if (montype=='TH')
    		sel['CODPRO']=dijit.byId('LSTSTA').attr('value')+'*';
    	else
	    	sel['SITE']=dijit.byId('LSTSTA').attr('value')+'*';
    	request = themesStore.fetch( {query: sel, onBegin : clearOldList , onComplete : gotItems, start: 0, count: pageSize, queryOptions: { }, sort : { } } );
    	maCarte();
    }
    var traitementListe = function(items, request){
    	var arrReg  = new Array();
    	var arrSta  = new Array();
    	var arrMMCV = new Array();
    	
    	regionStore.newItem({REGION: '*', LIBREG: 'Toutes les régions'});
    	stationStore.newItem({SITE: '*', LIBSIT: 'Toutes les stations'});
    	typeStore.newItem({TYPE: '*', LIBTYP: 'Tous les destinations'});

    	if (montype=='TH') {
	    	dojo.forEach(items, function(i){
	    		if (!arrReg[themesStore.getValue(i, "CODREG")]) {
	    			arrReg[themesStore.getValue(i, "CODREG")]=themesStore.getValue(i, "LIBREG");
	    			regionStore.newItem({REGION: themesStore.getValue(i, "CODREG"), LIBREG: themesStore.getValue(i, "LIBREG")});
	    		}
	    		if (!arrSta[themesStore.getValue(i, "CODPRO").substr(0,3)] && themesStore.getValue(i,"LIBSIT")!=null) {
	    			arrSta[themesStore.getValue(i, "CODPRO").substr(0,3)]=themesStore.getValue(i, "LIBSIT");
	    			stationStore.newItem({SITE: themesStore.getValue(i, "CODPRO").substr(0,3), LIBSIT: themesStore.getValue(i, "LIBSIT")});
	    		}
	    		if (!arrMMCV[themesStore.getValue(i, "MERMONCAMP")]) {
	    			arrMMCV[themesStore.getValue(i, "MERMONCAMP")]=themesStore.getValue(i, "MERMONCAMP");
	    			typeStore.newItem({TYPE: themesStore.getValue(i, "MERMONCAMP"), LIBTYP: type[themesStore.getValue(i, "MERMONCAMP")]});
	    		}
	    	});
    	} else {
	    	dojo.forEach(items, function(i){
	    		if (!arrReg[themesStore.getValue(i, "REGION")]) {
	    			arrReg[themesStore.getValue(i, "REGION")]=themesStore.getValue(i, "LIBREG");
	    			regionStore.newItem({REGION: themesStore.getValue(i, "REGION"), LIBREG: themesStore.getValue(i, "LIBREG")});
	    		}
	    		if (!arrSta[themesStore.getValue(i, "SITE").substr(0,3)] && themesStore.getValue(i,"LIBSIT")!=null) {
	    			arrSta[themesStore.getValue(i, "SITE").substr(0,3)]=themesStore.getValue(i, "LIBSIT");
	    			stationStore.newItem({SITE: themesStore.getValue(i, "SITE").substr(0,3), LIBSIT: themesStore.getValue(i, "LIBSIT")});
	    		}
	    		if (!arrMMCV[themesStore.getValue(i, "MERMONCAMP")]) {
	    			arrMMCV[themesStore.getValue(i, "MERMONCAMP")]=themesStore.getValue(i, "MERMONCAMP");
	    			typeStore.newItem({TYPE: themesStore.getValue(i, "MERMONCAMP"), LIBTYP: type[themesStore.getValue(i, "MERMONCAMP")]});
	    		}
	    	});
    	}
    	dijit.byId('LSTREG').store=regionStore;
    	dijit.byId('LSTSTA').store=stationStore;
    	dijit.byId('MMCV').store=typeStore;
    	dijit.byId('LSTREG').attr('value','*');
    	dijit.byId('LSTSTA').attr('value','*');
    	dijit.byId('MMCV').attr('value','*');
    };
    var traitementStation = function(items, request){
    	var itemsList = new Array();
    	stationStore = new dojo.data.ItemFileWriteStore({data: {identifier: 'SITE', items:[]}});
    	stationStore.newItem({SITE: '*', LIBSIT: 'Toutes les stations'});
    	if (montype=='TH') {
	    	dojo.forEach(items, function(i){
	    		if (!itemsList[themesStore.getValue(i, "CODPRO").substr(0,3)]) {
	    			itemsList[themesStore.getValue(i, "CODPRO").substr(0,3)]=themesStore.getValue(i, "LIBSIT");
	    			stationStore.newItem({SITE: themesStore.getValue(i, "CODPRO").substr(0,3), LIBSIT: themesStore.getValue(i, "LIBSIT")});
	    		}
	    	});
    	} else {
	    	dojo.forEach(items, function(i){
	    		if (!itemsList[themesStore.getValue(i, "SITE").substr(0,3)]) {
	    			itemsList[themesStore.getValue(i, "SITE").substr(0,3)]=themesStore.getValue(i, "LIBSIT");
	    			stationStore.newItem({SITE: themesStore.getValue(i, "SITE").substr(0,3), LIBSIT: themesStore.getValue(i, "LIBSIT")});
	    		}
	    	});
    	}
    	dijit.byId('LSTSTA').store=stationStore;
    	dijit.byId('LSTSTA').attr('value','*');
    	dijit.byId('MMCV').attr('value','*');
    };
	var gotError = function(error, request){
  	  alert("Problème. " +  error);
  	};
	function clearOldList(size, request) {
		if (liste) {
			while (liste.firstChild) {
				liste.removeChild(liste.firstChild);
			}
		}
		totalItems = size;
	}
	function nextPage() {
		if ((currentStart + currentCount) < totalItems ) {
			request.start += currentCount;
			request = themesStore.fetch(request);
			maCarte();
		}
	}
	function previousPage() {
		if (currentStart > 0) {
			request.start -= currentCount;
			request = themesStore.fetch(request);
			maCarte();
		}
	}
	function itemsLoaded(items, request){
		if (items.length < pageSize){
			outOfItems = true;
		} else {
			outOfItems = false;
		}
	}
	function gotItems(items, request) {
		currentStart = request.start;
		currentCount = request.count;
	    geoloc = new Array();

		if (parseInt(currentStart + pageSize) >= parseInt(totalItems)) {
			dojo.style('pagesui','display','none');
		} else { 
			dojo.style('pagesui','display','');
		}
		if (parseInt(currentStart - pageSize) < 0) {
			dojo.style('pagepre','display','none');
		} else { 
			dojo.style('pagepre','display','');
		}		
		if (liste) {
			var i;
			itemsList='';
			if (montype=="TH") {
				nom='LBLPRO';
				for (i = 0; i < items.length; i++) {
					var item = items[i];
		   			if (themesStore.getValue(item,"PRIXBPRO")!='0')
						prixb = " <span class='prixbarre'>" + themesStore.getValue(item,"PRIXBPRO")+" €</span>";
					else
						prixb = '';
					if (themesStore.getValue(item,"REMISE")!='')
						promo = "	<p class='promo'>" + themesStore.getValue(item,"REMISE")+"</p>";
					else
						promo = '';
					if (themesStore.getValue(item,"SAISON")=='H1') { saison=' (Hiver) '; urlIMG=urlIMGH1; imgsai='<img src="'+urlIMGH1+'/images/icone_hiver.gif" title="Hiver" alt="Hiver" align="right">'; } else { saison=' (Eté) '; urlIMG=urlIMGE1; imgsai='<img src="'+urlIMGH1+'/images/icone_ete.gif" title="Eté" alt="Eté"  align="right">'; };
					itemsList+="<div class='item' id='close'>"+
		"	<p class='chemin'>"+
		"		<a href='/r"+themesStore.getValue(item,"CODREG")+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"URLREG")+"' title='"+themesStore.getValue(item,"URLREG")+"'>"+themesStore.getValue(item,"LIBREG")+"</a> " +
		" > <a href='/tld"+themesStore.getValue(item,"CODPRO").substr(0,3)+"-"+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"URLSIT")+"' title='" +themesStore.getValue(item,"URLSIT")+ "'><span class='bold'>" +themesStore.getValue(item,"LIBSIT")+ "</span></a>" + 
		" > <a href='/h"+themesStore.getValue(item,"CODPRO")+"-"+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"URLRES")+'-'+themesStore.getValue(item,"URLSIT")+'-'+themesStore.getValue(item,"URLREG")+"' title='" +themesStore.getValue(item,"URLRES")+ "'>" +themesStore.getValue(item,"LBLPRO")+ "</a>" +
		"	</p>" +
		"	<br clear='all' /><a href='/h"+themesStore.getValue(item,"CODPRO")+"-"+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"URLRES")+'-'+themesStore.getValue(item,"URLSIT")+'-'+themesStore.getValue(item,"URLREG")+"' title='" +themesStore.getValue(item,"LBLPRO").replace('/','-').replace('\'','_')+ "'><img src='"+urlIMG+"/photo/"+themesStore.getValue(item,"SAISON")+"/130/"+themesStore.getValue(item,"CODPRO")+"1/"+themesStore.getValue(item,"URLREG")+"_"+themesStore.getValue(item,"URLSIT")+"_"+themesStore.getValue(item, "URLRES")+".jpg' class='photo' /></a>" +
		promo +
		"	<h3>"+imgsai+"<a href='/h"+themesStore.getValue(item,"CODPRO")+"-"+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"URLRES")+'-'+themesStore.getValue(item,"URLSIT")+'-'+themesStore.getValue(item,"URLREG")+"' title='"+themesStore.getValue(item,"LBLPRO")+"'>"+themesStore.getValue(item,"LBLPRO")+"</a></h3>" +
		"	<p class='txt'>"+themesStore.getValue(item,"TXTPRO",'')+"...</p>" +
		"	<p class='prix'>"+themesStore.getValue(item,"PRXDPRO",'')+" <span class='orange'>"+themesStore.getValue(item,"PRIXPRO",'')+" €</span> "+prixb+" "+themesStore.getValue(item,"PRXFPRO",'')+"</p>" +
		"	<p class='txt'><a href='/h"+themesStore.getValue(item,"CODPRO")+"-"+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"LBLPRO")+'-'+themesStore.getValue(item,"URLSIT")+'-'+themesStore.getValue(item,"URLREG")+"' title='Voir les dispos' class='voir'>Voir les dispos</a></p>" +
		"	<a href='/h"+themesStore.getValue(item,"CODPRO")+"-"+themesStore.getValue(item,"SAISON")+themesStore.getValue(item,"LANGPRO")+"-"+themesStore.getValue(item,"URLRES")+'-'+themesStore.getValue(item,"URLSIT")+'-'+themesStore.getValue(item,"URLREG")+"' title='info/réservation' class='info'><img src='"+urlIMG+"/images/bt_info-reservation.gif' alt='info/réservation' class='info'/></a>" +
		"</div>";
					geoloc[i]= { 0:themesStore.getValue(item, "CODPRO"), 1:themesStore.getValue(item, "LBLPRO"), 2:themesStore.getValue(item, "LON"),3:themesStore.getValue(item, "LAT"),4:themesStore.getValue(item, "SAISON"),5:themesStore.getValue(item, 'LANGPRO') };
				}
			} else {
				nom='LIBSIT';
			for (i = 0; i < items.length; i++) {
				var item = items[i];
				if (themesStore.getValue(item,"SAISON")=='H1') { saison=' (Hiver) '; urlIMG=urlIMGH1; imgsai='<img src="'+urlIMGH1+'/images/icone_hiver.gif" title="Hiver" alt="Hiver" align="right">'; } else { saison=' (Eté) '; urlIMG=urlIMGE1; imgsai='<img src="'+urlIMGH1+'/images/icone_ete.gif" title="Eté" alt="Eté"  align="right">'; };
				itemsList+="<div class='item' id='close'><p class='chemin'>"+
	"		<a href='/r"+themesStore.getValue(item,"REGION")+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"URLREG")
+ "' title='"+themesStore.getValue(item,"URLREG")+"'>"+themesStore.getValue(item,"LIBREG")+"</a> " +
	" > <a href='/tld"+themesStore.getValue(item,"SITE").substr(0,3)+"-"+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"URLSIT")+"-"+themesStore.getValue(item,"URLREG")
+"' title='" +themesStore.getValue(item,"URLSIT")+ "'><span class='bold'>" +themesStore.getValue(item,"LIBSIT")+ "</span></a>" + 
	" > <a href='/h"+themesStore.getValue(item,"SITE")+"-"+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"URLRES")+"-"+themesStore.getValue(item,"URLSIT")+"-"+themesStore.getValue(item,"URLREG")
+"' title='" +themesStore.getValue(item,"URLRES")+ "'>" +themesStore.getValue(item,"LIBRES")+ "</a>" +
	"	</p>" +
	"	<br clear='all' /><a href='/h"+themesStore.getValue(item,"SITE")+"-"+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"URLRES")+"-"+themesStore.getValue(item,"URLSIT")+"-"+themesStore.getValue(item,"URLREG")
+"' title='" +themesStore.getValue(item,"URLRES")+ "'><img src='"+urlIMG+"/photo/"+themesStore.getValue(item,"SAISON")+"/130/"+themesStore.getValue(item,"SITE")+"1/"+themesStore.getValue(item,"URLREG")+"_"+themesStore.getValue(item,"URLSIT")+"_"+themesStore.getValue(item, "URLRES")+".jpg' class='photo' /></a>" +
	"	<h3>"+imgsai+"<a href='/h"+themesStore.getValue(item,"SITE")+"-"+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"URLRES")+"-"+themesStore.getValue(item,"URLSIT")+"-"+themesStore.getValue(item,"URLREG")+"' title='"
+themesStore.getValue(item,"LIBRES")+"'>"+themesStore.getValue(item,"LIBRES")+"</a></h3>" +
	"	<p class='txt'>"+themesStore.getValue(item,"ZONE_101",'').substr(0,150)+"...</p>" +
	"	<p class='prix'>"+themesStore.getValue(item,"ZONE_100_2",'')+" <span class='orange'>"+themesStore.getValue(item,"ZONE_100_3",'')+" €</span></p>" +
	"	<p class='txt'><a href='/h"+themesStore.getValue(item,"SITE")+"-"+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"LIBRES")+"-"+themesStore.getValue(item,"URLSIT")+"-"+themesStore.getValue(item,"URLREG")+
"' title='Voir les dispos' class='voir'>Voir les dispos</a></p>" +
	"	<a href='/h"+themesStore.getValue(item,"SITE")+"-"+themesStore.getValue(item,"SAISON")+"FR-"+themesStore.getValue(item,"URLRES")+"-"+themesStore.getValue(item,"URLSIT")+"-"+themesStore.getValue(item,"URLREG")+
"' title='info/réservation' class='info'><img src='"+urlIMG+"/images/bt_info-reservation.gif' alt='info/réservation' class='info'/></a>" +
	"</div>";
				geoloc[i]= { 0:themesStore.getValue(item, "SITE"), 1:themesStore.getValue(item, "LIBRES"), 2:themesStore.getValue(item, "LON"),3:themesStore.getValue(item, "LAT"),4:themesStore.getValue(item, "SAISON"),5:'FR' };
				}
			}
			liste.innerHTML=itemsList;
			recherche='*';
			dojo.byId('totalrep').innerHTML=totalItems + ' réponses.';
			maCarte();
		}
	}
	listerch = themesStore.fetch( {onComplete : traitementListe, onError: gotError,sort: [{attribute:'LIBREG'},{attribute:nom}] } );
	request = themesStore.fetch( {query: sel, onBegin : clearOldList , onComplete : gotItems, onError: gotError, start: currentStart, count: pageSize } );
//	maCarte();
	
	dojo.byId('ETE').checked=true;
	dojo.byId('HIVER').checked=true;

	dojo.connect(dojo.byId('forward'), 'onclick', nextPage);
	dojo.connect(dojo.byId('back'), 'onclick', previousPage);

	dojo.connect(dojo.byId('ETE'), 'onclick', selsai);
	dojo.connect(dojo.byId('HIVER'), 'onclick', selsai);

	dojo.connect(dijit.byId('MMCV'), 'onChange', selmmcv);
	dojo.connect(dijit.byId('LSTREG'), 'onChange', selreg);
	dojo.connect(dijit.byId('LSTSTA'), 'onChange', selsta);

	function maCarte() {
		var myOptions = {
	      zoom: 5,
	      center: new google.maps.LatLng(46.9,1.56),
	      mapTypeId: google.maps.MapTypeId.TERRAIN
	    };
		var map = new google.maps.Map(dojo.byId("geolocal"), myOptions);
		  for (var i = 0; i < geoloc.length; i++) {
		    var res = geoloc[i];
		    var marker = new google.maps.Marker({
		        position: new google.maps.LatLng(res[3], res[2]),
		        map: map,
		        title: res[1]
		    });
			google.maps.event.addListener(marker, "click", function() { window.location.href="/h"+res[0]+"-"+res[4]+""+res[5]+"-"+res[1];});
		  }
	}
}

function dump(arr,level) {
	var dumped_text = "";
	if(!level) level = 0;

	//The padding given at the beginning of the line.
	var level_padding = "";
	for(var j=0;j<level+1;j++) level_padding += "    ";

	if(typeof(arr) == 'object') { //Array/Hashes/Objects
	 for(var item in arr) {
	  var value = arr[item];
	 
	  if(typeof(value) == 'object') { //If it is an array,
	   dumped_text += level_padding + "'" + item + "' ...\n";
	   dumped_text += dump(value,level+1);
	  } else {
	   dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
	  }
	 }
	} else { //Stings/Chars/Numbers etc.
	 dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
	}
	return dumped_text;
}