
jQuery(document).ready(function() {
    jQuery.easing.def = "easeInOutQuad";
	jQuery('#infoCarousel').jcarousel({
    // Config here
	animation:800,
	scroll:1

    });
});

// modified from JK's 24Ways article, renders the title tag of the blockquote - needs jqueryfying - todo 

jQuery(document).ready(function() {
	if (!document.getElementsByTagName || !document.createElement || !document.appendChild) return;
	var quotes = document.getElementsByTagName("blockquote");
	for (var i=0; i<quotes.length; i++) {
		var source = quotes[i].getAttribute("title");
		if (!source) continue;
		var span = document.createElement("span");
		span.className = "attribution";
		span.appendChild(document.createTextNode(source));
		quotes[i].appendChild(span);
	}
	});


// form helper, showing and hiding fields depending on choices

jQuery(document).ready(function() {
	
	$(".telephone").hide();
	$(".skypeName").hide();
	$(".imAddress").hide();
	clearValue('email');
	checkValue('#telephone');
	checkValue('#skypeName');
	checkValue('#imAddress');
	
	
	//email radio button
	$("#respond01").click(function() {					  
		
		clearValue('email');
		checkValue('telephone');
		checkValue('skypeName');
		checkValue('imAddress');
		
		});
	
	//telephone radio button
	$("#respond02").click(function() {					  
		
		checkValue('email');
		clearValue('telephone');
		checkValue('skypeName');
		checkValue('imAddress');

		
		});
	
	//telephone radio button
	$("#respond03").click(function() {					  
		
		
		checkValue('email');
		checkValue('telephone');
		clearValue('skypeName');
		checkValue('imAddress');

		
		});
	
	//telephone radio button
	$("#respond04").click(function() {					  
		
		
		checkValue('email');
		checkValue('telephone');
		checkValue('skypeName');
		clearValue('imAddress');

		
		});
	
	// value checkers
	function clearValue(fieldId){
			$("."+fieldId).hide();
			if($("#"+fieldId).attr("value")=="Please enter" || $("#"+fieldId).attr("value")=="youremail@yourdomain.com"){
					$("#"+fieldId).attr({ 
					  value: ""
					});	
				}
			$("."+fieldId).show();
			}
			
	function checkValue(fieldId){
		$("."+fieldId).hide();
		if($("#"+fieldId).attr("value")==undefined){
			//alert("inserting default into " + fieldId)
				if (fieldId !== "email") {$("#"+fieldId).attr({ 
				  value: "Please enter"
				});	
				}
				else {
					$("#"+fieldId).attr({ 
				  value: "youremail@yourdomain.com"
				});	
					}
			}
		
		}
	
});

// form animation

$(document).ready(function() {
    $("#shoutbox").validate({
	 submitHandler: function(form) {
	  $(".submissionSuccess").after("<span id='ajaxLoader'>Loading...</span>");
	  $.post('/shoutbox/outbox.php',$("#shoutbox").serialize(),function(data,status){
     		$(".submissionSuccess").animate({opacity: 0}, 100 , function(){
			$(".submissionSuccess").css( {display: 'block'} );
			if (data == "Marvellous, we can take it from here "){
				$("#ajaxLoader").animate({opacity: 0}, 600);
				$(".submissionSuccess").html("<h3>"+data+"</h3>");
				$(".submissionSuccess").animate({opacity: 1}, 600);
				$(".contactUsForm").animate({opacity: 1}, 2000);
				$(".contactUsForm").animate({marginLeft: "1000px"}, 1900,"easeInExpo",  function(){
				 $(".primaryAction").animate({opacity: 0}, 600, function(){ $(".primaryAction").hide()});
				 $(".contactUs").slideUp();
				   });
				}
			else {
				$(".submissionSuccess").html("<h3>Oh no, something's gone squiffy.</h3><p>"+data+" We have received an error report and will do our best to fix this problem as quickly as possible. If you have an urgent enquiry please email alexander.stevens@flukelondon.co.uk. <a id='closeSub' href='javascript:;'>Close</a></p>");
				$(".submissionSuccess").animate({opacity: 1}, 600);
				$("#closeSub").click(function() {
											  $(".submissionSuccess").css( {display: 'none'} );
											  $("#ajaxLoader").animate({opacity: 0}, 600);
											   });
				}
			
			}); 

   });
   return false
	 }
	});
})

