 $(document).ready(function() {

	//Toggle Header
   		$("#toggle").click(function(event) {
		event.preventDefault();
		$("#header").slideToggle();
		});
		
	//Drop the apple, Magritte!
	$("#apple").draggable({ 
		revert: "invalid",
		snap: "#droppable",
		snapMode: 'inner',
		containment: ".huro"
	});
	
	$( "#droppable" ).droppable({
			tolerance: 'fit',
			drop: function( event, ui ) {
				$(this)
					.find( "p" )
						.html( "<img src='http://huriata.com/wp-content/themes/hb/css/img/konami.gif' />" );
			}
		});
		
	//Highlight
		$("#process h1").mouseover(function () {
      		$("#process span").fadeTo("slow", 0.35);
      		$("#process h1").css("color","#6d7272");

    	});
		$("#process h1").mouseout(function() {
   			$("#process span").fadeTo("fast", 1);
   			$("#process h1").css("color","#474a4a");

   		});
   		
   	//Konami Code
   		konami = new Konami()
        konami.load("http://en.wikipedia.org/wiki/Ren%C3%A9_Magritte");

	//Sliding Recent Works
	$('#recentworks.captionfull').hover(function(){
		$(".cover", this).stop().animate({top:'180px'},{queue:false,duration:220});
	}, function() {
		$(".cover", this).stop().animate({top:'219px'},{queue:false,duration:160});
	});
	
	//Return false on click
	$("a.clickfalse").click(function () {
    	$("#mydiv").toggle();
    	return false; // Prevent browser from visiting `#`
	});	
	
	//Filtering
	
	$('#data li a').click(function() {				
			
					$('#data li').removeClass('selected');
					$(this).parent('li').addClass('selected');
					
					thisItem 	= $(this).attr('rel');
					
					if(thisItem != "all") {
					
						$('.item li[rel='+thisItem+']').stop()
							.fadeTo("slow", 1);
																			
						$('.item li[rel!='+thisItem+']').stop()
							.fadeTo("slow", 0.25);
					} else {
						
					$('.item li').stop()
						.fadeTo("slow", 1);
					}
				})
				
				$('.item li img').animate({'opacity' : 0.75}).hover(function() {
						$(this).animate({'opacity' : 1});
					}, function() {
						$(this).animate({'opacity' : 0.75});
					});
					
	//Floating Arrows
	$("#arrowsl").stickyfloat({duration: 400});
	$("#arrowsr").stickyfloat({duration: 400});	
							
	//Panning
		
	$("img#myPic").panFullSize(620, 383).css("border", "thin solid #757a7a");

});

window.onload = init;
 
function init() {
  disableDraggingFor(document.getElementById("draggingDisabled"));
}
 
function disableDraggingFor(element) {
  // this works for FireFox and WebKit in future according to http://help.dottoro.com/lhqsqbtn.php
  element.draggable = false;
  // this works for older web layout engines
  element.onmousedown = function(event) {
                event.preventDefault();
                return false;
              };
}
