
var active_color = '#444';
var inactive_color = '#999';

var default_values = new Array();




$(document).ready(function() {

	/* Input Textfield */
	 
  	$(":text").css("color", inactive_color);
	$(":text").css("font-weight", "bold");
 
 	
	
  	$(":text").focus(function() {
    	
		// Exclude password placeholders (which are normal textfields as well)
		if (this.id != "passw_placeholder" & this.id != "passw2_placeholder") {
	
			// Add default value to array once
			if (!default_values[this.id]) {
				default_values[this.id] = this.value;
			}
			
			// Set textfield when focused
			if (this.value == default_values[this.id]) {
				this.value = '';
				this.style.color = active_color;
				this.style.fontWeight = "normal";
			}
		
			// Set textfield when blurred
			$(this).blur(function(){
				if (this.value == '') {
					this.style.color = inactive_color;
					this.style.fontWeight = "bold";
					this.value = default_values[this.id];
				}
			
			});
			
		}
	});


	

	
		
	/* Input Password */
	 
  	$("div[id='password_fields']").css("display", "none");

	// Field 1
	$("input[id='passw_placeholder']").focus(function() {
		
		$("div[id='password_fields']").css("display", "");
		$("div[id='password_placeholders']").css("display", "none");
		
		$("input[id='passw']").focus();
  	
	});
	
	
	
	
	$("input[id='passw']").blur(function() {
     	 if (this.value == '') {
			$("div[id='password_fields']").css("display", "none");
			$("div[id='password_placeholders']").css("display", "");
		}
		
	});
	
	// Field 2 (Repeat)
	$("input[id='passw2_placeholder']").focus(function() {
 
		$("div[id='password_fields']").css("display", "");
		$("div[id='password_placeholders']").css("display", "none");
		
		$("input[id='passw2']").focus();
  	
	});
	
	
	
	
	$("input[id='passw2']").blur(function() {
     	 if (this.value == '') {
			$("div[id='password_fields']").css("display", "none");
			$("div[id='password_placeholders']").css("display", "");
		}
		
	});
	

	
	/* Textarea */
	
	$("textarea").css("color", inactive_color);
	$("textarea").css("font-weight", "bold");
	
	$("textarea").focus(function() {
    
	// Add default value to array once
	if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }

	
	// 
    if (this.value == default_values[this.id]) {
    	this.value = '';
      	this.style.color = active_color;
	  	this.style.fontWeight = "normal";
    }
	
	
	
	// Create blur event only after focus has been set for the 1st time
  		$(this).blur(function() {
     	 	if (this.value == '') {
        		this.style.color = inactive_color;
				this.style.fontWeight = "bold";
        		this.value = default_values[this.id];
      		}
    	});
  	});
});

