/*
26/05/2010
Behavior jQuery generic live
Reset - Reset input on focusin, focusout
OC - Correction pour :hover
Over - Gestion automatique des changements d'images      
Input et submit - Changement de style automatique pour les inputs  
Printr - Décrit un objet ou un tableau   
*/

$( document ).ready(
	function () {

/* RESET INPUT ON FOCUS*/
$( '.reset' ).live('focusin',
function () { 
	if($(this).val() == $(this).attr("default"))
	$(this).val('');
} ); 

/* RESET INPUT ON BLUR */
$( '.reset' ).live('focusout',
function () { 
	if(!$(this).attr("value"))
	$(this).attr("value",$(this).attr("default"));
} ); 

/* CHANGEMENT DE CLASS ON MOUSEOVER */
$( '.oc' ).live("mouseover", function () { 
	$( this ).addClass($( this ).attr("oc"));
});

$( '.oc' ).live("mouseout", function () {  
	$( this ).removeClass($( this ).attr("oc"));
});

/* ROLLOVER IMAGE */
$( '.over' ).live("mouseover", function () { 
	$(this).attr("src", $(this).attr("src").split(".").join("_over."));
});

$( '.over' ).live("mouseout", function () {  
	$(this).attr("src", $(this).attr("src").split("_over.").join("."));
});

/* ACTIVE HREF POUR TOUT ELEMENT */
$(".href").live("click", 
function () {    
window.location.href = $(this).attr("href");
});

/* CHANGEMENT DE CLASS POUR LES INPUT */
$("input[type='text'],input[type='password'],textarea,select").live("mouseover", 
function () { 

$( this ).addClass("input_over");
});

$("input[type='text'],input[type='password'],textarea,select").live("mouseout", 
function () {  
$( this ).removeClass("input_over");
});

$(".submit").live("mouseover", 
function () {  
$( this ).addClass("submit_over");
});

$(".submit").live("mouseout", 
function () {  
$( this ).removeClass("submit_over");
});   

$(".ajax").live("mouseover", 
function () {  
$( this ).addClass("ajax_over");
});

$(".ajax").live("mouseout", 
function () {  
$( this ).removeClass("ajax_over");
});

});   

/* PRINT_R */
function printr(theObj){
	if(theObj.constructor == Array ||
		theObj.constructor == Object){
			document.write("<ul>")
			for(var p in theObj){
				if(theObj[p].constructor == Array||
					theObj[p].constructor == Object){
						document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
						document.write("<ul>")
						print_r(theObj[p]);
						document.write("</ul>")
					} else {
						document.write("<li>["+p+"] => "+theObj[p]+"</li>");
					}
				}
				document.write("</ul>")
			}
		}