/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */

(function($) {
	/**
	 * equalizes the heights of all elements in a jQuery collection
	 * thanks to John Resig for optimizing this!
	 * usage: $("#col1, #col2, #col3").equalizeCols();
	 */

	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie && $.browser.version < 7 ? "1%" : "auto";

		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, this.offsetHeight);
			})
			.css("height", height)
			.each(function() {
				var h = this.offsetHeight;
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});

	};

})(jQuery);

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

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

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


$(document).ready(function() {

	// navigation with sub
	$('#navigation > ul > li').has('ul').addClass('withsub');

	//
	$('#content .column3 .slideshow-wrapper .slides').cycle({
		timeout: 6000,
		pager:  '#content .column3 .slideshow-wrapper nav'
	});

	//
	$('#content .column2 p').cycle({
		timeout: 6000,
		cleartypeNoBg: true
	});

	//
	$( ".login-wrapper .login-wrapper2 .login .field.checkbox input" ).button();

	//
	$( ".login-wrapper .login-wrapper2 .login .login-button").click(function(){
		$( ".login-wrapper").toggleClass('on');
		$( ".login-wrapper-bg").toggleClass('on');
	});

	//
	$('#navigation > ul > li > ul').slideUp(0);
	$('#navigation > ul > li').hover(
		function () {
			$(this).children('ul').slideDown(300);
		},
		function () {
			$(this).children('ul').slideUp(300);
		}
	);


	if (($.browser.msie) && ($.browser.version <= "9.0")) {

		//
		$('input[placeholder], textarea[placeholder]').placeholder();

		var CSS3PIE_selectors = [
			'#content .column2 p',
			'#navigation .top li ul',
			'#navigation > .top > li > a'
		];
		$( CSS3PIE_selectors.join(',') ).each( function() {
			PIE.attach(this);
		});

	}

});

$(window).load(function() {

	//
	//$("#sidebar, #content").equalizeCols();

});


