$(function(){
	// initialisation des formulaires
	//$('#formulaire_proposer_recette').hide();
	$('#formulaire_inscription_newsletter').hide();

	$('#boutton_popose_recetter').click(function() {
		$('#formulaire_proposer_recette').show();
		$('#formulaire_inscription_newsletter').hide();
	});

	$('#boutton_inscription_newsletter').click(function() {
		$('#formulaire_proposer_recette').hide();
		$('#formulaire_inscription_newsletter').show();
	});


	// traitement visuel lié à l'image
	$('[name=champsvisuel]').bind("focus",function() {
		if($('[name=champsvisuel]').val()!=''){
			$.ajax({
				 type:"POST",
				 url:j_basepath+'index.php',
				 data:"module=veauEtVous&action=veauEtVous:traitementVisuels&process=resize&fichier="+$(this).val(),
				 dataType:"json",
				 async:false,
				 success:function(resultat){
					$('#appercu').empty();
					$('#appercu').html(resultat.visuel);
					$('[name=auxvisuel]').val(j_basepath+j_resize+resultat.image);
				 }
			});
		}
	});
	
	$('#browseImg').click(function() {
		$('[name=champsvisuel]').removeClass('invalid');
		//$('#errorMessage').html('');
		browserImg();
	});
})
function browserImg(){
	ServerPath = j_basepath+j_medias;
	url=j_basepath+'FCKeditor/editor/filemanager/browser/default/browser.html?Type=Media&externe=yes&champs=champsvisuel&FolderDisplay=1&ServerPath='+ServerPath+'&CurrentFolder=/&Connector=' + j_basepath + 'FCKeditor/editor/filemanager/connectors/php/connector.php';
	//url=j_basepath + 'FCKeditor/editor/filemanager/browser/default/browser.html?DirectoryOnly=1&Type=Image&externe=yes&champs=champsvisuel_' + jId + '&FolderDisplay=1&ServerPath='+ServerPath+'&Connector=' + j_basepath + 'FCKeditor/editor/filemanager/connectors/php/connector.php';

	var iLeft = (screen.width  - screen.width * 0.7) / 2 ;
	var iTop  = (screen.height - screen.height * 0.7) / 2 ;

	var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
	sOptions += ",width=" + screen.width * 0.7 ;
	sOptions += ",height=" + screen.height * 0.7 ;
	sOptions += ",left=" + iLeft ;
	sOptions += ",top=" + iTop ;

	window.open( url, "BrowseWindow", sOptions ) ;
}