// JavaScript Document

/*
// --------------------------------------------------------------------------
// jQuery.custom.js by orangepointsolutions Ltd., www.orangepointsolutions.de
// --------------------------------------------------------------------------
*/

 $(document).ready(function() {

/*    $(window).load(function(){
		$("#overlay").animate({opacity: 0.85}, 1500);
		$("#overlay").fadeIn("fast", function() { 
			$("#step1").fadeOut(5000, function() {
		        $("#step2").fadeIn(2000); 
			});
		});
	});
*/
    $(".cd img").click(function(){ // click on a cover handler
		// switch class to clicked element
		$("img.active").removeClass("active");
        $(this).addClass("active");
		// extract cd title from classes
		var regExpression = /(\w.+)\s(\w.+)/;
		regExpression.exec( $(this).parent().attr("class") );
		var myClass = RegExp.$2;
		// show selected content
		$("div.details").hide();
		$("div."+myClass).show();
    });
	
    $("#pages > li.page").mouseover(function(){ // mouseover on pages navigation handler
		$(this).css("cursor","pointer");
	});
									
    $("#more_pages > li.page").mouseover(function(){ // mouseover on pages navigation handler
		$(this).css("cursor","pointer");
	});
									
    $("#pages > li.page").click(function(){ // click on pages navigation handler
		var pageSelect = $(this).text();
		// color current selection
		$("#pages > li.page").removeClass("active");
		$(this).addClass("active");
		// show all and hide selectively
		$("div.cd").show();
		$("div.separator").show();
		if ( pageSelect == 1 ) {
			$("div.cd:gt(2)").hide();
			$("div.separator:gt(1)").hide();
			reset_current_selection(0);
		}
		if ( pageSelect == 2 ) {
			$("div.cd:lt(3)").hide();
			$("div.cd:gt(5)").hide();
			$("div.separator:lt(3)").hide();
			$("div.separator:gt(4)").hide();
			reset_current_selection(3);
		}
		if ( pageSelect == 3 ) {
			$("div.cd:lt(6)").hide();
			$("div.cd:gt(8)").hide();
			$("div.separator:lt(6)").hide();
			$("div.separator:gt(7)").hide();
			reset_current_selection(6);
		}
		if ( pageSelect == 4 ) {
			$("div.cd:lt(9)").hide();
			$("div.cd:gt(11)").hide();
			$("div.separator:lt(9)").hide();
			$("div.separator:gt(10)").hide();
			reset_current_selection(9);
		}
		if ( pageSelect == 5 ) {
			$("div.cd:lt(12)").hide();
			$("div.cd:gt(14)").hide();
			$("div.separator:lt(12)").hide();
			$("div.separator:gt(13)").hide();
			reset_current_selection(12);
		}
    });
	
	function reset_current_selection(id) {
			$("img.active").removeClass("active");
			$("div.cd > img:eq("+id+")").addClass("active");
			$("div.details").hide();
			$("div.details:eq("+id+")").show();
	}
	
	// initial page preparation
	
	// show first cd element as active
	$("div.cd img:first").addClass("active");
	$("div.details:gt(0)").hide();

	// show first 3 elements and separators
/*	$("div.cd:gt(2)").hide();
	$("div.separator:gt(1)").hide(); */

//	$("#col_cd.right").height( $("#col_cd.left").height() );

    $("#more_pages > li.page").click(function(){ // click on pages navigation handler
		var pageSelect = $(this).text();
		// color current selection
		$("#more_pages > li.page").removeClass("active");
		$(this).addClass("active");
		// show all and hide selectively
		if ( pageSelect == 1 ) {
			$("div#page2").hide();
			$("div#page1").fadeIn("slow");
		}
		
		if ( pageSelect == 2 ) {
			$("div#page1").hide();
			$("div#page2").fadeIn("slow");
		}
	});

});

// --- end of jQuery.custom.js ---
