Event.observe(window, "load", function(){
	$('enterFormContent').setOpacity(0);
	$('rulesContent').setOpacity(0);
	$('prizesContent').setOpacity(0);
	$('mainWindowContent').setOpacity(0);
		
	if (thanks) {
		$('enterFormContent').fadeIn();
	} else {
		$('mainWindowContent').fadeIn();
	}
	
	tabs = [$('mainWindowContent'), $('enterFormContent'), $('rulesContent'), $('prizesContent')];
	
	$('mainContentTrigger').observe("click", function(){
		tabs.each(function(ele){
			if (ele.getOpacity() != 0 && ele.id != 'mainWindowContent'){
				ele.fadeOut();
				ele.style.zIndex = 0;
			}
		});
		
		if ($('mainWindowContent').getOpacity() != 1){
			$('mainWindowContent').fadeIn();
			$('mainWindowContent').style.zIndex = 10;	
		}
	});
	
	$('enterContentTrigger').observe("click", function(){
		tabs.each(function(ele){
			if (ele.getOpacity() != 0 && ele.id != 'enterFormContent'){
				ele.fadeOut();
				ele.style.zIndex = 0;
			}			
		});
		
		if ($('enterFormContent').getOpacity() != 1){
			$('enterFormContent').fadeIn();		
			$('enterFormContent').style.zIndex = 10;
		}
	});
	
	$('rulesContentTrigger').observe("click", function(){
		tabs.each(function(ele){
			if (ele.getOpacity() != 0 && ele.id != 'rulesContent'){
				ele.fadeOut();
				ele.style.zIndex = 0
			}
		});
		
		if ($('rulesContent').getOpacity() != 1){
			$('rulesContent').fadeIn();	
			$('rulesContent').style.zIndex = 10;	
		}
	});
	
	$('prizesContentTrigger').observe("click", function(){
		tabs.each(function(ele){
			if (ele.getOpacity() != 0 && ele.id != 'prizesContent'){
				ele.fadeOut();
				ele.style.zIndex = 0
			}
		});
		
		if ($('prizesContent').getOpacity() != 1){
			$('prizesContent').fadeIn();
			$('prizesContent').style.zIndex = 10;		
		}
	});
	
	$('musician').observe("click", function(){
		if(this.selectedIndex == 1){
			$('instrument').disabled = false;
		} else {
			$('instrument').value = '';
			$('instrument').disabled = true;
		}
	});
	
	$('musicStudy').observe("click", function(){
		if(this.selectedIndex == 1){
			$('studyLocation').disabled = false;
		} else {
			$('studyLocation').value = '';
			$('studyLocation').disabled = true;
		}
	});	
	
	$('enterSweepstakes').observe('submit', function(event) {
		$('firstNameLabel').style.color = "#000000";
		$('firstNameLabel').style.fontWeight = "normal";
		$('lastNameLabel').style.color = "#000000";
		$('lastNameLabel').style.fontWeight = "normal";
		$('emailLabel').style.color = "#000000";
		$('emailLabel').style.fontWeight = "normal";					
		$('emailConfirmLabel').style.color = "#000000";
		$('emailConfirmLabel').style.fontWeight = "normal";
		$('ageLabel').style.color = "#000000";
		$('ageLabel').style.fontWeight = "normal";
		$('musicianLabel').style.color = "#000000";
		$('musicianLabel').style.fontWeight = "normal";
		$('musicStudyLabel').style.color = "#000000";
		$('musicStudyLabel').style.fontWeight = "normal";
														
	    var isValid = true;

		if ($('firstName').value == ""){
			isValid = false;
			$('firstNameLabel').style.color = "#FF0000";
			$('firstNameLabel').style.fontWeight = "bold";
		}
		
		if ($('lastName').value == ""){
			isValid = false;
			$('lastNameLabel').style.color = "#FF0000";
			$('lastNameLabel').style.fontWeight = "bold";
		}

		var filter = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
		var emailTest = $('email').value;
		
		if ($('email').value == "" || !filter.test(emailTest)){
			isValid = false;
			$('emailLabel').style.color = "#FF0000";
			$('emailLabel').style.fontWeight = "bold";
		}
		
		if ($('emailConfirm').value == ""){
			isValid = false;
			$('emailConfirmLabel').style.color = "#FF0000";
			$('emailConfirmLabel').style.fontWeight = "bold";
		}
		
		if($('email').value != $('emailConfirm').value){
			isValid = false;
			$('emailLabel').style.color = "#FF0000";
			$('emailLabel').style.fontWeight = "bold";			
			$('emailConfirmLabel').style.color = "#FF0000";
			$('emailConfirmLabel').style.fontWeight = "bold";
		}
		
		if ($('age').value == ""){
			isValid = false;
			$('ageLabel').style.color = "#FF0000";
			$('ageLabel').style.fontWeight = "bold";
		}
		
		if ($('musician').selectedIndex < 1){
			isValid = false;
			$('musicianLabel').style.color = "#FF0000";
			$('musicianLabel').style.fontWeight = "bold";
		}

		if ($('musicStudy').selectedIndex < 1){
			isValid = false;
			$('musicStudyLabel').style.color = "#FF0000";
			$('musicStudyLabel').style.fontWeight = "bold";
		}												

	    if (!isValid){
	    	Event.stop(event);
	    }
	});
});