     var size = 100
     function doZoom()
     { 
     	if(size<130)
     	{
	     	var font_size = document.getElementById('pgcontent').style.fontSize
	     	if(font_size=="")
	     		size = 110;     	
	     	else     	
	     		size+=10;
	     	
	     	document.getElementById('pgcontent').style.fontSize=size+'%'; 
     	}
	} 
	function doNarrow()
     { 
     	if(size>85)
     	{
	     	var font_size = document.getElementById('pgcontent').style.fontSize
	     	if(font_size=="")
	     		size = 95;     	
	     	else     	
	     		size-=5;	     	
	     	document.getElementById('pgcontent').style.fontSize=size+'%'; 
     	}
	}
/* 
auther:tealy
date:2008-03-17
param: string strDivs ;  string  splitchar
result: get the reality height of some div, reset the div height
*/	
function setDivHeight(strDivs, splitchar )
{
	var DIVs = strDivs.split(splitchar);
	var objDiv = 0;
	var strlen = DIVs.length-1; //because the strDivs is like "id1,id2,id3,", use split the array DIVs has 4 element, the last one is null, DIVs.length-1 get the right quantity of you div
	var refer_id;
	//get height
	
	for( i=0; i < strlen; i++){
		//alert(DIVs[i]);
		if(objDiv < document.getElementById(DIVs[i]).scrollHeight ){
			objDiv = document.getElementById(DIVs[i]).scrollHeight+18;//let the bottom has 18px blank space
			refer_id = DIVs[i];
		}
	}
	//set height
	for( i=0; i < strlen; i++){
		//if( DIVs[i]!= refer_id )
			document.getElementById(DIVs[i]).style.height = objDiv+"px";
		//document.getElementById(DIVs[i]).style.borderBottom='2px solid red' ;
	}
	$(document).ready(function() {
  $(".middle_line").css("height",objDiv);
  });
}

function open_new_page(){

	var left = ( screen.width - 850 )/2;   
	var top = ( screen.height - 600 )/2;   
	var windowFeatures = "toolbar=yes,menubar=yes,scrollbars=yes,stausbar=yes,height=" + 600 + ",width=" + 850+",left=" + left + ",top=" + top;
	
	url = "https://www.cdc.retraites.fr/portail/spip.php?page=article&id_article=2894&cible=_actif";
	winTitle = '';
	
	window.open(url, winTitle, windowFeatures, true);
}

function ValidateEmail(j)    //check the email
{
    //var emailReg=/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    var emailReg=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
    return emailReg.test(j);
}
/* this function is come from enviar_email_articulo.html  move by tealy*/
  function checkSend(obj,str)
  {  
  	 if(obj.destino.value=="" || obj.email.value=="" || obj.coment.value=="")
  	 {
  	 	alert(str);
 		return false;
  	 	
  	 }else{
  	 	if(ValidateEmail(obj.destino.value) && ValidateEmail(obj.email.value)){
  	 		return true;
  	 	}else{
  	 		alert("Format d'email incorrect");
  	 		return false;
  	 	}
  	 }
  }
  
function set_frm_value(){
	document.getElementById('text_01').value = document.getElementById('input-1-ligne_1').value
	document.getElementById('text_02').value = document.getElementById('input-1-ligne_2').value
	document.getElementById('text_03').value = document.getElementById('input-1-ligne_3').value
	document.getElementById('text_04').value = document.getElementById('input-1-num_1').value
	document.getElementById('text_05').value = document.getElementById('input-1-email_1').value
	document.getElementById('text_06').value = document.getElementById('input-1-telephone_1').value
	document.getElementById('text_07').value = document.getElementById('input-1-ligne_4').value
	document.getElementById('text_08').value = document.getElementById('input-1-texte_1').value
	document.getElementById('contact_form').submit();
}

//Created by Tealy on June 4, 2009
function strBetweenSpecialChar(text, special){
	start = text.indexOf(special) + special.length;
	end = text.indexOf(special, start);
	mytext = text.substr(start, end - start);
	return mytext;
}

