function showCharacter(c) {
	c = c.substring(0,3);
	$('body').append('<div id="overlay"></div>');
	// Get page sizes
	var arrPageSizes = ___getPageSize();
	// Style overlay and show it
	$('#overlay').css({
		backgroundColor:	'#111',
		opacity:			0.3,
		width:				arrPageSizes[0],
		height:				arrPageSizes[1]
	}).fadeIn();
	
	$('embed, object, select').css({ 'visibility' : 'hidden' });	
	
	$('body').append('<div id="character_info_container"><div id="info_'+c+'" class="character_info" style="display:none;"><div id="info_close">Close X</div><div class="left"><img src="../images/characters/'+c+'.png" alt="'+c+'" /></div><div class="right"><div class="title">'+$('#__info_name_'+c).html()+'</div><div class="description"><p>'+$('#__info_misc_'+c).html()+'</p>'+$('#__info_description_'+c).html()+'</div></div></div></div>');
	
	$('#info_close').click(function(){close_overlay(c);});
	
	$('#info_' + c).fadeIn('slow');
}

function close_overlay(c){
	$('#info_' + c).fadeOut(function() {
		$('#info_' + c).remove();
		$('#character_info_container').remove();
		});
	
	$('#overlay').fadeOut(function() { $('#overlay').remove(); });
	// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
	$('embed, object, select').css({ 'visibility' : 'visible' });		
}

function ___getPageSize() {
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	return arrayPageSize;
}

var sentences = [];
function randomize_sentences() {
	var fonts = ["Arial, sans-serif", "Lucida, sans-serif", "Times, serif", "Palatino, serif", "Lucidatypewriter, monospace", "Comic Sans, cursive", "Zapf Chancery, cursive", "fantasy"];
	var colours = ["#C0A288", "#DD9C00", "#FF020E",
	              "#A6012B", "#EC003D", "#DC1E80",
	              "#F800FB", "#A500FB", "#6C18B3",
	              "#4725AA", "#001175", "#1836E7",
	              "#5394E5", "#13427D", "#005BCC",
	              "#007EFF", "#127E92", "#1ABDB7",
	              "#20A76C", "#13D681", "#0FD011",
	              "#024E03", "#2AB82D", "#2DA404",
	              "#69830E", "#521000", "#7D200A",
	              "#C93F1F", "#E98732"];
	
	$('div.sentence').each(function(){
		sentences[sentences.length] = this.id;
		c1 = Math.random()*0xffffff<<0;
		c2 = 0xFFFFFF - c1 + 0x111111;
		if(c2 > 0xffffff) c2 = 0xffffff - (c2 - 0xffffff);
		$(this).css('font-size', (Math.floor(Math.random()*20) + 20) +'px');
		//$(this).css('color', '#' + (c1).toString(16));
		$(this).css('color', colours[Math.floor(Math.random()*29)]);
		$(this).css('font-family', fonts[Math.floor(Math.random()*8)]);
		
		//$(this).css('background-color', '#' + (c2).toString(16));
		$(this).css('top', (Math.floor(Math.random()*210)) + 'px');
		$(this).css('left', (Math.floor(Math.random()*350) + 20) +'px');
	});
	disp(0);
}	

function disp(i) {
	if(i == sentences.length)
		i = 0;
	$('#'+sentences[i]).fadeIn('slow').delay(5000).fadeOut('slow', function(){disp(i+1);});
}

	