
function accept_disclaimer()
{
	SetCookie('disclaimer', 1, 4, '/' , DISCLAIMER_COOKIE_DOMAIN, 0 );
	$('#disclaimer,#disclaimer_overlay').css('display','none');
	//$('body').css('overflow','');
}

function SetCookie( name, value, expires, path, domain, secure )
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}



function harmonizeHeights()
{
	$("#page_wrap").unbind("resize", harmonizeHeights ); 
	
	$("#content_3col,#content_2col,#side_left,#side_right").css('min-height','');
	
	var pwh = parseInt($('#page_wrap').height());
	
	$('#content_3col,#content_2col').css('min-height',pwh).css('height','auto');
	$('#side_left,#side_right').css('min-height',pwh-5).css('height','auto');		
	
	$("#page_wrap").one("resize", harmonizeHeights ); 
}
				

Number.prototype.formatMoney = function(c, d, t){
	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

/***************************************************************
 *
 *************************************************************/ 
function header_live_reversements(s)
{
 
      somme = s + 0.01;
      
      $('#header_live_reversements span').html(somme.formatMoney(2, ' ', ' ')+'');
      setTimeout(function(){header_live_reversements(somme);},40);


}
 
 /****************************************************************
  *
  *************************************************************/   
function random_bg(){
	var myimages=new Array();
	//specify random images below. You can have as many as you wish
	myimages[1]="fond1.jpg";
	myimages[2]="fond2.jpg";
	myimages[3]="fond3.jpg";
	myimages[4]="fond4.jpg";
	myimages[5]="fond5.jpg";
	
	var ry=Math.floor(Math.random()*myimages.length);
	
	if (ry==0)
	 ry=1;
	//$('body').css('background' ,'#000 url(medias/images/'+myimages[ry]+') top center no-repeat');
}

 /****************************************************************
  *
  *************************************************************/  
  
function loadEtat(nom)
{	//alert(LireCookie(nom));
	if(LireCookie(nom)==1){
		EcrireCookie(nom, 0);
	}else{
		EcrireCookie(nom, 1);	
	}

}
  
/****************************************************************
  *
  *************************************************************/  
function changeStatus(a)
{
	if(a==1)
	{
		$('dl.info_societe').css('display','none');
		$('#fsSociete legend').html('Informations de la personne');
		$('#infos_particulier').css('display','block')
	}
	else{
		$('dl.info_societe').css('display','block');
		$('#fsSociete legend').html('Informations de la soci&eacute;t&eacute;');
		$('#infos_particulier').css('display','none')
	}
}
 
 /****************************************************************
  *
  *************************************************************/   
function g(ee)
  {
    return document.getElementById(ee);
  }

function open_departements()
  {
    $.fancybox(
      $('#deps').html(),
      {
      'transitionIn':'none',
      'transitionOut':'none',
      'width':500,
      'height':560,
      'padding':0,
      'overlayColor':'#000',
      'overlayOpacity':0.6,
      'title':'Sélection de départements',
      'autoDimensions':false,
      onStart:function(){
        $('#deps').html('');  
      
      },
      onCleanup:function(){
        var dd = $('#fancybox-inner').html();
        $('#deps').html(dd);
      }
      
      
      });
    
  
  }



/****************************************************
 *
 ****************************************************/ 
function openpopup(doc,w,h)
{
	typeof(w)=='undefined' ? w=800:false;
	typeof(h)=='undefined' ? h=600:false;
	fenetre = window.open(doc,'_blank','toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0,width='+w+',height='+h);
}


/********************************************
 *
 *******************************************/ 
function save_img(a){
	close_fancy();
	//alert(a);
	jQuery("#uploadify_photo").uploadifyClearQueue();
  $('#edit_fileQueue_photo').css('display','none') ;
  $('#webcam_fileQueue_photo').css('display','') ;
  $('#file_uploadify_photo').val('webcam.jpg') ;
  
	
	}
	
function close_fancy(){
	$.fancybox.close();
}
	

/********************************************************************
 * un ch'tite fct pour éviter les {literal} dans les templates smarty
 ********************************************************************/
function jq(elt)
  {       
      if(!elt)
        return $;
      else
        return $(elt);
  }
  
/*******************************************************
 * COOKIES
 ******************************************************/   
function EcrireCookie(nom, valeur)
{
	document.cookie=nom+"="+escape(valeur);
}
function getCookieVal(offset) {
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1)
	endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
 } 
