﻿function open_submenu(obj)
{
	switch(obj.name)
	{
		case 'home':
		{
			$('#ts').html('Widgets o minijuegos para llevarte a tu web, blog, facebook...').css('left','137px');
			break;
		}
		case 'widg':
		{
			$('#ts').html('Widgets o minijuegos para llevarte a tu web, blog, facebook...').css('left','147px');
			break;
		}
		case 'what':
		{
			$('#ts').html('¿Es un juguete, un cuento o una película?').css('left','222px');
			break;
		}
		case 'mktn':
		{
			$('#ts').html('Títiris es también contenido para tu web').css('left','287px');
			break;
		}
		case 'proj':
		{
			$('#ts').html('El buen uso de las nuevas tecnologías para niños').css('left','452px');
			break;
		}
		case 'shop':
		{
			$('#ts').html('La tienda de los Títiris').css('left','522px');
			break;
		}
		case 'lang':
		{
			$('#ts').html('Els títiris també en català!').css('left','567px');
			break;
		}
		case 'es':
		{
			$('#ts').html('<a href="es/shop.php"><img id="promo" src="img/promo_es.gif"></a>').css('left','1000px').animate({left: '100px'}, 10000, 'linear').animate({left: '1000px'}, 10000, 'swing');
			break;
		}
		case 'ca':
		{
			$('#ts').html('<a href="ca/shop.php"><img id="promo" src="img/promo_ca.gif"></a>').css('left','1000px').animate({left: '100px'}, 10000, 'linear').animate({left: '1000px'}, 10000, 'swing');
			break;
		}
		default:
		{
		}
	}
	
	if (g) clearTimeout(g);
	if (o) return;
	$('#submenu').animate({'top': '+=28px'}, 'slow');
	$('#logo').animate({'top': '+=28px'}, 'slow');
	o = true;
}

function close_submenu()
{
	if (g) clearTimeout(g);
	if (!o) return;
	
	var f = function()
	{
		$('#submenu').animate({'top': '-=28px'}, 'slow');
		$('#logo').animate({'top': '-=28px'}, 'slow');
//		$('#ts').html('');
		o = false;
	};
	
	g = setTimeout(f, 250);
}

function keep_submenu()
{
	if (g) clearTimeout(g);
}

var g;
var o = false;