function switchImages($targetToShow)
{
	imagePath = $("#reqIcon" + $targetToShow).attr("src");
	imagesDirPath = /(\/images\/[^\/]*\/)(.*)/.exec(imagePath)[1];
	$("#reqIcon" + $targetToShow).attr("src", imagesDirPath + "reqIcons_active_" + (24 + $targetToShow -1) + ".png");
	for($i = 1; $i <= 8; $i++)
	{
		if($i != $targetToShow)
		{
			$("#reqIcon" + $i).attr("src", imagesDirPath + "reqIcons_" + (24 + $i -1) + ".png");
		}
	}
}

function stopDemoVideo()
{
		$("#imageBack").animate({
		top:"-30px"
	}, 600);
  	$("#sliderDivDemo").animate({
		width:"307px"
	}, 600);
  	$("#demoImage").fadeIn('slow');
  	$("#demoVideo").hide();
}

function startDemoVideo(){
	trackPageView("video/demo");
	omnitureTrack("demo_video");
	
	getFlashMovie('homeFlash').sendTextToFlash('stop');
		$("#imageBack").animate({
		top:"0px"
	}, 600);
  	$("#sliderDivDemo").animate({
		width:"635px"
	}, 600);
  	$("#demoImage").hide();
  	$("#demoVideo").fadeIn('slow');
}

function showTaf()
{
	$("#coreIndexTaf").show();
	$("#coreIndexOnLoad").hide();
}
$(document).ready(function(){

						   
    $(function(){
	   $(".digitalBox").digitalBox();
	});						   
						   
    $("#imageBack").click(function(){
			stopDemoVideo();
    });

    $("#demoImage").click(function(){
			startDemoVideo();
    });

	$('.inTheBoxRight').click(function() {
		var $el = $(this);
		if ( ! $el.next().is('visible') ){
		   var $openOne = $('div.inTheBoxExpanded:visible');
                   $openOne.slideUp();
                   $openOne.prev().removeClass('inTheBoxRightActive'); 
		   $el.next().slideDown();
                   $el.next().prev().addClass('inTheBoxRightActive'); 
		}
	});
	
	$('p:last-child').addClass('pLast');

    $("#digitalReqsBtn").click(function(){
	
	
			imagePath = $("#digitalReqsBtn").attr("src");
			imagesDirPath = /(\/images\/[^\/]*\/)(.*)/.exec(imagePath)[1];
	
			$("#digitalReqsBtn").attr("src", imagesDirPath + "digitalReqsBtn_active.png");
			$("#digitalBoxBtn").attr("src",imagesDirPath + "digitalBoxBtn.png");
    	$("#digitalSpecsBoxWrapper").animate({
			marginLeft:"-662px"
		}, 600);
    });

    $("#digitalBoxBtn").click(function(){
			
					imagePath = $("#digitalReqsBtn").attr("src");
					imagesDirPath = /(\/images\/[^\/]*\/)(.*)/.exec(imagePath)[1];
			$("#digitalReqsBtn").attr("src", imagesDirPath + "digitalReqsBtn.png");
			$("#digitalBoxBtn").attr("src",imagesDirPath + "digitalBoxBtn_active.png");
    	$("#digitalSpecsBoxWrapper").animate({
			marginLeft:"0px"
		}, 600);
    });
	
    $(".boxImage").click(function(){
    	$("#boxOnLoadCopy").hide('2000');
    });
	
    $(".showVideos").click(function(){
    	$("#coreIndexTaf").hide();
    	$("#coreIndexOnLoad").show();
    });

    $(".showTaf").click(function(){
    	$("#coreIndexTaf").show();
    	$("#coreIndexOnLoad").hide();
    });


	
    $("#reqIcon1").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"0px"}, 600);
	switchImages(1);
    });

    $("#reqIcon2").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-624px"}, 600);
	switchImages(2);
    });

    $("#reqIcon3").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-1248px"}, 600);
	switchImages(3);
    });

    $("#reqIcon4").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-1872px"}, 600);
	switchImages(4);
    });

    $("#reqIcon5").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-2496px"}, 600);
	switchImages(5);
    });

    $("#reqIcon6").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-3120px"}, 600);
	switchImages(6);
    });

    $("#reqIcon7").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-3744px"}, 600);
	switchImages(7);
    });

    $("#reqIcon8").click(function(){
    	$("#reqBottomWrapper").animate({marginLeft:"-4368px"}, 600);
	switchImages(8);
    });

})
