// JavaScript Document
var current_section = null; //default pane
var speedPerSection = 1500;

function getSpeed(next_section){
	var nextPos = next_section.position();
	var currentPos = current_section.position();
	var diff = Math.abs(nextPos.left - currentPos.left);
	var num_section_away = Math.floor(diff/1024);
	current_section = next_section;
	var speed = num_section_away * speedPerSection;
	return speed;
}



function scrollTo(section){
	var next = $('#'+section);
	$('#window').scrollTo( next, getSpeed(next) );		
	}

$(document).ready(function(){
				  
				  $('.hoverable').each(function(){
				  	var image = $(this);
					var off = image.attr('src');
					var on = image.attr('hover'); 
					image.hover(
						function(){
							image.attr('src',on);
						},
						function(){
							image.attr('src',off);
						}
					);
				  });
				  
				  	   
				  current_section = $('#enter_sweeps'); //default pane
				  $('#test2').click(function(){
						var next = $('#enter_prizes');
						$('#window').scrollTo( next, getSpeed(next) );									
					});
				  
				   $('#test3').click(function(){
						var next = $('#enter_account');
						$('#window').scrollTo( next, getSpeed(next) );		
					});
				   
				   $('#test4').click(function(){
						var next = $('#enter_rules');
						$('#window').scrollTo( next, getSpeed(next) );
					});  
					$('#test5').click(function(){
						var next = $('#enter_rules');
						$('#window').scrollTo( next, getSpeed(next) );
					});
					   
					$('#test').click(function(){
						var next = $('#enter_sweeps');
						$('#window').scrollTo( next, getSpeed(next) );		
					});
					
					$('.open').each(function(){
						var link=$(this).attr('href');
						$(this).click(function(){
							$(link).show();
							return false;
											  });
						
											  });
					
								$('.popup').each(function(){
						var popup=$(this);
							popup.find('a.close').click(function(){
								popup.hide(); 
																 });
																 
															  });
					
				  
				  });

function moveAndclose (parent,where,nav) {
		var flashObject;
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		if(isIE) 
		 flashObject = window['nav'];
		else 
		 flashObject = document['nav'];

		flashObject.deepLink(nav);
		
		$(parent).hide();
	}
