$(document).ready(function(){ //requires jQuery
	Toyota.Contest = (function(){ //Contest singleton	
				var continueBtnToolTipState = "enabled";
				return {
					
					init:function(){
						$('#rules_btn').click(function(){
							Toyota.CommonTools.winOpen($(this).attr('href'), 800, 500, 0, 1);
							return false; 
						});
						
						//bind the tooltip to the #continue_btn
					   $('button#continue_btn').tooltip({
						   showURL:false,
						   onBeforeShow:function(){
							 if (continueBtnToolTipState === 'disabled'){
							   return false;
							 }
						   }
						   }
						 );
										
						//on each refresh make the checkbox unchecked
						$('#read_rule_option').attr('checked',false);
						
						$('#read_rule_option').click(function(){
							$('button#continue_btn').toggleClass('inactive');							
							if($(this).attr('checked') == true){		
								return continueBtnToolTipState = "disabled";	   					
							}else{
								return continueBtnToolTipState = "enabled";	
							}							
   						});
						
                        
						//disable the continue button if the checkbox has not been checked
						$('button#continue_btn').click(function(){
							if($('#read_rule_option').attr('checked') == false){
								return false;
							}
							
						});
						
					}
				};	
			})();
	
	Toyota.Contest.init();		
	
});



