// JavaScript Document
var config = Array();

jQuery(document).ready(function() {
	var color = '#000000';
	var over = Array();
	
	setupLightBoxes();
		
	jQuery('.halo').mouseover( function() {
		id = this.id;
		jQuery('#'+id).animate( { opacity: 1.0 }, 'fast', function(){} );							
	});
	
	jQuery('.halo').mouseout( function() {
		id = this.id;
		jQuery('#'+id).animate( { opacity: 0 }, 'fast', function(){} );							
	});

	jQuery('div#message p.welcome').click( function() {
		$('#info').load('welcome.html', function() {
//			history.go('index.php');
			$('#info a').css('color','#FF3333');
			$('#info').modal({onOpen: modalOpen, onClose: modalClose, autoResize: true, focus: true, maxHeight: config['welcome'].height+'px', maxWidth: config['welcome'].width+'px' });
		});
	});
	
	jQuery('div#halo-publications a img').hover( function() {
	    $(this).animate({opacity: 1});
    });
});

function setupLightBoxes() {
	var biography = Object();
	biography.width = 500;
	biography.height= 500;
	
	var welcome = Object();
	welcome.width = 500;
	welcome.height= 400;
	
	var contact = Object();
	contact.width = 300;
	contact.height= 300;
	
	var biography = Object();
	biography.width = 900;
	biography.height= 900;

	var resources = Object();
	resources.width = 700;
	resources.height= 500;

	var success = Object();
	success.width = 700;
	success.height= 500;

	var fail = Object();
	fail.width = 700;
	fail.height= 500;

	config['welcome'] = welcome;
	config['contact'] = contact;
	config['biography'] = biography;
	config['resources'] = resources;
	config['s'] = success;
	config['f'] = fail;
}

/**
 * Runs when the page is loaded.
 */
function pageLoaded(pageType) {
	setTimeout(function() {
		jQuery('.halo').animate( {opacity: 0.0 }, 'slow', function (){} );
	}, 1000 );
	lightBox(pageType);
}

function lightBox(id) {
	if (id != ''){
		var lb = config[id];
		if(id!='publications'&&id!='booking'){
			$('#info').load(id+'.html', function() {
				$('#info a').css('color','#FF3333');
				if(lb) {$('#info').modal({onOpen: modalOpen, onClose: modalClose, autoResize: true, focus: true, maxHeight: lb.height+'px', maxWidth: lb.width+'px' });}
				else { $('#info').modal({onOpen: modalOpen, onClose: modalClose, autoResize: true, focus: true });}
			});
		}
	}
}

var pics = Array();
var i = 0;
pics[0] = 'url(images/photo.jpg)';
pics[1] = 'url(images/pineapple.jpg)';


function startSlideshow(){
  $('#background').fadeOut(2000, function(){
    setTimeout(function(){
      $('#p1').fadeIn(2000, startSlideshow)
    },1000);
  });
}
	
	
//	div.animate( { opacity:".25" }, function() { div.css("background-image", val); }).animate( { background-image: val  } );//.animate( {opacity: "1"} );
//	jQuery('#biography').css("background-image", pics[i++%2]);
//	setTimeout("picChange()", 3000);	
//} 

/**
 * When the open event is called, this function will be used to 'open'
 * the overlay, container and data portions of the modal dialog.
 *
 * onOpen callbacks need to handle 'opening' the overlay, container
 * and data.
 */
function modalOpen (dialog) {
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.show('slow', function () {
			dialog.data.hide().fadeIn('slow', function() {
				$.modal.focus();
			});
		});
	});	
};

/**
 * When the close event is called, this function will be used to 'close'
 * the overlay, container and data portions of the modal dialog.
 *
 * The SimpleModal close function will still perform some actions that
 * don't need to be handled here.
 *
 * onClose callbacks need to handle 'closing' the overlay, container
 * and data.
 */
function modalClose (dialog) {
	dialog.data.fadeOut('fast', function () {
		dialog.container.hide('slow', function () {
			dialog.overlay.fadeOut('slow', function () {
				$.modal.close();
			});
		});
	});
};



/*     
	jQuery('.shalo').click( function() {
		id = this.id;
		id = id.substr(5, id.length);
		var lb = config[id];
		if(id!='publications'&&id!='booking'){
			$('#info').load(id+'.html', function() {
				$('#info a').css('color','#FF3333');
				if(lb) {$('#info').modal({onOpen: modalOpen, onClose: modalClose, autoResize: true, focus: true, maxHeight: lb.height+'px', maxWidth: lb.width+'px' });}
				else { $('#info').modal({onOpen: modalOpen, onClose: modalClose, autoResize: true, focus: true });}
			});
		}
	});
*/	
/*	jQuery('.menu-item').mouseover( function() {
		 color = $(this).css('color');
		 $(this).css( 'color', '#555555' );
		 over[this.id] = true;
	});
	
	jQuery('.menu-item').mousemove( function() {
		if(over[this.id]) {
			$(this).css( 'color', '#555555' );
		}		 
	});
	
	jQuery('.menu-item').mouseout( function() {
		 $(this).css( 'color', color );
		 over[this.id] = false;
	});
	
	jQuery('.menu-item').click( function() {
		 id = this.id;
		 id = id.substr(5, id.length);
		 color = '#4c0271';
		 $(this).css( 'color', color );
		 $('#info').load(id+'.html', function() {
			$('#info').modal({onOpen: modalOpen, onClose: modalClose, maxheight: 800});
		});
	}); */

