//Slider switching function
function switch_networks(){
		$("#supported-networks ul li:visible").fadeOut(500, function(e){
			if ($(this).next().is('li')){
				$(this).next().fadeIn(500);
			}
			else{					
				$(this).parent().find("li:first").fadeIn(500);
			}
		
		});
	}

$(document).ready(function(){
	
	//Hide other slides except for first one		
	$("#supported-networks ul li").not("#supported-networks ul li:first-child").hide();

	//Add overlay for main menu
	$("#menu li a").each(function(){
		$(this).append('<span class="overlay"></span>');			
	});	
	//Hide the overlay, only let selected item's overlay be visible	
	$("#menu li a .overlay").hide();
	$("#menu li.current_page_item a .overlay").fadeTo(1,0.07);		
	
	//Handle onmousein/out
	$("#menu a").hover(
		function(){				
			$(this).find('.overlay').fadeTo(300,0.07);
		},
		function(){
			if($(this).parent().hasClass('current_page_item') == false){
				$(this).find('.overlay').fadeTo(200,0.00);
			}
		}
	);
	
	
	$('h2, h3, #navigation div a').each(function(){
		$(this).wrapInner('<span class="title" />');
		$(this).append('<span class="shadow">'+$(this).text()+'</span>');
	});
	
	
	
	//Initialize cufon
	Cufon.replace('h2,h3');
	
	//Initiliaze slider	- only homepage and if there is more than 1 slide	
	if ($('body').hasClass('homepage') && $('#supported-networks ul li').size() > 1){
		var supported_networks = setInterval("switch_networks()", 5 * 1000);
	}
	
	
	$('.homepage .blog .post:last-child, #sidebar .widget:last-child, #sidebar .blog .post:last-child').addClass('last');
	

	
	$('.credentials input.password').focus(function(){								 
		$(this).prev('.overlay').hide();	
	});
	
	$('.credentials .overlay').click(function(){								 
		$(this).hide();	
		$(this).next('.password').focus();
	});
	
	
	$('#register .marketing input[name=all]').change(function(){		
			$(this).parents('table').find('input').attr("checked",$(this).attr("checked"));	
	});
	
	
	
	$('select').uniform({ useID: false});
	
	
	
	
	
	
	
	
});	