// JavaScript Document		<script language="javascript" type="text/javascript">
window.addEvent("domready", function() {  
	var ex6Carousel = new iCarousel("example_6_content", {  
		idPrevious: "example_6_previous",  
		idNext: "example_6_next",  
		idToggle: "undefined",  
		item: {  
			klass: "example_6_item",  
			size: 940
		},  
		animation: {  
			type: "scroll",  
			duration: 1000,  
			amount: 1  
		}
		
	});
	
	//*********
	// Arrow Show / Hide
	var showarrows = function() {
		arrows = document.getElementById("arrows");
		arrows.style.visibility = 'visible';
	}
	var hidearrows = function() {
		arrows = document.getElementById("arrows");
		arrows.style.visibility = 'hidden';
	}
	// Need to unbind showarrows mouseover function for pages that aren't gallery pages (i.e. Contact page)
	var destroybind = function() {
		$("container_bd").removeEvent("mouseover", showarrows);
	}
	var resetbind = function() {
		$("container_bd").addEvent("mouseover", showarrows);
	}
	// Attach the show/hide arrow functions to the gallery container
	$("container_bd").addEvent("mouseover",function(event){new Event(event).stop();});
	$("container_bd").addEvent("mouseout",function(event){new Event(event).stop();});
	$("container_bd").addEvent('mouseover', showarrows);
	$("container_bd").addEvent('mouseout', hidearrows);
	// Attach it to the arrows themselves too cause it freaks out otherwise
	$("leftarrow").addEvent("mouseover",showarrows);
	$("rightarrow").addEvent("mouseover",showarrows);
	
	//$("rightarrow").addEvent("click",function(event){alert(ex6Carousel.options.idPrevious);});
	
	// Keyboard Arrows yay!
	window.addEvent('keydown', function(event){
		if (event.keyCode == 39) ex6Carousel._next();
		if (event.keyCode == 37) ex6Carousel._previous();
		//alert(event.keyCode);
	});
	
	
	//*************
	// Thumbnails
	
	// FASHION
	$("portfolio").addEvent("click", function(event){ex6Carousel.goTo(0);flipto('fashion');});
	$("portfolio").addEvent("click", resetbind);
	$("img0").addEvent("click", function(event){ex6Carousel.goTo(0);filpto('fashion');});
	$("img1").addEvent("click", function(event){ex6Carousel.goTo(1);filpto('fashion');});
	$("img2").addEvent("click", function(event){ex6Carousel.goTo(2);filpto('fashion');});
	$("img3").addEvent("click", function(event){ex6Carousel.goTo(3);filpto('fashion');});
	$("img4").addEvent("click", function(event){ex6Carousel.goTo(4);filpto('fashion');});
	$("img5").addEvent("click", function(event){ex6Carousel.goTo(5);filpto('fashion');});
	$("img6").addEvent("click", function(event){ex6Carousel.goTo(6);filpto('fashion');});
	$("img7").addEvent("click", function(event){ex6Carousel.goTo(7);filpto('fashion');});
	$("img8").addEvent("click", function(event){ex6Carousel.goTo(8);filpto('fashion');});
	$("img9").addEvent("click", function(event){ex6Carousel.goTo(9);filpto('fashion');});
	$("img10").addEvent("click", function(event){ex6Carousel.goTo(10);filpto('fashion');});
	$("studio-one").addEvent("click", function(event){ex6Carousel.goTo(11);filpto('fashion');});
	$("studio-two").addEvent("click", function(event){ex6Carousel.goTo(12);filpto('fashion');});
	$("img11").addEvent("click", function(event){ex6Carousel.goTo(13);filpto('fashion');});
	$("img12").addEvent("click", function(event){ex6Carousel.goTo(14);filpto('fashion');});
	$("img13").addEvent("click", function(event){ex6Carousel.goTo(15);filpto('fashion');});

	// MISC
	$("misc").addEvent("click", function(event){ex6Carousel.goTo(16);flipto('architecture');});
	$("misc").addEvent("click", resetbind);
	$("louis-xiv-versailles-france").addEvent("click", function(event){ex6Carousel.goTo(16);flipto('architecture');});
	$("disney-concert-hall-one").addEvent("click", function(event){ex6Carousel.goTo(17);flipto('architecture');});
	$("disney-concert-hall-two").addEvent("click", function(event){ex6Carousel.goTo(18);flipto('architecture');});
	$("los-angeles-griffith-observatory").addEvent("click", function(event){ex6Carousel.goTo(19);flipto('architecture');});
	$("los-angeles-freeway").addEvent("click", function(event){ex6Carousel.goTo(20);flipto('architecture');});
	$("hollywood-sign-panoramic").addEvent("click", function(event){ex6Carousel.goTo(21);flipto('architecture');});
	$("los-angeles-panoramic").addEvent("click", function(event){ex6Carousel.goTo(22);flipto('architecture');});
	// FILM
	$("film").addEvent("click", function(event){ex6Carousel.goTo(23);flipto('film');});
	$("film").addEvent("click", resetbind);
	$("passage").addEvent("click", function(event){ex6Carousel.goTo(23);flipto('film');flipto('passasge');});
	$("spring").addEvent("click", function(event){ex6Carousel.goTo(24);flipto('film');flipto('spring');});
	$("untitled").addEvent("click", function(event){ex6Carousel.goTo(25);flipto('film');flipto('untitled');});
	$("anamorphic").addEvent("click", function(event){ex6Carousel.goTo(26);flipto('film');});
	// CONTACT
	$("contact").addEvent("click", function(event){ex6Carousel.goTo(27);flipto('contact');});
	$("contact").addEvent("click", destroybind);
	
	//**********
	// URL handler
	function seturl(id) {
		window.location.href = '#' + id;
	}
	// Force the destination based on url
	$(getpage()).fireEvent('click');
	
});

