// 
//  userpassfocus.js
//  insert the text in the username and password input after focusing and bluring
//  viadistance
//  
//  Created by Damien Saillard on 2009-01-29.
//  Copyright 2009 AP2S. All rights reserved.
// 

$(document).ready(function() {
	/* begin jQuery code for the text in username and password disappearing with focus and appearing again with blur */
	// var searchLabel = $('#form_login_container label').remove().text(); 
	// $('#password').val(searchLabel);
	$("input:text[@note],textarea[@note]")
	.each(function(){
		var $this = $(this);
		if(!$this.val() && $this.attr("note")) {
				$this.val($(this).attr("note"));
			}
		})
	.blur(function(){
			var $this = $(this);
			if(!$this.val() && $this.attr("note")) {
				$this.val($this.attr("note"));
			}
		})
	.focus(function(){
			var $this = $(this);
			if($this.val() == $this.attr("note")) {
				$this.val("");
			}
		});
	if(!$.browser.msie){
		$("input:password[@note]")
		.each(function(){
				var $this = $(this);
				// console.log($this.val());
				if(!$this.val() && $this.attr("note")) {
					this.type = "text";
					$this.val($this.attr("note"));
				}
			})
		.blur(function(){
				var $this = $(this);
				if(!$this.val() && $this.attr("note")) {
					this.type = "text";
					$this.val($this.attr("note"));
				}
			})
		.focus(function(){
				var $this = $(this);
				if($this.val() == $this.attr("note")) {
					$this.val("");
					this.type = "password";
				}
			});
	} else {
		$("input:password[@note]")
		.each(function(){
				var $this = $(this);
				if(!$this.val()) {
					$this.val("XXXXXX");
				}
			})
		.blur(function(){
				var $this = $(this);
				if(!$this.val()) {
					$this.val("XXXXXX");
				}
			})
		.focus(function(){
				var $this = $(this);
				if($this.val() == "XXXXXX") {
					$this.val("");
				}
			});
	}
	// console.log($('#breadcrumbs li:first').css({"padding-left": "5px"}));
	/* end jQuery code for the text in username and password disappearing with focus and appearing again with blur */
});