	window.addEvent('domready', function(){	

		Shadowbox.init();
				
		/* iframe opener links */ 
		Shadowbox.setup("a.shadowbox_iframe", {
			player: 'iframe'
	    });
	    
	    $$('.confirm_protected_terms').addEvent('click',function(e){
	    	var clickSource = this;			

	    	show_entry(clickSource);             
		    
		    e.stop();
		});
		
		$$('.confirm_terms').addEvent('click',function(e){
	    	var clickSource = this;
			
			Sexy.confirm('Please confirm that you accept the terms and conditions relating to this event.', {
		        textBoxBtnOk: 'I Agree',
		        textBoxBtnCancel: 'Cancel',
		        onComplete: function(returnvalue) {
		            if (returnvalue) {
		                //window.location.href += clickSource.get('href');
		                window.location.href = 'https://www.secureregistrations.com/ATRAA10/';
		            }
		            else {
		                window.location.href = 'javascript:void(0);';
		            }
		        }
		    });		    
		    
		    e.stop();
		});
	
	});
	
	function show_entry(clickSource){
		
		 Sexy.prompt ( 'Please enter your code:', '', {
	    	password: true,
	    	textBoxBtnOk: 'Continue',
	        textBoxBtnCancel: 'Cancel',
	        onComplete: function(returnvalue) {
	        	if(returnvalue.length){
	        		if((returnvalue[0]=='ATRAA10')&&(returnvalue[1]==true)){
	        			window.location.href += clickSource.get('href');
	        			return;
	        		}
	        		var msg = '';
	        		if(returnvalue[0]!='ATRAA10'){
	        			msg +='Your password is incorrect.'
	        		}
	        		if(returnvalue[1]!=true){
	        			msg +='You must accept the terms and conditions'
	        		}
	        		alert(msg);
	        		show_entry(clickSource);
	        	}
	        }
	    }); 
		
	}