$(function() {
	/** Can't believe we're doing this, but we have to for FF/Mac **/
	if ((navigator.userAgent.indexOf('Macintosh') > -1) && (navigator.userAgent.indexOf('Firefox') > -1))
		$('div.tabs li a').css('max-width', '115px');
	
	
	/** Home Banner **/
	var flashvars = { goURL: '/products' };
    var params = { wmode: "transparent" };
    var attributes = {};
    swfobject.embedSWF("/swf/coraidFlashHeaderApr_2010.swf", "banner", "880", "246", "8.0.0", "swfobject/expressInstall.swf", flashvars, params, attributes);
	
	
	/** Features/Benefits **/
	$('.feature-button').hover(
		// mouseover
		function() {
			var id = $(this).attr('id');
			var title = $('#'+ id +' h2').html();
			var details = $('#'+ id +' .detail').html();
			
			// Add rollover class for this button
			$(this).addClass('over');
			
			// Add a detail class so we can have a bg image
			$('#features-details').addClass(id +'-detail');
			
			// Get the background image
			var bgImage = $('#'+id+' .detail').css('background-image');
			
			// Add the contents into the detail area
			$('#features-details').html('<div class="detail-content"><h2>'+ title +'</h2>' + details + '</div>');
			
			// Move it into place, size
			$('#features-details').css('top', '-150px');
			$('#features-details').css('height', '150px');
			$('#features-details .detail-content').css('background-image', bgImage);
		},
		// mouseout
		function () {
			var id = $(this).attr('id');
			$('#features-details').removeClass(id +'-detail');
			
			$('#features-details').css('top', '0');
			$('#features-details').css('height', '10px');
			$('#features-details').html('');
			$(this).removeClass('over');
		}
	);
	
	
	/** Tabs **/
	$('.tabs li a').hover(
		// mouseover
		function() {
			var id = $(this).attr('href').replace('#', '');
			
			// Hide all tabs
			$('.tab').hide();
			$('.tabs li').removeClass('active');
			
			// Show the corresponding tab
			$('#'+id).show();
			$(this).parent().addClass('active');
		},
		
		// mouseout
		function() {}
		
	).click(
		function() {
			var id = $(this).attr('href').replace('#', '');
			window.location = $('#'+id+' a.more').attr('href');
		}
	);
	
});
