$(document).ready(function(){
			
		$('#newsletter_btn').click(function() {
			var email = $('#newsletter_courriel').val(); 
			if(email.length>0)
			{
				var regex = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
				if(regex.test(email)) {
					window.location = 'http://www.pacini.ca/index.php?cID=160?Question12='+email;
					
					return false;
				}
			}
			alert('Vous devez entrer votre courriel');
			return false;
		});		
		
		/*$('#envoyer_btn').click(function() {
			alert('Merci!');
		});		*/
	
	
	$('div.block-menu-accueil').each(function(){
		$(this).find('div.menu').each(function(){
			var ele = $('div#'+this.id.replace(/placeholder_/ , ''));
			ele.appendTo($(this));
			ele.show();			
		});
	})
	
	
	$('div.tabtitle').each(function(){
		$(this).attr('isover', 0);
		$(this).mouseenter(function(){
			if($(this).attr('isover') == 0)
				$(this).css('background-color', '#fbfbfb');
		});
		
		$(this).mouseleave(function(){
			if($(this).attr('isover') == 0)
				$(this).css('background-color', '#efeee8');
		});
		
		/*$(this).click(function(){*/
		$(this).each(function(){
			var list = $(this).next();
			if(list.is(':visible')){
				list.animate({height:'1px'}, function(){$(this).show();$(this).prev().css('background-color', '#efeee8');});
				$(this).attr('isover', 0);
			}else{
				list.show();
				var newHeight;
				if(list.hasClass('singlecontenttabbar')){
					//Its one column. get the height of the inner div
					newHeight = $(list.find('div')[0]).height();
				}else{
					// Its 2 columns, get the height of the higher column
					var liList = list.find('li');
					var firstHeight = $($(liList[0]).find('div')[0]).height();
					var secondHeight = $($(liList[1]).find('div')[0]).height();
					if(secondHeight > firstHeight)
						newHeight = secondHeight;
					else
						newHeight = firstHeight;
				}
				list.animate({height:newHeight+'px'}, function(){$(this).prev().css('background-color', '#fbfbfb');});
				$(this).attr('isover', 1);
			}	
		});
	});
	
	var x = window.location+""; 
	x = x.substring(x.indexOf("#")); 
	if(x.length >1) { 
		$(document).ready(function() { 
			$x = $(x); 
			if($x.hasClass('tabtitle')) {
				$x.trigger('click'); 
			}
		}); 		
	}
});

MenuSlider = {
		id:'',
		init : function(eid){
			this.id = eid;
			$($('div#'+eid).find('img.arrLeft')[0]).bind('click', {id:this.id}, this.SlideBackward);
			$($('div#'+eid).find('img.arrRight')[0]).bind('click', {id: this.id},this.SlideForward);
			$($('div#'+eid).find('ul')[0]).css('width',($('div#'+eid).find('li').length *460)+'px'); 
		},
		SlideForward : function(ev){
			var ulObj = $($('div#'+ev.data.id).find('ul')[0]);
			var pos = ulObj.position();
			var iWidth = $(ulObj.find('li')[0]).width();
			var uWidth = ulObj.width();

			if((pos.left - iWidth) > (uWidth*-1) ){
				ulObj.animate({left:(pos.left - iWidth)+'px'});
			}
		},
		SlideBackward: function(ev){
			var ulObj = $($('div#'+ev.data.id).find('ul')[0]);
			var pos = ulObj.position();
			var iWidth = $(ulObj.find('li')[0]).width();
			var uWidth = ulObj.width();

			if((pos.left + iWidth) <=0){
				ulObj.animate({left:(pos.left + iWidth)+'px'});
			}
		}		
	}
