﻿// JavaScript Document
// JavaScript Document
var vprintDate;
var GB_ANIMATION = true;

/* French initialisation for the jQuery UI date picker plugin. */
/* Written by Keith Wood (kbwood{at}iinet.com.au) and Stéphane Nahmani (sholby@sholby.net). */
jQuery(function($){
		$.datepicker.regional['en'] = {
		closeText: 'Done', // Display text for close link
		prevText: 'Prev', // Display text for previous month link
		nextText: 'Next', // Display text for next month link
		currentText: 'Today', // Display text for current month link
		monthNames: ['January','February','March','April','May','June',
			'July','August','September','October','November','December'], // Names of months for drop-down and formatting
		monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], // For formatting
		dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting
		dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting
		dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday
		weekHeader: 'Wk', // Column header for week of the year
		dateFormat: 'mm/dd/yy', // See format options on parseDate
		firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
		isRTL: false, // True if right-to-left language, false if left-to-right
		showMonthAfterYear: false, // True if the year select precedes month, false for month then year
		yearSuffix: '' // Additional text to append to the year in the month headers
		};
		
	$.datepicker.regional['fr'] = {
		closeText: 'Fermer',
		prevText: '&#x3c;Préc',
		nextText: 'Suiv&#x3e;',
		currentText: 'Courant',
		monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
		'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
		monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
		'Jul','Aoû','Sep','Oct','Nov','Déc'],
		dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
		dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
		dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
		weekHeader: 'Sm',
		dateFormat: 'dd/mm/yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	//$.datepicker.setDefaults($.datepicker.regional['fr']);
});

function actuaAjax(){
	location.reload(true)
    }
function onSelectChange(){
	var selected = $("#iChoixLangue option:selected");
	//var selectedText = selected.text();
	if(selected.val() != "0"){
		switch(selected.val()){
		case "fr":
			$(".sub-fr,.img-fr").css({display: "block",float: "left"});
			$(".sub-en,.img-en").css("display","none");
			$(".sub-es,.img-es").css("display","none");
			
		break;
		case "en":
			$(".sub-en,.img-en").css({display: "block",float: "left"});
			$(".sub-fr,.img-fr").css("display","none");
			$(".sub-es,.img-es").css("display","none");
			
		break;
		case "es":
			$(".sub-es,.img-es").css({display: "block",float: "left"});
			$(".sub-en,.img-en").css("display","none");
			$(".sub-fr,.img-fr").css("display","none");
		break;
		default:
			$(".sub-fr,.img-fr").css({display: "block",float: "left"});
			$(".sub-en,.img-en").css("display","none");
			$(".sub-es,.img-es").css("display","none");
		break;
		}
	
	}else{
		$(".sub-fr,.img-fr").css("display","none");
		$(".sub-en,.img-en").css("display","none");
		$(".sub-es,.img-es").css("display","none");
	}
}


