function popin(){
	
	var elm_window_width;
	var elm_window_height;
		
	this.popin_type;
	this.popin_link;
	
	this.build = function(popin){
		$(document.body).append('<div id="overlay"></div>');
		$("#overlay").css({'width' : elm_window_width,'height' : elm_window_height});
			 $.ajax({
			  url: this.popin_link,
			  global: false,
			  type: "GET",
			  dataType: "html",
			  success: function(callBack){
				$("#popin .popinN2").append(callBack);
				initInputTextEvents("#popin");
				initCheckForms("#popin",popin);
				$("#popin .btnClose").bind("click",function(){
					popin.close(popin);
					return false;
				});					
			  }
		   });
		  var target_elm =  $(document.body); 
		if(ie6) {
			target_elm =  $(".msie6"); 
		}
		target_elm.append('<div class="'+this.popin_type+'"><div id="popin"><div class="popinN1"><div class="popinN2"><a class="btnClose" href="#" title="Fermer la fenêtre"></a></div></div></div></div>');
	}
	this.remove = function(){
		$("#overlay").remove();
		$("#popin").remove();
	}
	this.close = function(popin){	
		if($.browser.msie){
			$("#popin").css('display','none');
			popin.remove();
		}
		else{
			$("#popin").fadeOut("fast",function () {
				popin.remove();
			});
		} 
		$("#overlay").fadeTo("slow", 0);
	}
	this.open = function(){
		$("#overlay").css('display','block');
	
		$("#overlay").css("opacity", 0.63);
		$("#overlay").fadeTo("fast", 0.33);
		
		if($.browser.msie){
			$("#popin").css('display','block');
		}
		else{
			$("#popin").fadeIn("slow",function () {
			});
		} 
	}

	this.init = function(popin){
		elm_window_width = $(document.body).innerWidth();
		elm_window_height = $(document.body).innerHeight();
		$(".popinLink").bind("click",function(){
			window.scrollTo(0,0); 
			
			popin.popin_type = $(this).attr("rel");
			popin.popin_link = $(this).attr("href");
			popin.build(popin);
			popin.open();
			
			return false;
		});
		
	}
	
	
	
	this.successForm = function(popin){
		popin.remove(popin);	
		popin.build(popin);
		popin.open();
	}

}

$(document).ready(function () {

	var popins = new popin();
	popins.init(popins);

	
});
