Event.observe(window, 'load', function() {	

	//Sets the default format of the form
	formset = 0;

	//Creates the cookie instance to retrieve or set the cookie
	jar = new CookieJar({
		expires:'',   // seconds
		path: '/'
		});

	//Attempts to retrieve a previous cookie
	
	clicked = jar.get('clicked');

	if(clicked != null) {
		
	} else {
		
		$('overlay').setStyle({
		top: '-34px'
		});
		
		
		//Reveal the state picker
		Effect.SlideDown('statepick', { duration: .8, delay: .5 });
		$('overlay').appear({ duration: .5, delay: 0, from: 0, to: .4 });
		
		new Effect.Morph('overlay', {
		style: 'top:0px;', // CSS Properties
		duration: .5, // Core Effect properties
		delay: .5
		});
	}

	//Hides the state drop down since javascript is enabled
	//$('stateformfield').hide();


	//Checks to see if a cookie already exists
	
	
	
	//Listens for the Change State link to be clicked

	
	$('continueDropdown').observe('click', function(event) {

	
		
		
		$('overlay').fade({ duration: .5, delay: 1, from:.4, to: 0 });
		
		Effect.SlideUp('statepick', { duration: .5, delay: .5 });
		
		new Effect.Morph('overlay', {
		style: 'top:-34px;', // CSS Properties
		duration: .5, // Core Effect properties
		delay: .5
		});
		
		Event.stop(event);
	
	});
	
	
	//Interval is set on page load to start object listener
	var heightinterval = setInterval("resized()", 10);

});


function resized() {
	var widthset;
	var offsets = document.viewport.getScrollOffsets();
	var string = new String(offsets);
	string = string.replace(/\,+/g,'');
	
	
	widthset = $('printMargins').offsetWidth;
	widthset = widthset + 40;
	
	$('statepick').setStyle({
  	width: widthset+'px'
	});
	
	$('overlay').setStyle({
  	width: widthset+'px'
	});
	
	string2 = string - 148;
	//$('tempfield1').innerHTML = string;
	//$('tempfield2').innerHTML = string2;
	
	if(string > 114) {
	
	$('statepick').setStyle({
  	top: string2+'px'
	});
	
	
	} else {
		
		$('statepick').setStyle({
  		top: '-36px'
		});
		
	}
	
	
	
}



