/*******************************************************************************

	CSS on Sails Framework
	Title: Qgiv
	Author: XHTMLized (http://www.xhtmlized.com/)
	Date: October 2011

*******************************************************************************/

var Engine = {
	init: function() {
		this.forms.customFields();
	
		if(typeof $.fn.cycle !== 'undefined') {
			this.testimonials();
		}
		if(typeof $.fn.accordion !== 'undefined') {
			this.accordion();
		}
		if(typeof $.fn.tabs !== 'undefined') {
			this.tabs();
		}		
		
		this.slideshow();
	},
	
	forms: {
		customFields: function() {
			$('select').JSizedFormSelect();
			$('input[type="radio"]').JSizedFormRadio();
		}
	},
	
	testimonials: function() {
		if(!$('.testimonials').length) {
			return;
		}
		
		$('.testimonials ul')
			.after('<div class="nav" />')
			.cycle({
				fx: 'scrollLeft',
				pager: '.testimonials .nav'
			});
	},

	accordion: function() {
		$( "#accordion" ).accordion({
			autoHeight: false
		});
	},
	
	tabs: function() {
		$("#tabs").tabs();
	},
	
	slideshow: function() {
		$('a.slideshow').colorbox({
			rel:'slideshow',
			opacity: 0.7,
			current: "{current} of {total}"
		});
	}
};

$(function(){
	$('body').addClass('js');
	Engine.init();
});
