function showNavMenu(sID) {
	$('screen').show();
	$(sID).show();
//	new Effect.BlindDown(sID, { queue: { position: 'end', scope: 'menuscope', limit: 5 } });
}

function hideNavMenu() {
	$('screen').hide();
	$('products_menu').hide();
	$('investor_menu').hide();	
	$('ourproducts_menu').hide();
//	new Effect.BlindUp('products_menu', { queue: { position: 'end', scope: 'menuscope', limit: 5 } });
//	new Effect.BlindUp('ourproducts_menu', { queue: { position: 'end', scope: 'menuscope', limit: 5 } });
}

function swapHomeImage() {
	window.setInterval(function() {
		var fade  = 'home_image_1';
		var appear = 'home_image_2';
		if (!$("home_image_1").visible()) {
			fade = 'home_image_2';
			appear = 'home_image_1';
		}

		new Effect.Fade(fade, { queue: { position: 'end', scope: 'homeimagescope', limit: 2 } });
		new Effect.Appear(appear, { queue: { position: 'end', scope: 'homeimagescope', limit: 2 } });
	}, 15000);
}


var features = null;

function doImages() {
	swapHomeImage();
	
	features = new Features();
	window.setInterval(features.render, 8000);
}

var Features = function() {
	var arr = ['<a href="http://www.loestrin24.com" target="_blank" id="feature_{1}" style="display: none"><img src="images/loestrin_box.gif" border="0" hspace="2"/></a>'
			 , '<a href="http://www.femconfe.com" target="_blank" id="feature_{1}" style="display: none"><img src="images/femcon_box.gif" border="0" hspace="2"/></a>'
			 , '<a href="products/doryx/" target="_blank" id="feature_{1}" style="display: none"><img src="images/doryx_box.gif" border="0" hspace="2"/></a>'
			 , '<a href="http://www.asacolhd.com" target="_blank" id="feature_{1}" style="display: none"><img src="images/asacolhd_box.jpg" border="0" hspace="2"/></a>'
			 , '<a href="http://www.actonel.com" target="_blank" id="feature_{1}" style="display: none"><img src="images/actonel_box.jpg" border="0" hspace="2"/></a>'
			 , '<a href="http://www.enablex.com" target="_blank" id="feature_{1}" style="display: none"><img src="images/enablex_box.jpg" border="0" hspace="2"/></a>'
			 ];

	arr.sort(function(s1, s2) {
		return (Math.random() > .5?1:-1);
	});

	var getByIndex = function(i) {
		return arr[i % arr.length].replace("{1}", i);
	}
	
	var currIndex = 0;

	Element.insert($('features'), getByIndex(currIndex));
	$('feature_' + (currIndex + 0)).show();
	Element.insert($('features'), getByIndex(currIndex + 1));
	$('feature_' + (currIndex + 1)).show();
	Element.insert($('features'), getByIndex(currIndex + 2));
	$('feature_' + (currIndex + 2)).show();
	Element.insert($('features'), getByIndex(currIndex + 3));
	$('feature_' + (currIndex + 3)).show();

	currIndex++;

	this.render = function() {
		new Effect.BlindUp('feature_' + (currIndex - 1), { scaleX: true, scaleY: false, duration: 2.0, queue: { position: 'end', scope: 'homeproductsscope' } });
		window.setTimeout(function() {
			Element.remove('feature_' + (currIndex - 1));
			Element.insert($('features'), getByIndex(currIndex + 3));
			new Effect.Appear('feature_' + (currIndex + 3), {duration: 2.0, queue: { position: 'end', scope: 'homeproductsscope' } });
			currIndex++;
		} , 2000);
	}
}

function changeLanguage(locale) {
	switch(locale) {
		case "en":
		case "it":
		case "es":
		case "es-es":
		case "fr":
		case "nl":
		case "de":
			break;
		default:
			return;
	}
	location.href = "?locale=" + locale;
}
