var currentSub, speed = 200;
var modeM = false; 

function rollCat() {
	$(".elemCatMenu").mouseover(function() {
		$(this).css( {background:"#fff", color:"#a69542"});
	});
	$(".elemCatMenu").mouseout(function() {
		$(this).css( {background:"#f5f3f0", color:"#807d79"});
	});
}

function showSub(subId,subElem) {
	subH = ((subElem * 25) + 62)+"px"; 
	$("#catAll").animate({height:"33px"},speed).queue(function(){
		$(this).hide().dequeue();
		
		$("#sub"+subId).show().queue(function() {
			$("#sub"+subId).animate({height:subH},speed);
			$(this).dequeue();
		});
		$(this).dequeue();
	});
	
	$(".catMenuT").css("cursor","pointer");
	$(".catMenuT").click(function(){
		showAll(10);
	});
	currentSub = subId;
}

function showAll(catElem) {
	catH = ((catElem * 25) + 33)+"px";
	$("#sub"+currentSub).animate({height:"33px"},speed).queue(function() {
		$(this).hide().dequeue();
		$("#catAll").show().queue(function() {
			$("#catAll").animate({height:catH},speed);
			$(this).dequeue();
		});
	});
	$(".catMenuT").unbind();
	$(".catMenuT").css("cursor","default");
}

function more(mode) {
	if(mode == "normal") {
		$("#buttonClist").click(function() {
			if(modeM == false) {
				$("#moreSwit").removeClass("moreHiddenChoices"); 
				$("#moreSwit").addClass("moreShownChoices").queue(function(){
					$(this).slideDown("normal");
					$(this).dequeue(); 
				});
				modeM = true; return;
			}
			if(modeM == true) {
				$("#moreSwit").slideUp("normal").queue(function(){
					$(this).removeClass("moreShownChoices"); $(this).addClass("moreHiddenChoices");
					$(this).dequeue();
				});
				modeM = false;
			}
		});
	}
	if(mode == "frozen") {
		$("#moreSwit").removeClass("moreHiddenChoices"); 
		$("#moreSwit").addClass("moreShownChoices").queue(function(){
			$(this).show()
			$(this).dequeue(); 
		});
		$("#buttonClist").unbind();
	}
}

this.photoMax = function(){	
	/* CONFIG */		
		xOffset = -5;
		yOffset = 5;				
	/* END CONFIG */		
	$("div.photoMax").hover(function(e){	
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='photoMax'><img src='"+this.t+"' alt='' /></p>");
		$("#photoMax")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");		
    },
	function(){
		this.title = this.t;		
		$("#photoMax").remove();
    });	
	$("div.photoMax").mousemove(function(e){
		$("#photoMax")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function(){
	rollCat();
	more("normal");
	photoMax();
});