$(document).ready(function(){
	//$(".ui-datepicker-week-end.ui-datepicker-other-month.ui-datepicker-unselectable.ui-state-disabled").text(" ");
	$("#wMembreSexeHomme").click(function(){
		$("#avatar").attr("src","/geronto/images/membres/homme.jpg");	
	});				   
	$("#wMembreSexeFemme").click(function(){
		$("#avatar").attr("src","/geronto/images/membres/femme.jpg");	
	});	
	
	switch(jLangue){
	case "fr": $.datepicker.setDefaults($.datepicker.regional['fr']);	
	break;
	case "en": $.datepicker.setDefaults($.datepicker.regional['en']);	
	break;
	default: $.datepicker.setDefaults($.datepicker.regional['fr']);
	break;
	}
	
	$("#nStructGMPDate").datepicker();
	$("#nStructDtOuv").datepicker();
	$("#nInscDN").datepicker();
	$("#chMembreAnnee").datepicker();					   
	$("#chEvtDtFin").datepicker();				   
	$("#chEvtDtDeb").datepicker();					   
	$("#wDocNewsletter").datepicker();
	$("#wDocNews").datepicker();
	$("#wDocDtDeb").datepicker();
	$("#wDocDtFin").datepicker();
	$("#wEvtDtNtDeb").datepicker();
	$("#wEvtDtNtFin").datepicker();
	$("#wEvtDtRlDeb").datepicker();
	$("#wEvtDtRlFin").datepicker();
	$("#wDtDebPrev").datepicker();
	$("#wDtFinPrev").datepicker();
	$("#wDtDebRee").datepicker();
	$("#wDtFinRee").datepicker();
	$("#wDtGroupeTCrea").datepicker();
	$("#wDtGroupeTFerm").datepicker();
	$("#wInscDtDeb").datepicker();
	$("#wInscDtFin").datepicker();
	var GB_ANIMATION = true;					   
	
	$(".autoDate").blur(function(){
			var months=new Array(13);
months[1]="01";
months[2]="02";
months[3]="03";
months[4]="04";
months[5]="05";
months[6]="06";
months[7]="07";
months[8]="08";
months[9]="09";
months[10]="10";
months[11]="11";
months[12]="12";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)    
year = year + 1900;
			$(this).parent('td').next('td').find('input').val(date+"/"+lmonth+"/"+year);					 
	});
	$(".form-validate-jquery").validate({
   rules: {
     // simple rule, converted to {required:true}
	 name: "required",
     // compound rule
     email: {
       required: true,
       email: true
     }
   }
});
	
	$(".form-validate").validate({
   rules: {
     // simple rule, converted to {required:true}
	 name: "required",
     // compound rule
     email: {
       required: true,
       email: true
     }
   }
});
		$("#automatooo").click(function(){
	 $("#otherCat3 input[type='text']").each(function(i){
	   $(this).val(i+1);
	 });			 
});
	$("#zeroooo").click(function(){
	 $("#otherCat3 input[type='text']").each(function(i){
	   $(this).val("0");
	 });			 
});
	$("#automatoo").click(function(){
	 $("#otherCat2 input[type='text']").each(function(i){
	   $(this).val(i+1);
	 });			 
});
	$("#zerooo").click(function(){
	 $("#otherCat2 input[type='text']").each(function(i){
	   $(this).val("0");
	 });			 
});
	$("#automato").click(function(){
	 $(".article input[type='text']").each(function(i){
	   $(this).val(i+1);
	 });			 
});
	$("#zeroo").click(function(){
	 $(".article input[type='text']").each(function(i){
	   $(this).val("0");
	 });			 
});
	
	$(".articleOrder").toggle(function(){			   
			 /*$('.orderArticle').css('display','block');*/$('.orderArticle').slideDown("slow");
			 $('.numerotoo').slideDown("slow");
		},function(){
			 /*$('.orderArticle').css('display','none');*/$('.orderArticle').slideUp("fast");
			  $('.numerotoo').slideUp("fast");
	});
	
	
	$('#btSupprInsc').click(function(){
		if(confirm('Êtes vous sur de vouloir supprimer ce menu')) //si ca return TRUE c'est qu'on a choisit OK
		{
			$.ajax({
			   url: "/4daction/w3_GRSaisieInsc",
			   data: "wInsc="+$('input:checked').val()+"&wAction=8",
			   async:false,
			   type:'POST',
			   success: function(){
				alert (data);
				 },
				 complete:function(){
					alert ('Le menu a été supprimé');
				   
				 }
			});	
		}
		else
		{
		
}
	});	
	
	
	
	
	$('.deletemenu').click(function(){
		if(confirm('Êtes vous sur de vouloir supprimer ce menu')) //si ca return TRUE c'est qu'on a choisit OK
		{
			$.ajax({
			   url: $(this).attr("title"),
			   data: $(this).attr("rel"),
			   async:true,
			   type:'POST',
			   success: function(){
				    /*$(this).css('display','none');
					$(this).prev('a').css('display','none');*/
				
				 },
				 complete:function(){
					/*$(this).parent('em').parent('.vignette').css('display','none');*/
					alert ('Le menu a été supprimé');
				   
				 }
			});	
		}
		else
		{
		
}
	});	
	
	$("a.greybox").click(function(){
		var t = this.title || $(this).text() || this.href;
		GB_show(t,this.href,570,770);
		return false;
	});
	$(".unedeux tr:even").css("background-color","#f2f7f2");
	$(".article li:even").css("background-color","#f2f7f2");
	$(".unedeux").css("border","1px solid #b8d1b8");
	$(".deuxune").css("border","1px solid #b8d1b8");
	$(".deuxune tr:odd").css("background-color","#f2f7f2");
	$("#wSelectOnceAbonnes").click(function(){
		if($("#ficstars").is(":visible")){
			$("#ficstars").slideUp("fast");
		}
		if($("#singlestars").is(":hidden")){
			$("#singlestars").slideDown("slow");	
		}	
	});
	
	$("#wSelectOnceAbonnes").click(function(){
		if($("#ficstars").is(":visible")){
			$("#ficstars").hide("fast");
		}
		if($("#singlestars").is(":hidden")){
			$("#singlestars").show("slow");	
		}	
	});
	$("#wSelectAllAbonnes").click(function(){
		if($("#singlestars").is(":visible")){
			$("#singlestars").hide("slow");
		}	
		if($("#ficstars").is(":visible")){
			$("#ficstars").hide("slow");
		}
	});
	$("#wSelectFicTxt").click(function(){
		if($("#singlestars").is(":visible")){
			$("#singlestars").hide("fast");
		}
		if($("#ficstars").is(":hidden")){
			$("#ficstars").show("slow");	
		}		   
	});
	
	$('.deleteguard').click	(function(){
		if(confirm('Êtes vous sur de vouloir supprimer le document?')) //si ca return TRUE c'est qu'on a choisit OK
		{
			$.ajax({
			   url: $(this).attr("title"),
			   async:true,
			   data: $(this).attr("rel"),
			   type:'POST',
			   success: function(){
				    $(this).css('display','none');
					$(this).prev('a').css('display','none');
				   
				 },
				complete: function(){
					
					alert ('Le membre a été supprimé, vous devrez rafraîchîr votre page pour le constater.');
				   
				 },
			});	
			
			$(this).parent("td").parent("tr").fadeTo('normal',0).css("display","none");
		}
		else
		{
		
}
	});	
	$('.link-delete').click	(function(){
		if(confirm('Êtes vous sur de vouloir supprimer le document?')) //si ca return TRUE c'est qu'on a choisit OK
		{
			$.ajax({
			   url: $(this).attr("title"),
			   async:true,
			   type:'POST',
			   success: function(){
				    $(this).css('display','none');
					$(this).prev('a').css('display','none');
					
				   
				 },
				
			});	
			$(this).parent("td").parent("tr").fadeTo('normal',0).css("display","none");
		}
		else
		{
		
}
	});	
	
	$(".look").mouseenter(function(e){
		$("#loader").ajaxSend(function(request,setting){$(this).css({"position":"absolute","left":e.pageX,"top":e.pageY}).show()});
		$("#loader").ajaxStop(function(request,setting){$(this).hide()});
		$.ajax({
			   url:'/4daction/w3_SISimpleAffQuest/'+$(this).attr("title"),
			   async:true,
			   type:'POST',
			   cache:false,
			  success:function(html){
				  
				  $("#cadre").empty().css({"left":"60%","top":e.pageY+20,"display": "inline"}).append(html);
				  
			}
		});
		
	});
	$("a.look").mouseleave(function(e){
					  
		$("#cadre").fadeOut("fast");
	});
	
	
	
	$("a.endbox").click(function(){
		$("#end").fadeIn("slow");
	});
	
	
	$("#btcache").click(function(){
		$("#subgenerik").hide();
	});
	$("#catActShow").click(function(e){
		$("#loader").ajaxSend(function(request,setting){$(this).css({"position":"absolute","left":e.pageX-500,"top":e.pageY-200}).show()});
		$("#loader").ajaxStop(function(request,setting){$(this).hide()});
		$.ajax({
			   url:'/4daction/w3_SISCatQuestXML/'+$(this).attr("title"),
			   async:true,
			   type:'POST',
			   cache:false,
			   success:function(html){
				   $("#otherCat4").empty(); 
				  $("#otherCat4").fadeIn("slow").append(html);
				}
			});	
	});
	
	$("input#btcache").click(function(e){
		$("#loader").ajaxSend(function(request,setting){$(this).css({"position":"absolute","left":e.pageX,"top":e.pageY}).show()});
		$("#loader").ajaxStop(function(request,setting){$(this).hide()});
		$.ajax({
			   url:'/4daction/w3_SISCatQuestXML/'+$(this).attr("title"),
			   async:true,
			   type:'POST',
			   cache:false,
			   success:function(html){
				   $("#otherCat4").empty(); 
				  $("#otherCat4").fadeIn("slow").append(html);
				}
			});	
	});
	
	$("a#catActHide").click(function(e){$("#otherCat4").fadeOut("slow");});
	
	
	$("input.greybox").click(function(e){
		$("#loader").ajaxSend(function(request,setting){$(this).css({"position":"absolute","left":e.pageX,"top":e.pageY}).show()});
		$("#loader").ajaxStop(function(request,setting){$(this).hide()});
		$.ajax({
			   url:'/4daction/w3_SISousCatQuest/'+$(this).attr("title"),
			   async:true,
			   type:'POST',
			   cache:false,
			  success:function(html){
				  $("#liste-quest").empty();
				  $("#liste-quest").append(html);
				  $("#btcache").fadeIn("slow");	
			}
		});
	});
	$("#otherCat").toggle(function(){			   
			$("#otherCat1").fadeIn("slow");					
		},function(){
			$("#otherCat1").fadeOut("fast");
			$("#otherCat2").fadeOut("fast");
			$("#otherCat4").fadeOut("fast");
			$("#btcache").fadeOut("fast");
	});	
	
	$("#questimage").click(function(){
		$(this).text("Commencez par enregistrer votre question");
	});
	
	
	$('textarea.tinymce').tinymce({
			// Location of TinyMCE script
			script_url : '/tiny/tiny_mce/tiny_mce.js',

			// General options
			theme : "advanced",
			plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",

			// Theme options
			theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
			theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
			theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
			theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_statusbar_location : "bottom",
			theme_advanced_resizing : true,

			// Example content CSS (should be your site CSS)
			content_css : "/tiny/css/content.css",
			convert_urls : false,
			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js",

			// Replace values for the template plugin
			template_replace_values : {
				username : "Some User",
				staffid : "991234"
			}
		});
});
var largeurEcranClient = screen.availWidth;
var hauteurEcranClient = screen.availHeight;

