function return_filename(url) {
   if (url)  {
      var m = url.toString().match(/.*\/(.+?)\./);
      if (m && m.length > 1) {
         return m[1];
      }
   }
   return "";
}

$j = jQuery.noConflict();
jQuery(document).ready(function() {
  
  var imgpath = '/fileadmin/template/dynamo-amsterdam.nl/';
  
  /* ------------------------------
    font size
  --------------------------------- */
   // Reset Font Size
    var org_fontsize = $j('#links').css('font-size');
  var org_lineheight = $j('#links').css('line-height');
    var el = $j('#links,#rechts,h1,h2');
  
  $j("#resetfont").click(function(){
      el.css({
      'font-size': org_fontsize,
      'line-height': org_lineheight
    });
    });
    // Increase Font Size
    $j("#increasefont").click(function(){
      var cur_fontnum = parseFloat(el.css('font-size'), 10);
      var new_fontsize = cur_fontnum + 2;
      el.css({
      'font-size': new_fontsize,
      'line-height': 'normal'
    });
      //return false;
    });
    // Decrease Font Size
    $j("#decreasefont").click(function(){
      var cur_fontnum = parseFloat(el.css('font-size'), 10);
      var new_fontsize = (cur_fontnum > 10) ? cur_fontnum - 2 : cur_fontnum;
      el.css({
      'font-size': new_fontsize,
      'line-height': 'normal'
    });
    //return false;
    });  
  
  /* -------------------------
    spice leeftijdmenu   
  ---------------------------- */
  $j(".smenu li:not(.smenu ul li li, .selected)").hover(
      function () {
//      $j(this).stop().animate({backgroundColor: '#7F2456"'}, 100)
      $j(this).stop().animate({backgroundColor: '#931258"'}, 100)  
    }, 
      function () {
      $j(this).stop().animate({backgroundColor: '#d67d22"'}, 800)
      }
  );
  /* ---------------------------
    spice middenkolom
  ------------------------------ */
  $j(".csc-menu li").hover(
      function () {
      $j(this).stop().animate({backgroundColor: '#d67d22"'}, 100)
      }, 
      function () {
      $j(this).stop().animate({backgroundColor: '#931258"'}, 100)
//      $j(this).stop().animate({backgroundColor: '#7F2456"'}, 1000)
      }
  );
  /* ----------------------------
    sf catmenu
    toggle icon's & child ul
  ---------------------------- */
  $j(".news-catmenu .icon").each(function(i,el) {
           
    $j(el).click(function() {
      
      var filename = return_filename($j(el).attr("src") );
      if (filename == 'minusonly') {     
        var imgsrc = $j(this).attr("src").replace("minus", "plus");
        $j(el).parent().find("ul:first").css("display", "none");
      } else {
        var imgsrc = $j(this).attr("src").replace("plus", "minus");
        $j(el).parent().find("ul:first").css("display", "block");
      }
          $j(el).attr("src", imgsrc); 
    });  
  });
  /* -----------------------------
    replace last icon with joinbottom
  -------------------------------- */
  $j(".news-catmenu ul").each(function() {
    

    var last = $j(this).find("li:last").find("img");
    var filename = return_filename($j(last).attr("src") );
    if (filename == 'join') {
      var lastimg = $j(last).attr("src").replace("join", "joinbottom");
      $j(last).attr("src", lastimg); 
    }
  });  
  
  /* ---------------------------
    activiteiten
  ------------------------------ */
/*  var catmenu = $j(".news-catmenu ul li:not(.news-catmenu ul li li, .active)");
  // mousieover
  catmenu.hover(
      function () {
      $j(this).find("a").css("color", "#FFD4BB");
      $j(this).children("a").css("color", "#FFD4BB");
      $j(this).stop().animate({backgroundColor: '#931258'}, 300);
      }, 
      function () {
      $j(this).find("a").css("color", "#FFFFFF"); // all subitems
      //$j(this).children("a").css("color", "#FFC59D");
      $j(this).animate({backgroundColor: '#931258'}, 1000);
      //$j(this).fadeTo(1000,0);
      }
  );*/
  
});
