//variables used to center pop-up windows
var width = screen.width;
var height = screen.height;
var popUpWidth = 0;
var popUpHeight = 0;
var positionTop = 0;
var positionLeft = 0;

function openWindow(pageURL,windowName,pWidth,pHeight,pResize,pScrollbars) {
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
  popup=window.open(pageURL,windowName, config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=' + pResize + ',menubar=1,location=1,directories=0,toolbar=1,scrollbars=' + pScrollbars + ',status=1');
	popup.focus();
}

function openWindowNoChrome(pageURL,windowName,pWidth,pHeight,pResize,pScrollbars) {
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
  popup=window.open(pageURL,windowName, config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=' + pResize + ',menubar=0,location=0,directories=0,toolbar=0,scrollbars=' + pScrollbars + ',status=0');
	popup.focus();
}

function leaveInterstitial(url){
	interstitial=window.open(url, target='_self');
}

function openExternalSiteInterstitial() {
  externalURL = queryString('url');
  pWidth = 640;
  pHeight = 480;
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
	window.self.history.go(-1);
  externalSite=window.open(externalURL,'externalSite', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=1,menubar=1,location=1,directories=0,toolbar=1,scrollbars=1,status=1');
	externalSite.focus();
}

function leaveSite(url){
  pWidth = 800;
  pHeight = 500;
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
	interstitial=window.open(url,'interstitial', config='width=' + pWidth + ',height=' + pHeight + ',top=' + positionTop + ',left=' + positionLeft + ',resizable=1,menubar=0,location=0,directories=0,toolbar=no,scrollbars=1,status=1');
}


function openExternalSite() {
  externalURL = queryString('url');
  pWidth = 640;
  pHeight = 480;
  positionTop = ((height/2) - (pHeight/2));
  positionLeft = ((width/2) - (pWidth/2));
	window.self.close();
  externalSite=window.open(externalURL,'externalSite', config='width=' + pWidth + ',height=' + pHeight + ',left=' + positionLeft + ',top=' + positionTop + ',resizable=1,menubar=1,location=1,directories=0,toolbar=1,scrollbars=1,status=1');
	externalSite.focus();
}

function queryString(val){
	var q  = unescape(location.search.substr(1)).split('&');

	for(var i=0; i<q.length; i++) {
		var t=q[i].split('=');
		if (t[0].toLowerCase()==val.toLowerCase()) return t[1];
	}
	return '';
}

function emailSelect(selectedOption) {
  var option1Style = document.getElementById('choose_a2').style;
  var option2Style = document.getElementById('choose_a1').style;

  if (selectedOption == "option0") {
	  option1Style.display = option1Style.display = "block";
	  option2Style.display = option2Style.display = "none";
	}
  if (selectedOption == "option1") {
	  option1Style.display = option1Style.display = "none";
	  option2Style.display = option2Style.display = "block";
	}
}