/* dom script to hide dd tags and call in a callout*/

jQuery(document).ready(function() {	
$(".ourServices dd").hide();
$(".ourServices dd").css({'position':'absolute', 'width': '203px', 'height':'106px', 'background':'url(../../_interface/callout.png) top left no-repeat','margin-left':'240px','margin-top':'-65px'});
$(".ourServices dt").hover(function(){
	$(this).next().show();
	$(".ourServices dd").hover(function(){
	$(this).show();
	},
	function (){
	$(this).fadeOut();
	});
	
	},
	function (){
	$(this).next().hide();
	});
});

/* dom script to show alt tags in a callout*/

/*jQuery(document).ready(function() {	
	$(".calloutAlt").hover(
      function () {
		 var calloutText = $(this).attr("alt");
		 $(this).css({'cursor':'pointer'});
         $(this).before($("<span class='calloutText'><span class='outer'><span class='inner'>"+calloutText+"</span></span></span>"));
		
      }, 
      function () {
       $(".calloutText").remove();
      }
    );
								
});*/

jQuery(document).ready(function() {	
$(".pastClients dd").hide();
$(".pastClients dt").hover(function(){
	$(this).next().show();
	$(".pastClients dd").hover(function(){
	$(this).show();
	},
	function (){
	$(this).hide();
	});
	
	},
	function (){
	$(this).next().hide();
	});
});

/*jQuery(document).ready(function() {	
	$(".calloutAlt").hover(function(){
		var calloutText = $(".calloutAlt").attr("alt");
		$(".calloutAlt").after("<span>"+calloutText+"</span>");
	});
});*/
/*
jQuery(document).ready(function() {	
$(".pastClients dd").hide();
$(".pastClients dd").css({'position':'absolute', 'clear':'left','width': '197px', 'height':'79px', 'background':'url(_interface/callout-homepage.gif) top left no-repeat'});
$(".pastClients dt").hover(function(){
	$(this).next().show();
	$(".pastClients dd").hover(function(){
	$(this).show();
	},
	function (){
	$(this).fadeOut();
	});
	
	},
	function (){
	$(this).next().hide();
	});
});
*/
/*Userfuly functions*/


jQuery(document).ready(function() {	
var userflyHost = (("https:" == document.location.protocol) ? "https://secure.userfly.com" : "http://asset.userfly.com");
$("head").append(unescape("%3Cscript src='" + userflyHost + "/users/22261/userfly.js' type='text/javascript'%3E%3C/script%3E"));						
	});


/*tabs*/
jQuery(document).ready(function() {	
$(function() {
		$("#tabs").tabs({ fx: { opacity: 'toggle' } });
	});
});

jQuery(document).ready(function() {	
									
									if (!document.getElementsByTagName) return false;
									/*Determines whether the page is using a secure or unsecure protocol*/
									var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
									/*Writes in the script to the document head*/
									var gaScript = document.createElement("script");
									gaScript.setAttribute("src",gaJsHost +"google-analytics.com/ga.js");
									gaScript.setAttribute("type","text/javascript");
									var domHead = document.getElementsByTagName("head")[0]
									domHead.appendChild(gaScript);
										
										function callGA(){   
										var pageTracker = _gat._getTracker("UA-5252276-1");
										pageTracker._initData();
										pageTracker._trackPageview();
										}
									setTimeout(callGA,2000)
	
								
								});

$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			padding: 40, /* padding for each side of the picture */
			opacity: 0.6, /* Value betwee 0 and 1 */
			showTitle: false, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: ' of ', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
		});
	});





