$(function(){
	
	// Add dotted lines into the feature article home group
	$('#article-groups .article-group').slice(0, 2).each(function(){ $(this).addClass('dotted'); });
	
	// Navigation highlighting - checks for the id on the body tag, if there is a related anchor using the "rel" link
	$('.rdnavigationcustomformatmenucontrol a[rel="'+ $(document.body).attr('id') +'"]').each(function(){ $(this).addClass('active'); });
	
	// Hide form labels, put the label value into input and apply a blur/focus functionality to show and hide the label
	$('#comment_form label').each(function(){
		$(this).css('display', 'block');
		var inputSelector = '#comment_form #' + $(this).attr('for');
		if( $(inputSelector).val() != '' )
			return true;
		var label = $(this).text();
		$(inputSelector).data( 'label', label );
		$(inputSelector).val( label )
		.focus(function(){
			if($(this).val() == label)
				$(this).val('');
		}).blur(function(){
			if($(this).val() == '')
				$(this).val(label);
		});
	}).hide();
	
	// OnSubmit make sure the user is submitting real info, and not the labels
	$('form#comment_form').attr( 'onsubmit', '' );
	$('form#comment_form').submit(function(){
		$(this).find( 'input,textarea' ).each(function(){
			if( $(this).val() == $(this).data( 'label' ) ){
				$(this).val( '' );
			}
		});
		var result = check( this );
		if(!result){
			$(this).find( 'input,textarea' ).each(function(){
				$(this).trigger('blur');																							 
			});
		}
		return result;
	});
	
	// Add generic CSS classes to inputs
	$('.rdpform input[type="text"], .rdpform input[type="input"], .rdpform select').each(function(){ $(this).addClass( 'standardTextField' ) });
	// Add generic CSS classes to textareas
	$('.rdpform textarea').each(function(){ $(this).addClass( 'messageAreaBox' ) });
	// Add dividers to footer navigation
	$('#menu-bottom li').each(function(){ $(this).after('<li>|</li>'); });
	$('#menu-bottom li:last').remove();
	// Add dividers to footer navigation
	$('#breadcrumb li').each(function(){ $(this).after('<li class="divide">»</li>'); });
	$('#breadcrumb li:last').remove();
	
});
