/*
 * jQuery utils
 */
$(document).ready(function() {
	//check and show horizontal navi
	var menuCount = $("[id$='-horizontalMenu']").css("display","none").length;
	if (menuCount > 0) {
		//check if a in parent is activ (class="isActive firstLevel" or first child is p >span)
		var parentId = $("[id$='-horizontalMenu']").parent().parent().attr("id");
		//alert("parentId:"+parentId+",\n has p->span:"+($("#"+parentId+" p > span").size() > 0)+",\n has isActive:"+$("#"+parentId+" p > a").hasClass("isActive"));
		if ($("#"+parentId+" p > a").hasClass("isActive") || $("#"+parentId+" p > span").size() > 0) {
			$(".content").before("<div class='horizontalMenu' style='display:none'><ul>"+$("#"+parentId+ " > ul").html()+"</ul></div>");
			$("div.horizontalMenu > ul > [id$='-horizontalMenu'] > p > a").removeAttr('onmouseover');
			$("div.horizontalMenu > ul > [id$='-horizontalMenu']").each(function(index){
				if (index != 0) {$(this).css("display","inline");}
			});
			$(".horizontalMenu").slideToggle("slow");
		}
	}

	//add big img show icon
	var showRaw = $("#showRaw");
	if (showRaw != 'undefined' && showRaw.val() == '1'){
		$("img[rev]").each(function(index){
			var revUrl = $(this).attr('rev');
			var revId = $(this).attr('id');
			//$(this).after("<div class='showScaledUpImg' style='left:"+($(this).width()-25)+"px;' onclick=\""+relUrl+"\">&nbsp;</div>");
			$(this).after('<div class="showScaledUpImg" style="left:'+($(this).width()-25)+'px;" rel="#'+revId+'ov">&nbsp;</div>');
			$('body').append('<div id="'+revId+'ov" class="apple_overlay"><div class="close"></div><img src="'+revUrl+'"></div>');
		});
		try {
			$(".showScaledUpImg").overlay({effect: 'apple'});
		} catch (e) {
			$(".showScaledUpImg").css("display","none")
		}
	}
});
