$(function () {

    var swap_nav = {
            showFeatures:           'welding',
            showGlance:             'cutting',
            showVideos:             'punching',
            showFeaturesScroll:     'drilling'
        },
        $content_swapper = $('#contentSwapper'),
        links = [];

    $.each(swap_nav, function (link, div) {

        var $link = $('#'+link);
        links.push($link);
        $link.data('content', $('#'+div));

        $link.click(function (e) {
            e.preventDefault();
            $.each(links, function (i, link) {
                link.removeClass('purple');
            });
            if (link == 'showFeaturesScroll')
                links[0].addClass('purple');
            else
                $link.addClass('purple');
            $content_swapper
                .css('height', $content_swapper.height())
                .fadeTo('fast', 0.001, function () {
                    $content_swapper.children().not($link.data('content')).hide();
                    $link.data('content').show();
                    $content_swapper.fadeTo('fast', 1);
                    $content_swapper.css('height', 'auto');
                });
            return false;
        });

    });

    /*
	var glanceContent   = $("#atAGlanceContent").html(),
		featuresContent = $("#featuresContent").html(),
		videosContent   = $("#videosContent").html();

	$("#showFeatures").click(function(e){		
		if($('#showGlance').attr('class')=='purple'){
			swapContent(featuresContent);
			$("#showGlance").attr('class','');
  		}
  		else if($('#showVideos').attr('class')=='purple'){
  			swapContent(featuresContent);
  			$("#showVideos").attr('class','');	
  		}
  		$("#showFeatures").attr('class','purple');  		  		
  		e.preventDefault();return false;
	});
	
	$("#showFeaturesScroll").click(function(e){		
		if($('#showGlance').attr('class')=='purple'){
			swapContent(featuresContent);
			$("#showGlance").attr('class','');
  		}
  		else if($('#showVideos').attr('class')=='purple'){
  			swapContent(featuresContent);
  			$("#showVideos").attr('class','');	
  		}
  		$("#showFeatures").attr('class','purple');  		  		
  		e.preventDefault();return false;
	});	
	
	$("#showGlance").click(function(e){
		if($('#showFeatures').attr('class')=='purple'){
			swapContent(glanceContent);
			$("#showFeatures").attr('class','');
  		}
  		else if($('#showVideos').attr('class')=='purple'){
  			swapContent(glanceContent);
  			$("#showVideos").attr('class','');	
  		}		
		$("#showGlance").attr('class','purple');  		
		e.preventDefault();return false;
	});
	
	$("#showVideos").click(function(e){		
		if($('#showGlance').attr('class')=='purple'){
			swapContent(videosContent);
			$("#showGlance").attr('class','');
  		}
  		else if($('#showFeatures').attr('class')=='purple'){
			swapContent(videosContent);
			$("#showFeatures").attr('class','');
  		}
		$("#showVideos").attr('class','purple');		
		e.preventDefault();return false;
	});

    var $contentSwapper = $('#contentSwapper');
	function swapContent(newContent){
		$contentSwapper.fadeOut("fast", function() {
			$contentSwapper
			    .html(newContent)
			    .show()
			    .css('visibility', 'hidden')
			    .fadeTo('fast', 0.001, function() {
				    $contentSwapper.css('visibility', 'visible').fadeTo('fast',1);
			    });
		});	
	}
	*/

});

