function openWindow(url,w,h) {
	var options='top=100,left=250,resizable=yes,scrollbars=yes,menubar=no,width='+w+',height='+h;
	window.open(url,'event',options);
}

function simpleArray() {
        this.length = 0;
        this.active = '';
}

function event(type, start, finish, image) {
        this.type = type;
        this.start = start;
        this.finish = finish;
        this.image = image;
}

events = new simpleArray();

function addEvent(type, start, finish, image) {
        events.length++;
        if (finish == 000) {
                finish = 2400;
        }
        events[events.length] = new event(type, start, finish, image);
}



var openPromo = "mainpromo";

function showPromo(promoToShow)
{
	hideLayer(openPromo);
	showLayer(promoToShow);
	openPromo = promoToShow;
}

function showLayer(id) 
{
	var div = returnDiv(id);
	div.visibility = "visible";
}

function hideLayer(id) 
{
        var div = returnDiv(id);
        div.visibility = "hidden";
//		previousLayer = "";
}
   
var tim;
var tim2;
var tim3;
var previousLayer = "";
var open_sub_layer = "";

function mouseOutOfLayer(id)
{
	if(id.indexOf("sub_") >= 0)
	{
//		alert("previousLayer = " + previousLayer);
		func = "hideLayer('"+previousLayer+"')";
		tim = setTimeout(func, 500);
		func = "hideLayer('"+id+"')";
		tim2 = setTimeout(func, 500);
	}
	else
	{
		if(open_sub_layer != "")
		{		
			func = "hideLayer('"+open_sub_layer+"')";
			tim2 = setTimeout(func, 500);
		}
		func = "hideLayer('"+id+"')";
		tim = setTimeout(func, 500);
	}
}
 
function mouseIntoLayer(id)
{
	clearTimeout(tim);
	clearTimeout(tim2);

	if(id.indexOf("sub_") >= 0)
	{  // we're mousing into a sub_layer
		if(open_sub_layer != id && open_sub_layer != "")
			hideLayer(open_sub_layer);
		clearTimeout(tim3);
		showLayer(id);
		showLayer(previousLayer);
		open_sub_layer = id;
	}
	else
	{  // we're just mousing into a regular layer

		if (open_sub_layer != "")
			hideLayer(open_sub_layer);
		if(previousLayer != id && previousLayer != "")
		{
			
			hideLayer(previousLayer);
		}
		showLayer(id);
		previousLayer = id;
	}
}

function returnDiv(id) {
	if (document.all) // IE
	{
		var div = document.all(id).style;
	}
	else if (document.layers) // NS4
	{
		var div = document.layers[id];
	}
	else if (document.getElementById) // NS6
	{
		var div = document.getElementById(id).style;
	}
	return div;
}

function openWindow(url,w,h) {
	var options='top=100,left=250,resizable=yes,scrollbars=yes,menubar=no,width='+w+',height='+h;
	window.open(url,'event',options);
}
