// Fix background image flickering in IE
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) { }

/* begin - Navigation Primary */
var NavigationPrimary = {
  init: function() {    
		var c = this;
		var n = $('#NavigationPrimary');
		
		// Use bgiframe to fix dropdowns over selects if it's available.
		$.fn.bgiframe && $('li', n).bgiframe();

		// Mark parent elements so that we can style them with CSS
		$('> li', n).each(function() { c.markParents(this); });
  	
  	// Use the hoverintent plugin if it's available
  	if ($.fn.hoverIntent)
    {
  	  $('li', n).hoverIntent( {
  	    sensitivity: 1,
  	    over: this.mouseenter,
  	    out: this.mouseleave,
  	    timeout: 100
  	  });
    }
  	else
  	  $('li', n).hover(this.mouseenter, this.mouseleave);
  },
  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); });
	},
	mouseenter: function() { $(this).addClass('over').children('a').addClass('over'); },
	mouseleave: function() { $(this).removeClass('over').children('a').removeClass('over'); }
	
};
$(function() { NavigationPrimary.init(); });
/* end - Primary Navigation */

/* begin - Navigation Secondary */
var NavigationSecondary = {
  init: function() {    
		var c = this;
		var n = $('#NavigationSecondary');
		
		// Use bgiframe to fix dropdowns over selects if it's available.
		$.fn.bgiframe && $('li', n).bgiframe();

		// Mark parent elements so that we can style them with CSS
		$('> li', n).each(function() { c.markParents(this); });
  	
  	// Use the hoverintent plugin if it's available
  	if ($.fn.hoverIntent)
    {
  	  $('li', n).hoverIntent( {
  	    sensitivity: 1,
  	    over: this.mouseenter,
  	    out: this.mouseleave,
  	    timeout: 100
  	  });
    }
  	else
  	  $('li', n).hover(this.mouseenter, this.mouseleave);
  },
  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); });
	},
	mouseenter: function() { $(this).addClass('over').children('a').addClass('over'); },
	mouseleave: function() { $(this).removeClass('over').children('a').removeClass('over'); }
	
};
$(function() { NavigationSecondary.init(); });
/* end - Secondary Navigation */

/* Preload background images */
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}

$.preloadImages(
	"/images/home/enterprise-applications-on.gif", 
	"/images/home/cloud-services-hosting-on.gif",
	"/images/home/disaster-recovery-on.gif",
	"/images/home/high-availability-on.gif",
	"/images/home/infrastructure-on.gif",
	"/images/secondary-navigation/footer-bg-on.gif",
	"/images/common/primary-nav-on.gif"
);
/* End of preload background images */

/* begin - open new window for external links and pdfs */
	$(function() {
		$('#Wrapper a[href^=http://]')
			.not($('a.noPopup'))
			.popupwindow(); // Fully qualified links
		$('#Wrapper a[href^=https://]').popupwindow(); // Secure HTTP connection links
		$('#Wrapper a[href$=.pdf]').popupwindow(); // PDFs by URL
		$('#Wrapper a.popup').popupwindow(); // specific internal links
		
	});
/* end - open new window for external links and pdfs */