// Get the url so we know what to fire
function getpage() {
		thehref = window.location.href;
		thepage = thehref.split("#");
		theimg = thepage[1].split("&");
		if(theimg[1]) {
			return theimg[1];
		}else{
			return thepage[1];
		}
	}


// Control to show proper thumbnails per section
function flipto(thediv) {
	fashdiv = document.getElementById("port_fashion");
	archdiv = document.getElementById("port_architecture");
	filmdiv = document.getElementById("port_film");
	passagediv = document.getElementById("vid_passage");
	healthdiv = document.getElementById("vid_health");
	springdiv = document.getElementById("vid_spring");
	untitleddiv = document.getElementById("vid_untitled");
	anamorphdiv = document.getElementById("vid_anamorph");
	switch(thediv) {
		case "fashion":
			fashdiv.style.display = "block";
			archdiv.style.display = "none";
			filmdiv.style.display = "none";
			break;
		case "architecture":
			fashdiv.style.display = "none";
			archdiv.style.display = "block";
			filmdiv.style.display = "none";
			break;
		case "film":
			fashdiv.style.display = "none";
			archdiv.style.display = "none";
			filmdiv.style.display = "block";
			break;
		case "contact":
			fashdiv.style.display = "none";
			archdiv.style.display = "none";
			filmdiv.style.display = "none";
			break;
		case "passage":
			passagediv.style.display = "block";
			healthdiv.style.display = "none";
			springdiv.style.display = "none";
			untitleddiv.style.display = "none";
			anamorphdiv.style.display = "none";
			break;
		case "health":
			passagediv.style.display = "none";
			healthdiv.style.display = "block";
			springdiv.style.display = "none";
			untitleddiv.style.display = "none";
			anamorphdiv.style.display = "none";
			break;
		case "spring":
			passagediv.style.display = "none";
			healthdiv.style.display = "none";
			springdiv.style.display = "block";
			untitleddiv.style.display = "none";
			anamorphdiv.style.display = "none";
			break;
		case "untitled":
			passagediv.style.display = "none";
			healthdiv.style.display = "none";
			springdiv.style.display = "none";
			untitleddiv.style.display = "block";
			anamorphdiv.style.display = "none";
			break;
		case "anamorph":
			passagediv.style.display = "none";
			healthdiv.style.display = "none";
			springdiv.style.display = "none";
			untitleddiv.style.display = "none";
			anamorphdiv.style.display = "block";
			break;
	}
}




