
/* POP-UP WINDOW */
function openwin(URL,theHeight,theWidth,addScroll) {
	var nXpos = (screen.availWidth - theWidth) / 2; 
	var nYpos = (screen.availHeight - theHeight) / 2; 
	var win = window.open(URL, 'popupWin', 'top=' + nYpos + ',left=' + nXpos + ',screenY=' + nYpos + ',screenX=' + nXpos + ',height=' + theHeight + ',width=' + theWidth + 'toolbar=0,scrollbars=' + addScroll + ',location=0,statusbar=0,menubar=0');
	win.focus();
}

/* OPEN EXTERNAL LINKS IN NEW WINDOW */
function externalLinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
}
window.onload = externalLinks;


/* COVER PAGE */
function coverPage(whichDiv, theWidth, theHeight) {
	
	var overlayHeight;
	var wholescreen = screen.availHeight;
	var wholepage = document.getElementById('page').offsetHeight;
	var leftMarginOffset = theWidth / 2;
	
	if (wholepage < wholescreen) {
		overlayHeight = wholescreen;
	} else {
		overlayHeight = wholepage;
	}
	
	var newdiv = document.createElement('div');
	newdiv.setAttribute('id', 'coverpage');
	newdiv.style.position = 'absolute';
	newdiv.style.top = '0px';
	newdiv.style.left = '0px';
	newdiv.style.zIndex = '50';
	newdiv.style.width = '100%';
	newdiv.style.height = overlayHeight + 'px';
 	newdiv.style.background = "#000";
 	newdiv.className = "opac80";
 	document.body.appendChild(newdiv);
 	
 	var popLayer = document.getElementById(whichDiv);
 	popLayer.style.display = 'block';
 	popLayer.style.zIndex = '150';
 	popLayer.style.marginLeft = '-' + leftMarginOffset + 'px';
 	popLayer.style.width = theWidth + 'px';
 	if (theHeight != "") {
 		popLayer.style.height = theHeight + 'px';
 	}
}


/* REMOVE COVER-UP AND POPUP */
function killCoverPage(whichDiv) {
	var coverit = document.getElementById('coverpage');
	var popLayer = document.getElementById(whichDiv);
	
	document.body.removeChild(coverit);
	popLayer.style.display = 'none';
}


/* --------------------------------------------------- */
function confirmAlert(theURL) {
	var confMsg = "Warning: You are now leaving the Volcano Corporation website.";
	if (confirm(confMsg)) {
	  var win = window.location = theURL;
	}
}
