
function renderNavMenu() {
	 //alert(siteUrl+wwwRoot)
   var currentUrl = document.location.href.replace(siteUrl,"");
	 //alert(document.location.href+"\n"+currentUrl)
   var currentUrlExploded = currentUrl.split("?");
   currentUrl = currentUrlExploded[0];
   $("#main_nav").find("a").each(function() {
      var item_title = $(this).text();
      var item_label = escape($(this).text());
      //alert(wwwRoot+"/dynamic/img/navmenu/"+item_level+"/"+item_label+".gif");
      var item_level = $(this).parent().parent().attr("class");
      //alert(wwwRoot+"/dynamic/img/navmenu/"+item_level+"/"+item_label);
      $(this).css("background", "transparent url('"+wwwRoot+"/dynamic/img/navmenu/"+item_level+"/"+item_label+".gif') no-repeat 0 0");
      //$(this).text("");
      $(this).attr("title",item_title);
      //alert($(this).attr("href")+" == "+currentUrl);
      if($(this).attr("href") == currentUrl) {
         $(this).addClass("on");
      }
   });
}
function renderFooter() {
	 //alert(siteUrl+wwwRoot)
   var currentUrl = document.location.href.replace(siteUrl,"");
	 //alert(document.location.href+"\n"+currentUrl)
   var currentUrlExploded = currentUrl.split("?");
   currentUrl = currentUrlExploded[0];
   $("#footer").find("a").each(function() {
      var item_title = $(this).text();
      if(item_title)
      {
      var item_label = escape($(this).text());
      //alert(wwwRoot+"/dynamic/img/navmenu/"+item_level+"/"+item_label+".gif");
      var item_level = $(this).parent().parent().attr("class");
      //alert(wwwRoot+"/dynamic/img/navmenu/"+item_level+"/"+item_label);
      //alert(wwwRoot+"/dynamic/img/footer/"+item_level+"/"+item_label+".gif")
      $(this).html("<img src=\""+wwwRoot+"/dynamic/img/footer/"+item_level+"/"+item_label+".gif\" border=\"0\">");
      //$(this).text("");
      $(this).attr("title",item_title);
      //alert($(this).attr("href")+" == "+currentUrl);
      if($(this).attr("href") == currentUrl) {
         $(this).addClass("on");
      }
      }
   });
}

function renderScrollableLayers(parentObj) {
   $(parentObj+" .scroll-pane").jScrollPane({
      scrollbarWidth:7, 
      scrollbarMargin:0,
      dragMinHeight:25,
      dragMaxHeight:25,
      dragMaxWidth:25,
      showArrows:true,
      arrowSize: 3
   });
}

function renderTitles(parentObj) {
   
   $(parentObj+" h1:not(.alt),"+parentObj+" h2:not(.alt),h3:not(.alt)").each(function(i) {
      var item_title  = $(this).text();
      
      if (item_title != '') {
      
   	   var alternativeStyle  = $(this).attr("class");
   	   if(alternativeStyle){
   	     var item_level  = alternativeStyle;
   	   }
   	   else {
   	     var item_level  = this.tagName;
   	   }
   	      
   	   //alert(item_title);
   	   //alert(item_level);
   	      
          var item_label  = escape($(this).text());
   	      var item_width  = $(this).css("width");
   	      if (item_level == 'H1') {
   	         var item_height= '21px';
   	      }
   	      else if (item_level == 'H2') {
   	         var item_height= '21px';
   	      }
   	      else if (item_level == 'H3') {
   	         var item_height= '16px';
   	      }
   	      
   	      //var item_height  = $(this).css("height");
   	      var item_id     = item_level+"_"+i;
   	      //alert(item_width+" || "+item_height);
   	      var img_tag = "<img id=\""+item_id+"\" style=\"/*width:"+item_width+";height:"+item_height+"*/\" src=\""+wwwRoot+"/dynamic/img/titles/"+item_level+"/"+item_width+"/"+item_label+".png\" alt=\""+item_title+"\" />";
   	      
   	      $(this).text("");
   	      $(this).html(img_tag);
      }
   });
   if ($.browser.msie) { $(".png").ifixpng(); }
}

function dialog(content,width,height) {

   $("#ex2").css("width",width+"px");
   $("#ex2").css("height",height+"px");
   $("#ex2").css("top","50%");
   $("#ex2").css("margin-top","-"+(height/2)+"px");
   $("#ex2").css("margin-left","-"+(width/2)+"px");
   $("#ex2").html("<table width=\"100%\" height=\"100%\"><tr><td align=\"center\" valign=\"middle\"><img src=\""+wwwroot+"/comuni/img/loading.gif\" alt=\"loading\" style=\"padding-top: 4px\" /> loading...</td></tr></table>");
   $("#ex2").jqm({overlay:50}).jqmShow();

	   $.ajax({
	      type:     "GET",
	      url:      content,
	      success: function(response){
	         $("#ex2").html(response);
	      }
	   });

}



function showHide()
{
    if ($('#lineeList').is(":hidden")) {
      $('#lineeList').slideDown("fast");
    } else {
      $('#lineeList').slideUp("fast");
    }
}

function showHideBox(pref,id)
{
    if ($('#'+pref+id).is(":hidden")) {
    	$('.'+pref).slideUp("fast");
      $('#'+pref+id).slideDown("fast");
    } else {
      $('#'+pref+id).slideUp("fast");
    }
}

/* ------------------------------------------------------------------
// DOCUMENT READY
------------------------------------------------------------------ */
$(document).ready(function() {
   //renderTitles("");
   //if ($.browser.msie) { $('img[@src$=.png]').ifixpng(); $('.png').ifixpng(); }
   // fix IE6 flickering images bug
   try {
      document.execCommand("BackgroundImageCache", false, true);
   } catch(err) {}

    /*$('#logo').flash({
        src: wwwRoot+'/comuni/swf/top.swf',
        width: 939,
        height: 273
    });*/

    /* 
   $('#slideshowBox').slideshow({
        width:939,
        height:273, 
        time:3500, 
        effect:'fade',  // aviable fade, scrollUp/Down/Left/Right, zoom, zoomFade, growX, growY
        effecttime:1000,// aviable fast,slow,normal and any valid fx speed value
        title:false,     // show title
        panel:false,     // show controls panel
        imgcenter:true,       // set image to center // TODO     
        playframe:false}).playSlide();     
        
        //alert(756)
	jQuery("#ticker").ticker({
 		cursorList:  " ",
 		rate:        10,
 		delay:       4000
	}).trigger("play").trigger("stop");

    // Trigger events ----------------------------------------------------------

    jQuery(".stop").click(function(){
        jQuery("#ticker").trigger("stop");
        return false;
    });
    
    jQuery(".play").click(function(){
        jQuery("#ticker").trigger("play");
        return false;
    });
    
    jQuery(".speedup").click(function(){
        jQuery("#ticker")
        .trigger({
            type: "control",
            item: 0,
            rate: 10,
            delay: 4000
        })
        return false;
    });
    
    jQuery(".slowdown").click(function(){
        jQuery("#ticker")
        .trigger({
            type: "control",
            item: 0,
            rate: 90,
            delay: 8000
        })
        return false;
    });
    
    jQuery(".next").live("click", function(){
        jQuery("#ticker")
        .trigger({type: "play"})
        .trigger({type: "stop"});
        return false;
    });

    jQuery(".style").click(function(){
        jQuery("#ticker")
        .trigger({
            type: "control",
            cursor: jQuery("#ticker").data("ticker").cursor.css({width: "4em", background: "#efefef", position: "relative", top: "1em", left: "-1em"})
        })
        return false;
    });*/
     
})

