// JQUERY CUSTOM COMMANDS
var $j = jQuery.noConflict();



$j(document).ready(function() { // start javascript when document is loaded
// $() will work as an alias for jQuery() inside of this function	
	
	
	
	
	
	// Add class to last navigational element
	$j('#nav ul:first li:last').addClass('last');

	
	
	
	
	// add class to textarea P
	$j('textarea#msg').parents('p').addClass('textareaP');
	
	
	
	
	// Add stuff if post is KOEL
	$j(".screenimg span:has(a:contains('Koel'))").parent().addClass('koel');
	$j(".singlePost p.categories:has(a:contains('Koel'))").parents('.singlePost').addClass('koel');
	
	
	
	
	
	// Add link to Koele Webwinkel label, link derived from link underneath 
	$j('.screenimg.koel').click(function(event) {
		if ($j(event.target).is(":not('a')") ) {
			window.location = $j(this).find('a').attr("href");
		}
	});
	
	
	
	
	
	// Scale Sidebar if content is longer
	var lefth = $j('#leftcontent').height();
	var widgeth = $j('#widgetcontainer').height();
	if (lefth >= widgeth) {
		$j('#sidebar #widgetcontainer').height(lefth - 43).css({"background" : "url(http://www.ecommercegallery.nl/wp-content/themes/snapshot/styles/coolblue/side_back_after.gif) repeat-y 18px top"});
		$j('#content.homepage #sidebar #widgetcontainer, #content.singlePost #sidebar #widgetcontainer, #content.tag #sidebar #widgetcontainer, #content.archive #sidebar #widgetcontainer').height(lefth - 29).css({"background" : "url(http://www.ecommercegallery.nl/wp-content/themes/snapshot/styles/coolblue/side_back_after.gif) repeat-y 18px top"});
	}
	
	
	
	
	
	// Add negative class if -, add positive class if +
	$j(".ratingtext strong:contains('-')").parent().addClass('negative');
	$j(".ratingtext strong:contains('+')").parent().addClass('positive');
	
	
	
	
	/*
	// Validator overwrite
	$j.validator.messages.required = "Vul alsjeblieft het verplichte veld in";
	$j.validator.messages.author = "Vul alsjeblieft een correcte naam in";
	$j.validator.messages.email = "Vul alsjeblieft een correct e-mailadres in";
	$j.validator.messages.comment = "Vul alsjeblieft een bericht in";
	*/
	
	
	
	
	// Add author class if p contains door:
	$j("#content #leftcontent .description p:contains('door:')").addClass('author');
	
	
	

	
	/* 
	Wordt helaas in firefox en ie soms weer verwijderd huh??
	
		// Comment errors: Add class authorError if errorlabel is for author
		$j('label.error[for=author]').parent().find('label.error[for=author]').addClass('authorError');
		// Comment errors: Add class emailError if errorlabel is for email
		$j('label.error[for=email]').parent().find('label.error[for=email]').addClass('emailError');
		// Comment errors: Add class commentError if errorlabel is for comment
		$j('label.error[for=comment]').parent().find('label.error[for=comment]').addClass('commentError');
	});
	*/
	
	
	
}); // end ready function

