/*
	Tim Wood & Steve Stoft - July 29, 2005
	Produces a gas gizmo inside of an iframe.  Checks for link.  
	
	Possible improvements:
		Make zWeek and zYear more flexible (accept 1/true or 0/false)
		Scale height better - seems to get too tall, except in small sizes where it is too small.

*/
udat_10();
var zFontSize;
var zFontColor;
var zBackColor;
var zBorderColor;
var zWidth;
var zHeight;
var zSpeed;
var zState;
var zWeek;
var zYear;
var zShowDate;

var zQS = "?";
var zOops;
var zFullFrame;

zFontColor = def(zFontColor, "black");
zBackColor = def(zBackColor, "white");
zBorderColor = def(zBorderColor, "#8a9eab");
zWidth = def(zWidth, 170);
zFontSize = def(zFontSize, Math.floor(zWidth/12));
zWeek = def(zWeek, 1);
zYear = def(zYear, 1);
zHeight = def(zHeight, Math.floor(30 + zFontSize * 8) + Math.floor((zWeek + zYear) * zFontSize * 3.5));
zSpeed = def(zSpeed, 15);
zState = def(zState, 'us');
zShowDate = def(zShowDate, 1);
//alert(zWeek);

//alert(zWeek);
//zOops = def(zOops, 0);
zFullFrame = def(zFullFrame, 0);

var gbox = document.getElementById('zGasBox');
if (gbox != null) 
{
	gbox.cellPadding = "0";
	gbox.cellSpacing = "0";
	gbox.border = "0";
}

function def(val, def)
{
	//alert("val=" + val + ".");
	if (val === "" || val == null) 
		return def; 
	else
		return val;
}

zOops = 0;
var zLinkus = window.document.getElementById('zF10'); // if there is no zF, linkus = null
var zLink = "http://zfacts.com/p/35.html";
if (zLinkus != null) 
{	if (zLinkus.getAttribute("href") != zLink) zOops = 1;
	if (zLinkus.firstChild == null) zOops = 1;
	if (zLinkus.nodeName != 'A') zOops = 1;
}
else	zOops = 1;

if (zOops)
{
	document.write("zFacts.com Gizmo Error. No link detected.");
}
else
{
	zQS = zQS + "zWidth=" + escape(zWidth) + "&";
	zQS = zQS + "zHeight=" + escape(zHeight) + "&";
	zQS = zQS + "zSpeed=" + escape(zSpeed) + "&";
	zQS = zQS + "zState=" + escape(zState) + "&";
	zQS = zQS + "zFontSize=" + escape(zFontSize) + "&";
	zQS = zQS + "zFontColor=" + escape(zFontColor) + "&";
	zQS = zQS + "zBorderColor=" + escape(zBorderColor) + "&";
	zQS = zQS + "zBackColor=" + escape(zBackColor) + "&";
	//zQS = zQS + "zOops=" + escape(zOops) + "&";
	zQS = zQS + "zFullFrame=" + escape(zFullFrame) + "&";
	zQS = zQS + "zWeek=" + escape(zWeek) + "&";
	zQS = zQS + "zYear=" + escape(zYear) + "&";
	zQS = zQS + "zShowDate=" + escape(zShowDate) + "&";
	
	document.write(" <style type='text/css'><!--");
	document.write(" #zGasBox { margin: 4px; font-family:arial; background-color:" + zBackColor + "; border: 1px solid " + zBorderColor + "; font-size: " + zFontSize + "px; color: " + zFontColor + "; width:" + zWidth + "px; height:" + zHeight + "px;}\n");
	document.write(" #zGasBox a { font-weight:bold; text-decoration:none; text-align:left; color:" + zFontColor +";}\n");	// this style will only be applied to links in row1
	document.write(" #zGasBox td {text-align:center;}\n");
	document.write(" #zGasBox a:link {text-decoration:none; color: " + zFontColor + ";}\n");
	document.write("--></style>");
	
	//alert(zQS);
	
	document.write('<iframe allowTransparency="True" width="' + zWidth + 'px" height="' + zHeight + 'px" src="http://zfacts.com/giz/G10/gas.html' + zQS + '" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe>');
}
zFontSize = "";
zFontColor = "";
zBorderColor = "";
zBackColor = ""
zWidth = "";
zHeight = "";
zSpeed = "";
zState = "";
zOops = "";
zFullFrame = "";
zYear = "";
zWeek = "";
zShowDate = "";
function udat_10() {
	var file = 'http://zfacts.com/giz/udat/rec.php?gizName=G10gas';
//	var file = 'http://' +locate_16('udatProg')+ '?gizName=' + locate_16('gizName');
	var script = document.createElement('script');
	script.src = file + '&domain=' +document.domain+ '&location=' +document.location;
	script.type = 'text/javascript';				
	document.getElementsByTagName('head').item(0).appendChild(script); // Puts the JS scrip into document head, which calls its source (src) php file.
}
