var noback = false;
var interstitialBox={
displayfrequency: ["cookie", "session"],
defineheader: '<div id="hdrwrap" class="headerbar"><h2 id="popheader"></h2><span id="backwrap"><a id="stial_back" href="#"><strong>Back</strong></a> | </span><a id="stial_close" href="#"><strong>Close</strong></a></div>',
cookiesetting: ["stitialcookie", "path=/"],
ajaxbustcache: false,
disablescrollbars: true,
autohidetimer: 0,
launch:true,
scrollbarwidth: 17,
createcontainer:function(){
document.write('<div id="interContainer">'+this.defineheader+'<div id="interContent"></div></div><div id="interVeil"></div>')
this.interContainer=document.getElementById("interContainer") 
this.interVeil=document.getElementById("interVeil")
this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
},
showcontainer:function(){
if(noback) {
	if(document.getElementById("backwrap")){
		document.getElementById("hdrwrap").removeChild(document.getElementById("backwrap"));
	}
}
if (this.interContainer.style.display=="none") return 
var ie=document.all && !window.opera
var dom=document.getElementById
var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
if(document.documentElement.scrollTop) {
	scroll_top = document.documentElement.scrollTop;
}
var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
var docheightcomplete = ((self.innerHeight>document.documentElement.clientHeight) ? self.innerHeight : document.documentElement.clientHeight >document.body.clientHeight) ? (self.innerHeight>document.documentElement.clientHeight) ? self.innerHeight : document.documentElement.clientHeight : document.body.clientHeight;
var objwidth=this.interContainer.offsetWidth
var objheight=this.interContainer.offsetHeight
this.interVeil.style.width="100%"
this.interVeil.style.left=0
this.interVeil.style.top=0 
this.interVeil.style.visibility="visible"
this.interContainer.style.left=docwidth/2-objwidth/2+"px"
if(scroll_left==0 && (docwidth/2-objwidth/2)<0 ) { this.interContainer.style.left=0; this.interContainer.style.position = "absolute";}
this.interContainer.style.top=(docheight>objheight)? docheight/2-objheight/2+"px" : scroll_top+5+"px";
if (document.all && !window.opera && !window.XMLHttpRequest) { this.interContainer.style.top = (docheight>objheight)? scroll_top + docheight/2-objheight/2+"px" : scroll_top+5+"px"; }
if((docheight/2-objheight/2)<0 ) { this.interContainer.style.tops=0; this.interContainer.style.position = "absolute";}
this.pageheight = getPageSize();
this.interVeil.style.height= this.pageheight[1]+"px";
this.interContainer.style.visibility="visible";
},
movePop:function() {
	if (interstitialBox.interContainer.style.visibility!="visible") return
	var ie=document.all && !window.opera
	var scroll_top=(ie)? interstitialBox.standardbody.scrollTop : window.pageYOffset
	var scroll_left=(ie)? interstitialBox.standardbody.scrollLeft : window.pageXOffset
	var docwidth=(ie)? interstitialBox.standardbody.clientWidth : window.innerWidth-interstitialBox.scrollbarwidth
	var docheight=(ie)? interstitialBox.standardbody.clientHeight: window.innerHeight
	var objwidth=interstitialBox.interContainer.offsetWidth
	var objheight=interstitialBox.interContainer.offsetHeight
	interstitialBox.interContainer.style.left=docwidth/2-objwidth/2+"px"
	if(scroll_left==0 && (docwidth/2-objwidth/2)<0 ) { interstitialBox.interContainer.style.left=0; }
	if((docheight/2-objheight/2)>0 && window.XMLHttpRequest) {
		interstitialBox.interContainer.style.top=(docheight>objheight)? docheight/2-objheight/2+"px" : scroll_top+5+"px";
	}
	if((docheight/2-objheight/2)>0 && window.XMLHttpRequest) { interstitialBox.interContainer.style.position = "fixed";}
	if(document.all && !window.opera && !window.XMLHttpRequest) { interstitialBox.interContainer.style.top = scroll_top+(docheight/2-objheight/2)+"px" }
	if((docheight/2-objheight/2)<0 ) { interstitialBox.interContainer.style.position = "absolute";}
},
scrollPop:function() {
	if (interstitialBox.interContainer.style.visibility!="visible") return
	var docheight=interstitialBox.standardbody.clientHeight;
	var objheight=interstitialBox.interContainer.offsetHeight;
	var s = document.documentElement.scrollTop;
	if((docheight/2-objheight/2)>0) { interstitialBox.interContainer.style.top = s+(docheight/2-objheight/2)+"px" }  
},
closeit:function(){
interstitialBox.interVeil.style.visibility="hidden"
interstitialBox.interContainer.style.visibility="hidden"
if (interstitialBox.disablescrollbars && window.XMLHttpRequest) 
interstitialBox.standardbody.style.overflow="auto"
if (typeof interstitialBox.timervar!="undefined") clearTimeout(interstitialBox.timervar)
document.getElementById("interContent").innerHTML = '';
//make the selects come back
if(document.all && !window.opera && !window.XMLHttpRequest) {
	var hselects = document.getElementsByTagName("select");
	for(s=0;s<hselects.length;s++){
		hselects[s].style.display = "inline";
	}
}
return false;
},
getscrollbarwidth:function(){
var scrollbarwidth=window.innerWidth-(this.interVeil.offsetLeft+this.interVeil.offsetWidth) //http://www.howtocreate.co.uk/emails/BrynDyment.html
this.scrollbarwidth=(typeof scrollbarwidth=="number")? scrollbarwidth : this.scrollbarwidth
},
hidescrollbar:function(){
if (this.disablescrollbars){ 
if (window.XMLHttpRequest) 
this.standardbody.style.overflow="hidden"
else 
window.scrollTo(0,0)
}
},
dotask:function(target, functionref, tasktype){ 
var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
if (target.addEventListener)
target.addEventListener(tasktype, functionref, false)
else if (target.attachEvent)
target.attachEvent(tasktype, functionref)
},
clicking:function() {
this.dotask(window, function(){interstitialBox.hidescrollbar(); interstitialBox.getscrollbarwidth(); setTimeout("interstitialBox.showcontainer()", 100)}, "load")
this.dotask(window, function(){interstitialBox.showcontainer()}, "resize")	
},
initialize:function(){
this.createcontainer()
}
}
if (interstitialBox.launch) {
	interstitialBox.initialize();
}
// infocus' back button modded for new popup
function popOverGoBack() {
	if (interstitialBox.displayfiles[0] == parent.frames["popOverWindow_IFRAME"].location) { interstitialBox.closeit(); }
	else { top.frames["popOverWindow_IFRAME"].history.back(); }
}
function initPop() { 
	var as = document.getElementsByTagName('a');
	for(i=0;i<as.length;i++) {
		if (as[i].className.indexOf("popover")!=-1) {
			as[i].onclick = function () {
				if(document.all && !window.opera && !window.XMLHttpRequest) {
					var hselects = document.getElementsByTagName("select");
					for(s=0;s<hselects.length;s++){	hselects[s].style.display = "none";	}
				}
				interstitialBox.displayfiles = [this.href];
				document.getElementById("stial_close").onclick = interstitialBox.closeit;
				if(document.getElementById("stial_back")) {	document.getElementById("stial_back").onclick = popOverGoBack; }
				if(this.title.indexOf("Serial")!=-1) { noback = true; }
				if(this.title!="") {
					document.getElementById("popheader").innerHTML = this.title;					
				} else 
				if(document.getElementsByTagName("h1").length>0) {
					document.getElementById("popheader").innerHTML = document.getElementsByTagName("h1")[0].innerHTML +' Buying Options';
				} else { document.getElementById("popheader").innerHTML = 'Buying Options'; }
	
				document.getElementById("interContent").innerHTML='<iframe id="popOverWindow_IFRAME" name="popOverWindow_IFRAME" src='+this.href+'></iframe>';
				interstitialBox.showcontainer();
				
				return false;
			}
		}
	}	
}
// from lightbox
function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
addEvent(window,'load',initPop);
addEvent(window,'resize',interstitialBox.movePop);
if(document.all && !window.opera && !window.XMLHttpRequest) {
	addEvent(window,'scroll',interstitialBox.scrollPop);
}