function init(){
	//F_dimensionnerSiteEcranClient();
	//F_dimensionnerTitreSiteListe();
}
function F_dimensionnerSiteEcranClient(){
	if(largeurEcranClient >= 1200){
		document.getElementById("body").style.fontSize = "12px";	
	}else if(largeurEcranClient >= 1000 & largeurEcranClient <= 1200){
		document.getElementById("body").style.fontSize = "11px";	
	}else{
		document.getElementById("body").style.fontSize = "11px";	
	}
}


function report(element, event) {
	var elmtname = element.name;
	if ((element.type == "select-one") || (element.type == "select-multiple")){
		value = " ";
		for(var i = 0; i < element.options.length; i++)
			if (element.options[i].selected)
			value = element.options[i].value + " ";
			}
			else if (element.type == "textarea") value = "...";
			else value = element.value;
			var msg = value;
			var t = element.form.textarea;
			t.value =  msg;
}

function addhandlers(f) {
		for(var i = 0; i < f.elements.length; i++) {
			var e = f.elements[i];
			//e.onclick = function() { report(this, 'Click'); }
			e.onchange = function() { report(this, 'Change'); }
			//e.onfocus = function() { report(this, 'Focus'); }
			//e.onblur = function() { report(this, 'Blur'); }
			//e.onselect = function() { report(this, 'Select'); }
			//alert(e);
		}
		f.boutoneffacer.onclick = function( ) {
			this.form.textarea.value='';
			report(this/'Click');
	}
	f.boutonenvoyer.onclick = function () {
	report(this, 'Click'); return false;
	}
	f.boutonannuler.onclick = function( ) {
	this.form.reset( ); report(this, 'Click'); return false;
	}
}
//addhandlers(document.multicrit);

