var messageTop = '<p class="Message" id="AlertFocus"><span>';
var messageBottom = '</span></p><p class="Button"><span><button type="button" onclick="hideAlert();">Okay</button></span></p>';

function tsAlert(txt) {
	if (typeof document.height != 'undefined') {
		tsGetElementById('AlertOverlay').style.height = document.height + 'px';
	}
	else if (document.compatMode && document.compatMode != 'BackCompat') {
		tsGetElementById('AlertOverlay').style.height = document.documentElement.scrollHeight + 'px';
	}
	else if (document.body && typeof document.body.scrollHeight != 'undefined') {
		tsGetElementById('AlertOverlay').style.height = document.body.scrollHeight + 'px';
	}
	tsGetElementById('AlertOverlay').style.width = document.body.scrollWidth + 'px';
	tsGetElementById('AlertOverlay').style.display = 'block';
	tsGetElementById('AlertMessage').innerHTML = messageTop + txt + messageBottom;
	if (typeof document.height != 'undefined') {
		tsGetElementById('AlertMessage').style.marginTop = (window.pageYOffset - 85) + 'px';
	}
	else if (document.compatMode && document.compatMode != 'BackCompat') {
		tsGetElementById('AlertMessage').style.marginTop = (document.documentElement.scrollTop - 85) + 'px';
	}
	else if (document.body && typeof document.body.scrollHeight != 'undefined') {
		tsGetElementById('AlertMessage').style.marginTop = (document.body.scrollTop - 85) + 'px';
	}
	tsGetElementById('AlertMessage').style.display = 'block';
	tsGetElementById('AlertFocus').focus();
	tsGetElementById('Body').className = 'HideSelect';
}
function posAlert() {
	if(tsGetElementById('AlertMessage').style.display == 'block') {
		if (typeof document.height != 'undefined') {
			tsGetElementById('AlertMessage').style.marginTop = (window.pageYOffset - 85) + 'px';
		}
		else if (document.compatMode && document.compatMode != 'BackCompat') {
			tsGetElementById('AlertMessage').style.marginTop = (document.documentElement.scrollTop - 85) + 'px';
		}
		else if (document.body && typeof document.body.scrollHeight != 'undefined') {
			tsGetElementById('AlertMessage').style.marginTop = (document.body.scrollTop - 85) + 'px';
		}
	}
}
function hideAlert() {
	tsGetElementById('AlertMessage').style.display = 'none';
	tsGetElementById('AlertMessage').innerHTML = '';
	tsGetElementById('AlertOverlay').style.display = 'none';
	tsGetElementById('Body').className = '';
}
window.onscroll = posAlert;