/**
 * Determine whether a value is empty. This is true when all characters in the
 * value are one of "\n, \t, ' '".
 */
function isEmpty(value) 
{
    if (value) {
        for (var i= 0; i < value.length; i++) {
        	var c = value.charAt(i);
    	    if ((c != ' ') && (c != '\n') && (c != '\t')) {
    	        return false;
    	    }
        }
        return true;
    } else {
        return true;
    }
    
}

jQuery(document).ready(function() {
    jQuery('textarea').maxlength({
		'feedback' : '.charsLeft'
	});
	
	$("#add_comment").bind( "submit", function() {
    	var valid = true;	
    	$(this).find(".required").each(function(){	
    		if ( isEmpty( $(this).val() ) ) {
    			valid = false;
    			$(this).addClass("notvalid");
    		}
    	});
    	if (!valid) {
    		alert( "Formulaire incomplet !" );
    	}
    	return valid;
    });
    
    $(":input.required").focus(function() {
		$(this).removeClass("notvalid");
	});
	
	$(".comment:even").addClass("even");
	$(".comment:odd").addClass("odd");
	
	
	
	//$('.realisations a').lightbox({fitToScreen:true});
	$('.lightbox-wrapper a').lightBox({
	    txtOf:'de',
	    imageLoading:			'/imports/jscript/jquery/lightbox/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon
		imageBtnPrev:			'/imports/jscript/jquery/lightbox/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
		imageBtnNext:			'/imports/jscript/jquery/lightbox/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
		imageBtnClose:			'/imports/jscript/jquery/lightbox/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
		imageBlank:				'/imports/jscript/jquery/lightbox/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
	    txtOf:'de'
	    
    });
	
});
