/* Created by Richard Vacchino Marceau on April 2011
   Designed with Jquery 1.5.2
   Contact: richard@triomphe.ca	
 
*/


function Mmenu(id, type, height, length){
	this.i = id;
	this.h = height
	this.l = length;
	$('#'+this.i+' .sub').height(0);
	
	if(type == 'slide'){
		this.animate = Slide;
	}
	
}


function Slide(){
	var h = this.h
	var l = this.l
	
	$('#'+this.i+' li.bt').hover(function(){
	
		$(this).addClass('actif');
		$(this).siblings().children('div.sub').stop();
		$(this).siblings().children('div.sub').stop().height(0);
		
		if($(this).children('div.sub').length > 0){
			
			$position = $(this).children('div.sub').offset()
			
			if ($position.left + $(this).children('div.sub').width() >= $(document).width()) {
			
				$(this).children('div.sub').addClass('special')
				
			}
			else {
				
				if ($position.left + ($(this).children('div.sub').width()*2) - $(this).width() < $(document).width()) {
					
					$(this).children('div.sub').removeClass('special')
					
				}
			}
			
			$(this).children('div.sub').stop().delay(200).animate({'height':h},l);
		}
		
	},function(){
		$(this).siblings().stop().children('div.sub').height(0);
		$(this).removeClass('actif');
		if($(this).children('div.sub')){
		
			$(this).children('div.sub').stop().delay(100).animate({'height':0},l);
			
		}
			
	})
}
