// JavaScript Document
$(document).ready(function() { 
	   $("#body-background").ezBgResize();
	   $('#body-background').crossSlide({ sleep: 30,  fade: 2}, [{src: 'img/back/slave_back3.jpg' }, { src: 'img/back/slave_back2.jpg' }]);
							   								
		$('#statement').dialog({
			autoOpen: false,
			show: 'fade',
			hide: 'fade',
			resizable:false,
			minHeight: 336,
			minWidth:336,
			height: 336,
			width:336,
			dialogClass: 'back_statement',
			position: [20,100]
		});
		
		$('.links a.statement').click(function() {$('#statement').dialog('open');
		 return false; });
		
		$('#contact').dialog({
			autoOpen: false,
			show: 'fade',
			hide: 'fade',
			resizable:false,
			minHeight: 422,
			minWidth:422,
			height: 422,
			width:422,
			dialogClass: 'back_contact',
			position: [200,300]
		});
		
		$('.links a.contact').click(function() {$('#contact').dialog('open'); return false; });
		
		$('#subscribe').dialog({
			autoOpen: false,
			show: 'fade',
			hide: 'fade',
			resizable:false,
			minHeight: 395,
			minWidth:395,
			height: 395,
			width:395,
			dialogClass: 'back_subscribe',
			position: [500,100]
		});
		
		$('.links a.subscribe').click(function() {$('#subscribe').dialog('open'); return false; });
		
		$('#credits').dialog({
			autoOpen: false,
			show: 'fade',
			hide: 'fade',
			resizable:false,
			minHeight: 368,
			minWidth:368,
			height: 368,
			width:368,
			dialogClass: 'back_credits',
			position: [800,300]
		});
		
		$('.links a.credits').click(function() {$('#credits').dialog('open');
		$('.back_credits span.text').jScrollPane(); return false; });
		
		
	});
	
	$(window).bind("resize", function(){ $("#body-background").ezBgResize(); });

	 $(function () {
        var img = new Image();
        $(img).load(function () {
            //$(this).css('display', 'none'); // .hide() doesn't work in Safari when the element isn't on the DOM already
            $(this).hide();
			$('#body-background').fadeOut();
            $('#body-background').removeClass('loading').append(this);
			$("#body-background").ezBgResize();
			$('#body-background').fadeIn();
         }).error(function () {
            // notify the user that the image could not be loaded
        }).attr('src', '/img/back/slave_back1.jpg');  
		$(this).fadeIn(2000);        
		$("#body-background").ezBgResize();
    });
	 
	 function subscribe_me(){
		 $.ajax({
		  url: '/scripts/send.php',
		  type: 'POST',
		  async: true,
		  data: 'email='+$('#email').val()+'&name='+$('#name').val()+'&comments='+$('#comments').val(),
		  success: function(response){
			  $('#email').val('');
			  $('#name').val('');
			  $('#comments').val('');
			 $('.back_subscribe span.text').hide();
			 $('.back_subscribe span.text').html("<label class='message'>Thanks for subscribing</label>");
			 $('.back_subscribe span.text').show();
			}
		});	
	}
