$(document).ready( function() {
	var value_labeled_fields = $('input.value-labeled');

	value_labeled_fields.focus( function( e) {
		if ( typeof this.original_value == 'undefined')
		{
			this.original_value = this.value;
			this.value = '';
		} else if ( this.value == this.original_value)
		{
			this.value = '';
		}
		$(this).removeClass('value-labeled');
	});

	value_labeled_fields.blur( function( e) {
		if ( (this.value == '') && ( typeof this.original_value != 'undefined'))
		{
			this.value = this.original_value;
			$(this).addClass('value-labeled');
		}
	});
	$('img[align=left]').addClass('left');
	$('#main-menu > ul > li').mouseover( function( e) {
		$(this).addClass('hover');
	});
	$('#main-menu > ul > li').mouseout( function( e) {
		$(this).removeClass('hover');
	});
	$('form.auto-validate').validate();
	if ($("base").length) {
        // regular expression for anchor link
        var re1 = /#([\w-]+)/; // anchor parts
        var re2 = /^#([\w-]+)/; // only anchor
        // read current url
        var thisUrl = document.location.href;
        // remove anchor from current url
        thisUrl=thisUrl.replace(re1,"");
        // inicialization
        var href = '';
        var anchor = '';
        // loop all A tags whith attribute href
        $("a[href]").each(function(){
            href = $(this).attr("href");
            // check - href is anchor?
            if (re2.test(href)) {
                anchor = href.match(re2);
                $(this).attr("href", thisUrl + '#' + anchor[1]);
            }
        });
    }	
});
