/*

// 15-07-2009 
// mdg : I have added some code to hide a temp input field which shows a textvalue (example : Your password...) in the input field
// you can not change the type=text to type=password therefor we need to hide this input field and show another field which has set type to password
// this is created by code that will set style of the temp input to display:none and it will set the next input box to display:block.
// note! in your html you need to add rel=password to create this functionality and set manually the default style to the input type=password to 
// style="display:none"



* jQuery emptyonclick plugin
*
* Created by Andreas Creten (andreas@madewithlove.be) on 2008-06-06.
* Copyright (c) 2008 madewithlove. All rights reserved.
*
* Version: 1.2
*
* Changelog :
* Version 1.2 (17 Jun 2008)
*  - Empty the fields onsubmit when they are not changed
*
* Version 1.1 (11 Jun 2008)
*  - Fixed a bug when working with an empty field (no default value)
*
* Version 1.0 (06 Jun 2008):
*  - Original version
*/


// mdg : add an expression to find all rel="password" + type="text" to set to display=block (by default this is hidden in html file in case javascript is turned off)
$.expr[':'].passwordtypetext = function(obj){	
	var $this = $(obj);
	if(($this.attr('rel') == 'password') && ($this.attr('type') == 'text'))
		return $this;	
	return false;
};

// mdg : add an expression to find all rel="password" + type="password" to set to display=none (by default this is visible in html file in case javascript is turned off)
$.expr[':'].passwordtypepassword = function(obj){	
	var $this = $(obj);
	if(($this.attr('rel') == 'password') && ($this.attr('type') == 'password'))
		return $this;
	return false;
};




jQuery.fn.extend({
    emptyonclick: function(options) {
        return this.each(function() {
            new jQuery.EmptyOnClick(this, options);
        });
    }
});


jQuery.EmptyOnClick = function(element, options) {
	
	var defaultValue = $(element).val(); 
	
	// mdg - needed to restore default password text value
	var previousdefaultValue = $(element).prev("input").val(); 
	
	// mdg
	var relAttributeValue = $(element).attr("rel"); 
	var typeAttributeValue = $(element).attr("type"); 
	
	
    // Bind event handlers to the element
    $(element)
	
    // On Focus: Store the default value if it's not set, empty the field
    .bind("focus", function(e) {
        if(defaultValue == $(this).val())
            $(this).val('');
		
		// mdg
		if((relAttributeValue == "password") && (typeAttributeValue == "text"))
		{	
			$(this).css("display","none");
			$(this).next("input").css("display","block");
			$(this).next("input").focus();
		}

    })
	
    // On Blur: if the field is empty, reset the default value
    .bind("blur", function(e) {
        if(!$(this).val()) {
            $(this).val(defaultValue);
        }		
				
		// mdg
		if($(this).val() == "")
		{
			if((relAttributeValue == "password") && (typeAttributeValue == "password"))
			{
				$(this).css("display","none");				
				$(this).prev("input").css("display","block");
				$(this).prev("input").val(previousdefaultValue);
			}
		}
		
    });

    // Search for the form which has the element
    $("form:has(#"+element.id+")")
    // If the form gets resetted, set the default value back
    .bind('reset', function(e) {
        $(element).val(defaultValue);
        $(element).removeClass(options.changeClass);
    }) 
    // If the form gets submitted empty, remove the default values
    .bind('submit', function(e) {
        if($(element).val() == defaultValue)
            $(element).val('');
    });
	

	
};
