
/************************************************
	
	*Author: 		Hugo Henrique
	*Date create: 	20/11/2008
	*E-mail: 		hugohenriqueweb@gmail.com
	
*************************************************/

function showAlert(msg){
	
	//var s = 5;
	var s = 10;
	
	var div = document.createElement('div');
	div.className =  'messageAlert';
	
	var closeButton = document.createElement('div');
	closeButton.className = 'btX';
	closeButton.onclick = function () {
	document.body.removeChild(this.parentNode);
	};
	div.appendChild(closeButton);

	var clock = document.createElement('div');
	clock.textContent = clock.innerText = 'Closing in '+s;
	clock.className = 'clock';
	div.appendChild(clock);
	
	var bodyMsg = document.createElement('div');
	bodyMsg.className = 'bodyMsg';
	div.appendChild(bodyMsg);
	
	var divMsg = document.createElement('div');
	divMsg.className = 'divMsg';
	divMsg.textContent = divMsg.innerText = msg;
	bodyMsg.appendChild(divMsg);
	
	var divImg = document.createElement('div');
	divImg.className = 'imgAlert';
	bodyMsg.appendChild(divImg);
	
	document.body.appendChild(div);
	
	// position center the div
	div.style.top = document.documentElement.clientHeight/2 - div.offsetHeight/2 + document.documentElement.scrollTop + 'px';
	div.style.left = document.documentElement.clientWidth/2 - div.offsetWidth/2 + document.documentElement.scrollLeft + 'px';
	
	var closeTimeout = setInterval(function () {
		clock.textContent = clock.innerText = 'Closing in '+(--s);
		if (!s) try {
			clearInterval(closeTimeout);
			closeButton.onclick();
		} catch (e) {}
	}, 1000);
}