$(document).ready(function(){
$(".panel").hide();
$("#web").show();
$("li:even").css("background-color", "#edebe8");
$(document).pngFix(); 
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
 
$.preloadImages("images/wallpaper_BW.jpg",
"images/nav.jpg",
"images/head-off3.jpg",
"images/head-on3.jpg",
"images/ribbon-wide.jpg",
"images/zero-thumb.jpg",
"images/first-thumb.jpg",
"images/second-thumb.jpg",
"images/third-thumb.jpg",
"images/fourth-thumb.jpg",
"images/fifth-thumb.jpg",
"images/sixth-thumb.jpg",
"images/seventh-thumb.jpg",
"images/eighth-thumb.jpg",
"images/ninth-thumb.jpg",
"images/tenth-thumb.jpg",
"images/eleventh-thumb.jpg",
"images/twelfth-thumb.jpg",
"images/thirteenth-thumb.jpg",
"images/fourteenth-thumb.jpg",
"images/prev.gif",
"images/next.gif",
"images/compass-01.jpg",
"images/ny-lounge-01.jpg",
"images/sensia-01.jpg",
"images/moody-01.jpg",
"images/hart2hart-01.jpg",
"images/nwres-01.png",
"images/twill-01.jpg",
"http://www.mamascience.com/flog/wp-content/uploads/2008/10/twill_october_ad_new1.jpg",
"http://www.mamascience.com/flog/wp-content/uploads/2008/11/picture-5.png",
"http://www.mamascience.com/flog/wp-content/uploads/2009/01/picture-25-231x300.png",
"http://www.mamascience.com/flog/wp-content/uploads/2008/10/twill_september_ad_new.jpg",
"http://www.mamascience.com/flog/wp-content/uploads/2008/03/twill_se_ex_web.png",
"http://www.mamascience.com/flog/wp-content/uploads/2008/02/nwres_sign.jpg",
"http://www.mamascience.com/flog/wp-content/uploads/2008/02/twillmercfall_issuead01.png"
);

// fancybox
$(".print .post-image a").fancybox({ 'overlayShow': true }); 

// accordion settings	
$('#menu').accordion({
	header: '.head'
});


// prevents default link behavior only within in container element
$(".head a, #menu ul li a, .sub-nav a, .thumbs a, #contact a, #old-link a, #menu-2 ul li a").click(function(event){
   event.preventDefault();
 });

 $(".head").click(function () {
   $(".active").removeClass("active");
 });	
// sets selection behavior for links within ul section
 $("ul li").click(function () {
     $("ul li").removeClass("active");
     $(this).addClass("active");
    });	
// allows links to show corresponding panels in panel div    
 $("ul li a,.head a, .back a, .thumbs a, #contact a, #old-link a").click(function () {
     $(".panel").hide();
     var pointer = $(this).attr("href");
     $(pointer).show();
  });
   $("#contact a").click(function () {
     $("ul li").removeClass("active");
    });	

// thumbnail selectors make corresponding list item active
 $(".thumbs a").click(function () {
 	 $(".active").removeClass("active");
 	 var pointee = $(this).attr("href");
 	 $("#menu ul:visible li a[href="+pointee+"]").parent().addClass("active");
 	 
 });
// manages next and previous buttons and prevents traversing one list to the next
$(".next").click(function (ev) {
    $target= $(ev.target);
    if ( $target.hasClass('dead-link')) return 0;
     $(".active").removeClass("active").next().addClass("active");
     $(".panel:visible").hide().next().show();
     if ($("#ul-one li.active").is(":last")) {
        $("#seventh .next").removeClass("next").addClass("dead-link");
     }
    else {   
        }
});  $(".prev").click(function (ev) {
	$target= $(ev.target);
    if ( $target.hasClass('dead-link')) return 0;
     $(".active").removeClass("active").prev().addClass("active");
     $(".panel:visible").hide().prev().show();
      if ($("#ul-two li.active").is(":first")) {
        $("#eighth .prev").removeClass("prev").addClass("dead-link");
     }
    else {
        $(".prev").show();      
        }
  });
// prevents traversing one list to the next when direct clicking of first and last links in second and first ul sections respectively  
  $("#ul-one li a:last").click(function () {	
  	$("#seventh.panel .next").removeClass("next").addClass("dead-link");
	});
  $("#ul-two li a:first").click(function () {	
  	$("#eighth .prev").removeClass("prev").addClass("dead-link");
  	}); 
  $("#ul-three a").click(function () {	
  	$("#seventh .dead-link").removeClass("dead-link").addClass("next");
  	$("#eighth .dead-link").removeClass("dead-link").addClass("prev");
	}); 		
  $("#web .thumbs-image a").click(function () {	
  	$("#seventh.panel .next").removeClass("next").addClass("dead-link");
	});
  $("#print .thumbs-image a").click(function () {	
  	$("#eighth .prev").removeClass("prev").addClass("dead-link");
  	}); 
}); 
