function makeLabels()
{
	var name    = $(this).attr('name');
	var value   = $(this).val();
	
	if( !labelsObject[name] ) labelsObject[name] = value;
}

function enableTips(form)
{
	$(form + ' dt label').each(function(key, value) 
	{
		if( $(this).attr('for') && $(this).html() )
		{
			$('#'+ $(this).parent('dt').attr('id').replace('label','object') ).append('<div class="alertMessage"><p>'+$(this).html()+'</p></div>');
			$(this).hide();
		}
	});	
}

function showTip()
{
	var _parent = $(this).parent('dd').attr('id');
	$('#'+_parent+' .alertMessage').toggle();
}

function changeText()
{
	var _parent  = $(this).parent('dd').attr('id');
	var isLogged = $(this).parents('form').hasClass('logged');
	var name     = $(this).attr('name');
	var value    = $(this).val();
	if( !labelsObject[name] ) labelsObject[name] = value;
	
	if( !isLogged ) ( value == labelsObject[name] ) ? $(this).val('') : $(this).val( (value == '') ? labelsObject[name] : value );
	
	$('#'+_parent+' .alertMessage').toggle();
	$('#'+_parent+' .erroMessage').remove();
	$('#'+_parent).removeClass('error');
	
	if( objMask[name] && objMask[name] != 'number' ) $(this).mask( objMask[name], {placeholder:' '} );
	if( objMask[name] && objMask[name] == 'number' ) $(this).priceFormat({limit: 6, centsLimit: 2,prefix: '', thousandsSeparator: ''});
	
}

function changeInPassword()
{
	var obj  = $(this).parent('dd');
	var name = obj.attr('id');
	var value = $('#'+name+' input').val();
	
	$('#'+name+' input').removeClass( obj.attr('id') );
	
	$('#'+name+' .erroMessage').remove();
	$('#'+name).removeClass('error');
	$('#'+name+' input').live('focusout',changeOutPassword);
}

function changeOutPassword()
{
	var obj  = $(this).parent('dd');
	var name = obj.attr('id');
	var value = $('#'+name+' input').val();
	
	if(!value) $('#'+name+' input').addClass( obj.attr('id') );
}

function changePassword(_obj)
{
	var obj   = _obj.parent('dd');
	var name  = obj.attr('id');
	var value = $('#'+name+' input').val();
	$('#'+name+' input').addClass( obj.attr('id') );
	$('#'+name+' input').live('focusin',changeInPassword);
}

function aplyErrorMessage(key, value)
{
	if( $('#' + key.toLowerCase() + '-object').attr('class') != 'error' )
	{
		$('#' + key.toLowerCase() + '-object').addClass('error');
		if(value != 'border') $('#' + key.toLowerCase() + '-object').append('<div class="erroMessage"><p>'+value+'</p></div>');
	}
};

function clearError()
{
	var obj   = $(this).parent('dd');
	var name  = obj.attr('id');
	
	$('#'+name+' .erroMessage').remove();
	$('#'+name).removeClass('error');
}

function clearStr(str, from, to) 
{
	for(var i = 0; i < from.length; i++) str = str.replace(from.charAt(i), to.charAt(i));
	
	str = str.replace(/ /g, '-');
	str = str.replace(/_/g, '-');
	str = str.replace(/[^A-z0-9-]/g,'');
	str = str.replace(/--+/g,'-');
	
	return str.toLowerCase();
}

var passwordObject = {}
var labelsObject = {}




