// JavaScript Document
//created by Marcone Ferreira Ramos 16/11/2011
//contact development@marconeramos.com
(function($){
jQuery.fn.bmformlabels=function(slabel,csslabel,cssvalue, appafter){
//gives a name to the element
var element=this;
//calls the function bellow, applyBehavior
applyBehavior();
//starts the function
function appendNoMasked(){
	if ($(element).attr("type")=="password") {
		//get all attributes
		var passname=$(this).attr('name');
		var passid=$(this).attr('id');
		var passclass=$(this).attr('class')
		$(element).remove($(this).attr('id'));
			$('<input type="text" value="'+slabel+'" name="'+passname+'" id="'+ passid +'" class="' + passclass + '" />').appendTo(appafter);
	}
}

function appendMasked(){
	if ($(element).attr("type")=="password") {
		//get all attributes
		var passname=$(this).attr('name');
		var passvalue=$(this).attr('value');
		var passid=$(this).attr('id');
		var passclass=$(this).attr('class')
		$(element).remove($(this).attr('id'));
			$('<input type="password" value="'+value+'" name="'+passname+'" id="'+ passid +'" class="' + passclass + '" />').appendTo(appafter);
	}
}
function applyBehavior(){
	
	//gets the value sent
	$(element).attr("value",slabel);
	//alert(label);
	$(element).addClass("longin_label_input");
	$(element).click(function(){
			//if it is a password filed, remove the old and create a new one
			//clear the field
			if ($(element).attr("value")==slabel) {
				$(element).attr("value","")	
			}
	});
	$(element).blur(function(){
			//clear the field
			if ($(element).attr("value")=="") {
				$(element).attr("value",slabel)	
			}
	});
	
}
};
})(jQuery);
