/* dropdown menu (richiede JQUERY & Superfish) ================================================== */

$(document).ready(function(){
	$("#nav ul").superfish({
		hoverClass	: "sfHover",
		delay		: 100,
		animation	: {height:"show"},
		speed		: "fast"
		});
});

/* fix z-index link sottostante */
$(document).ready(function(){
	$("#nav ul").mouseover(function(){
		$("div.special").css("z-index",1);
	});
	$("#nav ul").mouseout(function(){
		$("div.special").css("z-index",3);
	});
});

/* menu homepage =================================================================================

$(document).ready(function(){
	$("#homeNav ul li").mouseover(function(){
		$(this).addClass("sfHover");
	});
	$("#homeNav ul li").mouseout(function(){
		$(this).removeClass("sfHover");
	});

}); */

$(document).ready(function(){
	$("#homeNav ul").superfish({
		hoverClass	: "sfHover",
		delay		: 100,
		animation	: {height:"show"},
		speed		: "fast",
		autoArrows:    false
		});
});



/* rollover menu laterale ========================================================================*/

$(document).ready(function(){
	$(".menuTree>li>a").mouseover(function(){
		$(this).css("background","url(/App_Themes/ccfs/img/btn_side_top_hover.gif) left top no-repeat");
		$(this).find("span").css("background","url(/App_Themes/ccfs/img/btn_side_bott_hover.gif) left bottom no-repeat");
	});
	$(".menuTree>li>a").mouseout(function(){
		$(this).css("background","url(/App_Themes/ccfs/img/btn_side_top.gif) left top no-repeat");
		$(this).find("span").css("background","url(/App_Themes/ccfs/img/btn_side_bott.gif) left bottom no-repeat");
	});
});

$(document).ready(function(){
	$(".menuTree>li>.active").mouseover(function(){
		$(this).css("background","url(/App_Themes/ccfs/img/btn_side_top_hover.gif) left top no-repeat");
		$(this).find("span").css("background","url(/App_Themes/ccfs/img/btn_side_bott_hover.gif) left bottom no-repeat");
	});
	$(".menuTree>li>.active").mouseout(function(){
		$(this).css("background","url(/App_Themes/ccfs/img/btn_side_top_hover.gif) left top no-repeat");
		$(this).find("span").css("background","url(/App_Themes/ccfs/img/btn_side_bott_hover.gif) left bottom no-repeat");
	});
});

/*  menu laterale ===============================================================================*/
	
$(document).ready(function(){
	$('.menuTree a.acollapse').collapsor({easing:'linear', speed: 200});
});

/* trasparenza PNG in IE6 (richiede JQUERY & ifixpng2) ========================================== 

$(document).ready(function(){
	$.ifixpng("img/pixel.gif");
	$("#homeNav div, #homeNav ul, #wrapper").ifixpng();
});*/

/* JSTarget function by Roger Johansson, www.456bereastreet.com ================================== */

var JSTarget = {
	init: function(att,val,warning) {
		if (document.getElementById && document.createElement && document.appendChild) {
			var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
			var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
			var strWarning = ((typeof warning == 'undefined') || (warning == null)) ? ' (opens in a new window)' : warning;
			var oWarning;
			var arrLinks = document.getElementsByTagName('a');
			var oLink;
			var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
			for (var i = 0; i < arrLinks.length; i++) {
				oLink = arrLinks[i];
				if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
					oWarning = document.createElement("em");
					oWarning.appendChild(document.createTextNode(strWarning));
					oLink.appendChild(oWarning);
					oLink.onclick = JSTarget.openWin;
				}
			}
			oWarning = null;
		}
	},
	openWin: function(e) {
		var event = (!e) ? window.event : e;
		if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
		else {
		    var oWin = window.open(this.getAttribute('href'), '_blank');
			if (oWin) {
				if (oWin.focus) oWin.focus();
				return false;
			}
			oWin = null;
			return true;
		}
	},
	/*
	addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	*/
	addEvent: function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn]( window.event );}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
JSTarget.addEvent(window, 'load', function(){JSTarget.init("rel","external","");});