/* 
 	Script: Default
	Project: AMA Sound
	Author: CMT Studio
	Last Update: March 2010
	
	Table of Contents:

						GLOBAL
						LAYOUT

*/



$(document).ready(function() { 
	
	Cufon.replace('header.global nav h1');
	
	// Global navigation animation (don't show for IE7)
	if (! $.browser.msie || ($.browser.msie && $.browser.version > 7)) {
	    $('ul.global-nav').superfish({
			delay: 600,
			autoArrows: false
		});
	}
    
	// Fade slider on navigation hover
	var fadeSpeed = 'slow';
	$('ul.global-nav').hover(function() {
		$('div#slider').fadeTo(fadeSpeed, 0.7);
	}, function() {
		$('div#slider').fadeTo(fadeSpeed, 1).dequeue();
	});
	
	// Rotate the slides
	var switchSpeed = 5000;
	$("#slide-switcher").tabs({fx:{opacity: "toggle"}}).tabs("rotate", switchSpeed, true);

	// Pause slide rotation on mouse over
	$("#slider").hover(  
		function() {  
			$("#slide-switcher").tabs("rotate",0,true);  
		},  
		function() {  
			$("#slide-switcher").tabs("rotate",switchSpeed,true);    
		}
	);
	
	// Animate footer list items on hover
	var listSpeed = 70;
	$('nav.latest-articles li a, nav.latest-partners li a, aside.sidebar li a').hover(function(){
		$(this).animate({'marginLeft': '5'}, listSpeed, 'linear');
		$(this).children('img').animate({'marginLeft': '-5'}, listSpeed, 'linear');
	}, function(){
		$(this).animate({'marginLeft': '0'}, listSpeed, 'linear').dequeue();
		$(this).children('img').animate({'marginLeft': '0'}, listSpeed, 'linear');
	});
	
	// Fade "What we use" thumbnails
	var dlFade = 0.5;
	var dlFadeSpeed = 300;
	$('.footer-top dt, .studio-thumbs img').fadeTo(dlFadeSpeed, dlFade);
	$('.footer-top dt, .studio-thumbs img').hover(function() {
		$(this).fadeTo(dlFadeSpeed, 1);
	}, function() {
		$(this).fadeTo(dlFadeSpeed, dlFade).dequeue();
	});
	
	// Form toggle
	var formSpeed = 300;
	$('form.order-form fieldset.slide ul').hide(); // first hide everithing
	$(':checked').siblings('ul').show(); // if the form was submitted with h2 checked, show its content
	
	$('input.toggler').bind('click', function() { // toggle
		if( $(this).is(':checked') ) {
			$(this).siblings('ul').show();
		}
		else {
			$(this).siblings('ul').hide();
		}
	});
	
	// New instrument input
	$('input#enter-new').hide(); // first hide it
	$('input#new-instrument:checked').siblings('input').show(); // if the checkbox was submitted, show the text field
	
	$('input#new-instrument').bind('click', function(){ // toggle
		if( $(this).is(':checked') ) {
			$(this).siblings('input').fadeIn();
		}
		else {
			$(this).siblings('input').fadeOut();
		}
	});
	
	// Remove last list bullet on faq >> address
	$('div.inner-page article ul ul').parent('li').css({ 'list-style' : 'none'});
}); 
