var gooCalc = {
	ready : function() {
		//setting initial radio button and select states
		$('input#Front').attr("checked", true);
		$('input#Rear').attr("checked", false);
		$('select#projectorBrightness').attr("disabled", false);
		$('select#ambientLight').attr("disabled", false);
		//disabling selects based on selection and setting common variables
		var $gooCalcRearRec = $('div#gooCalcRearRec');
		var $gooCalcWhiteRec = $('div#gooCalcWhiteRec');
		var $gooCalcMaxRec = $('div#gooCalcMaxRec');
		var $gooCalcHighRec = $('div#gooCalcHighRec');
		var $gooCalculate = $('input#gooCalculate');
		$('input#Rear').click(
		  function(){
			  $('select#projectorBrightness').attr("disabled", true);
			  $('select#ambientLight').attr("disabled", true);
		  });
		$('input#Front').click(
		  function(){
			  $('select#projectorBrightness').attr("disabled", false);
			  $('select#ambientLight').attr("disabled", false);
		  });
		$gooCalculate.click(
			function(){
				var $projType = $('input:radio:checked').val();
				var $projBrightness = $('select#projectorBrightness').val();
				var $ambientLight = $('select#ambientLight').val();
				if ($projType == 'Rear'){
					$gooCalcRearRec.animate({top:"20px"},500,'swing');
				} else if (($projBrightness == 1 && $ambientLight== 3) || ($projBrightness == 1 && $ambientLight== 2) ||  ($projBrightness == 2 && $ambientLight== 3)) {
					$gooCalcWhiteRec.animate({top:"20px"},500,'swing');
				} else if (($projBrightness == 2 && $ambientLight== 2) || ($projBrightness == 1 && $ambientLight== 1) || ($projBrightness == 3 && $ambientLight== 3)){
					$gooCalcHighRec.animate({top:"20px"},500,'swing');
				} else {
					$gooCalcMaxRec.animate({top:"20px"},500,'swing');
				}
				});
		$('a#calcRearHide').click(
            function(event){
				event.preventDefault();
				$gooCalcRearRec.animate({top:"200px"},500,'swing');
			});
		$('a#calcMaxHide').click(
            function(event){
				event.preventDefault();
				$gooCalcMaxRec.animate({top:"200px"},500,'swing');
			});
		$('a#calcHighHide').click(
            function(event){
				event.preventDefault();
				$gooCalcHighRec.animate({top:"200px"},500,'swing');
			});
		$('a#calcWhiteHide').click(
            function(event){
				event.preventDefault();
				$gooCalcWhiteRec.animate({top:"200px"},500,'swing');
			});
	}
}


var tabsObj = {	
	ready : function(){
		var gooPicArray=new Array();
		//goo gallery array
		gooPicArray[0]="goo-3.jpg";
		gooPicArray[1]="goo-4.jpg";
		gooPicArray[2]="goo-2.jpg";
		gooPicArray[3]="goo-6.jpg";
		var animationInProgress = 0;
		var $gooBanner = $('img.gooBanner');
		var $gooText = $('div.gooText');
		var $gooTabList = $('div#gooContainerTabs ul li');
		//hiding hiden tabs
		$gooBanner.first().nextAll().hide();
		$gooText.first().nextAll().hide();
		$gooTabList.first().addClass('gooTabOn');
		//rollover tab text coloring
		$gooTabList.hover( function(){ $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); });
		//gallery image clicked function
		$('img.gooThumbnail').mouseenter( function(){
			var imageMousedOver = $('img.gooThumbnail').index(this);
			$('img#gooBanner2').attr("src","images/manuPageLayouts/gooGallery/"+gooPicArray[imageMousedOver]) 
			});
		//tab clicked function
		$gooTabList.click( 
		function(){
		//determining if the tab clicked should be animated or if another animation is still in progress
		var currentPosition = $gooTabList.index(this);
		var gooPicVisible = $('img#gooBanner'+currentPosition+':visible').size();
		
			if ((!animationInProgress)&&(gooPicVisible !== 1)){
				animationInProgress = 1;
				$('div#gooContainerTabs ul li.gooTabOn').removeClass('gooTabOn');
				$(this).addClass('gooTabOn');
				$gooBanner.fadeOut('slow');
				$gooText.hide();
				$('div#gooText'+currentPosition).show();
				$('img#gooBanner'+currentPosition).fadeIn(400,
					function (){
					 	$().delay(60, animationInProgress = 0);
								});
				}
		});
	}
};
$(document).ready(tabsObj.ready);
$(document).ready(gooCalc.ready);
