// IE6 flicker fix
try { document.execCommand("BackgroundImageCache", false, true); } catch(err) {}

// allow jquery to work with Sitecore Prototype ($) and others
$.noConflict();

// add code to make js aware
jQuery("html").addClass("js");

// define FBR object if not present
if (!FBR) var FBR = {};

// all your code inside here to declare it
(function($) {
	FBR.setup = function(){
		// css fixes
		$("li:first-child").addClass("first");
		$("li:last-child").addClass("last");
		$("#nav-primary > li > a").addClass("a-1");
		$("#nav-primary > li").addClass("li-1").bind('mouseover',function(){
			$(this).addClass('over');
		});
		$("#nav-primary > li").bind('mouseout',function(){
			$(this).removeClass('over');
		});
		$("#nav-primary > li > ul").each(function(i){
			$(this).attr("id", "ul-" + (i+1))
		});
		// $("#nav-primary").before("<div id=\"nav-shim\"></div>");
		$("#container").append("<div id=\"nav-shim\"></div>");
		
		if ($.browser.msie && $.browser.version < 8) {
			$("#nav-primary > li.li-1.first").addClass("iefirst");
			if ($.browser.version < 7) {
				$("#nav-primary li.li-1").eq(2).addClass('iefix');
				$("#nav-primary li.li-1").eq(1).bind('mouseover', function(){
					$("#nav-primary li.li-1").eq(2).removeClass('iefix');
				});
				$("#nav-primary li.li-1").eq(1).bind('mouseout', function(){
					$("#nav-primary li.li-1").eq(2).addClass('iefix');
				});
			};
		};
		
		$("#branding-slideshow p.btn-learnmore a").prepend("<span class=\"btn\">&nbsp;</span>").append("<span class=\"edge\">&nbsp;</span>");
		
		if ( $("#branding-slideshow .slide").size() > 1 ) {
			// slide show code
			$('#branding-slideshow .content').cycle({
				fx: 'fade',
				speed: 'slow',
				timeout: 3500,
				pause: true,
				pager: '#branding-slideshow .controls ul',
				pagerAnchorBuilder: function(id) {
				   return '<li><a href="#"><span></span></a></li>';
				}		
			});

			$('#branding-slideshow .controls a').click(function(){
				$(this).blur();
			});

			$('#branding-slideshow .controls > a').click(function(){
				if($(this).hasClass('pause')) {
					$('#branding-slideshow .content').cycle('resume');		
					$(this).removeClass('pause');
					$(this).addClass('play');				
				} else {
					$('#branding-slideshow .content').cycle('pause');		
					$(this).removeClass('play');
					$(this).addClass('pause');							
				}
				return false;	
			});		
		} else {
			$("a.playback").remove();
		}

	};
		
	// domloaded
	$(function(){
		FBR.setup();
	})

})(jQuery);


