$(document).ready(function() {
	
	//settings
	var opacity = 1, toOpacity = 0.8, duration = 100, textOpacity = 0.4;
	
	//hide the contest steps ul
	$('#contestSteps').hide();
	$('#contestSteps').children().hide();
	$('#contestForms').hide();
	//$('#contestSteps li').children().fadeTo(0, .4);
	$("#step1").fadeTo(1, 1);
	$("#step2").fadeTo(1, .4);
	$("#step3").fadeTo(1, .4);
	$("#step4").fadeTo(1, .4);
	
	
	//set opacity and events for hover states
	$('#mainNav a img').css('opacity',opacity).hover(function() {
													
			$(this).fadeTo(duration,toOpacity);
			
		}, function() {
			
			$(this).fadeTo(duration,opacity);
		}
	);
	
	//set opacity and events for hover states
	$('#enterAge a').css('opacity',opacity).hover(function() {
													
			$(this).fadeTo(duration,toOpacity);
			
		}, function() {
			
			$(this).fadeTo(duration,opacity);
		}
	);
	
	
	//creates the on state for contest button, expands the steps and form
	/*$('a#contest').click(function(){          
        		
		//shows the ul
		$('#contestSteps').slideDown(400, function(){
			
			//shows the ul content after its open
			$(this).children().show(200);
			
			//sets first instruction to full opacity
			$('#step1').children().fadeTo(0, 1);
			
			//shows contest form holder
			$('#contestForms').animate({width: '940px', height: '294px'}, {duration: 'medium', 'easing': 'swing'});
			
		});
    	
		//opens the height of the nav container to fit the form
		$('#mainNav').animate({height: '373px'}, 400);
	
    
			return false;                                           
			
		});*/
		
	//creates the on state for contest button on the about page, moves browser up then expands the steps and form
	$('a#contestBottom').click(function(){    
	
		//moves browser position to the top of the page
		$.scrollTo('#container', 500, {onAfter:function(){ 
		
			//shows the ul
			$('#contestSteps').slideDown(400, function(){
				
				//shows the ul content after its open
				$(this).children().show(200);
				
				//sets first instruction to full opacity
				$('#step1').children().fadeTo(0, 1);
				
				//shows contest form holder
				$('#contestForms').animate({width: '940px', height: '294px'}, {duration: 'medium', 'easing': 'swing'});
				
				
			});
		
		} });      
        		
		    	
		//opens the height of the nav container to fit the form
		$('#mainNav').animate({height: '373px'}, 400);
	
    
			return false;                                           
			
		});
	
	//closes the contest panel
	$('.closeContest').click(function(){          
        		
		//hides the contestSteps children
		$('#contestSteps').children().hide();
		
		//hides contestSteps
		$('#contestSteps').slideUp(200);
		
		//hides contestForms
		$('#contestForms').hide(150);
    	
		//closes the height of the nav container to fit the form
		$('#mainNav').animate({height: '69px'}, 200);
    
			return false;                                           
			
		});
		
	
		
		
		//closes the contest panel after submit
	$('.submitClose').click(function(){          
        		
		//hides the contestSteps children
		$('#contestSteps').children().hide();
		
		//hides contestSteps
		$('#contestSteps').slideUp(200);
		
		//hides contestForms
		$('#contestForms').hide(150);
    	
		//closes the height of the nav container to fit the form
		$('#mainNav').animate({height: '69px'}, 200);
    
			return false;                                           
			
		});
	
	
	//tabs for the share form
	$(function() {
		   function handleTabSelect(event, tab) {

             if (tab.index == 0) {

                 // Facebook tab selected
                 $('img#facebooktab').attr({ src: src="/images/tab_facebook.png" });
                 $('img#emailtab').attr({ src: "/images/tab_email_off.png" });
             }

             else if (tab.index == 1) {

                 // Email tab selected
                 $('img#emailtab').attr({ src: "/images/tab_email.png" });
				 $('img#facebooktab').attr({ src: "/images/tab_facebook_off.png" });
             }
         }

         // set tab constructor values & initialize tabs
         $('#tabShare').tabs({ selected: '0', select: handleTabSelect });

     });
	 


});
