$(document).ready(function() {
   $("body.home div.scrollable").scrollable({
		size:1,
		prev: 'a.previous',
		next: 'a.next',
		autoplay:true,
		loop:true,
		clickable:true
	}).autoscroll({interval:5000, speed:4000, autoplay:true, steps:1 }).circular();
   
   $("body.projects div.scrollable").scrollable({
		size:1,
		prev: 'a.previous',
		next: 'a.next',
		autoplay:false,
		loop:true,
		speed:1000,
		vertical:true,
		clickable:false
	}).navigator("#main_navi").circular();
   
   	// Tooptip
	//$("ul.social_icons li a img[title]").tooltip('div.tooltip_left');
	
	// Check for iPhone orientation
	/*if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
		if(window.orientation != 0) {
			$("#background_image, #projects, #projects div.items, #projects div.project, #projects div.items, div.project img, #map").height($("#wrapper").height());	
		} else {
			$("#background_image, #projects, #projects div.items, #projects div.project, #projects img, #map").height($(document).height());	
		}
	}*/
	
	// Supersize images
	/*$.fn.supersized.options = {  
				startwidth: 5,  
				startheight: 3,
				vertical_center: 1,
				slideshow: 0,
				navigation: 1,
				transition: 0, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
				pause_hover: 0,
				slide_counter: 0,
				slide_captions: 0,
				slide_interval: 3000  
			};
	$('#supersize').supersized();*/
	
	
	$("#projects div.items div.project img").cjObjectScaler({
		destObj: $("#projects div.items div.project img").parent("div.project"), // must be a jQuery object (required)
		method: "fill", // can either be fit or fill (default fill)
		fade: 0
	});
	
	$("#supersize img").cjObjectScaler({
		destObj: $("#supersize img").parent("#supersize"), // must be a jQuery object (required)
		method: "fill", // can either be fit or fill (default fill)
		fade: 0
	});
   

	// Tooltips	
	$("a.twitter").hover(function () {$("#twitter_tooltip").show();},function () {$("#twitter_tooltip").hide();});
	$("a.flickr").hover(function () {$("#flickr_tooltip").show();},function () {$("#flickr_tooltip").hide();});
	$("a.facebook").hover(function () {$("#facebook_tooltip").show();},function () {$("#facebook_tooltip").hide();});
	$("a.blog").hover(function () {$("#blog_tooltip").show();},function () {$("#blog_tooltip").hide();});
	$("a.favourite").hover(function () {$("#favourite_tooltip").show();},function () {$("#favourite_tooltip").hide();});
	$('a.favourite').jFav();
   
   
   // Toggle Contact Form
   $("p.contact_form_mail").toggle(function(){
		$("#form_email").height(487);
		$("#form_email").slideDown("slow");
		return false;
	},
	function () {
		$("#form_email").slideUp("slow");
		return false;
	});
   
	// Fancybox
   	$("div.project a, a.fancybox").fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500
 	});

	
	// Team Profiles
	$("ul.team li, div.team_box").click(function() {$("div.team_box").hide();}); // Hide whatever is open if a box is clicked	
	$("#g_1_1").click(function() {$("#box_1_1").show();	});
	$("#g_1_3").click(function() {$("#box_1_3").show();});
	$("#g_1_5").click(function() {$("#box_1_5").show();});
	//$("#g_1_6").click(function() {$("#box_1_6").show();});
	$("#g_2_2").click(function() {$("#box_2_2").show();});
	$("#g_2_4").click(function() {$("#box_2_4").show();});
	$("#g_2_6").click(function() {$("#box_2_6").show();});
	$("#g_3_1").click(function() {$("#box_3_1").show();});
	//$("#g_3_3").click(function() {$("#box_3_3").show();});
	$("#g_3_4").click(function() {$("#box_3_4").show();});
	$("#g_3_5").click(function() {$("#box_3_5").show();});
	$("#g_3_6").click(function() {$("#box_3_6").show();});
	$("#g_4_2").click(function() {$("#box_4_2").show();});
	//$("#g_4_3").click(function() {$("#box_4_3").show();});
	$("#g_4_4").click(function() {$("#box_4_4").show();});
	$("#g_4_6").click(function() {$("#box_4_6").show();});
	$("#g_5_3").click(function() {$("#box_5_3").show();});
	$("#g_5_5").click(function() {$("#box_5_5").show();});
	$("#g_5_1").click(function() {$("#box_5_1").show();});
	$("#g_6_1").click(function() {$("#box_6_1").show();});
	$("#g_6_2").click(function() {$("#box_6_2").show();});
	$("#g_6_4").click(function() {$("#box_6_4").show();});
	$("#g_6_6").click(function() {$("#box_6_6").show();});
	
	// Projects	
	$("#p_1_1 img").hover(function () {$("p.project_title").text("crossroads, kirkham");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_1_2 img").hover(function () {$("p.project_title").text("the bars, chester");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_1_3 img").hover(function () {$("p.project_title").text("ribble valley homes' offices, clitheroe");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_1_4 img").hover(function () {$("p.project_title").text("warwick house, preston");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_1_5 img").hover(function () {$("p.project_title").text("clitheroe market");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_1_6 img").hover(function () {$("p.project_title").text("uclan architecture studio");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_2_1 img").hover(function () {$("p.project_title").text("classroom extension, kirkham grammar school");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_2_2 img").hover(function () {$("p.project_title").text("kirkham baths, kirkham");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_2_3 img").hover(function () {$("p.project_title").text("heysham, morecambe");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_2_4 img").hover(function () {$("p.project_title").text("community one - the vertical community");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_2_5 img").hover(function () {$("p.project_title").text("childrens centre, carnforth");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_2_6 img").hover(function () {$("p.project_title").text("meadow street, preston");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
   	$("#p_3_1 img").hover(function () {$("p.project_title").text("normoss pool, blackpool");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_3_2 img").hover(function () {$("p.project_title").text("shakespeare street, sunderland");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_3_3 img").hover(function () {$("p.project_title").text("ashfield court, bispham");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_3_4 img").hover(function () {$("p.project_title").text("library childrens centre, adlington");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_3_5 img").hover(function () {$("p.project_title").text("blackfield street, liverpool");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_3_6 img").hover(function () {$("p.project_title").text("willows church, kirkham");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	//$("#p_4_1 img").hover(function () {$("p.project_title").text("normoss farm, poulton");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_4_1 img").hover(function () {$("p.project_title").text("bowness avenue, blackpool");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_4_2 img").hover(function () {$("p.project_title").text("st michaels spire, kirkham");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_4_3 img").hover(function () {$("p.project_title").text("nelson court, preston");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_4_4 img").hover(function () {$("p.project_title").text("glyndwr university");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_4_5 img").hover(function () {$("p.project_title").text("morecambe football club");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_4_6 img").hover(function () {$("p.project_title").text("st annes health centre");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_5_1 img").hover(function () {$("p.project_title").text("tower wharf, chester");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_5_2 img").hover(function () {$("p.project_title").text("sports barn grange park, blackpool");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_5_3 img").hover(function () {$("p.project_title").text("docherty house, rusholme");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_5_4 img").hover(function () {$("p.project_title").text("cherry tree, blackpool");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_5_5 img").hover(function () {$("p.project_title").text("holker street, barrow-in-furness");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_5_6 img").hover(function () {$("p.project_title").text("the crib, burnley");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_6_1 img").hover(function () {$("p.project_title").text("skelmersdale library");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_6_2 img").hover(function () {$("p.project_title").text("west cliff, preston");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_6_3 img").hover(function () {$("p.project_title").text("student residence walker street, preston");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_6_4 img").hover(function () {$("p.project_title").text("elder street, rochdale");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_6_5 img").hover(function () {$("p.project_title").text("rose hill, northenden");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
	$("#p_6_6 img").hover(function () {$("p.project_title").text("whitehaven central harbour site");$("p.project_title").show();},function () {$("p.project_title").hide();$("p.project_title").text("");});
});

// Google map
$(document).ready(function() {	
  initialize();
});


$(window).resize(function() {
	 $("#projects div.items div.project img").cjObjectScaler({
		destObj: $("#projects div.items div.project img").parent("div.project"), // must be a jQuery object (required)
		method: "fill", // can either be fit or fill (default fill)
		fade: 0
	});
	
	$("#supersize img").cjObjectScaler({
		destObj: $("#supersize img").parent("#supersize"), // must be a jQuery object (required)
		method: "fill", // can either be fit or fill (default fill)
		fade: 0
	});
});


// Check orientation
/*$(document).ready(function() {	
  checkClient();
});*/
