

$(document).ready(function(){
	
	$('#categorydropdown').change(function() {
		if ($(this).val() != '') {
			window.location.href = $(this).val();
		}
	})
	
	$('.regenerateCaptcha').live("click",function () {
		regenerateCaptcha();
	});
	
	$("#login").validationEngine({
		scroll :  false,
		unbindEngine: false,
		inlineValidation: false,
		success : function(){$.formsClassJson.saveAction(sendServerloginform)},
		failure : function(){}
	});
	
	$("#volunteer").validationEngine({ 
		unbindEngine: false,
		success : function(){$.formsClassJson.saveAction(sendServerVolunteer)},
		failure : function(){} 
	});
	
	
	
	$("#infoletters").validationEngine({ 
		scroll :  false,
		unbindEngine: false,
		inlineValidation: false,
		success : function(){$.formsClassJson.saveAction(sendServerInfoletters)},
		failure : function(){setTimeout("$.validationEngine.closePrompt('#emailinfoletter')", 3000);} 
	});
	
	 $('.colorbox').live("click", function () {
			$(this).colorbox( {
				href :$(this).attr('rel'),
				open :true,
				height:'80%',
				width:'80%'
			});
			return false;
		});
		$(document).bind('cbox_open', function(){
			$.validationEngine.closePrompt(".formError",true);
			$('html').css({overflow:'hidden'});
			$('embed,object').css({visibility:'hidden'});
		});
		$(document).bind('cbox_closed', function(){
			$.validationEngine.closePrompt(".formError",true);
			$('html').css({overflow:'auto'});
			$('embed,object').css({visibility:'visible'});
		});	

	var clearMePrevious = '';
	
	// clear input on focus
	$('.clearMeFocus').focus(function()
	{
		if($(this).attr('readonly')!=true){
			if($(this).val()==$(this).attr('title'))
			{
				clearMePrevious = $(this).val();
				$(this).val('');
			}
		}
	});
	// if field is empty afterward, add text again
	$('.clearMeFocus').blur(function()
	{
		if($(this).val()==''){
			$(this).val(clearMePrevious);
		}
	});
	
	
	/* Sub Navigation sub menu and hover */
	$('ul.subNav li').not(".login").hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none');
			});
	
	$('ul.subNav li.login').click(function(){
		$(this).find("ul").css('display', 'block');
	})
	$("#content,#searchkeyword").bind("click", function(e){

		$('ul.subNav li.login ul').css("display","none")
	})		
	$("#closeConnect").click(function(){
		$.validationEngine.closePrompt(".formError",true);
		$('ul.subNav li.login ul').css("display","none")
		return false;
	})
	/* hover */
	$("ul.subNav li").hover(
		  function () {
			$(this).children(':first-child').addClass("hover");
		  },
		  function () {
			$(this).children(':first-child').removeClass("hover");
			$.validationEngine.closePrompt(".formError",true);
		  }
	);
	
	
	/* Main Navigation sub menu and hover */
	/*2nd level*/
	$('#navBar ul.navigation li').hover(
			function() { $('ul.lvl2', this).css('display', 'block'); },
			function() { $('ul.lvl2', this).css('display', 'none');
			});
	/*3rd level*/
	$('#navBar ul.navigation li ul li.thirdHover').hover(
			function() { $('ul.lvl3', this).css('display', 'block'); },
			function() { $('ul.lvl3', this).css('display', 'none');
			});

	/* hover */
	/*2nd level*/
	$("#navBar ul.navigation li").hover(
		  function () {
			$(this).children(':first-child').addClass("hover");
		  },
		  function () {
			$(this).children(':first-child').removeClass("hover");
		  }
	);
	/*3rd level*/
	$("#navBar ul.navigation li ul li").hover(
		  function () {
			$(this).children(':first-child').addClass("hover");
		  },
		  function () {
			$(this).children(':first-child').removeClass("hover");
		  }
	);

	/* sign in layer */

	$('#navBar .right ul.logger li.login').hover(
			function() { $('.layer', this).css('display', 'block'); },
			function() { $('.layer', this).css('display', 'none');
			});
	

	/* hover */
	$("#navBar .right ul.logger li.login").hover(
		  function () {
			$(this).addClass("hover");
		  },
		  function (){ 		
			$(this).removeClass("hover");
			$.validationEngine.closePrompt(".formError",true);
		  });
	



	/*content box tab navigation toggle*/
	$('.tabs div.toggle').css('display', 'none');
		$('.tabs div.toggle:first').css('display', 'block');
		$('.tabs ul.tabNav li:first').addClass('active');
		 
		$('.tabs ul.tabNav li a.tabs').click(function(){
			//close validationEngine
			$.validationEngine.closePrompt(".formError",true);
			$('.tabs ul.tabNav li').removeClass('active');
			$(this).parent().addClass('active');
			var currentTab = $(this).attr('href');
			$('.tabs div.toggle').css('display', 'none')
				$(currentTab).css('display', 'block');

			return false;
		});
		
		/* hover pour tabs */
	$(".tabs ul.tabNav li").hover(
		  function () {
			$(this).addClass("hover");
		  },
		  function () {
			$(this).removeClass("hover");
		  }
	);
	
	/*if there is a second set of tabs on the page use this one for the second*/
	$('.tabs2 div.toggle').css('display', 'none');
		$('.tabs2 div.toggle:first').css('display', 'block');
		$('.tabs2 ul.tabNav li:first').addClass('active');
		 
		$('.tabs2 ul.tabNav li a.tabs').click(function(){
			//close validationEngine
			$.validationEngine.closePrompt(".formError",true);
			$('.tabs2 ul.tabNav li').removeClass('active');
			$(this).parent().addClass('active');
			var currentTab = $(this).attr('href');
			$('.tabs2 div.toggle').css('display', 'none')
				$(currentTab).css('display', 'block');

			return false;
		});
		
		/* hover pour tabs */
	$(".tabs2 ul.tabNav li").hover(
		  function () {
			$(this).addClass("hover");
		  },
		  function () {
			$(this).removeClass("hover");
		  }
	);
	
	//bookmark
	$(document).ready(function(){
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){ // don't overwrite the rel attrib if already set
			$("a.jqbookmark").attr("rel","sidebar");
		}
	}

	$("a.jqbookmark").click(function(event){
		this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.espaces.ca');
		event.preventDefault();
		/** // prevent the anchor tag from sending the user off to the link
		var url = this.href;
		var title = this.title;

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing - the rel="sidebar" should do the trick
		} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
			 	fieldId = "#bookmarkfrontfooter"
				$.validationEngine.buildPrompt(fieldId, "Erreur! Ce navigateur ne supporte pas cette commande. Ajouter le lien &agrave; vos favoris manuellement.", "error");
				setTimeout("$.validationEngine.closePrompt('" + fieldId + "')", '5000');
		}
		**/
	});
});
	
});

function addevent(url){
	genericPrototype(url, 'genericJson');
}


/*sharethis configs*/
var addthis_config = {
     ui_language: "fr"
}
var addthis_share = {
	email_template: "GroupeEspaces"
} 
