window.addEvent('domready', function() {
	// Newsletter-Subscribe
	$$('a[rel=boxed]').addEvent('click', function(e){
		e.stop();
		SqueezeBox.open('/includes/subscribe.html', { 
			size: {x: 270, y: 468},
			ajaxOptions: {
				onSuccess: function(html){
					try {(function (){$('subscribe_form').addEvent('submit', function(e) {
						e.stop();
					});
					subscribe_formcheck = new FormCheck('subscribe_form', { 
              			 display : { 
            	           errorsLocation : 1, 
            	           indicateErrors : 1, 
          	        	   keepFocusOnError : 0, 
                	       closeTipsButton : 1, 
                       	   showErrors : 1,
                           scrollToFirst: false
              			 }, 
               			 submitByAjax: true 
     		 		}) 
      				subscribe_formcheck.addEvent('onAjaxRequest', function(){ 
              			 subscribe_submit(); 
      			 	}); }).delay(1000); } catch (err) {}
				}
			},
		});
	});
	// Show Video-Lightbox on index.html
	try {
		$('showVideoBox').addEvent('click', function(e){
			e.stop();
			SqueezeBox.open('includes/video.html', { 
				size: {x: 480, y: 300}			
			});
		});
	} catch (err) {}	
});

function subscribe_submit(){
		var subreq = new Request.HTML({
				url: '/includes/subscribe_send.php',
     			data: $('subscribe_form'),
				onSuccess: function(html){
					$('subscribe-adopt').set('text', '');
					$('subscribe-adopt').adopt(html);
					$('subscribe-adopt').setStyle('width', '270px')
					SqueezeBox.open($('subscribe-adopt'), {
						handler: 'adopt',
						size: {x: 300, y: ($('subscribe-adopt').getStyle('height').toInt() + 0)}
					});
					$$('a[rel=boxed]').removeEvents();
					$$('a[rel=boxed]').addEvent('click', function(e){
						e.stop();
						SqueezeBox.open('/includes/subscribed.html', { 
							size: {x: 300, y: 280}
						});
					});
				}
			});
	subreq.send();
}
