function showPopup(popup_width, popup_height, div_name)
{
	checkWindowSize();
	left_point = parseInt((window_width-popup_width)/2); 
	top_point = parseInt((window_height-popup_height)/2); 
	document.getElementById(div_name).style.left = left_point;
//	document.getElementById(div_name).style.top = top_point;
	document.getElementById(div_name).style.display = '';
}

// taken from: http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
function checkWindowSize() {

  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    window_width = window.innerWidth;
    window_height = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    window_width = document.documentElement.clientWidth;
    window_height = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    window_width = document.body.clientWidth;
    window_height = document.body.clientHeight;
  }
}

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function setCookiePopup(popup_freq, popup_name) {
// setting the cookie to expire in the set date on the Index.asp
		var date = new Date();
		date.setTime(date.getTime()+popup_freq);
		document.cookie= popup_name + "=yes;" + "expires= " + date.toGMTString();
}

function popupScript(popup_width, popup_height, popup_freq, popup_main, popup_name, div_name) {
	popupEnabled = 1;
// if popup isn't supposed to popup on the main page, and this is the main page, don't show popup
	query = window.location.search.toLowerCase();

	if (!popup_main && query.indexOf("?p=main") != -1) {
		popupEnabled = 0
	}	


	if (popupEnabled) {
		if (get_cookie(popup_name) == '') {
			showPopup(popup_width, popup_height, div_name);
//			setCookiePopup(popup_freq, popup_name);
		}
	}
}