function isNumeric(strString) //  check for valid numeric strings	
{
	if(!/\D/.test(strString)) return true;//IF NUMBER
	else if(/^\d+\.\d+$/.test(strString)) return true;//IF A DECIMAL NUMBER HAVING AN INTEGER ON EITHER SIDE OF THE DOT(.)
	else return false;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

	
function hideDocument(){
	document.getElementById("feed_back_box").style.display="none";
	document.getElementById("fad").style.display="none";
	
	//ie6 bug fixing
	document.getElementById("option").style.visibility = "visible";
	document.getElementById("year").style.visibility = "visible";
	document.getElementById("month").style.visibility = "visible";
}
function hideHelpDocument(){
	document.getElementById("help").style.display="none";
	document.getElementById("fad").style.display="none";
}
	
function show_help(){
	$('#help').bgiframe();
	document.getElementById("help").style.display="block";
	document.getElementById("fad").style.display="block";
}


function show_iframe(){
	
	var elem = document.getElementById("btn_print");
	
	elem.href = elem.href.replace(/&iframe=0/g, "");
	elem.href = elem.href.replace(/&iframe=1/g, "");

	if(document.getElementById("iframe").style.display == 'none'){
		document.getElementById("iframe").style.display = "block";
		elem.href += "&iframe=1"; 
	}else{
		document.getElementById("iframe").style.display = "none";
		elem.href += "&iframe=0"; 
	}
}

function print_page(elem){
	
}

function total_points_value_display(){
	var show = document.getElementById("total_points_display").style.display;
	
	if( show == 'none' ){
		
		$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=4', 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){
            //the operations to be done here.
            result = strBetweenSpecialChar(html, '@@@@@@@@')
           
            $('#total_points_value').text(result);
        },
        error: function(){ 						
            alert('the expected operation failed!'); 
        }
	});
		
		
		document.getElementById("calculate_bottom_box").style.display = "none";
		document.getElementById("total_points_display").style.display = "block";
	}else{
		document.getElementById("total_points_display").style.display = "none";
	}
}

function show_total(){
			
	var ObjTotalBox = document.getElementById('feed_back_box');

	//get the html for total box
	$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=6', 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){

            //the operations to be done here.
            var result = strBetweenSpecialChar(html, '@@@@@@@@')
            $('#feed_back_box').html(result);
        },
        error: function(){ 						
            alert('the expected operation failed! please have check'); 
        }
	});
	
	document.getElementById("option").style.visibility = "hidden";
	document.getElementById("year").style.visibility = "hidden";
	document.getElementById("month").style.visibility = "hidden";
	ObjTotalBox.style.display = 'block';
	document.getElementById("fad").style.display="block";
}

function show_subtotal(){
	var result = '';
	var objYear = document.getElementById("year");
	var objMonth = document.getElementById("month");
	var year = objYear.options[objYear.selectedIndex].value;
	var month = objMonth.options[objMonth.selectedIndex].value;
	
	var ObjSubTotalBox = document.getElementById('calculate_bottom_box');

	if(ObjSubTotalBox.style.display == 'none'){
		
		//get the sub-total of the month mode=4
		$.ajax({
	        type: 'GET',							
	        url:'spip.php?page=calc_callback', 						
	        data: 'mode=4&year=' + year + '&month=' + month, 	
	        dataType: 'html', 						
	        cache: false, 							
	        success: function(html){
	            //the operations to be done here.
	            result = strBetweenSpecialChar(html, '@@@@@@@@')
	            $('#value_subtotal').text(result);
	        },
	        error: function(){ 						
	            alert('the expected operation failed!'); 
	        }
    	});
    	
    	//get the html for sub-total box
    	$.ajax({
	        type: 'GET',							
	        url:'spip.php?page=calc_callback', 						
	        data: 'mode=5&year=' + year + '&month=' + month, 	
	        dataType: 'html', 						
	        cache: false, 							
	        success: function(html){

	            //the operations to be done here.
	            var result = strBetweenSpecialChar(html, '@@@@@@@@')
	            $('#calculate_bottom_box').html(result);
	        },
	        error: function(){ 						
	            alert('the expected operation failed!'); 
	        }
    	});
		
		//show this subtotal box
		document.getElementById("total_points_display").style.display = "none";	
		ObjSubTotalBox.style.display = 'block';
	}else{
		ObjSubTotalBox.style.display = 'none';
	}
}


