
var _rulesAdded = false;

function doPopUp(html,w,h) {
	if (canDo()) {
		$safe('modalContent').innerHTML=html;
		$safe('modalWindow').style.width=w+'px';
		$safe('modalWindow').style.height=h+'px';
		$safe('modalWindow').style.display=$safe('modalBackground').style.display='block';

		// call once to center everything
		OnWindowResize();
		
		if (window.addEventListener!=null)
			window.addEventListener('resize',OnWindowResize, false);
		else if (window.attachEvent!=null)
			window.attachEvent('onresize',OnWindowResize);
		else
			window.onresize=OnWindowResize;
	}
}
function canDo() {
	var bCanDo=false;
	var vers=navigator.appVersion;
	if (vers.indexOf('MSIE')!=-1) {
		var from=vers.indexOf('MSIE');
		var to=vers.indexOf(';',from);
		var iever=(to==-1 ? 0 : vers.substring(from+4,to).trim());
		bCanDo=(iever>=7.0);
	}
	else {
		bCanDo=true;
	}
	return bCanDo;
}

function OnWindowResize() {
	// we only need to move the dialog based on scroll position if
	//   we're using a browser that doesn't support position: fixed, like < IE 7
	var left = window.XMLHttpRequest == null ? document.documentElement.scrollLeft : 0;
	var div = $safe('modalWindow');
	
	div.style.left = Math.max((left + (GetWindowWidth() - div.offsetWidth) / 2), 0) + 'px';
}

function closeModal() {
	$safe('modalWindow').style.display = $safe('modalBackground').style.display = 'none';
	
	if (window.removeEventListener!=null)
		window.removeEventListener('resize', OnWindowResize, false);
	else if (window.detachEvent!=null)
		window.detachEvent('onresize', OnWindowResize);

	else
		window.onresize = null;
}


/* HANDY */
function GetWindowWidth() {
	var width =	document.documentElement && document.documentElement.clientWidth ||
			document.body && document.body.clientWidth ||
			document.body && document.body.parentNode && document.body.parentNode.clientWidth ||
			0;
	return width;
}
function GetWindowHeight() {
    var height =	document.documentElement && document.documentElement.clientHeight ||
			document.body && document.body.clientHeight ||
  			document.body && document.body.parentNode && document.body.parentNode.clientHeight ||
  			0;
  		
  	return height;
}

function $safe(id) {
	return document.getElementById(id);
}
