// JavaScript Document

var ads = new Array();
ads[0] = "2020.jpg";
ads[1] = "britlock.jpg";

var link = new Array();
link[0] = "http://sandtoft.com/tiles/our-products/natural-clay-range/plain-tiles/2020/product/";
link[1] = "http://sandtoft.co.uk/tiles/our-products/sandtoft-slate-range/interlocking/britlock-slate/product/";

/*var elink = new Array();
elink[0] = "mailto: info@sandtoft.co.uk?subject=Tiles%20For%20The%20Times%2020/20";
elink[1] = "mailto: info@sandtoft.co.uk?subject=Tiles%20For%20The%20Times%20Gritlock";*/

var r_val = Math.floor(Math.random() * ads.length);

function draw_overlay() {
	var arr = getPageSize();
    var overlay = document.getElementById("overlay").style;
	var addBox  = document.getElementById("centered").style;
	//document.body.style.position = "fixed";
	overlay.display = "block";
    //overlay.width   = (window.innerWidth) + "px";
	overlay.height  = arr[1] + "px";
	addBox.top      = ((arr[3] - 460) / 2) +"px";
	addBox.display  = "block";
}

function close() {
	var overlay = document.getElementById("overlay").style;
	overlay.display = "none";
}


function getPageSize() {
	
	var xScroll, yScroll, pageWidth, pageHeight;
	
	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;
	}


	var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