function getSubTotal(){
	var result = '';
	var objYear = document.getElementById("year");
	var objMonth = document.getElementById("month");
	var year = objYear.options[objYear.selectedIndex].value;
	var month = objMonth.options[objMonth.selectedIndex].value;

	
	var objValueMonth = document.getElementById('value_month');
	objValueMonth.value = trim(objValueMonth.value);
	var value_month = objValueMonth.value;

	if(value_month != ''){
		if(!isNumeric(value_month)) {
			alert('pas un nombre valide!');
			return;
		}
	}
	
	//submit the input value of the month
	$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=3&year=' + year + '&month=' + month + '&value_month=' + value_month, 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){
            //no operations 
            result = strBetweenSpecialChar(html, '@@@@@@@@')
        },
        error: function(){ 						
            alert('the expected operation failed!'); 
        }
	}); 

	//get the the total mode=4
	$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=4', 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){
            //the operations to be done here.
            result = strBetweenSpecialChar(html, '@@@@@@@@')
            $('#value_subtotal').text(result);
            $('#total_points_value').text(result);
        },
        error: function(){ 						
            alert('the expected operation failed!'); 
        }
	});
	
	//get the html for sub-total box
	$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=5&year=' + year + '&month=' + month, 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){

            //the operations to be done here.
            var result = strBetweenSpecialChar(html, '@@@@@@@@')
            $('#calculate_bottom_box').html(result);
        },
        error: function(){ 						
            alert('the expected operation failed!'); 
        }
	});
	
}

function yearMonthChange(){
	//set the month value from the table defined at back office
	
	var objYear = document.getElementById("year");
	var objMonth = document.getElementById("month");
	var objSubTotal = document.getElementById('calculate_bottom_box');
	
	
	var year = objYear.options[objYear.selectedIndex].value;
	var month = objMonth.options[objMonth.selectedIndex].value;
	
	if(objSubTotal.style.display != 'none') objSubTotal.style.display = 'none';

	
	$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=1&year=' + year + '&month=' + month, 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){
            //the operations to be done here.
            var result = strBetweenSpecialChar(html, '@@@@@@@@')
            document.getElementById('ratio_month').value = result;
        },
        error: function(){ 						
            alert('the expected operation failed!'); 
        }
	});
	
	//set the month value retrieved from the session
	$.ajax({
        type: 'GET',							
        url:'spip.php?page=calc_callback', 						
        data: 'mode=2&year=' + year + '&month=' + month, 	
        dataType: 'html', 						
        cache: false, 							
        success: function(html){ 			
            //the operations to be done here.

            var result = strBetweenSpecialChar(html, '@@@@@@@@')
           
            document.getElementById('value_month').value = result;
        },
        error: function(){ 						
            alert('the expected operation failed!'); 
        }
	});
	document.getElementById("btn_print").href = url_print + '&year=' + year + '&month=' + month;

}
function tempHideSomething(){
	document.getElementById("recaptcha_switch_audio").src = host + "/squelettes/images/audio_blank.gif";
	document.getElementById("recaptcha_switch_audio").alt = "";
	document.getElementById("recaptcha_switch_audio_btn").title = "";
	document.getElementById("recaptcha_switch_audio_btn").href = "#";
}

function changeLabel(label){
	
	$(document).ready(function() {
		$('#recaptcha_switch_audio_btn').removeAttr('href').css('cursor', 'default');
		$('#recaptcha_instructions_image').html(label);

	});
}

function setImageLinkAndSize(id_art, title, max_width, max_height){
    
	//imgobj = $('#text_'+id_art+'>span>a').attr('href', $('#link_'+id_art).attr('href') ).attr('title', title);
	
    imgobj = $('#text_'+id_art+'>span').css('width', 'auto');
    
    inSpan = imgobj.find('a[@href]').html();
    
    if( inSpan != null){
        imgobj.html(inSpan);
    }

    beforeAddA = imgobj.html();
    if( beforeAddA != null){
        imgobj.html('<a title="'+title+'" href="'+$('#link_'+id_art).attr('href')+'">'+ beforeAddA + '</a>');
    }
    
    // set image width and height
    imgobj = imgobj.find('img[@src]');
    
	if(imgobj.width() > imgobj.height()){
	    
	    if( imgobj.width() > max_width ){
	        
	        height = 'auto';
	        imgobj.width( max_width ).height( height ).removeAttr('height').removeAttr('width').attr('alt', title);
	    }
	    
	}else{
	    
	    if( imgobj.height() > max_height ){	        
	        imgobj.height( max_height ).width('auto').removeAttr('height').removeAttr('width').attr('alt', title);
	    }
	    
	}
	
}

function openPopup(url, winName, width, height){   
  	var winTitle = escape(winName);
	var left = ( screen.width - width )/2;   
	var top = ( screen.height - height )/2;   
	var windowFeatures = "toolbar=no,menubar=no,scrollbars=yes,stausbar=no,height=" + height + ",width=" + width+",left=" + left + ",top=" + top;
	var thePopup = window.open(url, winTitle, windowFeatures, true);
	thePopup.focus();
}   