var params_meteo = "";

function displayGuide( obj ) {
	refreshTKModule( obj ) ;
}

function getAvis( club ) {
	jQuery.post('externals/golfcontact/indexajax.php' , 
		{
			act : 'forum_golf3',
			avis: 1,
			golf:club
			 
		},
		function ( data ) {
			jQuery('#gdgavis').html( data.html ) ;
			gdg_changeLinks('#gdgavis');
			onrender_tkajax_gdg();
		},
		"json"
		
	);
} 	
function getClassement() {
	jQuery.post('externals/golfcontact/indexajax.php' , 
		{
			act : 'classement'
		},
		function ( data ) {
			jQuery('#gdgclassement').html( data.html ) ;
			gdg_changeLinks('#gdgclassement');
			onrender_tkajax_gdg();
		},
		"json"
		
	);
}
function getLastAvis() {
	jQuery.post('externals/golfcontact/indexajax.php' , 
		{
			act : 'last_avis'
			
			 
		},
		function ( data ) {
			jQuery('#gdglastavis').html( data.html ) ;
			gdg_changeLinks('#gdglastavis');
			onrender_tkajax_gdg();
		},
		"json"
		
	);
}

function  gdg_changeLinks( id  ) {
	jQuery(id + ' a').each( function() { 
		if ( jQuery(this).attr('href') ) {
			href = jQuery(this).attr('href').replace('index.php?', 'externals/golfcontact/indexajax.php?');
			jQuery(this).attr('href', href );
			jQuery(this).click( function() { return gdg_external(this, id ); } ) ;
		}
	});
	jQuery(id + ' form').each( function() {
		action = jQuery(this).attr('action');
		action = action.replace('index.php?', 'externals/golfcontact/indexajax.php?');
		jQuery(this).attr('action', action) ;
	});
	jQuery(id + ' :submit').each( function() {
		jQuery(this).click( function() { return refreshTKModule(this); } ) ; 
	});
	
}
function gdg_external(obj, id ) {
	href = jQuery(obj).attr('href');
	if ( 0 == href.indexOf("javascript:" ) ) {  // on laisse passer le javascript...
		 return true ;
	}
	
	if ( 0 == href.indexOf("Le+guide")) { // on laiisse passer les links internes mais hors ajax
		return true;
	} 
	
	if ( -1 == href.indexOf('http://www.golfcontact.com/') ) {
		if ( 0 == href.indexOf("http:") ) {  // on laisse passer les links exterieurs
			return true;
		}
	}		
	jQuery.post(href , 
		{
		},
		function ( data ) {
			jQuery(id).html( data.html ) ;
			gdg_changeLinks( id );
			onrender_tkajax_gdg();
		},
		"json"
	);
	return false;
}
function setRegion(   ) {
	jQuery('#gdgregion').html('');jQuery('[name=sel_id_region]').val('');
	jQuery('#gdgdept').html('');jQuery('[name=sel_id_dept]').val('');
	jQuery('#gdgclub').html('');jQuery('[name=sel_id_club]').val('');
	jQuery.post('lib/lib_golfcontact/getAjaxData.php',
		{
			act : 'getreg',
			pays: jQuery('[name=sel_id_pays]').val()
					
		},
		function ( data ) {
			jQuery('#gdgregion').html( data.html ) ;
			onrender_tkajax_gdg();
				
		},
		"json"
	);
	
} 
function setDept(  ) {
	jQuery('#gdgdept').html('');jQuery('[name=sel_id_dept]').val('');
	jQuery.post('lib/lib_golfcontact/getAjaxData.php',
		{
			act : 'getdept',
			pays: jQuery('[name=sel_id_pays]').val(),
			region:jQuery('[name=sel_id_region]').val()
			
			 
		},
		function ( data ) {
			jQuery('#gdgdept').html( data.html ) ;
			onrender_tkajax_gdg();			
		},
		"json"
	);
} 
function setClub( ) {
	jQuery('#gdgclub').html('');jQuery('[name=sel_id_club]').val('');
	jQuery.post('lib/lib_golfcontact/getAjaxData.php',
		{
			act : 'getclub',
			onchange:'displayGuide(this)', 
			pays: jQuery('[name=sel_id_pays]').val(),
			region:jQuery('[name=sel_id_region]').val(),
			dept:jQuery('[name=sel_id_dept]').val()
		},
		function ( data ) {
			jQuery('#gdgclub').html( data.html ) ;
			onrender_tkajax_gdg();				
		},
		"json"
	);
} 

function getModerationFiche( code_golf, id ) {
	
	jQuery(id).html( 'test');	
}

function displayMeteo(ville) {
	var params_meteo="type_meteo=terrestre&amp;langue=fr&amp;fond=FFF0AA&amp;texte=0000FF&amp;saisie="+ville;
	jQuery('[name=gdg_meteo]').html('<ILAYER target="meteo1" ID="meteo1" VISIBILITY="hidden" WIDTH="140" HEIGHT="175"></ILAYER><NOLAYER>' +
			'<IFRAME name="meteo1" width="140" height="175" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" ' +
			'SRC="http://meteodirect.meteoconsult.fr/vignette/md_vignette.php?params_meteo='+params_meteo+'">&nbsp;</IFRAME></NOLAYER>');
	
}
	


