
$(document).ready(function() {

		/*main img overlay on front page*/
		$("#maintrig[rel]").overlay({
		expose: '#111',
		closeOnClick: true
		}); 
	
	
	

	/* chained call: scrollable().find("a").tooltip().overlay().gallery(); */	
	/*sets up gallery gallery*/
	
	
	$("#scrollablez").scrollable({	
		size:4,
		nextPage: '#testbut2z',
		prevPage: '#testbut1z'		
		
	}).find("a").tooltip({
	
		// use this single tooltip element for all trigger elements
		tip: '#tooltip'

	}).overlay({

		// each trigger uses the same overlay with id "gallery"
		target: '#gallery',

		// optional exposing effect with custom color
		expose: '#111',

		// clicking outside the overlay does not close it
		closeOnClick: true

	// gallery plugin
	}).gallery({

		// do not use the same disabled class name as scrollable
		disabledClass: 'inactive',
		speed: 'slow',
		prev: '.prevz',
		next: '.nextz'
	});
	







	/* changed via nextPage: '#testbut2z', prop instead
	$("#testbut1").click(function() 
	{
		//alert("clicked!");
		var apiz = $("#scrollablez").scrollable();
		// we scroll two items forward 
		apiz.move(5); 
				
	});


	$("#testbut2").click(function() 
	{
		//alert("clicked!");
		var apiz = $("#scrollablez").scrollable();
		// we scroll two items forward 
		apiz.move(-5); 
				
	});

	*/
	
	
	
	
	//sets up main scrolls 
	var api = $("#scroll").scrollable({
		items: '#tools',
		size: 1,
		clickable: false

	// use the navigator plugin
	}).navigator({api: true});

	
	
	/*
	var badBrowser = (/MSIE ((7)|8)/.test(navigator.userAgent) && navigator.platform == "Win32");
	if (badBrowser) {
		alert("ie7 or ie8");
		$("#scroll").css("background-color:", "#f22");
		$('#scroll').css('opacity',0.45);
		$("#scroll").css("background-image:", "#f22");
	}
	*/
	
	
	
	
	
	//Do IE6 stuff - relates to changing pic of active menu item and changing page
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {

	//alert("IE6 damn it");	 
	 
		$('.oldbrowser').css("display", "block");	//displays a div to people using IE 6 or prev warning of bad performance.
		
		$('.ie6hover').hover(			
			
			function() 
			{				
			prevpos = ($(this).css('background-position-y'));
				if(prevpos == "-160px")
				{
					//alert("is active");
				}
				else
				{
					$(this).css("background-position", "0px -80px");
					
				}
				
			}, function() 
			{
			prevpos = ($(this).css('background-position-y'));
				if(prevpos == "-160px")
				{
					//alert("is active");
				}
				else
				{
					$(this).css("background-position", "0px 0px");	
					
				}
			}
		);
		
		/*needed to manually move background in IE6 because toggling class wouldnt work with png fix for some hideous reason*/
			
		$("#homenav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(0); 
			
			$("#philnav").css("background-position", "0px 0px");	
			$("#artisnav").css("background-position", "0px 0px");	
			$("#galnav").css("background-position", "0px 0px");	
			$("#homenav").css("background-position", "0px -160px");	
			$("#scroll").css("height", "500px");
					
		});
		
		
		$("#galnav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 				
			apiz.seekTo(1); 
			$("#philnav").css("background-position", "0px 0px");	
			$("#artisnav").css("background-position", "0px 0px");	
			$("#galnav").css("background-position", "0px -160px");	
			$("#homenav").toggleClass("active", false);
			$("#homenav").css("background-position", "0px 0px");	
			$("#scroll").css("height", "500px");
					
					
		});
		
		
		$("#artisnav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(2); 	
			
			$("#philnav").css("background-position", "0px 0px");	
			$("#artisnav").css("background-position", "0px -160px");	
			$("#galnav").css("background-position", "0px 0px");	
			$("#homenav").toggleClass("active", false);
			$("#homenav").css("background-position", "0px 0px");	
			$("#scroll").css("height", "500px");		
		});
			
		
		$("#philnav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(3); 	
			
			$("#philnav").css("background-position", "0px -160px");	
			$("#artisnav").css("background-position", "0px 0px");	
			$("#galnav").css("background-position", "0px 0px");	
			$("#homenav").toggleClass("active", false);
			$("#homenav").css("background-position", "0px 0px");	
			$("#scroll").css("height", "900px");
				
		});
		
		
		//activate pngfix for ie6
		//$(document).pngFix(); 
		
		
		//this png fix supports png background position
		DD_belatedPNG.fix('.png_bg, .close, .squig2, .squig1');

		
	
	}
	else
	{			
		$("#homenav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(0); 	
			
			$("#philnav").toggleClass("active", false);	
			$("#artisnav").toggleClass("active", false);	
			$("#galnav").toggleClass("active", false);	
			$("#homenav").toggleClass("active", true);
			$("#scroll").css("height", "500px");		
		});


		$("#galnav").click(function() 
		{
			
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(1); 	
			
			$("#philnav").toggleClass("active", false);	
			$("#artisnav").toggleClass("active", false);	
			$("#galnav").toggleClass("active", true);	
			$("#homenav").toggleClass("active", false);
			$("#scroll").css("height", "500px");
					
		});


		$("#artisnav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(2); 	
			
			$("#philnav").toggleClass("active", false);	
			$("#artisnav").toggleClass("active", true);	
			$("#galnav").toggleClass("active", false);	
			$("#homenav").toggleClass("active", false);
			$("#scroll").css("height", "700px");
		});

		$("#philnav").click(function() 
		{
			//alert("clicked!");
			var apiz = $("#scroll").scrollable();
			// we scroll two items forward 
			apiz.seekTo(3); 	
			
			$("#philnav").toggleClass("active", true);	
			$("#artisnav").toggleClass("active", false);	
			$("#galnav").toggleClass("active", false);	
			$("#homenav").toggleClass("active", false);
			$("#scroll").css("height", "900px");
		});

	
	}
	
	//alert(window.location);
	
	
	//check if needs to move to new slide via address
	var location = "" + window.location;
	var count = location.length;
	var startspot = (count - 4)	
	//alert(count);
	//alert(startspot);
	var moveto = (location.substr(startspot, 4));
	if (moveto == "gall")
	{
		$('#galnav').trigger('click');
	}
	else if(moveto == "cove")
	{
		$('#artisnav').trigger('click');
	}
	else if(moveto == "phil")
	{
		$('#philnav').trigger('click');
	}

});