function F_dimensionnerTitreSiteListe(){
	var nombreDeBalises = document.getElementsByTagName("h3");
	for(var i=0;i<=nombreDeBalises.length-1;i++){
		var nombreDeLettresDansBalises = nombreDeBalises[i];
		for(var j=0;j<=nombreDeLettresDansBalises.length-1;j++){
			alert(nombreDeLettresDansBalises.length);
		}
	}
}



function address(){
var map = null;
var geocoder = null;
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.silk-info.com/images/fleur-aqua-rgmbc.png";//
baseIcon.shadowSize = new GSize(30, 30);
baseIcon.iconAnchor = new GPoint(5, 32);
baseIcon.infoWindowAnchor = new GPoint(5, 0);	
var address = address1 + address2;

if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map_canvas"));
		//map.setCenter(new GLatLng(46.75984,1.738281, 11.051697,26.367188), 13);
		map.addControl(new GLargeMapControl);
		geocoder = new GClientGeocoder();
		if (geocoder) {
			geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					//alert(address + " non-géolocalisée");
					callVille();
				} else {
					map.setCenter(point, 13);
					markerOptions = { icon:baseIcon };
				  	var marker = new GMarker(point, markerOptions);
					map.addOverlay(marker);
					/*marker.openInfoWindowHtml();"<h3><span>"+proprio+" </span></h3><p><span>"+address+"</span></p>"*/
					
				}
			}
		);
		}
		}
	
}
function callVille(){
	var map = null;
var geocoder = null;
var baseIcon = new GIcon();
baseIcon.shadow = "http://www.silk-info.com/images/fleur-aqua-rgmbc.png";//
baseIcon.shadowSize = new GSize(30, 30);
baseIcon.iconAnchor = new GPoint(5, 32);
baseIcon.infoWindowAnchor = new GPoint(5, 0);
var address = address3;
if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map_canvas"));
		//map.setCenter(new GLatLng(46.75984,1.738281, 11.051697,26.367188), 13);
		map.addControl(new GLargeMapControl);
		geocoder = new GClientGeocoder();
		if (geocoder) {
			geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					callVille();
				} else {
					map.setCenter(point, 13);
					markerOptions = { icon:baseIcon };
				  	var marker = new GMarker(point, markerOptions);
					map.addOverlay(marker);
					/*marker.openInfoWindowHtml();"<h3><span>"+proprio+" </span></h3><p><span>"+address+"</span></p>"*/
					
				}
			}
		);
		}
	}
}

