/*nifty corners layout*/

$(document).ready(function(){
	Nifty("div#header");
	Nifty("ul#nav a","small transparent");	
	Nifty("div#container");
	Nifty("div#breadcrumb");
	Nifty("div#content,div#sidebar","same-height small");
	Nifty("div#about","transparent");
	Nifty("div.sidebar_nav h3","transparent");
	Nifty("div#footer","transparent");	

	$('img[@src$=.png]').ifixpng();	
	
	Date.firstDayOfWeek = 7;
	Date.format = 'mm/dd/yyyy';
	/* use this to enable a click on the input box to activate calendar: clickInput:true */
	$(function(){
		$('.date-pick').datePicker({startDate:'01/01/1900'});
	});

	$('a').track();
});

jQuery(function($) { $('ul.gallery').galleria(); });


$(function() {
	var validator = $("#commentForm").submit(function() {
		// update underlying textarea before submit validation
		tinyMCE.triggerSave();
	}).validate({
		rules: {
			title: "required",
			content: "required",
			honey: {
			       required: false,
			       maxlength: 0
			}

		},
		errorPlacement: function(label, element) {
			// position error label after generated textarea
			if (element.is("textarea")) {
				label.insertBefore(element.next());
			} else {
				label.insertAfter(element)
			}
		}
	});
	if(validator){
		validator.focusInvalid = function() {
			// put focus on tinymce on submit validation
			if( this.settings.focusInvalid ) {
				try {
					var toFocus = $(this.findLastActive() || this.errorList.length && this.errorList[0].element || []);
					if (toFocus.is("textarea")) {
						tinyMCE.get(toFocus.attr("id")).focus();
					} else {
						toFocus.filter(":visible").focus();
					}
				} catch(e) {
					// ignore IE throwing errors when focusing hidden elements
				}
			}
		}
	}
});

