//Form Effects
$(document).ready(function() {
	//Generic Form Text
	$('input[type="text"]').addClass("inactive");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("inactive").addClass("active");
    	    if (this.value == this.defaultValue){ 
    		   	this.value = '';
			}
			if(this.value != this.defaultValue){
	    		this.select();
	    	}
    	});
    	$('input[type="text"]').blur(function() {
    		$(this).removeClass("active").addClass("inactive");
    	if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
    });
    //Generic Form Password
    $('input[type="password"]').addClass("inactive");
	$('input[type="password"]').focus(function() {
		$(this).removeClass("inactive").addClass("active");
    	    if (this.value == this.defaultValue){ 
    		   	this.value = '';
			}
			if(this.value != this.defaultValue){
	    		this.select();
	    	}
    	});
    	$('input[type="password"]').blur(function() {
    		$(this).removeClass("active").addClass("inactive");
    	if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
    });
    //Generic Form Password
	$('textarea').focus(function() {
		$(this).removeClass("inactive").addClass("active");
    	    if (this.value == this.defaultValue){ 
    		   	this.value = '';
			}
			if(this.value != this.defaultValue){
	    		this.select();
	    	}
    	});
    	$('textarea').blur(function() {
    		$(this).removeClass("active").addClass("inactive");
    	if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
    });
    //Checkboxes
	$('input[type="checkbox"]:checked').parent("label").addClass("checked");
	$('input[type="checkbox"]').click(
		function(){
		
		var label = $(this).parent("label");
		
		if ($(this).attr("checked") == true) {
			$(label).addClass("checked");
		} else {
			$(label).removeClass("checked");
		}
	});
	
	// Select all
    $("A[href='#select_all']").click( function() {
        $("INPUT[type='checkbox']").attr('checked', true);
        $('input[type="checkbox"]').parent("label").removeClass("checked");
        $('input[type="checkbox"]:checked').parent("label").addClass("checked");
        return false;
    });
    $("A[href='#select_none']").click( function() {
        $("INPUT[type='checkbox']").attr('checked', false);
        $('input[type="checkbox"]').parent("label").removeClass("checked");
        return false;
    });
});
