$(window).bind('load', function() {
	//$('#slideshow img').protectImage();
});

$(document).ready(function(){
	
	//body css
	/*$("#outer").css({"padding-top":getPageHeight()+"px"});
	
	$(window).resize(function(){
		$("#outer").css({"padding-top":getPageHeight()+"px"});
	});*/
	
	
	
   /*pages with slide down class*/
   $(".slide_down").hide();
   $(".slide_down").slideDown("slow",function(){
   		$(".slide_down").css({background: "#fff" });
	});
	
   /*pages with fade class*/
   $(".fade").hide();
   $(".fade").fadeOut("slow",function(){
   	   $(".fade").css({background: "#fff" });
   });
   
   /*pages with show class*/
   $(".show").hide();
   $(".show").show("slow",function(){
   	   $(".show").css({background: "#fff" });
   });
   
  /*slide show for two column pages */
  $('#slideshow').after('<div class="clearboth fw" style="height:1px"></div><ul id="nav">').cycle({ 
    fx:     'scrollHorz', 
    speed:  'slow', 
    timeout: 0
    });
    
    
	$('#slideshow').cycle({ 
	    fx:     'scrollHorz', 
	    speed:  'slow', 
	    next:   '#slideshow', 
	    timeout: 0 , 
   		pager:  '#nav', 
    	// callback fn that creates a thumbnail to use as pager anchor 
    	pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a id="'+(idx+1)+'" href="#"><img src="' + slide.src + '" class="anchorimage" /></a></li>'; 
    	} 
	});
	
	
	$('#slideshow') .find('img').click( function() { 
		$("#nav li a").removeClass("activeSlide");
		var id = $(this).attr("id");
		id = parseInt(id) + 1;
		$("#nav").find('#' + id + '').addClass("activeSlide");
	
	} );
	
	$('#slideshow') .find('img').change( function() { 
		$("#nav li a").removeClass("activeSlide");
		var id = $(this).attr("id");
		id = parseInt(id) + 1;
		$("#nav").find('#' + id + '').addClass("activeSlide");
	
	} );
	
	
	var $counter=1; 
	/**slide show for home page big image **/
	$(function() {
	    
	    $('#blindY').cycle({
	       fx:     'blindY',
	       speed:   1000,
	       timeout: 6000,
	       delay:  -2000,
	       cssBefore: { opacity: 1 },
       	   animOut:   { opacity: 0 }
	    });
	    
	    /**and small images **/
	    $('#blindY1').cycle({
	       fx:     'blindY',
	       speed:   1000,
	       timeout: 6000,
	       delay:  -2000
	    });
	    
	    $('#blindY2').cycle({
	       fx:     'blindY',
	       speed:   1000,
	       timeout: 6000,
	       delay:  -2000,
	       cssBefore: { opacity: 1 },
       	   animOut:   { opacity: 0 }
	    });
	    
	    $('#blindY3').cycle({
	       fx:     'blindY',
	       speed:   1000,
	       timeout: 6000,
	       delay:  -2000,
	       cssBefore: { opacity: 1 },
       	   animOut:   { opacity: 0 }
	    });

	});
	
	
   /*  testimonials page animation */
   
   $('#blindY_testimonials').after('<ul id="nav_testimonials">').cycle({ 
	    fx:     'scrollHorz', 
	    speed:  'slow', 
	    timeout: 0, 
	    next:   '#blindY_testimonials img',
	    pager:  '#nav_testimonials', 
	     
	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#"><img src="' + slide.src + '.thumb.jpg" width="237" height="41" /></a></li>'; 
	    } 
   });
   

	/** mouse hove on other bottoms **/
	//services pages
	$(".small_identity_brentwalsh").hover(function(){
	  $(this).attr({ src: "images/services/identity/identity_brentwalsh_hover.jpg", alt: "Brent Walsh"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/identity/identity_brentwalsh.jpg", alt: "" });
	});
	
	$(".small_identity_jellyfish").hover(function(){
	  $(this).attr({ src: "images/services/identity/identity_jellyfish_hover.jpg", alt: "Jellyfish"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/identity/identity_jellyfish.jpg", alt: "" });
	});
	
	$(".small_identity_williamgrant").hover(function(){
	  $(this).attr({ src: "images/services/identity/identity_williamgrant_hover.jpg", alt: "William Grant &amp; Sons"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/identity/identity_williamgrant.jpg", alt: "" });
	});
	
	$(".small_identity_bullet").hover(function(){
	  $(this).attr({ src: "images/services/identity/identity_bullet_hover.jpg", alt: "Bullet"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/identity/identity_bullet.jpg", alt: "" });
	});
	
	//services print
	$(".small_print_williamgrant").hover(function(){
	  $(this).attr({ src: "images/services/print/print_williamgrant_hover.jpg", alt: "Brent Walsh"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/print/print_williamgrant.jpg", alt: "" });
	});
	
	$(".small_print_virgin").hover(function(){
	  $(this).attr({ src: "images/services/print/print_virgin_hover.jpg", alt: "Jellyfish"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/print/print_virgin.jpg", alt: "" });
	});
	
	$(".small_print_pernod").hover(function(){
	  $(this).attr({ src: "images/services/print/print_pernod_hover.jpg", alt: "William Grant &amp; Sons"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/print/print_pernod.jpg", alt: "" });
	});
	
	$(".small_print_bonne").hover(function(){
	  $(this).attr({ src: "images/services/print/print_bonne_hover.jpg", alt: "Bullet"}) 
	  },
	  function(){
	  $(this).attr({ src: "images/services/print/print_bonne.jpg", alt: "" });
	});
	
	
	//function to have alt by getting a class called hover
	$(".service_hover").hover(function() {
	  var xx = $(this).attr("hover");
	  var normalimg = xx+".jpg";
	  var hoverimg = xx+"_hover.jpg";
 
	  $(this).attr({ src: hoverimg, alt: ""}) 
	  },
	  function(){
	    var xx = $(this).attr("hover");
	    var normalimg = xx+".jpg";
	    var hoverimg = xx+"_hover.jpg";
	   $(this).attr({ src: normalimg, alt: ""});
	});
	
	
	
	
	
	/* contact us page*/
	$("#map_logo_link").click(function(){
		$("#map").css({"display":"block"});
	});
	
	$("#gmap").click(function(){
		$("#map").css({"display":"block"});
	});
	
}); //end of it



function getPageHeight()
{
	var windowHeight = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
	var pagetop = (windowHeight - 614)/2;
	if(pagetop<0) {
	pagetop=0; 
	}
	return pagetop;
}