$(document).ready(function() {
	 $('.hover').hover(function() {
		hoverOverOut( $(this) );
	 });
	 
	 /********* HOME PAGE NAVIGATION *****************/
	 
	 $('#nav_photographer').click(function() {
		window.location = '/photographer.php';
	 });
	 
	 $('#nav_home2').click(function() {
		window.location = '/';
	 });
	 $('#nav_photos').click(function() {
		window.location = '/portfolio.php';
	 });
	 $('#nav_contact').click(function() {
		window.location = '/contact.php';
	 });
	 
	 $('#contactLine #email').click(function() {
		window.location = 'mailto:dusti@dusticunningham.com';
	 });
	 $('#footer_contactLine #email').click(function() {
		window.location = 'mailto:dusti@dusticunningham.com';
	 });
	 $('#contactLine #copyright').click(function() {
		window.location = '/';
	 });
	 $('#footer_contactLine #copyright').click(function() {
		  window.location = '/';
	 });
	 
	 $('#social_fb').click(function() {
		var location = 'https://www.facebook.com/pages/Dusti-Cunningham-Photography/174622472863?ref=ts';
		var newWin = window.open(location,'facebook','');
	 });
	 $('#social_flickr').click(function() {
		var location =  'http://www.flickr.com/photos/diablodivine/';
		var newWin = window.open(location,'flickr','');
	 });
	 $('#social_tumblr').click(function() {
		var location = 'http://diablodivine.tumblr.com/';
		var newWin = window.open(location,'tumblr','');
	 });
	 
	 /************* PORTFOLIO PAGE NAVIGATION ****************/
	 
	  $('#nav_home').click(function() {
		window.location = '/';
	 });
	 
	 $('#portfolio_main #home_link').click(function() {
		window.location = '/';
	 });
	 
// 	 $('a#nav_portraits').fancybox();
// 	 $('a#nav_headshots').fancybox();
// 	 $('a#nav_weddings').fancybox();
// 	 $('a#nav_families').fancybox();
// 	 $('a#nav_queens').fancybox();
// 	 $('a#nav_erotic').fancybox();
// 	 $('a#nav_pets').fancybox();
	 
	 /************* PORTFOLIO GALLERY FUNCTIONALITY ************/
	 
	 $('#gallery_thumbs img').click(function() {
// 		 alert($(this).get(0).id);
		var imageID = $(this).get(0).id;
		
		//clear all classes from main images, reset all to hidden except large version of imageID
		$('#gallery_main span').each( function () {
		  $(this).removeClass('hidden').addClass('hidden');
		});
		$('#gallery_main #'+imageID).removeClass('hidden');
	 });
	 
	 
	$('#navLeft ul li').click(function() {	getSlide( $(this).get(0),9 ); }); 
	$('#navRight ul li').click(function() {	getSlide( $(this).get(0),5 ); }); 
 });
 
 
 function slideToggle(e){
	$(e).animate({opacity: 0.4},'fast').slideToggle('fast').animate({opacity: 1},'fast');
  }
  
  function slideUp(e) {
	 $(e).animate({opacity: 0.4},'fast').slideUp('fast').animate({opacity: 1},'fast');
  }
  
  function getNextSlide(e,tot) {
	 var slideNum = e.id.split("_")[1];
	 if( slideNum == tot ) slideNum = 0;
	 var nextSlide = "slide_"+(parseInt(slideNum)+1);
	 slideToggle(e);
	 slideToggle(eval(nextSlide));
  }
  
	function getSlide(e,tot) {
	 var slideNum = e.id.split("_")[1];

	 var thisSlide = "slide_"+(parseInt(slideNum));
    for(i=1;i<=tot;i++) {
		slideUp($(eval("slide_"+i)) );
	 }
	 slideToggle($(eval(thisSlide)));
  }
  
  function hoverOverOut(e) {
  ////////////////////////////////////////////
  //arg: image element
  //req: "_over.png" that matches element id
  ///////////////////////////////////////////
	 var src = $(e).attr("src");
	 if(src.indexOf('over') > -1 ) $(e).attr("src", "/_img/"+$(e).get(0).id + ".png");
	 else $(e).attr("src", "/_img/"+$(e).get(0).id + "_over.png");
  }


