$("document").ready(function(){

	Cufon.replace('#header ul li a, h1, h2, h3, h4, #header .sidebar li, #trail p, .blog-article-left',  { hover: true});

	// is firefox?

	if (typeof document.body.style.MozBoxShadow === 'string') {

	$("#homespin > div").css("top", "201px");	

	}

	var homeSpinner = $("#homespin div img");



	$("#homespin > a").click(function(){

				// check for ie, if ie just link through to relevant pages

				if(jQuery.support.htmlSerialize){

					var rotation;

					switch($(this).attr('id')){

					

						case 'work':

						rotation = "124deg";

						break;

						case 'why':

						rotation = "-116deg";

						break;

					

					}

					

					homeSpinner.animate({rotate: rotation, 'margin-top': 80}, 1000);			   

					return false;

									  }

								   });

	$('#trophycabinet a').mouseenter(function(){
										 
										 var awardsListActive = $("#awardlist").hasClass("active"); 
										 if($(this).attr("id") != "seeall"){
											 if($(this).attr("id") != "close"){
										 	if(!awardsListActive){
										 var divNumber = $(this).attr('class');
										 $('#trophycabinet #' + divNumber +'').fadeTo('slow', 0.8);
										 }}}
										 }).mouseleave(function(){
											 var awardsListActive = $("#awardlist").hasClass("active");
											 if($(this).attr("id") != "seeall"){
												  if($(this).attr("id") != "close"){
												 										 	if(!awardsListActive){

											 var divNumber = $(this).attr('class');
											 $('#trophycabinet #' + divNumber + '').fadeTo('slow', 0);
											 
											 }}}
											 
										 });

$("#seeall").click(function(){
							
							$("#awardlist").animate({"height": 305, "opacity":1}, 500).addClass("active");
							$("#close").css("display", "block");
							return false;
							
							});

$("#close").click(function(){  
						   
						   $("#awardlist").animate({"height": 0, "opacity":0}, 500).removeClass("active");
							$("#close").css("display", "none");
							return false;
						   
						   
						   });

							$("#service-jars ul").fadeOut("fast", function(){  $("#relationingredients").fadeIn("fast"); });

							 $('#service-jars a').mouseenter(function(){
															   
											var jarType = $(this).attr("id");
											var up;
											var down;
											if(jarType == 'jarrelations'){ 
											up = 'jarrelations'; down = 'jarcreative';
											
											$('#' + down +' img').animate({ 'width': 200, 'top':79, 'left':286}, 300, function(){
												$('#' + up +' img').animate({'top':7, 'width': 276}, 300).css('z-index', 7);
														$("#creativeingredients").fadeOut("fast", function(){ $("#relationingredients").fadeIn("fast"); });							 
																												
																	   }).css('z-index', 6);
											}
											else{ down = 'jarrelations'; up = 'jarcreative';
																		 
											$('#' + down +' img').animate({ 'width': 200, 'top':79}, 300, function(){
												$('#' + up +' img').animate({'top':7, 'width': 276, 'left': 200}, 300).css('z-index', 7);
																					 
																	$("#relationingredients").fadeOut("fast", function(){ $("#creativeingredients").fadeIn("fast"); });											
																	   }).css('z-index', 6);
											
											}
											
											
																	   });
							 
							 $('#footer-second div div img').css('opacity', 0.5);
							$('#footer-second div div img').mouseenter(function(){
																				
																				$(this).fadeTo('fast', 1);
																				
																				}).mouseleave(function(){
																									  
																					$(this).fadeTo('fast', 0.5);				  
																									  
																									  });
});
