Ext.onReady(function(){
//	alert("tototo");
	var getVignette = function(e){
		var id = e.target.id;
		var tab = id.split("_");
		/**
	 	 * on commence par creer nos paramétres
		 */
		var param = new Object();
		//param["reference"] = tab[2];
		param.reference = tab[2];
		
		if(
		 Ext.get("mymoteur_count_numcolonne") &&
		 Ext.get("mymoteur_count_numcolonne").getValue() != "" &&
		 Ext.get("mymoteur_count_numcolonne").getValue() != 0 &&
		 !isNaN(parseInt(Ext.get("mymoteur_count_numcolonne").getValue(),10))
		 ){
			param.count_column = Ext.get("mymoteur_count_numcolonne").getValue();
		}else{
			param.count_column = 2;
		}
		
//		var count_url = Ext.get("count_url").dom.value;
		var count_url = Ext.get("count_url").getValue();
		if(typeof count_url != ""){
			param.moteur_count_url = count_url;
		}
		
		var msg = Ext.get('count_details');
		msg.load({
			url: "/MoteurRecherche/index/vignette/",
			params : param,
////			params : {reference : id , count_column : 2}, 
			text: "Attendez...",
			method:"POST"
//			callback : addclick
		});
		msg.show();
	}
	
	var addclick = function(){
		Ext.select('h3').on({
								'click': {
									fn: gotoPage
									, stopEvent: true
									}
							});
	}
	
	var createAction = function(){
		list = Ext.get("moteur_count_listID").dom.value;
		tab = list.split(",");
		for(var i =0; i< tab.length;i++){
			if(tab[i] != "debut" && tab[i] != "fin"){
				Ext.get(tab[i]).on('click',getVignette);
			}
		}
	}
	
	
	createAction();
	
});

//
var gotoPage = function(id){
//		id = e.target.id;
//		alert(id);
		if(id){
//		tab = id.split("_");
//		pos = id.indexOf("vignette_titre_");
//			alert(id);
//			alert(tab[0]+"__"+tab[1]);
//			if(tab[0] == "vignette" && tab[1] == "titre"){
//				rpos = id.lastIndexOf("_");
//				rid = id.substr(rpos+1,id.length);
//				rid = tab[2];
//				alert(rid);
				hidden = Ext.get("filtre");
				hidden.dom.value = id; 
//			}
			document.vignette_form.submit();
		}
	}	
	
//	Ext.select('td').on('click',getVignette);
