/*
* 
* Textarea Maxlength Setter JQuery Plugin 
* Version 1.0
* 
* Copyright (c) 2008 Viral Patel
* website : http://viralpatel.net/blogs
* 
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* 
*/

jQuery.fn.maxlength = function(){
	$("textarea[maxlength]").keypress(function(event){ 
		var key = event.which;
		//all keys including return.
		if(key >= 33 || key == 13) {
			var maxLength = $(this).attr("maxlength");
			var length = this.value.length;
			if(length >= maxLength) {

				event.preventDefault();
			}
		}
	});

}

$(document).ready(function(){

	/*$("h1#logo_zone").mouseover(function(){
		$("span:first", this).text("Réseau des anciens de l'École de design industriel de l'Université de Montréal");
	}).mouseout(function(){
		$("span:first", this).text("Réseau des anciens de l'École de design industriel de l'Université de Montréal");
	});*/

	$("div.cohorte_dossier").mouseover(function(){
		$(this).css({ backgroundPosition:"-80px 0" });
	}).mouseout(function(){
		$(this).css({ backgroundPosition:"0 0" });
	});
	
	$(".search_default").each(function() {
		var default_value = this.value;
		$(this).focus(function() {
		
			if(this.value == default_value) {
				this.value = '';
			}
		});
		$(this).blur(function() {
			if(this.value == '') {
				this.value = default_value;
			}
		});
		
		$(this).parent("form").submit(function() {
			if($("input#searchTerm").val() == default_value) {
				$("input#searchTerm").val('');
			}
		});
	});
	
	// maxlength for textarea rule
	$().maxlength();
	
	

});



