function renderNavMenu() {
   //var currentUrl = document.location.href.replace(siteUrl+wwwRoot,"");
   var currentUrlExploded = currentUrl.split("?");
   currentUrl = currentUrlExploded[0];
   
   
   $("ul.lev1 li a").each(function() {
      var item_title = $(this).text();
      var item_label = escape($(this).text());
      //var item_level = $(this).parent().parent().attr("class");
      //$(this).css("background", "transparent url('"+wwwRoot+"/common/navmenu/"+item_level+"/"+item_label+".png') no-repeat 0 0");
      $(this).html("<img src=\""+wwwRoot+"/common/navmenu/lev1/"+item_label+".png\" />");
         
      //$(this).text("");
      $(this).attr("title",item_title);
      /*
      if($(this).attr("href") == currentUrl) {
         $(this).addClass("on");
      }
      */
         
      $(this).mouseover(function(i) { 
         $(this).parent().addClass("on");
      });
      $(this).mouseout(function(i) { 
         $(this).parent().removeClass("on");
      });
      
   });
   
   
   $("ul.lev2 li a").each(function(i) {
      var item_title = $(this).text();
      var item_label = escape($(this).text());

      $(this).html("<img class=\"off\" id=\"lev2_"+i+"_off\" src=\""+wwwRoot+"/common/navmenu/lev2/"+item_label+".png\" /><img class=\"on\" id=\"lev2_"+i+"_on\"src=\""+wwwRoot+"/common/navmenu/lev2_on/"+item_label+".png\" style=\"display:none\" />");

      $(this).attr("title",item_title);

      if($(this).attr("href") == currentUrl) {
         var off_id = "lev2_"+i+"_off";
         var on_id = "lev2_"+i+"_on";
         $("#"+on_id).show();
         $("#"+off_id).hide();
      }
      
   });

   
   $("ul.lev2 li a img.off").mouseover(function(i) {
      if($(this).parent().attr("href") != currentUrl) {
         var on_id = $(this).attr("id").replace("off","on");
         $(this).hide();
         $("#"+on_id).show();
      }
   });
   
   $("ul.lev2 li a img.on").mouseout(function(i) {
      if($(this).parent().attr("href") != currentUrl) {
         var on_id = $(this).attr("id").replace("on","off");
         $(this).hide();
         $("#"+on_id).show();
      }
   });
   
   if ($.browser.msie) { $("ul.lev1 li a img").ifixpng(); }
   if ($.browser.msie) { $("ul.lev2 li a img").ifixpng(); }
   
   
   
}



function renderTitles(parentObj) {
   $(parentObj+" h1:not(.alt),"+parentObj+" h2:not(.alt),h3:not(.alt),h2:not(.noimg),h3:not(.noimg)").each(function(i) {
      var item_title  = $(this).text();
      var item_label  = escape($(this).text());
      
      var item_level  = this.tagName;
      var item_width  = $(this).css("width");
      var item_class  = $(this).attr("class");
      if (item_class != undefined) {
         item_level = item_level + "_" + item_class;
      }
      if (item_level == 'H1') {
         var item_height= '39px';
      }
      else if (item_level == 'H2') {
         var item_height= '36px';
      }
      else if (item_level == 'H3') {
         var item_height= '10px';
      }
      //var item_height  = $(this).css("height");
      var item_id     = item_level+"_"+i;
      var img_tag = "<img id=\""+item_id+"\" class=\"png\" src=\""+wwwRoot+"/common/titles/"+item_level+"/"+item_width+"/"+item_label+"\" alt=\""+item_title+"\"  />";
      
      $(this).text("");
      $(this).html(img_tag);
   });
   //if ($.browser.msie) { $(".png").ifixpng(); }
}


function renderSlideshow() {
   $(".slideshow").each(function() {
      $(this).show();
      $(this).cycle('fade'); 
   });
   //$('#top_image').cycle('fade'); 
}

function antispam(a,b,c) {
   document.location.href="mailto:"+a+'@'+b+'.'+c;
}


$(document).ready(function(){

   // navmenu
   renderNavMenu();
   
   // titles (h1,h2,h3)
   renderTitles("");
   
   // slideshows
   renderSlideshow();  
   
   // png fix
   $('img[@src$=.png], .png').ifixpng(); 
   
});
