$(document).ready(function(){



/* test show/hide Icon */

$("a.list").hover(
		function(){
			var num=(($(this).attr("href").split("_"))[2].split("-"))[0];
			$("div.wrapIcon:eq("+num+")").show();

		},

		function(){
				$("div.wrapIcon").hide();
				}
);

/* end of test show/hide Icon */

/* p.button-like activation */
	$("p.button-like").mouseover(function(){$(this).addClass("hover")}).mouseout(function(){$(this).removeClass("hover")});
/* end of p.button-like activation */

/* karl swedberg's accordion method */
  $('#menu-main> ul').hide();  
  $('p.button-like').click(function() {
    var $nextDiv = $(this).next('ul');
    var $visibleSiblings = $nextDiv.siblings('ul:visible');
 
    if ($visibleSiblings.length ) {
      $visibleSiblings.slideUp('normal', function() {
        $nextDiv.slideToggle('normal');
      });
    } else {
       $nextDiv.slideToggle('normal');
    }
  });
/* end of karl swedberg's accordion method */

/* text-credits-data */
	$("#credits").hide();
	$("#data").hide();
	$("li.text-nav_description").show();
	
	$("#img-text").click(function(){
		$("#credits").hide();
		$("#data").hide();
		$("#text").show();
		$("li.text-nav_credits").hide();
		$("li.text-nav_data").hide();
		$("li.text-nav_description").show();
		$('.scroll-pane').jScrollPane({showArrows:true});
		$("#img-credits").attr({src: "../../img/dot-nav-credits-00.jpg"}).css({'cursor':'pointer'});
		$("#img-data").attr({src: "../../img/dot-nav-data-00.jpg"}).css({'cursor':'pointer'});
		$("#img-text").attr({src: "../../img/dot-nav-text.jpg"}).css({'cursor':'default'});
	});
	$("#img-credits").click(function(){
		$("#text").hide();
		$("#data").hide();
		$("#credits").show();
		$("li.text-nav_data").hide();
		$("li.text-nav_description").hide();
		$("li.text-nav_credits").show();
		$('.scroll-pane').jScrollPane({showArrows:true});
		$("#img-text").attr({src: "../../img/dot-nav-text-00.jpg"}).css({'cursor':'pointer'});
		$("#img-data").attr({src: "../../img/dot-nav-data-00.jpg"}).css({'cursor':'pointer'});
		$("#img-credits").attr({src: "../../img/dot-nav-credits.jpg"}).css({'cursor':'default'});
	});
	$("#img-data").click(function(){
		$("#text").hide();
		$("#credits").hide();
		$("#data").show();
		$("li.text-nav_credits").hide();
		$("li.text-nav_description").hide();
		$("li.text-nav_data").show();
		$('.scroll-pane').jScrollPane({showArrows:true});
		$("#img-text").attr({src: "../../img/dot-nav-text-00.jpg"}).css({'cursor':'pointer'});
		$("#img-credits").attr({src: "../../img/dot-nav-credits-00.jpg"}).css({'cursor':'pointer'});
		$("#img-data").attr({src: "../../img/dot-nav-data.jpg"}).css({'cursor':'default'});
	});

/* end of text-credits-data */

/* back button */
	$("#back-icon").click(function(){history.go(-1);return false;});
	$("#back-text").click(function(){history.go(-1);return false;});
/* end of back button */

/* initialize scroller */
	$(function(){
		$('.scroll-pane').jScrollPane({showArrows:true});
	});
/* end of initialize of scroller */
						   
/* image browser */
	
	$("li.image:gt(0),li.image-name:gt(0)").hide();
	var n=$("li.image").length;
	var i=0;
	
	$(".img-animate, .img-next").click(function(){
		if (!$("li.image,div.image").is(':animated') ) { 
			if (i<n-1) {
				$(".img-animate").css({'cursor':'default'});
				$("li.image-name:eq("+i+")").fadeOut(600);
				$("li.image:eq("+i+")").fadeOut(600, function(){ 
					i=i+1; 

					var ImgWidth=$("img.img-animate:eq("+i+")").css("width");
					var ImgHeight=$("img.img-animate:eq("+i+")").css("height");
					
					$("#wrap01").animate({width:ImgWidth}, 500);	// change width of first wrapper
					$('div.image').animate({width:ImgWidth,height:ImgHeight}, 500, function(){
						$("li.image-name:eq("+i+")").fadeIn(600);
						$("li.image:eq("+i+")").fadeIn(600, function(){
							$(".img-animate").css({'cursor':'pointer'});												 
							});
						});
					});
			}
			else {
				$(".img-animate").css({'cursor':'default'});
				$("li.image-name:eq("+i+")").fadeOut(600);
				$("li.image:eq("+i+")").fadeOut(600, function(){
					i=0;
					
					var ImgWidth=$("img.img-animate:eq("+i+")").css("width");
					var ImgHeight=$("img.img-animate:eq("+i+")").css("height");
					
					$("#wrap01").animate({width:ImgWidth}, 500);  // change width of first wrapper
					$('div.image').animate({width:ImgWidth,height:ImgHeight}, 500, function(){
						$("li.image-name:eq("+i+")").fadeIn(600);
						$("li.image:eq("+i+")").fadeIn(600, function(){
							$(".img-animate").css({'cursor':'pointer'});
							});
						});
					});
			};
		};
	});
});
