

function clean_whitespace( text ) { // remove all space
	return (text || "").replace(/\s/g, "" );
}

function validateField(field) {
	var error = false;

	// remove whitespace
	$(field).val( jQuery.trim( $(field).val() ) );

	// required fields
	if ($(field).attr("class").indexOf("required") != -1) {
		if (!$(field).val().length)
			error = true;
	}
	// numeric fields
	if ($(field).val().length && $(field).attr("class").indexOf("numeric") != -1) {
		if (!/^[0-9]*$/.test($(field).val()))
			error = true;
	}
	// emails
	if ($(field).val().length && $(field).attr("class").indexOf("email") != -1) {
		if (!/^[a-zA-Z0-9]{1}([\._a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+){1,3}$/.test($(field).val()))
			error = true;
	}
	// url
	if ($(field).val().length && $(field).attr("class").indexOf("url") != -1) {
		if (!/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test($(field).val()))
			error = true;
	}

	if (error) {
		$(field).addClass("focus");
	} else {
		$(field).removeClass("focus");
	}

	return !error;
}


/* Handle 
$('a').focus( function() {
	this.blur();
});

*/

/* */
$(document).ready(function() {
	// Initial Menu
	$("ul.menu").superfish();

	$("div#Container a").each( function() {
		if ($(this).attr('href') == '#' || $(this).attr('href') == '') {
			if ( !$(this).parent().hasClass('accordion') &&
				 !$(this).parent().parent().hasClass('thumbnail') &&
				 !$(this).hasClass('next') &&
				 !$(this).hasClass('prev') ) {
				$(this).attr({href:''});
				$(this).css('cursor', 'default');
				$(this).click( function() {
					return false;
				});
			}
		}
		$(this).focus( function() {
			$(this).blur();
		});
	});

	// Back to top
	$("a.toTop").click(function() {
		$('#tbFrame').ScrollTo(300);
		return false;
	});


});