$(document).ready(function() {

	///Header - Main nav
	$("nav.main-nav ul").superfish({
		delay: 500,
		autoArrows:  false,
		dropShadows: false,
		animation: { opacity:'show', height:'show' },
		speed: 'fast'
	});
	$("nav.main-nav ul li ul").superfish({
		delay: 500,
		autoArrows:  false,
		dropShadows: false,
		speed: 'fast'
	});
	/*
$('nav.main-nav ul li ul li a').hover(function(){
		$(this).stop(true, false).animate({
			paddingLeft: '20px',
			paddingRight: '0',
			backgroundColor: '#bcc0c2'
		}, 'fast');
	}, function(){
		$(this).animate({
			paddingLeft: '10px',
			paddingRight: '10px',
			backgroundColor: '#d1d6d8'
		}, 'fast');
	});
*/

	//Shadows
	$('.main-nav').after('<div class="main-nav-shadow"></div>')
	$('.related-nav ul').after('<div class="related-nav-shadow"></div>')
	
	//Tabs
	$("#tabs").tabs({ fx: { height: 'toggle', opacity: 'toggle' } });
	
	//Tags
	$('#tabs .tags a').hover(function(){
		$(this).stop(true, false).animate({
			backgroundColor: '#ebeff2'
		}, 'fast');
	}, function(){
		$(this).animate({
			backgroundColor: '#fff'
		}, 'fast');
	});
	
	//UL.list
	$('#main .list li, #main .xoxo li').hover(function(){
		$(this).stop(true, false).animate({
			paddingLeft: '10px',
			backgroundColor: '#ebeff2'
		}, 'fast');
	}, function(){
		$(this).animate({
			paddingLeft: '0',
			backgroundColor: '#fff'
		}, 'fast');
	});
	$('footer .list li, footer .xoxo li, footer .footer-nav li').hover(function(){
		$(this).stop(true, false).animate({
			paddingLeft: '10px'
		}, 'fast');
	}, function(){
		$(this).animate({
			paddingLeft: '0'
		}, 'fast');
	});
	$('#listing .list-alt li').hover(function(){
		$(this).stop(true, false).animate({
			backgroundColor: '#ebeff2'
		}, 'fast');
	}, function(){
		$(this).animate({
			backgroundColor: '#fff'
		}, 'fast');
	});
	
	//Clear
	$('.list li, .list-alt').addClass('clearfix');
	$('footer #footer-image, #comments-list li, .related-nav ul, .pagination-nav ul').after('<div class="clear"></div>');
	
	//Wrap
	$('.more').wrapInner('<span />');
	$('ol li').wrapInner('<p />');
	$('iframe').wrap('<div class="iframe"></div>');
	
	//Toggle
	$('.toggle-content').hide();
	$('.toggle-button').click(function() {
		if($(this).hasClass('active') == true) {
			$(this).removeClass('active');
			$(this).next('.toggle-content').slideUp(0);
		}
		else { 
			$(this).addClass('active');
			$(this).next('.toggle-content').slideDown(0);
		}
	});
	$('.toggle-button').mouseover(function() {
		$(this).addClass('hover');
	}).mouseout(function() {
		$(this).removeClass('hover');										
	});
	$('.toggle-content').hide();
	
	//Form submit & validation
	$("#comment-form-submit").click(function() {
		$("#comment-form").submit();
	});
	$("#comment-form").validate();
	$("#contact-form-submit").click(function() {
		$("#contact-form").submit();
	});
	$("#contact-form").validate();
	
});
