var Ctrl = new function()
{
  var options;
  
  this.init = function(opt)
  {
    Ctrl.options = opt;

    Ctrl.initDom($("#dms_layout_parts"));
  }
	
  this.initDom = function($dom)
  {
//	  $(".accordion h3:first").addClass("active");
		$(".accordion .panel").hide();

		$(".accordion h3").click(function(){
			$(this).next(".panel").slideToggle("slow")
			.siblings(".panel:visible").slideUp("slow");
			$(this).toggleClass("active");
			$(this).siblings("h3").removeClass("active");
		});
		
		if($('div.envoi_simulation_ok').length)
		{
			$.facebox.settings.classBody = 'envoi_ok';
			$.facebox("\
			<div class=picto_envoi_ok clearfix>\
			  \
			</div>	\
			<span class='message_reussit'>Votre demande de simulation sera bientôt traité. Merci</span>"
			);
		}
		
		if ($("div.flash_message").length) {
			$.facebox.settings.classBody = 'envoi_ok';
			$.facebox("\
			<div class=picto_envoi_ok clearfix>\
			  \
			</div>	\
			<span class='message_reussit'>Votre demande de contact sera bientôt traitée. Merci</span>"
			);
		}
		if ($tabs = $("div.tabs_me > ul").orNot())
	    {
	      $tabs.tabs({
	        fx: { opacity: 'toggle', duration: 500 }
	      });
	      $('a.loi_scellier').click();
	    }
		if($('div.loi_sceillier_selectionner').length)
			$('a.loi_scellier').click();
		
		$.validator.messages = 
        {
          required:   "",
          email:      ""
        }
		$('form.formProjet', $dom).each(function(){$(this).validate()});
		
		$('.in_fine').hide();
		$('.taux_pret').each(function(){
			$(this).rebind('change', function(){
				if($(this).val() == 1)
				{
					$('.ammortissable').show();
					$('.in_fine').hide();
				}
				else
				{
					$('.ammortissable').hide();
					$('.in_fine').show();
				}
				
			});
		});
  }
};

Dms.registerController(Ctrl);