function LireCookie (name) {
	var arg=name+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen) {
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg)
		return getCookieVal (j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
	}
	return null;
} 
 /*******************************************************
 *
 ******************************************************/ 
function efm_securepay_mbox(payment_form_id)
{
  
  var mboxcontent='';
  mboxcontent += '<div style="background:black;color:white;">';
  mboxcontent += '<img style="height: 30px;float: left;vertical-align:middle;" src="medias/images/logo-efm-secure-pay.png">';			
  mboxcontent += '<span style="margin-left:100px;line-height:2.2em;font-family:courier new;letter-spacing:1px;"><b>Paiement sécurisé via SSL</b>';
  mboxcontent += '';			
  mboxcontent += '';			
  mboxcontent += '<div class="clr"></div>';			
  mboxcontent += '</div><div class="clr"></div>';
  mboxcontent += '<iframe height="650" frameborder="0" width="700" src="javascript:void(0)" id="iframe_paiement" name="iframe_paiement"> </iframe>';
  
  
  $.fancybox(
    mboxcontent,
    {
    'transitionIn':'none',
    'transitionOut':'none',
    'width':700,
    'height':700,
    'padding':0,
    'overlayColor':'#000',
    'overlayOpacity':0.6,
    'autoDimensions':false,
    onComplete:function(){$('#'+payment_form_id).submit();}
    
    });
    
}

  /**********************************************
   *
   *********************************************/     
  function processlogin(form)
  {
    var fields = $(form).serialize();
  
    $.post( 
      absolute_path+'/modules/comptes/ajax.php',
      {fields: fields, doaction:'processlogin'}, 
      function(data) {   
			  	$.fancybox.close(); 
       } , 
      "script"
    );
  }

/***********************************************************
 *
 ***********************************************************/     
function desabonnement()
  {
  $.fancybox(
    
    {
    'transitionIn':'none',
    'transitionOut':'none',
    'width':750,
    'height':700,
    'padding':0,
    'titleShow':true,
    'title':'Désabonnement',
    'type':'iframe',
    'href':'https://www.eurofirstsecurepay.com/accesmembre/',
    'overlayColor':'#000',
    'overlayOpacity':0.6,
    'autoDimensions':false
    
    
    });
    
}

/***********************************************************
 *
 ***********************************************************/     
function update_mon_compte()
  {
  
    $.validationEngine.closePrompt('*');

    var fields = $("#formID").serialize();
    
    $.ajax({
      url: 'ajax_main.php',
      type: "POST",
      contentType: 'application/x-www-form-urlencoded;charset=iso-8859-1',
      dataType: "script",
      processData:true,
      scriptCharset:'iso-8859-1',
      data: {fields : fields, doaction:'update_compte'},
      cache:false,
      success: function(data) {
           
        }
    });
  
}
  
  
  
/***********************************************************
 *
 ***********************************************************/     
function valid_contact()
  {

    // désactivation du bouton ...
    $('input[name=do_contact]').attr('disabled','disabled');
    var oldvalue = $('input[name=do_abus]').val();
    $('input[name=do_contact]').val('Veuillez patienter...');
    
      
    $.validationEngine.closePrompt('*');

    var fields = $("#formID").serialize();
    
    $.ajax({
      url: 'ajax_main.php',
      type: "POST",
      contentType: 'application/x-www-form-urlencoded;charset=iso-8859-1',
      dataType: "script",
      processData:true,
      scriptCharset:'iso-8859-1',
      data: {fields : fields, doaction:'valid_contact'},
      cache:false,
      success: function(data) {
          
          $('input[name=do_contact]').attr('disabled','');
          $('input[name=do_contact]').val(oldvalue);
                     
        }
    });
   
}  

  function SelectText(element) {
    var text = document.getElementById(element);
    if ($.browser.msie) {
        var range = document.body.createTextRange();
        range.moveToElementText(text);
        range.select();
    } else if ($.browser.mozilla || $.browser.opera) {
        var selection = window.getSelection();
        var range = document.createRange();
        range.selectNodeContents(text);
        selection.removeAllRanges();
        selection.addRange(range);
    } else if ($.browser.safari) { 
        var selection = window.getSelection();
        selection.setBaseAndExtent(text, 0, text, 1); 
        selection.selectAllChildren(text);
    }
  }


