function get_arg(arg, qstr, dval) {
  args = qstr.split('&');
  r = '';
  for (var i = 0; i < args.length; i++) {
    if (args[i].slice(0,args[i].indexOf('=')) == arg) {
      r = args[i].slice(args[i].indexOf('=')+1);
      break;
    }
  }
  return (r.length > 0 ? unescape(r).split(',') : dval)
}

function loadurl(url, qstr, container) {
  var cache = get_arg("c", qstr, 1);

  if (cache && $.jCache.hasItem(url)) {
    container.html($.jCache.getItem(url)+"<p>This content was loaded from cache!</p>");
  } else {
    $.ajax({
      type: "GET",
      url: url,
      data: qstr,
      success: function(msg) {
        if (cache != 0)
          $.jCache.setItem(url, msg);
        container.html(msg);
      },
      error: function(xhdr, status, err) {
        container.html("Error retrieving info: "+status+"/"+err);
      }
    });
  }
}

(function($) {
  var cookies = Array();
  var prefix = "_once_";
  var pair, el = document.cookie.split(';');
  for(var i = 0; i < el.length; i++)
  {
      pair = el[i].split('=');
      cookies[pair[0].replace(/^\s\s*/, '').replace(/\s\s*$/, '')] = 1;
  }

  $.fn.once = function(fn, when) {
    if (fn == undefined) return;
    this.each(function(){
      if (this.id != undefined && cookies[prefix+this.id] == undefined) {
        var expires = '';
        if (when != undefined)
        {
          expires = new Date();
          expires.setTime(expires.getTime() + when*1000);
          expires = '; expires=' + expires.toGMTString();
        }
        document.cookie = prefix + this.id + '=1' + expires + '; path=/';
  
        fn();
      }
    });
    return this;
  }
}) (jQuery);

$(document).ready(function(){
  sfclear = function() { $(".menu li").each(function () { this.className = this.className.replace(/sfhover/, ""); }); };
  $(".menu li").mouseover(function() { sfclear(); this.className += " sfhover"; });
  $(".menu li").mouseout(function() { sfclear(); });

  $(".imgscroll").once(function(){
    var content = $("#content");
    var text = $("#content-text");
    content.css('position', 'absolute');
    content.css('top', '26.75em' /*$("#content-wrap").css('height')*/);
    text.css('display', 'none');
    content.animate({ top: 0 }, 5000, 'swing', function() {
    text.fadeIn(2000);});
  });
});
