var $j;
if (location.href.match(/\/azienda\/campagne-pubblicitarie/i) || location.href.match(/\/azienda\/photo-gallery/i) || location.href.match(/\/partner\/formazione-partner/i)){
		$j = jQuery.noConflict();
} else {
	$j = $;	
}

$j(document).ready(function(){	
	
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	$j.getScript(gaJsHost + "google-analytics.com/ga.js", function(){

		try {
			var pageTracker = _gat._getTracker("UA-4119077-2");
			pageTracker._trackPageview();
		} catch(err) {
			var x=1;
		}
	});
	
	//italiaOggi
	//try {
		/*if ($j.cookie('itOggiCookie') != "yes"){
			//non è stato mai visualizzato il bannerone
			$j("body").prepend('<div id="itOggiOverlay" style="z-index:9119;left:0;"><div style="margin:0 auto;width:1030px;"><div id="itOggiOverlayFlash">&nbsp;&nbsp;</div></div></div>');
			$j("#itOggiOverlay").height(200).width("100%").css("position","fixed").css("top","180px");
			var soit = new SWFObject("/fileadmin/flash/Banner_tour_OverLayer_pxl.swf", "italiaoggibannerone", "1030", "180", "9", "#FFFFFF");
			soit.addParam("wmode", "transparent");
			soit.write("itOggiOverlayFlash");
			
			$j.cookie('itOggiCookie', "yes", { expires: 1 });
		}*/
	/*} catch(err) {
		var iiiii=1;
	}*/
    
	//uniformazione dei input di login box
	if ($j.browser.msie){
		//ie
		$j("#form_area_riservata input").not("#invia").css("width","56px").css("height","14px");
		$j("#form_area_riservata #invia").css("width","56px").css("height","18px").css("top","6px");
	} else {
		//browser degni di questo nome
		$j("#form_area_riservata input").not("#invia").css("width","56px").css("height","14px");
		$j("#form_area_riservata #invia").css("width","56px").css("height","18px").css("margin-top","1px");
	}
	
	//homepage?
	if (location.pathname == "/"){
		//blocco per la home
		$j(".corpo_notizia:last").css("border-bottom","none");
		$j("#contenitore_soluzione .intestazione_grigia").prev().prev(".cella_soluzione").css("border-bottom","none");
		$j("#contenitore_soluzione .cella_soluzione:last").css("border-bottom","none");
		
	}
	
	//link attivo
	highlight_active_sidebar_links();	
	
	//codice menu
	$j("#top_menu li").not(".intermezzo").bind("mouseenter",function(){
		$j("#top_menu li").removeClass("lion");
		$j("#bottom_menu ul").css("display","none");
		$j(this).addClass("lion");		
		var id = "#" + $j(this).attr("id") + "_contenuto";		
		$j(id).css("display","block");
	}).bind("mouseleave",function(){});

	if (location.href.match(/\/azienda/i)){
		$j("#top_li_2").addClass("lion");
		$j("#top_li_2_contenuto").show();
	} else if (location.href.match(/\/soluzioni-gestionali/i)){
		$j("#top_li_3").addClass("lion");
		$j("#top_li_3_contenuto").show();
	} else if (location.href.match(/\/partner/i)){
		$j("#top_li_4").addClass("lion");
		$j("#top_li_4_contenuto").show();
	}

	/*****    click su search  *******/
	$j("div#searchbox input").click(function(e){
		$j(this).val("");
	});
	
	$j("div#searchbox input").keypress(function (e) { 
		if (e.which == 13){
			$j("#form_searchbox").submit();
		}
	});	
	/********* end ***********/
	
	/********** mi trovo nelle news? *************
	if (location.pathname.match(/^\/news\//i)){
		//ci sono le notizie?
		var ln = $("div.news-list-container>div.news-list-item").length;
		if (ln == 1){
			//se c'è una sola notizia la trovo ed effettuo redirect
			document.location = $("div.news_abstract a").attr("href");
		}
	}*/
	
	//rimozione di ultimi intermezzi
	$j("ul li.intermezzo:last-child").hide();
	
	//search
	if ($j("#tx-indexedsearch-searchbox-sword").length == 1){
		$j("#form_searchbox input[type=text]").val($j("#tx-indexedsearch-searchbox-sword").val());
	}
	
	function highlight_active_sidebar_links() {
		$j("#bottom_menu a").each(function(){
			var current_href = $j(this).attr("href");
			if (!$j.browser.msie) {
				current_href = $j(this).attr("baseURI") + current_href;
			} else {
				current_href = $j(this).get(0).href;
			}
			if (document.location.href == current_href ) {
				$j(this).css("color","#E2001A");			
				return;
			}
		});
	}
});
function chiudiOverlayItOggi(){
    $("#itOggiOverlay").hide();
}

