// Email Spam hiding.
function popMail(host,user) {
	var acct = user +'@'+ host;
	self.location.href = 'mailto:'+ acct;
}
function linkMail(host,user,cls) {
	document.write('<a href="javascript:popMail(\''+ host +'\',\''+ user +'\');"');
	if (cls) {
		document.write(' class="'+ cls +'"');
	}
	document.write('>');
	showMail(host,user);
	document.write('</a>');
}
function showMail(host,user) {
	var acct = user +'@'+ host;
	document.write(acct);
}

var curHomeNewsItem = '0';    
	
function showHomeNewsItem(id) {
	//logToFirebug('log','called showHomeNewsItem()');
	
	if (curHomeNewsItem != id) {
		$('homeNewsNav_' + curHomeNewsItem).removeClassName('on');
		$('homeNewsItem_' + curHomeNewsItem).hide();
		
		$('homeNewsNav_' + id).addClassName('on');
		$('homeNewsItem_' + id).show();
		
		curHomeNewsItem = id;
	}
}



var viewport = null;

function openModal(id) {
	var viewport = document.viewport.getDimensions();
	var bodyElm = $('container');
	if(viewport.height > bodyElm.getHeight())
	{
		$('blackOut').setStyle({width: viewport.width + 'px',height: viewport.height + 'px'});
	} else {
		$('blackOut').setStyle({width: viewport.width + 'px',height: bodyElm.getHeight() + 'px'});
	}
	
	
	var offset = $('container').cumulativeScrollOffset();
	var top = offset.top + 137;
	$('OuterContainer').setStyle({top: top + 'px'});
	
	$('modal_' + id).show();
	$('blackOut').show();
	$('OuterContainer').show();
}

function closeModal(id) {
	$('modal_' + id).hide();
	$('blackOut').hide();
	$('OuterContainer').hide();
	if(id == 'gallery')
	{
		$('gallery_container').innerHTML = '';
	}
}

function launchVideo(video_id) {
	openModal(video_id);
	eval('UFO.create(FO_' + video_id + ', "videoDiv_' + video_id + '")');
}




var curGalleryPhoto = '0';    
var curGalleryVideo = '0';

var scrollingEffect = null;
var scrollingVideoEffect = null;

var scrollingSpeed = 2;

function showGalleryPhoto(id) {
	if (curGalleryPhoto != id) {
		$('galleryThumb_' + curGalleryPhoto).removeClassName('on');
		$('galleryMain_' + curGalleryPhoto).hide();
		
		$('galleryThumb_' + id).addClassName('on');
		$('galleryMain_' + id).show();
		
		curGalleryPhoto = id;
	}
}

function scrollGalleryStop() {
	if (scrollingEffect) {
		scrollingEffect.cancel();
	}
}

function scrollGalleryNavLeft() {
	if ($('galleryThumbs').getWidth() > $('galleryThumbsContainer').getWidth()) {
		scrollingEffect = new Effect.Move($('galleryThumbs'),{x: 0, y: 0, duration: scrollingSpeed, mode:'absolute'})
	}
}

function scrollGalleryNavRight() {
	if ($('galleryThumbs').getWidth() > $('galleryThumbsContainer').getWidth()) {
		scrollingEffect = new Effect.Move($('galleryThumbs'), {x:(-($('galleryThumbs').getWidth() - $('galleryThumbsContainer').getWidth() - 8)), y: 0, duration: scrollingSpeed, mode:'absolute'});
	}
}


function showGalleryVideo(id) {
	if (curGalleryVideo != id) {
		$('galleryVideoThumb_' + curGalleryVideo).removeClassName('on');
		
		$('galleryVideoThumb_' + id).addClassName('on');
		eval("UFO.create(FO_"+ id +", 'videoDiv')");
		
		curGalleryVideo = id;
	}
}

function scrollVideoGalleryStop() {
	if (scrollingVideoEffect) {
		scrollingVideoEffect.cancel();
	}
}

function scrollVideoGalleryNavLeft() {
	if ($('galleryVideoThumbs').getWidth() > $('galleryVideoThumbsContainer').getWidth()) {
		scrollingVideoEffect = new Effect.Move($('galleryVideoThumbs'),{x: 0, y: 0, duration: scrollingSpeed, mode:'absolute'})
	}
}

function scrollVideoGalleryNavRight() {
	if ($('galleryVideoThumbs').getWidth() > $('galleryVideoThumbsContainer').getWidth()) {
		scrollingVideoEffect = new Effect.Move($('galleryVideoThumbs'), {x:(-($('galleryVideoThumbs').getWidth() - $('galleryVideoThumbsContainer').getWidth() - 8)), y: 0, duration: scrollingSpeed, mode:'absolute'});
	}
}







function logToFirebug(type, message) {
	if (false == (typeof console == 'undefined') && true === dev) {
		eval('console.' + type + "('" + message + "');");
	}
}