var timer = null;
var mx = 0;
var my = 0;

$(document).ready(function () {
	$().mousemove(function(e){
		mx = e.pageX;
		my = e.pageY
	});
	positionElements();
	var so = new SWFObject("http://www.mitel.com/resources/SeriesX_2_Demo_4_Web.swf", "titlebanner", 605, 290, "8", "#ffffff");
	so.addParam("quality", "high");
	so.addParam("loop", "true");
	so.addParam("allowScriptAccess", "always");
	so.write("video");
});

function positionElements() {
	var offset = $('#pageBackground').offset();
	var offsetLeft = offset.left;
	var offsetTop = offset.top;
	$('#buttons').css({left: offsetLeft + 740, top:offsetTop + 448});
	$('#video').css({left: offsetLeft + 291, top:offsetTop + 102});
	$('#topText').css({left: offsetLeft + 291, top:offsetTop + 81});
	$('#content').css({left: offsetLeft + 312, top:offsetTop + 411});
	$('#documents').css({left: offsetLeft + 29, top:offsetTop + 125});
	$('#footer').css({left: offsetLeft + 29, top:offsetTop + 854});
	$('#leftNav').css({left: offsetLeft + 29, top:offsetTop + 575});
};

window.onresize = positionElements;

function turnOnTimer() {
	if (timer!=null) {
		clearTimeout(timer);
		timer = null;
	}
	timer = setTimeout("hidePopupDateSelection()", 500);
}

function turnOffTimer() {
	if (timer!=null) {
		clearTimeout(timer);
		timer = null;
	}
}

function popupDateSelection() {
	if (!($('#registerPopupMenu').is(':visible'))) {
		$('#registerPopupMenu').css({left: mx-100, top:my-30});
		$('#registerPopupMenu').slideDown('normal');
	}
}

function hidePopupDateSelection() {
	if ($('#registerPopupMenu').is(':visible')) {
		$('#registerPopupMenu').slideUp('normal');
	}
}

function highlight(m) {
	m.style.backgroundColor = '#fab76a';
}

function unhighlight(m) {
	m.style.backgroundColor = '';	
}

function openWindow(theLink) {
	var w = window.open(theLink,'registrationWindow','width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
	w.focus();
}
