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

// IE6 alpha PNG support
// http://www.dillerdesign.com/experiment/DD_belatedPNG/
var DD_belatedPNG;
if (DD_belatedPNG) {
	DD_belatedPNG.fix('.featureBox .channel .icon img, .featuredWebcast p.image img, .featureBox .speaker p.logo img, .featuredWebcast p img');
}

// Convert on-tabbed display into tabbed display and activate tabs
$(document).ready(function() {
	var $tabs = $('div.tabs');
	var $tabnav = $tabs.find('ul.tabNav');
	if ($tabnav.length == 0) {
		$tabnav = $tabs.prepend('<ul class="tabNav selfclear"></li>').find('> ul');
		$tabs	.find('> div')
			.each( function(i) {
				var id = this.id;
				var $h2 = $(this).find('h2');
				var title = $h2.html();
				$tabnav.append('<li><a href="#' + id + '" class="noPopup"><span>' + title + '</span></a></li>');
				$h2.remove();
			});
			// Need delay for browsers to get their DOM in order
			setTimeout(
				function() {
					$tabs.tabs();

					// Enable links to tabs to activate tab
					$('a.tabLink').click(function() { // bind click event to link
						$tabs.tabs('select', this.hash);
						return false;
					});

					// Scroll back to top if there's a tab to select.
					// Need to do this because we have a delay before tabs are built and browsers will
					// scroll down to where the tab content was before the tab was built.
					//if (document.location.hash)
					//	$.scrollTo(0);
				},
				500
			);


			window.scrollTo(0,0);
	}
	
	$('#BannerNav a').hover(function() {
	$('#BannerNav a').removeClass("active");
	$(this).addClass("active");
	var setelem = $(this).attr("rel");							   
	$('.homeBanners').hide();
	$(setelem).show();
	
	

	
	return false;

  });
		 
});

/* begin - Navigation Primary */
var NavigationPrimary = {
  init: function() {    
		var c = this;
		var n = $('#NavigationPrimary ul');
		
		// 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 function for the expandable lists */
var expandableList = {

	init: function() {
		if (document.location.hash) {
				
				var setelem = document.location.hash;
				var setaelem = document.location.hash + "Show";
				var setbelem = document.location.hash + "Hide";
			    expandableList.showInfo(setelem,setaelem, setbelem);
				$.scrollTo(setelem);
		}
		$('img.show').click(
			function() {
				var setelem = "#" + $(this).attr("rel");
				var setaelem = "#" + $(this).attr("rel") + "Show";
				var setbelem = "#" + $(this).attr("rel") + "Hide";
			    expandableList.showInfo(setelem,setaelem, setbelem);
				
				return false;
			}
		);
		$('img.hide').click(
			function() {
				var setelem = "#" + $(this).attr("rel");
				var setaelem = "#" + $(this).attr("rel") + "Hide";
				var setbelem = "#" + $(this).attr("rel") + "Show";
				expandableList.hideInfo(setelem,setaelem, setbelem);
				return false;
			}
		);
	},
	showInfo: function(el, ela, elb) {
		// el is the div that contains the title to show info for
		$(el).show();
		$(ela).hide();
		$(elb).show();
		return false;
	},

	hideInfo: function(el, ela, elb) {
		// el is the div that contains the title to show info for
		$(el).hide();
		$(ela).hide();
		$(elb).show();
		return false;
	}

};
$(function() { expandableList.init(); });
/* end function for the expandable list */

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