/*
	javascript for idocument page.

	idocument.js v4.0
	created on 2009-11-09 by Oscar Woo
	modified on 2011-10-09 by Oscar Woo

*/

$(document).ready(function() {
	$(".carousel").scrollable({
		onBeforeSeek: function(event, i) {
			if(i<this.getSize()){
				$("#arrow").animate({ left: 119+i*136 }, 400 );
				switch(i){
					case 0:{
						$(".carousel").animate({ height: 1630}, 400); break;
					}
					case 1:{
						$(".carousel").animate({ height: 840}, 400); break;
					}
					case 2:{
						$(".carousel").animate({ height: 960}, 400); break;
					}
					case 3:{
						$(".carousel").animate({ height: 610}, 400); break;
					}
					case 4:{
						$(".carousel").animate({ height: 530}, 400); break;
					}
					case 5:{
						$(".carousel").animate({ height: 768}, 400); break;
					}
				}		
			}
		}
	}).navigator(".main_nav1").navigator(".main_nav2");
	
	$(".scroll_quote").scrollable({ vertical: true, circular: true }).autoscroll(2000);
	
	$("#idocument_annotation").hover(function(){
		var mapmark = $(this).find(".mapmark > div");
		mapmark.stop(true, true).animate({ width: 50, height: 50, top: "-=20px", left: "-=20px", opacity: 0 }, 200, function(){
			$(this).animate({width: 10, height: 10, top: "+=20px", left: "+=20px", opacity: 0.6 }, 100);
		});
	});
	
	
	
	$("#idocument_annotation > .mapmark").hover(
		function(){
			$("#"+$(this).attr("href").substr(1)).show();
		},
		function(){
			$("#"+$(this).attr("href").substr(1)).hide();
		}
	);
	$("#idocument_annotation > .mapmark").click(function(){return false;});

	$("#toggle_switch").toggle_switch($("#collection_and_tag .img"), $("#collection_and_tag .desc"));
});


(function($){
$.fn.toggle_switch = function(target1, target2){
	
	var knob = $(this).find("div.knob");
	
	$(this).click(function(){
		if($(this).attr("class") == "left"){
			knob.animate({ left: 43 }, 300, function(){
				$(this).parent().removeClass("left");
				$(this).parent().addClass("right");
    		});
    		target1.find(".items").animate({ left: -490}, 300);
			target2.find(".items").animate({ left: -490}, 300);

		}else if($(this).attr("class") == "right"){
			knob.animate({ left: 2 }, 300, function(){
				$(this).parent().removeClass("right");
				$(this).parent().addClass("left");
    		});
			target1.find(".items").animate({ left: 0}, 300);
			target2.find(".items").animate({ left: 0}, 300);
		}
	});
}
})(jQuery);








