/*
File name: Surftide global javascript file
Version: 1.0
Author: Ben Ellis
Author URI: http://www.hungrybrowser.co.uk
Created: 15/10/2009
Updated: 15/10/2009
*/

// FUNCTION TO SCROLL THE PAGE
function scrollPage(target){
	$.scrollTo(target,1500);
}

// ATTACH EVENTS FOR THE MAIN NAV EFFECT
$(document).ready(function(){
	generateSprites(".main_nav", "current-", true, 250, "fade");
});

// ATTACH EVENTS FOR OPACITY
$(document).ready(function(){
	$('#caption').css('opacity',0.75);
	$('#iphone').css('opacity',0.75);
	$('#widget').css('opacity',0.75);
	$('#controls').css('opacity',0.85);
});

// ATTACH EVENTS FOR SIDEBAR ITEMS
$(document).ready(function(){
	// Attach attributes for Flickr
	$('ul#flickr a').each(function() {
		$(this).attr('rel','prettyPhoto[flickr]');
		var imgSrc = $(this).children().attr('src');
		$(this).attr('href',imgSrc.replace('_s.jpg','.jpg'))
	});
	// Attach attributes for Vimeo
	
	$('div#vimeo a').each(function() {
		$(this).attr('rel','prettyPhoto[vimeo]');
		var videoUrl = $(this).attr('href');
		$(this).attr('href',videoUrl.replace('http://vimeo.com/','http://vimeo.com/moogaloop.swf?flashvars=clip_id='))
	});
	// Attach attributes for YouTube links
	$('div#youtube a').each(function() {
		$(this).attr('rel','prettyPhoto[youtube]');
	});
	// Run the Prettyphoto script
	$("a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_rounded'});
});


// ATTACH EVENTS FOR SHOW/HIDE MODULES
$(document).ready(function(){
	
	$("#module_3").hide();
	//$("#module_5").hide();
	$("#module_6").hide();

	$(".expandable").toggle(function(){
		$(this).addClass("active"); 
		}, function () {
		$(this).removeClass("active");
	});
	
	$(".expandable").click(function(){
		$(this).next(".container").slideToggle("slow,");
	});
});
