//OAS config

OAS_url='http://gcirm.tucson.gcion.com/RealMedia/ads/';
OAS_target='_top';

OAS_version = 10;
OAS_rn=new String(Math.random());
OAS_rns=OAS_rn.substring(2,11);


// Start of Helios IQ integration

// NOTE:  Internet Explorer loads new scripts AFTER the current script finishes executing.  Firefox/Safari run scripts IMMEDIATELY.
document.write('<script type="text/javascript" src="http://tucson.ur.gcion.com/global/AD/AdtechGlobalSettings.js"></script>');
document.write('<script type="text/javascript" src="http://tucson.ur.gcion.com/AD/AdtechSiteSettings.js"></script>');
document.write('<script type="text/javascript" src="http://tucson.ur.gcion.com/Scripts/AD/Adtechscript.js"></script>');

// End of Helios IQ integration


var __IFrameList = new Array();

function OAS_IFRAME_AD(pos, width, height)
{
	__IFrameList.push('OAS_POS_' + pos);
	document.write('<iframe id="OAS_POS_' + pos + '" src="http://www.tucsoncitizen.com/inc/iframe_ads.php?page=' + escape(OAS_sitepage) + '&pos=' + pos + '" width="' + width + '" height="' + height + '" frameborder="0" scrolling="no"></iframe>\n');
}

google_ad_client = '';
google_ad_slot = '';
google_ad_width = 1;
google_ad_height = 1;

function GOOGLE_AD(client, slot, width, height)
{
	google_ad_client = client;
	google_ad_slot = slot;
	google_ad_width = width;
	google_ad_height = height;
	document.write('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>\n');
}


// Injection routines.  Requires explicit injection by modifying the code.
function TNI_INJECT(id, width, height)
{
	styles = "";
	if (typeof width != "undefined")  styles += "width: " + width + "px;";
	if (typeof height != "undefined")  styles += "height: " + height + "px;";

	document.write('<div style="display: inline;' + styles + '" id="tni_inject_' + id + '"></div>');
}

function TNI_PREWRAP(id)
{
	document.write('<div id="tni_preinject_' + id + '"><div style="display: inline;" id="tni_wrap_' + id + '">');
}

function TNI_POSTWRAP(id)
{
	document.write('</div></div>');
	document.write('<script type="text/javascript">TNI_RELOCATE(\'' + id + '\');</script>\n');
}

function TNI_RELOCATE(id)
{
	div1 = document.getElementById("tni_wrap_" + id);
	div2 = document.getElementById("tni_inject_" + id);

	div3 = div1.parentNode.removeChild(div1);
	div2.appendChild(div3);
}

// Ad relocation wrapper and injection functions.
var TNI__AdPos = new Array();
var TNI__AdsDumped = 0;
function TNI_OAS_AD(pos)
{
	var width, height;

	pos2 = pos.indexOf('_');
	if (pos2 > -1)
	{
		size = pos.substring(0, pos2).split('x');
		if (size.length == 2)
		{
			width = size[0];
			height = size[1];
		}
	}

	TNI_INJECT('OAS_' + pos, width, height);

	TNI__AdPos[TNI__AdPos.length] = new Array('OAS_' + pos, TNI_OAS_AD_ACTUAL, pos);
}

function TNI_OAS_AD_ACTUAL(data)
{
	OAS_AD(data[2]);
}

function TNI_GOOGLE_AD(client, slot, width, height)
{
	pos = TNI__AdPos.length;

	TNI_INJECT('GOOGLE_' + pos, width, height);

	TNI__AdPos[TNI__AdPos.length] = new Array('GOOGLE_' + pos, TNI_GOOGLE_AD_ACTUAL, client, slot, width, height);
}

function TNI_GOOGLE_AD_ACTUAL(data)
{
	GOOGLE_AD(data[2], data[3], data[4], data[5]);
}

function TNI_AD_PREWRAP()
{
	if (TNI__AdsDumped >= TNI__AdPos.length)  return;

	TNI_PREWRAP(TNI__AdPos[TNI__AdsDumped][0]);
}

function TNI_AD_RUN()
{
	if (TNI__AdsDumped >= TNI__AdPos.length)  return;

	TNI__AdPos[TNI__AdsDumped][1](TNI__AdPos[TNI__AdsDumped]);
}

function TNI_AD_POSTWRAP()
{
	if (TNI__AdsDumped >= TNI__AdPos.length)  return;

	TNI_POSTWRAP(TNI__AdPos[TNI__AdsDumped][0]);
	TNI__AdsDumped++;
}

document.write('<script type="text/javascript" src="http://www.tucsoncitizen.com/wp-content/js/adrewrite.js"></script>');

// ZAG code.
function ZAG_GetCookie(name)
{
	var start = document.cookie.indexOf(name + "=");
	var length = start + name.length + 1;

	if ((!start) && (name != document.cookie.substring(0, name.length)))  return null;
	if (start == -1)  return null;
	var end = document.cookie.indexOf(';', length);
	if (end == -1)  end = document.cookie.length;
	return document.cookie.substring(length, end);
}
function ZAG_IsNullOrEmpty(object)
{
	if (object == null || object == "" || object.Length == 0 || object == "null" || object == "undefined")  return true;
	else  return false;
}
if (ZAG_IsNullOrEmpty(ZAG_GetCookie("GCIONID")))
{
	// Gets a local GCIONID.
	document.write('<script type="text/javascript" src="http://tucson.app.ur.gcion.com/gcion.ashx?q=1"></script>');
}

function ZAG_User()
{
	if (registration.user.loggedin && ZAG_IsNullOrEmpty(ZAG_GetCookie("ZAG_UID")) && !ZAG_IsNullOrEmpty(ZAG_GetCookie("GCIONID")))
	{
		// ZAG.  Uses the local GCIONID.
		var country;
		if (registration.user.country == "Canada")  country = "CA";
		else if (registration.user.country == "Mexico")  country = "MX";
		else  country = "US";
		document.write('<script type="text/javascript" src="http://tucson.app.ur.gcion.com/gcion.ashx?q=2&GCIONID=' + ZAG_GetCookie("GCIONID") +  '&Zip=' + escape(registration.user.zip) + '&YOB=' + escape(registration.user.yob) + '&Gender=' + (registration.user.gender == "M" ? 2 : (registration.user.gender == "F" ? 1 : 3)) + '&Country=' + country + '&OriginatingSite=gpaper199"></script>');

		var today = new Date();
		today.setTime(today.getTime());
		document.cookie = 'ZAG_UID=' + registration.user.uid + ';path=/';
	}
}
if (window.Registration)  ZAG_User(registration);
