function jFacebox(url)
{
	$.ajax({
		  type: "GET",
		  url: url,
		  cache: false,
		  success: function(html){
			jQuery.facebox(html);
	  		}
		});
	return false;
}

function jSubmit(form_id, url)
{
	var values = $(form_id).serialize();
	$.post(url, values, function (data) {
		$('#pu_div_form').html(data);
		}
	);
	return false;
}

function jRefresh(url, id)
{
	$.get(url, '', function (data) {
	$('#' + id).html(data);
	$('html, body').animate({ scrollTop: 0 }, 'slow');
		}
	);
	return false;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function initforms()
{
	$('.required').blur(function (){ 
		this.value = trim(this.value);
		$(this).removeClass('error');
		if(!this.value.length)
		{
			$(this).addClass('error');	
		}
	});
	$('.required').focus( function () {
		$(this).removeClass('error');
	});
	$('input').each(function() {
	if (this.type == 'submit' || this.type == 'file')
            this.style.height = '22px';

    });

    $('a[rel*=facebox]').facebox();
}

function on_click_password(input) 
{
    if (input.type == 'text' ) 
    {
        input.type = 'password';
    }

    input.value='';
}


