jQuery(document).ready(function($) {
	
	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		DD_belatedPNG.fix('h1#logo a, #featured, #navigation li a, #main-content, .box h3, .box-b, #overlay, img');
	};
	
	$(window).resize(function() {
		$('#overlay').css({
			width: '100%',
			height: $(document).height()
		});
	}).resize();
	
	$('#navigation li a').click(function() {
		if ($(this).attr('href') != '#' && $(this).attr('id') != 'link' ) {
			var href = $(this).attr('href');
			$('#overlay').fadeIn();
			$(href).fadeIn();
			return false;
		};
	});
	
	$('.brands li a').click(function() {
		$(this).parents('.popup').fadeOut();
		if ($(this).attr('href') != '#' && $(this).attr('id') != 'link' ) {
			var href = $(this).attr('href');
			$('#overlay').fadeIn();
			$(href).fadeIn();
			return false;
		};
	});
	
	$('.popup .close').click(function() {
		$(this).parents('.popup').fadeOut();
		$('#overlay').fadeOut();
		return false;
	});
	
	$('#spar').click(function() {
		if ($(this).attr('href') != '#') {
			var href = $(this).attr('href');
			$('#overlay').fadeIn();
			$(href).fadeIn();
			return false;
		};
	});
	
	
	var titles = $('#s4 div.item').find("h2").map(function() { return $(this).text(); });
	//Add an unordered list to contain the navigation
	//Invoke the cycle plugin on #cycleContainer
	$('#s4').before('<ul id="pager"></ul>').cycle({
	//Specify options
	fx:     'fade', //Name of transition effect 
	timeout: 0,           //Disable auto advance
	pager:  '#pager',         //Selector for element to use as pager container 
	pagerAnchorBuilder: function (index) {               //Build the pager
	return '<li class="' + titles[index] + '"><a href="#">' + titles[index] + '</a></li>';
	},
	updateActivePagerLink: function(pager, currSlideIndex) { 
	$(pager).find('li').removeClass('active').filter('li:eq('+currSlideIndex+')').addClass('active'); 
	}
	});
	
	
	
});
