/*!
 * Ext JS Library 3.0.0
 * Copyright(c) 2006-2009 Ext JS, LLC
 * licensing@extjs.com
 * http://www.extjs.com/license
 */
 
/* <!> uses the gup function located inside the mt_functions.js file */ 
Ext.onReady(function(){
	
	var lang_search_params_title = 'Votre recherche';
	/*
	var lang_modify_search = 'Modifier la recherche';
	var lang_back = 'Retour en arrière';
	*/
	var inner = '';
	inner = '<div id="mobi-mt-search-params-top">'+
				'<div id="mobi-mt-search-params-data">'+
				'</div>'+
				/*
				'<div class="mobi-mt-search-params-edit" onclick="history.go(-1)">'+
					lang_back+
				'</div>'+
				
				'<div class="mobi-mt-search-params-back" onclick="history.go(-1)">'+
					lang_modify_search+
				'</div>'+
				*/
			'</div>';
			
	var seachParamsPanel = new Ext.Panel({ 
		id: 'mobi-mt-search-params-panel',
		title: lang_search_params_title,
		hideLabel: true,
		width:'auto',
		height: 'auto'
	});
	var temp = new Ext.Panel({ 
		html: inner
	});
	
	seachParamsPanel.add(temp);
	seachParamsPanel.render('mobi-mt-search-params');

	if (gup('do') != '' && gup('do') !== 'null' && gup('do') !== '-'){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_date_ouverture'
			},
			success: function(responseObject){
				title=responseObject.responseText;
				var v = gup('do').split('-',2);
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-dol">'+title+'</div>'+
							'<div class="mobi-mt-search-params-do">'+
								v[0].substring(6,8)+' '+
								intToMonth(v[0].substring(4,6))+' '+
								v[0].substring(0,4)+
								' - '+
								v[1].substring(6,8)+' '+
								intToMonth(v[1].substring(4,6))+' '+
								v[1].substring(0,4)+
							'</div>'
				});
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
		},
			failure:function(){							
			}
		});
	}
	if (gup('dr') != '' && gup('dr') !== 'null' && gup('dr') !== ''){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_date_reservation'
			},
			success: function(responseObject){
				title=responseObject.responseText;
				var v = gup('dr').split('-',2);
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-drl">'+title+'</div>'+
							'<div class="mobi-mt-search-params-dr">'+
								v[0].substring(6,8)+' '+
								intToMonth(v[0].substring(4,6))+' '+
								v[0].substring(0,4)+
								' - '+
								v[1].substring(6,8)+' '+
								intToMonth(v[1].substring(4,6))+' '+
								v[1].substring(0,4)+
							'</div>'
				});
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('e') != '' && gup('e') !== 'null' && gup('e') !== '' ) {
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_egp'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		var ou =gup('e');
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getPGAs',
				list: ou
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-el">'+title+'</div>'+
							'<div class="mobi-mt-search-params-e">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('eb') != '' && gup('eb') !== 'null' && gup('eb') !== '' ) {
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_egpbis'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		var ou =gup('eb');
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getPGAs',
				list: ou
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-el">'+title+'</div>'+
							'<div class="mobi-mt-search-params-e">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('eb2') != '' && gup('eb2') !== 'null' && gup('eb2') !== '' ) {
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_egpbis2'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		var ou =gup('eb2');
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getPGAs',
				list: ou
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-el">'+title+'</div>'+
							'<div class="mobi-mt-search-params-e">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('p') != '' && gup('p') !== 'null' && gup('p') !== ''){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_price'
			},
			success: function(responseObject){
				title=responseObject.responseText;
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-pl">'+title+'</div>'+
							'<div class="mobi-mt-search-params-p">'+gup('p')+'</div>'
				});
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('t') != '' && gup('t') !== 'null'  && gup('t') !== ''&& gup('t').length>2){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_the'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getCaNTh',
				canth: gup('t').substr(0,gup('t').length-2)
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-tl">'+title+'</div>'+
							'<div class="mobi-mt-search-params-t">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('tb') != '' && gup('tb') !== 'null' && gup('tb') !== ''&& gup('tb').length>2){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_thebis'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getCaNTh',
				canth: gup('tb').substr(0,gup('tb').length-2)
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-tbl">'+title+'</div>'+
							'<div class="mobi-mt-search-params-tb">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}	
	if (gup('tb2') != '' && gup('tb2') !== 'null' && gup('tb2') !== ''&& gup('tb2').length>2){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_thebis2'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getCaNTh',
				canth: gup('tb2').substr(0,gup('tb2').length-2)
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-tb2-1">'+title+'</div>'+
							'<div class="mobi-mt-search-params-tb2">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('tb3') != '' && gup('tb3') !== 'null' && gup('tb3') !== ''&& gup('tb3').length>2){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_thebis3'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getCaNTh',
				canth: gup('tb3').substr(0,gup('tb3').length-2)
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-tb3-1">'+title+'</div>'+
							'<div class="mobi-mt-search-params-tb3">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('av') != '' && gup('av') !== 'null' && gup('av') !== ''){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_srh_prestation'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getPrest',
				prest: 1,
				selprest: gup('av'),
				spid: gup('spid')
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-avl">'+title+'</div>'+
							'<div class="mobi-mt-search-params-av">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	if (gup('av2') != '' && gup('av2') !== 'null' && gup('av2') !== ''){
		var conn = new Ext.data.Connection();
		var title='';
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getTitle',
				spid: gup('spid'),
				table: 'mt_search_mx_srh_prestation2'
			},
			success: function(responseObject){
				title=responseObject.responseText;
			},
			failure:function(){							
			}
		});
		conn.request({
			url: '/fileadmin/ressources_mob/mt_search_params/form_functions.php',
			method: 'POST',
			params :{
				actionMobi: 'getPrest',
				prest: 2,
				selprest: gup('av2'),
				spid: gup('spid')
			},
			success: function(responseObject){
				var temp = new Ext.Panel({ 
					html: '<div class="mobi-mt-search-params-av2l">'+title+'</div>'+
							'<div class="mobi-mt-search-params-av2">'+responseObject.responseText+'</div>'
				});
				
				seachParamsPanel.add(temp);
				seachParamsPanel.render('mobi-mt-search-params');
			},
			failure:function(){							
			}
		});
	}
	seachParamsPanel.render('mobi-mt-search-params');
});
