	$(document).ready(function() { 
		jQuery.fx.interval = 1000;

		$(window).resize(function() {
			backgroundFill();
		});	
		
		if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
		{
			$("#image-navigation").css("position", "absolute");
			$("#image-pagination").css("position", "absolute");
			$("#background").css("position", "absolute");
			$("#footer").css("position", "absolute");
			
			var wrapHieght = $("#wrap").height();

			if (wrapHieght <= 1300) {
				$("#wrap").css("height",1300);
				$("#image-navigation").css("top",1268);
				$("#footer").css("top",1300);
			} else {
				$("#footer").css("top",$("#wrap").height());
			}
			  
			$("#image-pagination").width(1300);	
			$("#image-navigation").width(1300);	
			$("#footer").width(1300);	
		};		
		
		if($.browser.msie && $.browser.version=="6.0") {
			$('<div></div>').insertAfter('#header-alpha');		
			
			$('#footer').fadeIn(1000, function(){
				$(this).css('filter','');
			});				
		}		
		
		$("#loading").width($(window).width());	
		$("#loading").height($(window).height());			
				
		$("#project-description .toggle, #project-description .toggle-title").click(function() {
			$("#project-description .toggle").toggleClass("min");
			$('#project-artist-hidden').slideUp('slow');
			
			$('#project-artist .min').removeClass("min");
			$('#project-description-hidden').slideToggle('slow');
		});		
		
		$("#project-artist .toggle, #project-artist .toggle-title").click(function() {
			$("#project-artist .toggle").toggleClass("min");
			$('#project-description-hidden').slideUp('slow');
			
			$('#project-description .min').removeClass("min");
			$('#project-artist-hidden').slideToggle('slow');
		});
		
		$("#playvideo").click(function() {
			$("#project-video").show();
		});
		
		$("#project-video .close").click(function() {
			$("#project-video").hide();
		});

		$("#project-description,#project-artist").hoverIntent({
			over: makeVisible,
			timeout: 1000,
			out: makeOpaque 
		});
		
		$("#header-beta-navigation ul li").hoverIntent({
			over: level1MenuShow,
			timeout: 200,
			out: level1MenuHide 
		});		
		
		$("#header-beta-navigation ul li ul li").hoverIntent({
			over: level2MenuShow,
			timeout: 200,
			out: level2MenuHide 
		});			

		$("#header-beta-navigation ul li ul li ul li").hoverIntent({
			over: level3MenuShow,
			timeout: 200,
			out: level3MenuHide 
		});	
		
		$(".resize").backgroundScale({
			imageSelector: ".mode_fill",
			centerAlign: true,
			containerPadding: 0
		});			
				
		$('.grid-images,.grid-images-small').cycle({                            
			timeout: 200,
			delay:  1, 
			speed:  800
		}).cycle("pause").hover(function() {
			$(this).cycle('resume');
		},function(){
			$(this).cycle(0); 
			$(this).cycle('pause');				
		});	

		$(".Actions input").hover(
		  function () {
			$(this).css('background-color','#9AA7A0');
		  }, 
		  function () {
			$(this).css('background-color','#465651');
		  });
		  
		swapValue = [];
		$("#Search-Terms").each(function(i){
		   swapValue[i] = $(this).val();
		   $(this).focus(function(){
			  if ($(this).val() == swapValue[i]) {
				 $(this).val("");
			  }
			  $(this).addClass("focus");
		   }).blur(function(){
			  if ($.trim($(this).val()) == "") {
				 $(this).val(swapValue[i]);
			 $(this).removeClass("focus");
			  }
		   });
		});	
		
		$("#hero-images").jcarousel({
			scroll: 1,
			initCallback: carousel_initCallback,
			buttonNextHTML: null,
			buttonPrevHTML: null 				
		});
		
        $("#Search input, input#Form_Form_Quantity").click(function() {
                $(this).attr("value","");
        });		
			
		function carousel_initCallback(carousel) {
			jQuery('#hero-thumbs-inner a').bind('click', function() {
				carousel.scroll(jQuery.jcarousel.intval(jQuery(this).attr('class')));
				return false;
			});
		}; 
		
		$('#sets ul li.category a').click(function() {
			$('#sets ul li.category a').removeClass('current');
			$(this).addClass('current');
		});

	});	
	
	function gotoslide(slide) {
		$('.cycle-project').cycle(slide-1); 
	}
		
	function onBefore() { 
		$('#footer-gamma p').html(this.alt); 
	}; 	
	
	function CatLoad(categoryname) {		
		var slideFound = false;
		$(".cycle-project img").each(function(i){
		
			var currentSection = $(this).attr('rel');
		
			if (currentSection == categoryname && slideFound == false) {
				$('.cycle-project').cycle(i);
				slideFound = true;
			}
		});			 
	}	
	
	function makeVisible() {
		$(this).fadeTo(100,1);
	}
	
	function makeOpaque() {
		$(this).fadeTo('slow',0.75);
	}	

	
	function level1MenuShow() {
		$(this).children('ul.first_level').fadeIn("fast");
	}
	
	function level1MenuHide() {
		$(this).children('ul.first_level').hide();
	}

	function level2MenuShow() {
		$(this).siblings().children("a").removeClass('current');
		$(this).children('ul.second_level').show();
	}
	
	function level2MenuHide() {
		$(this).children("a").removeClass('current');
		$(this).children('ul.second_level').hide();
	}	

	function level3MenuShow() {
		$(this).siblings().children("a").removeClass('current');
		$(this).children('ul.third_level').show();
		$(this).children('ul.third_level li a').removeClass('current');
	}
	
	function level3MenuHide() {
		$(this).removeClass('current');
		$(this).children('ul.third_level').hide();
	}		
	
	function CycleImageSize() {
		var thisRel = $(this).attr('rel');

		$('#sets ul li.category a').removeClass('current');
		$('a.'+thisRel).addClass('current');		
	
		$(".resize").backgroundScale({
			imageSelector: ".mode_fill",
			centerAlign: true,
			containerPadding: 0
		});	
	}
	
	function TriggerCycle() {
		
		//$("#image-pagination p span").empty();
		
		var thisSlideOwner = $(".resize img:first").attr('alt');
		$('#footer-gamma p').text(thisSlideOwner);	
	
		var FadeImages = $(".resize img").length;

		if (FadeImages < 2) {
			$("#prev,#next").hide();
		} else {
			$("#prev,#next").show();
		}	
	
		$('.cycle-project').cycle({ 
			prev:   '#prev', 
			next:   '#next', 
			timeout: 0,
			speed:  1,
			//pager:  '#image-pagination p span',
			before: onBefore,
			after: CycleImageSize
		});	
			
		$("#loading").hide();
	}	
	
	function backgroundFill() {
	
		if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
			var windowHeight = 1300;
			var contentHeight = $("#content").height();
			
			if (windowHeight >= contentHeight) {
				$(".size-aware").width(windowHeight);				
				$(".size-aware").height(windowHeight - 118);	
			}
			
			$("#background").width(1300);			
			$("#background div").width(1300);			
			$("#background").height(windowHeight);		
			$("#background div").height(windowHeight);
		} 
		else {
			var windowHeight = $(window).height();
			var contentHeight = $("#content").height();
			
			if (windowHeight >= contentHeight) {
				$(".size-aware").width($(window).width());				
				$(".size-aware").height(windowHeight - 118);
			}
			
			$("#background,#background div").width($(window).width());	
			$("#background,#background div").height(windowHeight);				
		}
		
		$(".resize").backgroundScale({
			imageSelector: ".mode_fill",
			centerAlign: true,
			containerPadding: 0
		});
		
		var FadeImages = $(".resize img").length;

		if (FadeImages < 2) {
			$("#prev,#next").hide();
		} else {
			$("#prev,#next").show();
		}		
		
		$('.cycle-project').cycle({ 
			prev:   '#prev', 
			next:   '#next', 
			timeout: 0,
			speed:  1,
			//pager:  '#image-pagination p span',
			before: onBefore,
			after: CycleImageSize
		});			
		
		$('#loading').fadeOut("slow");
		
		var thisSlideOwner = $(".resize img:first").attr('alt');
		$('#footer-gamma p').text(thisSlideOwner);	
		
	}

