// Fix background image flickering in IE
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) { }

/* begin - Navigation Primary */
var NavigationPrimary = {
  init: function() {
    if ($.browser.msie) // iframe to fix dropdowns over select items
        $('#NavigationPrimary li').append('<iframe style="display: none;" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>');
		
		var c = this;
		var n = $('#NavigationPrimary');
		// Mark parent elements so that we can style them with CSS
		$('> li', n).each(function() { c.markParents(this); });
  	
    $('li', n).hover(
      function() {
        $(this).addClass('over').children('a').addClass('over');
        if ($.browser.msie)
        {
          var h = $(this).children('ul').height();
          var w = $(this).children('ul').width() + 1;
          var i = $(this).children('iframe');
          if (i.length > 0 && h != null && w != null)
            i.height(h).width(w).show();  
        }
      },
      function() {
        $(this).removeClass('over').children('a').removeClass('over');
        if ($.browser.msie)
          $(this).children('iframe').hide();
      }
    );
  },
  markParents: function(li) {
    var c = this;
    if ($('> ul', li).size() > 0)
	    $(li).addClass('parent').find('> a').addClass('parent').end().find('> ul li').each( function() { c.markParents(this); });
	}
	
};
$(function() { NavigationPrimary.init(); });
/* end - Primary Navigation */

function toggledivs() {
  var inc, endInc=arguments.length;
  for (inc=0; inc<endInc; inc+=2) {
    var id = arguments[inc];
    if (arguments[inc+1] == 'none') param = "none";
    else if(arguments[inc+1]=='block') param = "block";
    if (document.layers) document.layers['container'].layers[id].visibility = param;
    else if (document.all) eval("document.all." + id + ".style.display = \"" + param + "\"");
    else if (document.getElementById) eval("document.getElementById(id).style.display = \"" + param + "\"");
  }
}

function imageover(el,which){
  el.src=el.getAttribute(which || "off");
}

function imageswap(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var over = x[i].getAttribute("over");
    if (!over) continue;
      
    // preload image
    x[i].over_img = new Image();
    x[i].over_img.src=over;
    // set event handlers
    x[i].onmouseover = new Function("imageover(this,'over');");
    x[i].onmouseout = new Function("imageover(this);");
    // save original src
    x[i].setAttribute("off",x[i].src);
  }
}