// ### Array Helper Functions ###

function tiiArrayContains (array, value) {
	if (array != null) {
		var al = array.length;
		for (var i = 0; i < al; i++) {
			if (array[i] == value) return true;
		}
	}
	return false;
}

// ### Key=Value; Functions ###

function tiiHashKeys(string) {
	var keys = null;
	if (string != null) {
		var hash = string.split(';');
		var hl = hash.length - 1;
		if(hl > 0){
			keys = new Array();
			for(var i = 0; i < hl; i++){
				var data = hash[i].split('=');
				keys[i] = data[0].replace(' ', '');
			}
		}
	}
	return keys;
}

function tiiHashGet(string, key) {
	var value = null;
	if (string != null) {
		var keyStart = key + '=';
		var offset = string.indexOf(keyStart);
		if (offset != -1) {
			offset += keyStart.length;
			var end = string.indexOf(';', offset);
			if (end == -1) {
				end = string.length;
			}
			value = string.substring(offset, end);
		}
	}
	return value;
}

function tiiHashSet(string, key, value) {
	var string = tiiHashDelete(string, key);
	var newValue = key + '=' + value + ';';
	if (string != null) newValue = newValue + string;
	return newValue;
}

function tiiHashDelete(string, key) {
	var oldValue = tiiHashGet(string, key);
	var newString = string;
	if (oldValue != null) {
		var search = key + '=';
		var start = string.indexOf(search);
		var offset = start + search.length;
		var end = string.indexOf(';', offset) + 1;
		if (end == -1) end = string.length;
		newString = string.slice(0,start) + string.slice(end,string.length);
		return newString;

	}
	return newString;
}

function tiiGetQueryParamValue(param) {
	var startIndex;
	var endIndex;
	var valueStart;

	var qs = document.location.search;
	var detectIndex = qs.indexOf( "?" + param + "=" );
	var detectIndex2 = qs.indexOf( "&" + param + "=" );
	var key = "&" + param + "=";
	var keylen = key.length;

	if (qs.length > 1) {
		if (detectIndex != -1) {
			startIndex = detectIndex;
		} else if (detectIndex2 != -1) {
			startIndex = detectIndex2;
		} else {
			return null;
		}

		valueStart = startIndex + keylen;

		if (qs.indexOf("&", valueStart) != -1) {
			endIndex = qs.indexOf("&", startIndex + 1)
		} else {
			endIndex = qs.length
		}

		return (qs.substring(qs.indexOf("=", startIndex) + 1, endIndex));
	}

	return null;
}

// ### Date/Time Functions ###

function tiiDateGetOffsetMinutes(minutes)	{ var today = new Date(); return today.getTime() + (60000) * minutes;}
function tiiDateGetOffsetHours(hours)		{ var today = new Date(); return today.getTime() + (3600000) * hours; }
function tiiDateGetOffsetDays(days)			{ var today = new Date(); return today.getTime() + (86400000) * days; }
function tiiDateGetOffsetWeeks(weeks)		{ var today = new Date(); return today.getTime() + (604800000) * weeks; }
function tiiDateGetOffsetMonths(months)		{ var today = new Date(); return today.getTime() + (259200000) * months; }
function tiiDateGetOffsetYears(years)		{ var today = new Date(); return today.getTime() + (31536000000) * years; }
// ### Core Cookie Functions ###

function tiiCookieExists(cookieName) {
	return tiiArrayContains(tiiCookieGet(), cookieName);
}

function tiiCookieGet(cookieName) {
	if (arguments.length == 0) {
		return tiiHashKeys(document.cookie);
	}

	var cookie = tiiHashGet(document.cookie, cookieName);
	if (cookie != null) cookie = unescape(cookie);
	return cookie;
}

function tiiCookieSet(cookieName, cookieValue, domain, path, expires, secure) {
	if (expires != null) {
		expire_date = new Date();
		expire_date.setTime(expires);
	}
	var curCookie = cookieName + '=' + escape(cookieValue)
		+ ((expires) ? '; expires=' + expire_date.toGMTString() : '')
		+ ((path) ? '; path=' + path : '')
		+ ((domain) ? '; domain=' + domain : '')
		+ ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

function tiiCookieSetUnescape(cookieName, cookieValue, domain, path, expires, secure) {
	if (expires != null) {
		expire_date = new Date();
		expire_date.setTime(expires);
	}
	var curCookie = cookieName + '=' + cookieValue
		+ ((expires) ? '; expires=' + expire_date.toGMTString() : '')
		+ ((path) ? '; path=' + path : '')
		+ ((domain) ? '; domain=' + domain : '')
		+ ((secure) ? '; secure' : '');
	document.cookie = curCookie;
}

function tiiCookieDelete(cookieName) {
	tiiCookieSet(cookieName, null, null, null, '', 0);
}

// ### Core Chip Functions ###
function tiiCookieChipGet(cookieName, chipName) {
	if (arguments.length == 1) {
		return tiiHashKeys(tiiCookieGet(cookieName));
	}
	return tiiHashGet(tiiCookieGet(cookieName), chipName);
}

function tiiCookieChipSet(cookieName, chipName, chipValue, domain, path, expire, secure) {
	var new_cookieValue = tiiHashSet(tiiCookieGet(cookieName), chipName, chipValue);
	tiiCookieSet(cookieName, new_cookieValue, domain, path, expire, secure);
}

function tiiCookieChipDelete(cookieName, chipName, domain, path, expire, secure) {
	var new_cookieValue = tiiHashDelete(tiiCookieGet(cookieName), chipName);
	if (new_cookieValue == null) new_cookieValue = '';
	tiiCookieSet(cookieName, new_cookieValue, domain, path, expire, secure);
}

// ### Permanent Cookie/Chip Functions ###
function tiiPermCookieChipGet(chipName) {
	return tiiCookieChipGet('tii_perm', chipName);
}

function tiiPermCookieChipSet(chipName, chipValue) {
	tiiCookieChipSet('tii_perm', chipName, chipValue, null, '/', tiiDateGetOffsetYears(2), 0);
}

function tiiPermCookieChipDelete(chipName) {
	tiiCookieChipDelete('tii_perm', chipName, null, '/', tiiDateGetOffsetYears(2), 0);
}

// ### Session Cookie/Chip Functions ###
function tiiSessCookieChipGet(chipName) {
	return tiiCookieChipGet('tii_sess', chipName);
}

function tiiSessCookieChipSet(chipName, chipValue) {
	tiiCookieChipSet('tii_sess', chipName, chipValue, null, '/', null, 0);
}

function tiiSessCookieChipDelete(chipName) {
	tiiCookieChipDelete('tii_sess', chipName, null, '/', null, 0);
}

/**
 * FlashObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 */
if(typeof com=="undefined"){var com=new Object();}
if(typeof com.deconcept=="undefined"){com.deconcept=new Object();}
if(typeof com.deconcept.util=="undefined"){com.deconcept.util=new Object();}
if(typeof com.deconcept.FlashObjectUtil=="undefined"){com.deconcept.FlashObjectUtil=new Object();}
com.deconcept.FlashObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
//this.instanceof=null;
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=com.deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
this.useExpressInstall=_7;
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new com.deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=com.deconcept.FlashObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}
};
com.deconcept.FlashObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},createParamTag:function(n,v){
var p=document.createElement("param");
p.setAttribute("name",n);
p.setAttribute("value",v);
return p;
},getVariablePairs:function(){
var _19=new Array();
var key;
var _1b=this.getVariables();
for(key in _1b){_19.push(key+"="+_1b[key]);}
return _19;
},getFlashHTML:function(){
var _1c="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");
}
_1c="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_1c+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1d=this.getParams();
_1d["instanceOf"]=null;
for(var key in _1d){_1c+=[key]+"=\""+_1d[key]+"\" ";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_1c+="flashvars=\""+_1f+"\"";}
_1c+="/>";
}else{
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_1c="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_1c+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _20=this.getParams();
for(var key in _20){_1c+="<param name=\""+key+"\" value=\""+_20[key]+"\" />";}
var _22=this.getVariablePairs().join("&");
if(_22.length>0){_1c+="<param name=\"flashvars\" value=\""+_22+"\" />";
}_1c+="</object>";}
return _1c;
},write:function(_23){
if(this.useExpressInstall){
var _24=new com.deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_24)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}
}else{this.setAttribute("doExpressInstall",false);}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _23=="string")?document.getElementById(_23):_23;
if(typeof n != 'undefined'){
	n.innerHTML=this.getFlashHTML();
}else{
	document.writeln(this.getFlashHTML());
}
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}}};


function tiiVBGetFlashVersionExists() {
	var result = true;
	try {
		var dontcare = tiiVBGetFlashVersion( 3 ); 
	} catch(e) { result = false }
	
	
	return result;
}

com.deconcept.FlashObjectUtil.getPlayerVersion=function(_26,_27){
	var _28 = new com.deconcept.PlayerVersion(0,0,0);
	if ( navigator.plugins && navigator.mimeTypes.length ){
		var x = navigator.plugins["Shockwave Flash"];
		if ( x && x.description ){
			_28 = new com.deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));
		}
	} else {
		try {
			if ( ! tiiVBGetFlashVersionExists() ) {
				
				
				var axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash" );
				for ( var i = 3; axo != null; i++ ) {
					axo = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
					_28 = new com.deconcept.PlayerVersion( [ i, 0, 0 ] );
				}
			} else {
				
				
				var versionStr = "";
				for ( var i = 25; i > 0 ; i-- ) {
					var tempStr = tiiVBGetFlashVersion( i );
					if ( tempStr != "" ) {
						versionStr = tempStr;
						break;
					}
				}
				if ( versionStr != "" ) {
					
					var splits = versionStr.split(" ");
					var splits2 = splits[1].split(",");
					_28 = new com.deconcept.PlayerVersion( [ splits2[0], splits2[1], splits2[2] ] );
				}
			}
		} catch(e) {}
		if (_26&&_28.major>_26.major ){return _28;}
		if ( !_26 || ((_26.minor!=0||_26.rev!=0)&&_28.major==_26.major) || _28.major != 6 || _27){
			try {
				_28 = new com.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
			} catch(e) {}
		}
	}

	
	return _28;
};

com.deconcept.PlayerVersion=function(_2c){
this.major=parseInt(_2c[0])||0;
this.minor=parseInt(_2c[1])||0;
this.rev=parseInt(_2c[2])||0;
};
com.deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}
return true;
};

com.deconcept.util={getRequestParameter:function(_2e){
var q=document.location.search||document.location.hash;
if(q){var _30=q.indexOf(_2e+"=");
var _31=(q.indexOf("&",_30)>-1)?q.indexOf("&",_30):q.length;
if(q.length>1&&_30>-1){
return q.substring(q.indexOf("=",_30)+1,_31);}}return "";
},removeChildren:function(n){
while(n.hasChildNodes()){
n.removeChild(n.firstChild);}}};
if(Array.prototype.push==null){
Array.prototype.push=function(_33){
this[this.length]=_33;
return this.length;};}

var getQueryParamValue=com.deconcept.util.getRequestParameter;
var FlashObject=com.deconcept.FlashObject;
var PlayerVersion=com.deconcept.PlayerVersion;

function tiiGetFlashVersion() {
	var flashversion = 0;
	if (navigator.plugins && navigator.plugins.length) {
		var x = navigator.plugins["Shockwave Flash"];
		if(x){
			if (x.description) {
				var y = x.description;
				var flashFullDescriptionArray = y.split('.');
				var flashPartialDescriptionArray = flashFullDescriptionArray[0].split(' ');
				flashversion = flashPartialDescriptionArray[flashPartialDescriptionArray.length - 1];
			}
		}
	} else {
		result = false;
		for(var i = 15; i >= 3 && result != true; i--){
			execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
			flashversion = i;
		}
	}
	return flashversion;
}

function tiiDetectFlash(ver) {
	if (tiiGetFlashVersion() >= ver) {
		return true;
	} else {
		return false;
	}
}

 
/*-----------------------------------------------------------------------------*/
/* MB - 10/23/07 - Brightcove Wrapper / JavaScript support functions           */
/* Function: TiiBcLcDcTracker - Called by Brightcove Flash wrapper to notify   */ 
/* DoubleClick / DART that a Lightningcast ad was served                       */
/* Requirements: adsitename i.e. &adsitename=3745.mre needs to be passed to    */
/* the BC wrapper. If no adzone is specified the default value will be used    */
/*-----------------------------------------------------------------------------*/
function TiiBcLcDcTracker (omniAdSiteName,omniAdZone) {
	var defaultFlg = 'false';
	if (omniAdZone == 'default') {  
		omniAdZone = 'video_main_bc_lightningcast';
		defaultFlg = 'true';
	}    
	var bcLCDCTmpPixel = new Image();
	bcLCDCTmpPixel.src = 'http://ad.doubleclick.net/ad/'+omniAdSiteName+'/'+omniAdZone+';sz=1x1;ord='+Math.ceil(1+1E12*Math.random());
	return 'Tracking successful - adSiteName="'+omniAdSiteName+'" ,adZone="'+omniAdZone+ '" defaultFlg="'+defaultFlg+'"'; 
}    
	         
function TiiBrightcovePlayer() {
	this.cfg = new Array();
	this.flashUrl = "/web/tii/shared/swf/BrightcoveWrapper.swf";
	this.flashUrl = "/shared/static/swf/BrightcoveWrapper.swf";
	this.bgcolor = "#ffffff";

	// Default cfg
	this.cfg["objectId"] = "bcVideoPlayer";
	this.cfg["divId"] = "";
	this.cfg["testmode"] = "";
	this.cfg["autostart"] = false;
	this.cfg["lctracking"] = "";
	this.cfg["adsitename"] = "";
	this.cfg["lcadzone"] = ""; 
	this.setParam = TiiBcSetParam;
	this.write = TiiBcWrite;
}

function TiiBcSetParam(key, value) {
	this.cfg[key] = value;
}

function TiiBcWrite() {
	var fo = new FlashObject(this.flashUrl, this.cfg["objectId"], this.cfg["width"], this.cfg["height"], 8, this.bgcolor);
	
	fo.addParam("allowScriptAccess", "always");
	fo.addParam("menu", "false");
	fo.addParam("quality", "high");
	fo.addParam("bgcolor", this.bgcolor);
	fo.addParam("loop", "false");
	fo.addParam("wmode", "opaque");

	fo.addVariable("account", this.cfg["account"]);
	fo.addVariable("channel", this.cfg["siteId"]);
	fo.addVariable("prop16", this.cfg["channel"]);

	fo.addVariable("playerwidth", this.cfg["width"]);
	fo.addVariable("playerheight", this.cfg["height"]);
	fo.addVariable("playerid", this.cfg["playerId"]);
	fo.addVariable("videoid", this.cfg["videoId"]);
	fo.addVariable("lineupid", this.cfg["lineupId"]);
	fo.addVariable("autostart", this.cfg["autostart"]);
	
	fo.addVariable("lctracking", this.cfg["lctracking"]); // MB - added 10/23/07
	fo.addVariable("adsitename", this.cfg["adsitename"]); // MB - added 10/23/07
	fo.addVariable("lcadzone", this.cfg["lcadzone"]);     // MB - added 10/23/07
	
	fo.addVariable("objectid", this.cfg["objectId"]);	
	fo.addVariable("adserverurl", this.cfg["adServerUrl"]);
	if (this.cfg["testmode"] != "") {
		fo.addVariable("testmode", this.cfg["testmode"]);	
	}
	
	fo.altTxt = "";

	if (this.cfg["divId"] != "") {
		fo.write(this.cfg["divId"]);
	} else {
		fo.write();
	}
}

function tiiQuigoSetEnabled(b) {
	_tiiQuigoEnabled = b;
}

function tiiQuigoIsEnabled() {
	if (typeof(_tiiQuigoEnabled) == "boolean") {
		return _tiiQuigoEnabled;
	}
	return true;
}

function tiiQuigoWriteAd(pid, placementId, zw, zh, ps) {
	if (tiiQuigoIsEnabled()) {
		qas_writeAd(placementId, pid, ps, zw, zh, 'ads.adsonar.com');
	}
}


function ajaxObj ()
{
	this.req = null;
	this.url = null;
	this.status = null;
	this.statusText = '';
	this.method = 'GET';
	this.async = true;
	this.dataPayload = null;
	this.readyState = null;
	this.responseText = null;
	this.responseXML = null;
	this.handleResp = null;
	this.responseFormat = 'text', // 'text', 'xml', 'object'
	this.mimeType = null;
	this.headers = [];
	this.init = function ()
	{
		var i = 0;
		var reqTry = [ 
			function() { return new XMLHttpRequest (); },
			function() { return new ActiveXObject ('Msxml2.XMLHTTP'); },
			function() { return new ActiveXObject ('Microsoft.XMLHTTP'); }];
			
		while (!this.req && (i < reqTry.length))
		{
			try
			{
				this.req = reqTry [i++] ();
			}
			catch (e) {}
		}
		return true;
	};
	this.doGet = function (url, handler, format)
	{
		this.url = url;
		this.handleResp = handler;
		this.responseFormat = format || 'text';
		this.doReq ();
	}
	this.doReq = function ()
	{
		if (!this.init ())
		{
			alert ('Could not create XMLHttpRequest object.');
			return;
		}
		this.req.open (this.method, this.url, this.async);
		if (this.mimeType)
		{
			try
			{
				req.overrideMimeType (this.mimeType);
			}
			catch (e)
			{
				// Couldn't override MIME type -- IE6 or Opera?
			}
		}
		var self = this; // Fix loss-of-scope in inner function
		this.req.onreadystatechange = function ()
		{
			var resp = null;
			if (self.req.readyState == 4)
			{
				switch (self.responseFormat)
				{
					case 'text':
						resp = self.req.responseText;
						break;
					case 'xml':
						resp = self.req.responseXML;
						break;
					case 'object':
						resp = req;
						break;
				}
				if (self.req.status >= 200 && self.req.status <= 299)
				{
					self.handleResp (resp);
				}
				else
				{
					self.handleErr (resp);
				}
			}
		}
		this.req.send (this.postData);
	};
	this.setMimeType = function (mimeType)
	{
		this.mimeType = mimeType;
	};
	this.handleErr = function () {};
	this.abort = function ()
	{
		if (this.req)
		{
			this.req.onreadystatechange = function () {};
			this.req.abort ();
			this.req = null;
		}
	};
}/* Request controller for JSON-P access */
var $isrc =
{
	NAMESPACE : 'is_',
	CALLBACK_SUFFIX : 'CallbackFn',
	POLL_TIMEOUT : 10000,
	POLL_INTERVAL : 500,
	IS_OPERA : typeof window.opera != 'undefined',
	IS_IE : typeof document.all != 'undefined' && !this.IS_OPERA && navigator.vendor != 'KDE',
	domHook: null,
	isrs : new Array (),
	isrIndex : -1,
	hasBeenLoggedIn : false,
	setDomHook : function (init) { if (init) { document.write ('<div id="domHook"></div>'); } this.domHook = document.getElementById ('domHook'); },
	registerObj : function (obj) { this.isrs [++this.isrIndex] = obj; },
	getPrevObj : function (obj) { if (this.isrIndex > 0) { return this.isrs [this.isrIndex - 1]; }; return null; },
	clearObj : function (obj) { this.isrs [obj.index] = obj = null; }
};
$isrc.setDomHook (true);

/* Request object for JSON-P access */
function $isr ()
{
	$isrc.registerObj (this);
	var self = this;
	this.index = $isrc.isrIndex;
	this.script = document.createElement ('script');
	this.scriptCallback = $isrc.NAMESPACE + 'script' + this.index + $isrc.CALLBACK_SUFFIX,
	this.interval = null;
	this.loadSuccess = false;
	this.timeout = null;
	this.timedOut = false;
	this.prevObj = $isrc.getPrevObj ();
	this.data = null;
	this.getData = function (url, queryString, callback, callbackName)
	{
		if (!$isrc.domHook) { $isrc.setDomHook (false); }
		if (arguments.length > 0)
		{
			this.url = url;
			this.queryString = queryString;
			this.userCallback = callback;
			if (typeof callbackName != 'undefined' && callbackName) { this.scriptCallback = callbackName; }
		}
		if (typeof window [this.scriptCallback] != 'function')
		{
			window [this.scriptCallback] = function (jsonData)
			{
				if (!self.timedOut)
				{
					clearTimeout ($isrc.isrs [self.index].timeout);
					self.loadSuccess = true;
					self.data = jsonData;
					if (!$isrc.IS_IE) { $isrc.domHook.removeChild (self.script); }
					self.userCallback.call ('', jsonData);
				}
			}
		}
		if (this.script.src == '')
		{
			this.script.src = this.url + '?callback=' + this.scriptCallback;
			if (typeof this.queryString != 'undefined' && this.queryString && this.queryString != '') { this.script.src += '&' + this.queryString; }
		}
		this.interval = setInterval (function ()
		{
			if (!self.prevObj || self.prevObj.loadSuccess || self.prevObj.timedOut)
			{
				clearInterval (self.interval);
				self.timeout = setTimeout (function ()
				{
					self.timedOut = true;
					if (!$isrc.IS_IE) { $isrc.domHook.removeChild (self.script); }
					var callback = self.userCallback;
					$isrc.clearObj (self);
					self.userCallback.call ('', { error : 'Service not available' }, self.index);
				}, $isrc.POLL_TIMEOUT);
				$isrc.domHook.appendChild (self.script);
			}
		}, $isrc.POLL_INTERVAL);
	}
}

function tii_globalRecirc (rootId, toutClass, feedSrc, rulesSrc, useJSONP)
{
	var self = this;
	this.docRoot = null;
	this.touts = null;
	this.feedOrder = null;
	this.ajax = new ajaxObj ();
	this.ajax.setMimeType ('text/plain');
	if (typeof useJSONP != 'undefined' && useJSONP)	{ this.useJSONP = true; }
	else { this.useJSONP = false; }
	this.getFeeds = function ()
	{
		var nextFunction = function (data) { self.main (self.useJSONP ? data.content : data, rulesSrc); };
		if (this.useJSONP) { new $isr ().getData (feedSrc, '', nextFunction, 'recircData'); }
		else { this.ajax.doGet (feedSrc, nextFunction); }
	}
	this.main = function (data, rulesSrc)
	{
		var parseBuffer = document.createElement ('div');
		parseBuffer.innerHTML = data;
		var root = parseBuffer.getElementsByTagName ('div').item (0);
		this.docRoot = document.getElementById (rootId);
		if (root && this.docRoot)
		{
			var toutPattern = new RegExp (toutClass, 'i');
			this.touts = new Array ();
			var rootChildren = root.childNodes;
			var rootChildrenLength = rootChildren.length;
			var toutIndex = 0;
			for (var i = 0; i < rootChildrenLength; i++)
			{
				var rootChild = rootChildren.item (i);
				if (rootChild.nodeName == 'DIV' && toutPattern.test (rootChild.className))
				{
					this.touts [toutIndex] = rootChild;
					toutIndex++;
				}
			}
		}
		var nextFunction = function (rulesJSON) { self.setFeedOrder (rulesJSON); };
		if (this.useJSONP) { new $isr ().getData (rulesSrc, '', nextFunction, 'recircRules'); }
		else { this.ajax.doGet (rulesSrc, nextFunction); }
	}
	this.setFeedOrder = function (rulesJSON)
	{
		var feedRules = this.useJSONP ? rulesJSON : eval ('(' + rulesJSON + ')');
		var feedsNeeded = feedRules.feedsNeeded;
		var fixedIndices = feedRules.fixedIndices;
		var fixedIndicesLength = fixedIndices.length;
		var randomIndices = feedRules.randomIndices;
		var randomIndicesLength = randomIndices.length;
		if (fixedIndicesLength + randomIndicesLength != feedsNeeded)
		{
			alert ('The total number of fixed feeds and random feeds needed does not equal the total number of feeds needed.');
			return;
		}
		var feedInfo = feedRules.feedInfo;
		var feedInfoLength = feedInfo.length;
		var feedOrder = new Array ();
		var randomFeeds = new Array ();
		var randomIndex = 0;
		for (var i = 0; i < feedInfoLength; i++)
		{
			var feed = feedInfo [i];
			if (feed.fixed)
			{
				feedOrder [feed.index] = i;
			}
			else
			{
				var relativeWeight = (typeof feed.relativeWeight == 'undefined' || feed.relativeWeight == null) ? 1 : feed.relativeWeight;
				randomFeeds [randomIndex] = [i, relativeWeight * Math.random ()];
				randomIndex++;
			}
		}
		randomFeeds.sort (function (a, b) { return b [1] - a [1]; });
		for (var j = 0; j < randomIndicesLength; j++)
		{
			feedOrder [randomIndices [j]] = randomFeeds [j] [0];
		}
		this.feedOrder = feedOrder;
		this.attachFeeds ();
	}
	this.attachFeeds = function ()
	{
		if (this.feedOrder)
		{
			var feedOrderLength = this.feedOrder.length;
			for (var j = 0; j < feedOrderLength; j++)
			{
				this.docRoot.appendChild (this.touts [this.feedOrder [j]]);
			}
		}
	}
}




function tii_callFunctionOnWindowLoad (functionToCall)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener ('load', functionToCall, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener ('load', functionToCall, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent ('onload', functionToCall);
  }
  else
  {
    var oldFunctionToCall = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = functionToCall;
    }
    else
    {
      window.onload = function ()
      {
        oldFunctionToCall ();
        functionToCall ();
      };
    }
  }
}


function tii_callFunctionOnElementLoad (targetId, functionToCall)
{
	var myArguments = arguments;
	tii_callFunctionOnWindowLoad (function ()
		{
			window.loaded = true;
		});
	var targetElement = document.getElementById (targetId);
	if (targetElement == null && !window.loaded)
	{
		var pollingInterval = setInterval (function ()
			{
				if (window.loaded)
				{
					clearInterval (pollingInterval);
				}
				targetElement = document.getElementById (targetId);
				if (targetElement != null)
				{
					clearInterval (pollingInterval);
					var argumentsTemp = new Array ();
					var argumentsTempLength = myArguments.length - 2;
					for (var i = 0; i < argumentsTempLength; i++)
					{
						argumentsTemp [i] = myArguments [i + 2];
					}		
					functionToCall.apply (this, argumentsTemp);
				}
			}, 10);
	}
}


function tii_addEventHandlerOnElementLoad (targetId, eventType, functionToCall, bubbleEventUpDOMTree)
{
	tii_callFunctionOnWindowLoad (function ()
		{
			window.loaded = true;
		});
	var targetElement = document.getElementById (targetId);
	if (targetElement == null && !window.loaded)
	{
		var pollingInterval = setInterval (function ()
			{
				if (window.loaded)
				{
					clearInterval (pollingInterval);
				}
				targetElement = document.getElementById (targetId);
				if (targetElement != null)
				{
					clearInterval (pollingInterval);
					tii_addEventHandler (targetElement, eventType, functionToCall, bubbleEventUpDOMTree);
				}
			}, 10);
	}
}


function tii_addEventHandler (targetElement, eventType, functionToCall, bubbleEventUpDOMTree)
{
  if (!targetElement)
  {
	  window.status = 'Warning: Tried to attach event to null object';
	  return false;
  }
  if (typeof targetElement.addEventListener != 'undefined')
  {
    targetElement.addEventListener (eventType, functionToCall, bubbleEventUpDOMTree);
  }
  else if (typeof targetElement.attachEvent != 'undefined')
  {
    targetElement.attachEvent ('on' + eventType, functionToCall);
  }
  else
  {
    eventType = 'on' + eventType;
    if (typeof targetElement [eventType] == 'function')
    {
      var oldListener = targetElement [eventType];
      targetElement [eventType] = function ()
      {
        oldListener ();
        return functionToCall ();
      }
    }
    else
    {
      targetElement [eventType] = functionToCall;
    }
  }

  return true;
}



function tii_removeEventHandler (targetElement, eventType, functionToRemove, bubbleEventUpDOMTree)
{
  if (typeof targetElement.removeEventListener != "undefined")
  {
    targetElement.removeEventListener (eventType, functionToRemove, bubbleEventUpDOMTree);
  }
  else if (typeof targetElement.detachEvent != "undefined")
  {
    targetElement.detachEvent ("on" + eventType, functionToRemove);
  }
  else
  {
    targetElement ["on" + eventType] = null;
  }
  
  return true;
}
/* Global dropdown menu variables */
var tii_pnav_closeMenuDelay = 1; /* milliseconds */
var tii_pnav_closeMenuDelayIE6 = 1; /* milliseconds */

/* This is the core dropdown menu function */
function tii_pnav_initializeDropdownMenu (primaryNavId, hideOrShowMenuFunction, changeStateFunction)
{
	var isopera = typeof window.opera != 'undefined';
	var isie = typeof document.all != 'undefined'
		&& !isopera && navigator.vendor != 'KDE';
	var isie6 = navigator.userAgent.indexOf ('MSIE 6.0') > -1;
	var issafari = navigator.vendor == 'Apple Computer, Inc.';
	var isfirefox = navigator.userAgent.toLowerCase ().indexOf ('firefox') > -1;
	var root = document.getElementById (primaryNavId);
	var doHandleFocus = true;
	var doHandleAllFocus = true;
	var focusEventSource;
	var focusLevel = -1;
	var lastEventType = -1;
	var lastEventSource;
	var lastPrimaryLi;
	var lastLevel = -1;
	var lastMenu;
	var delayMenuClose;
	var delayMenuUlClose;
	var lastBlurEventSource;
	var lastBlurPrimaryLi;
	var lastBlurLevel = -1;
	var lastLastEventType = -1;
	var lastLastBlurEventSource;
	var lastLastBlurPrimaryLi;
	var lastLastBlurLevel = -1;
	if (!root)
	{
		return false;
	}
	var primeUl = root.getElementsByTagName ('ul').item (0);
	if (!primeUl)
	{
		return false;
	}
	if (window.Node && Node.prototype && !Node.prototype.contains)
	{
		Node.prototype.contains = function (arg)
		{
			return !!(this.compareDocumentPosition (arg) & 16)
		}
	}
	if (issafari)
	{
		primeUl.contains = containsFunction;
	}
	if (!isie)
	{
		tii_dom_removeWhitespaceTextNodes (primeUl);
	}
	tii_addEventHandler (primeUl, 'mouseout', function (event)
	{
		var related = typeof event.relatedTarget != 'undefined' ? event.relatedTarget : window.event.toElement;
		if (related && !primeUl.contains (related))
		{
			var menu = getMenu (event);
			if (menu)
			{
				if (!focusEventSource || focusEventSource != lastEventSource || menu.contains (focusEventSource))
				{
					deactivateLink (lastEventSource, lastLevel, true, true);
				}
			}
		}		
	}, false);
	var primeLis = primeUl.childNodes;
	var primeLisLength = primeLis.length;
	for (var i = 0; i < primeLisLength; i++)
	{
		primeLi = primeLis.item (i);
		if (issafari)
		{
			primeLi.contains = containsFunction;
		}
		var primeLiKids = primeLi.childNodes;
		var primeLiKidsLength = primeLiKids.length;
		for (var j = 0; j < primeLiKidsLength; j++)
		{
			var primeLiKid = primeLiKids.item (j);
			var primeLiKidNodeName = primeLiKid.nodeName;
			if (primeLiKidNodeName == 'A')
			{
				addLinkEventHandlers (primeLiKid, 0);
			}
			else if (primeLiKidNodeName == 'UL')
			{
				if (!isie)
				{
					tii_dom_removeWhitespaceTextNodes (primeLiKid);
				}
				if (issafari)
				{
					primeLiKid.contains = containsFunction;
				}
				tii_pnav_assignFlyoutLis (primeLiKid, addLinkEventHandlers)
			}
		}
	}
	var keyevent = issafari || isie ? 'keydown' : 'keypress';
	tii_addEventHandler (document, keyevent, function (event)
	{
		var target = typeof event.target != 'undefined'? event.target : event.srcElement;
		if (primeUl.contains (target) && target.getAttribute ('href'))
		{
			if (event.keyCode == 27) /* escape key */
			{
				closeAllDropdowns ();
				if (typeof event.preventDefault != 'undefined')
				{
					event.preventDefault ();
				}
				return false;
			}
		}
		return true;
	}, false);
	var elements = document.getElementsByTagName ('*');
	var elementsLength = elements.length;
	for (p = 0; p < elementsLength; p++)
	{
		tii_addEventHandler (elements.item (p), 'focus', function (event)
		{
			if (doHandleAllFocus)
			{
				var target = typeof event.target != 'undefined'? event.target : event.srcElement;
				if (!primeUl.contains (target))
				{
					closeAllDropdowns ();
				}
			}
		}, false);
	}
	if (isfirefox)
	{
		tii_addEventHandler (document, 'focus', function (event) 
		{
			var target = typeof event.target != 'undefined'? event.target : event.srcElement;
			if (target == document)
			{
				if (lastBlurPrimaryLi)
				{
					doHandleFocus = false;
					deactivateLink (lastBlurPrimaryLi.getElementsByTagName ('a').item (0), 0, true, true);
					var resetDelay = setTimeout (function () { changeStateFunction (lastBlurPrimaryLi, false, 0); }, 1);
				}
			}
		}, false);
	}
	else
	{
		tii_addEventHandler (window, 'blur', function () 
		{
			if (lastEventSource)
			{
				deactivateLink (lastEventSource, lastLevel, true, true);
			}
		}, false);	
	}
	function containsFunction (node)
	{
		if (node == null)
		{
			return false;
		}
		if (node == this)
		{
			return true;
		}
		else
		{
			return this.contains (node.parentNode);
		}
	}
	function getMenu (event)
	{
		try
		{
			var menu = typeof event.target != 'undefined'? event.target : event.srcElement;
			while (menu && menu.parentNode.parentNode.parentNode != root)
			{
				menu = menu.parentNode;
			}
			if (menu && menu.parentNode.parentNode.parentNode == root)
			{
				return menu;
			}
			else
			{
				return null;
			}
		}
		catch (error) { return null; }
	}
	function closeAllDropdowns ()
	{
		for (var n = 0; n < primeLisLength; n++)
		{
			deactivateLink (primeLis.item (n).getElementsByTagName ('a').item (0), 0, true, true);
		}
	}
	function addLinkEventHandlers (link, level)
	{
		tii_addEventHandler (link, 'mouseover', callHandleEvent, false);
		tii_addEventHandler (link, 'mouseout', callHandleEvent, false);
		tii_addEventHandler (link, 'focus', callHandleEvent, false);
		tii_addEventHandler (link, 'blur', callHandleEvent, false);
		function callHandleEvent (event)
		{
			handleEvent (event, level);
		}
	}	
	function handleEvent (event, level)
	{
		var eventSource = typeof event.target != 'undefined' ? event.target : window.event.srcElement;
		while (eventSource && eventSource.nodeName != 'A')
		{
			eventSource = eventSource.parentNode;
		}
		if (!eventSource || eventSource.nodeName != 'A')
		{
			return;
		}
		var eventType = event.type;
		if (issafari && (eventType == 'mouseover' || eventType == 'mouseout') && tii_pnav_isUnwantedTextEvent ())
		{
			return;
		}
		if (eventType == 'mouseover')
		{
			handleMouseover (eventSource, level);
		}
		if (eventType == 'mouseout' && level == 0)
		{
			handleMouseout (eventSource, level, event);
		}
		else if (eventType == 'focus')
		{
			handleFocus (eventSource, level);
		}
		else if (eventType == 'blur')
		{
			handleBlur (eventSource, level);
		}
	}
	function handleMouseover (eventSource, level)
	{
		var closeMenu = false;
		if (level == 0)
		{
			if (eventSource.parentNode != lastPrimaryLi)
			{
				closeMenu = true;
			}
			else
			{
				if (lastLevel > 0)
				{
					clearTimeout (delayMenuClose);
				}
				closeMenu = false;
			}
			deactivateLink (lastEventSource, lastLevel, false, closeMenu);
			activateLink (eventSource, level);
		}
		else
		{
			if (issafari)
			{
				if (lastPrimaryLi && !lastPrimaryLi.contains)
				{
					lastPrimaryLi.contains = containsFunction;
				}
			}
			if (isfirefox && lastEventType == 2 && lastLastEventType == 2)
			{
				if (!lastLastBlurPrimaryLi.contains (eventSource) || !lastBlurPrimaryLi.contains (eventSource))
				{
					var delayBlurMenuClose = setTimeout (function () 
					{
						var lastLastBlurMenu = lastLastBlurPrimaryLi.getElementsByTagName ('ul').item (0);
						hideOrShowMenuFunction (lastLastBlurMenu, true, lastLastBlurPrimaryLi);
						changeStateFunction (lastLastBlurPrimaryLi, false, 0);
					}, (isie6 ? tii_pnav_closeMenuDelayIE6 : tii_pnav_closeMenuDelay));
				}
			}
			if (lastEventSource)
			{
				if (lastPrimaryLi.contains (eventSource))
				{
					clearTimeout (delayMenuClose);
					closeMenu = false;
				}
				else
				{
					closeMenu = true;
				}
				deactivateLink (lastEventSource, lastLevel, false, closeMenu);
			}
			activateLink (eventSource, level);
		}
		lastLastEventType = lastEventType;
		lastEventType = 0;
		lastEventSource = eventSource;
		lastPrimaryLi = level == 0 ? lastEventSource.parentNode : (level == 1 ? lastEventSource.parentNode.parentNode.parentNode : lastEventSource.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);
		lastLevel = level;
		doHandleFocus = false;
		doHandleAllFocus = false;
		eventSource.focus ();
	}
	function handleMouseout (eventSource, level, event)
	{
		var related = typeof event.relatedTarget != 'undefined' ? event.relatedTarget : window.event.toElement;
		if (!eventSource.parentNode.contains (related))
		{
			deactivateLink (eventSource, level, true, true);
		}
	}
	function handleFocus (eventSource, level)
	{
		var closeMenu = false;
		if (!doHandleFocus)
		{
			doHandleFocus = true;
			return;
		}
		doHandleAllFocus = true;
		focusEventSource = eventSource;
		focusLevel = level;
		if (lastEventSource)
		{
			if (issafari && !lastPrimaryLi.contains)
			{
				lastPrimaryLi.contains = containsFunction;
			}
			if (lastPrimaryLi && lastPrimaryLi.contains (eventSource))
			{
				closeMenu = false;
			}
			else
			{
				closeMenu = true;
			}
			deactivateLink (lastEventSource, lastLevel, true, closeMenu);
		}
		activateLink (eventSource, level);
		lastLastEventType = lastEventType;
		lastEventType = 2;
		lastEventSource = eventSource;
		lastPrimaryLi = level == 0 ? lastEventSource.parentNode : (level == 1 ? lastEventSource.parentNode.parentNode.parentNode : lastEventSource.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);
		lastLevel = level;
	}
	function handleBlur (eventSource, level)
	{
		lastLastBlurEventSource = lastBlurEventSource;
		lastLastBlurPrimaryLi = lastBlurPrimaryLi;
		lastLastBlurLevel = lastBlurLevel;
		lastBlurEventSource = eventSource;
		lastBlurPrimaryLi = level == 0 ? lastBlurEventSource.parentNode : (level == 1 ? lastBlurEventSource.parentNode.parentNode.parentNode : lastBlurEventSource.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);
		lastBlurLevel = level;
	}
	function activateLink (link, level)
	{
		if (level == 0)
		{
			changeStateFunction (link.parentNode, false, 2);
			var menu = link.parentNode.getElementsByTagName ('ul').item (0);
			if (!menu)
			{
				return;
			}
			hideOrShowMenuFunction (menu, false, menu.parentNode);
		}
		else if (level == 1 || level == 2)
		{
			var secondLi = link.parentNode;
			if (level == 1)
			{
				menu = secondLi.parentNode;
			}
			else
			{
				menu = secondLi.parentNode.parentNode.parentNode.parentNode;
			}
			hideOrShowMenuFunction (menu, false, menu.parentNode);
			changeStateFunction (secondLi, true, 2);
			if (lastLevel == 0)
			{
				changeStateFunction (menu.parentNode, false, 1);
			}
		}
	}
	function deactivateLink (link, level, skipDelay, closeMenu)
	{
		var menu;
		var primeLi;
		var secondLi;
		if (level == 0)
		{
			primeLi = link.parentNode;
			menu = primeLi.getElementsByTagName ('ul').item (0);
			if (!menu)
			{
				changeStateFunction (primeLi, false, 0);
				return;
			}
		}
		else if (level == 1 || level == 2)
		{
			secondLi = link.parentNode;
			changeStateFunction (secondLi, true, 0);
			if (level == 1)
			{
				menu = secondLi.parentNode;
			}
			else
			{
				menu = secondLi.parentNode.parentNode.parentNode.parentNode;
			}
			primeLi = menu.parentNode;
		}
		if (menu && closeMenu)
		{
			doMenuClose (menu, primeLi, skipDelay);
		}
	}
	function doMenuClose (menu, primeLi, skipDelay)
	{
		if (skipDelay)
		{
			hideOrShowMenuFunction (menu, true, menu.parentNode);
			changeStateFunction (primeLi, false, 0);
			return;
		}
		delayMenuClose = setTimeout (function () 
		{
			hideOrShowMenuFunction (menu, true, menu.parentNode);
			changeStateFunction (primeLi, false, 0);
		}, (isie6 ? tii_pnav_closeMenuDelayIE6 : tii_pnav_closeMenuDelay));
	}
}

function tii_pnav_assignFlyoutLis (flyoutUl, addLinkEventHandlers)
{
	var isMulticolumn = true;
	var flyoutLis = flyoutUl.childNodes;
	var flyoutLisLength = flyoutLis.length;
	for (var k = 0; k < flyoutLisLength; k++)
	{
		var flyoutLi = flyoutLis.item (k);
		var secondFlyoutLis = flyoutLi.getElementsByTagName ('li');
		var secondFlyoutLisLength = secondFlyoutLis.length;
		if (secondFlyoutLisLength == 0)
		{
			var flyoutLinks = flyoutLi.getElementsByTagName ('a');
			var flyoutLinksLength = flyoutLinks.length;
			for (var m = 0; m < flyoutLinksLength; m++)
			{
				addLinkEventHandlers.call (this, flyoutLinks.item (m), 1);
			}
		}
		else
		{
			for (var n = 0; n < secondFlyoutLisLength; n++)
			{
				var secondFlyoutLi = secondFlyoutLis.item (n);
				var secondFlyoutLinks = secondFlyoutLi.getElementsByTagName ('a');
				var secondFlyoutLinksLength = secondFlyoutLinks.length;
				for (var p = 0; p < secondFlyoutLinksLength; p++)
				{
					addLinkEventHandlers.call (this, secondFlyoutLinks.item (p), 2);
				}
			}
		}
	}
}

function tii_pnav_isUnwantedTextEvent ()
{
 	return (navigator.vendor == 'Apple Computer, Inc.'
      && (event.target == event.relatedTarget.parentNode
      || (event.eventPhase == 3
      && event.target.parentNode == event.relatedTarget)));
}
function tii_dom_createElement (nodeName, attributes)
{
	var isopera = typeof window.opera != 'undefined';
	var isie = typeof document.all != 'undefined'
   		&& !isopera && navigator.vendor != 'KDE';
		
	var newElement;
	try
	{
		newElement = document.createElement (nodeName);
	}
	catch (error)
	{
		return null;
	}
	
	var attributesLength = attributes.length;
	for (var i = 0; i < attributesLength; i++)
	{
		var attribute = attributes [i] [0];
		var value = attributes [i] [1];
		newElement.setAttribute (attribute, value);
		switch (attribute)
		{
			case 'id':
				newElement.id = value;
				break;
			case 'class':
				if (isie)
				{
					newElement.setAttribute ('className', value);
				}
				newElement.className = value;
				break;
			case 'style':
				newElement.style.cssText = newElement.style.cssText + ' ' + value;
				break;
			case 'for':
				if (isie)
				{
					newElement.setAttribute ('htmlFor', value);
				}
				newElement.htmlFor = value;
		}
	}
	
	return newElement;
}


function tii_dom_removeWhitespaceTextNodes (node)
{
  for (var x = 0; x < node.childNodes.length; x++)
  {
    var child = node.childNodes [x];
    if (child.nodeType == 3 && !/\S/.test (child.nodeValue))
    {
      node.removeChild (node.childNodes [x]);
      x--;
    }
    if (child.nodeType == 1)
    {
      tii_dom_removeWhitespaceTextNodes (child);
    }
  }
}


tii_callFunctionOnWindowLoad (function ()
{
	tii_pnav_initializeDropdownMenu.apply (this, new Array ('topnav', instyle_pnav_hideMenuFunction, instyle_pnav_changeStatusFunction));
});

function instyle_pnav_hideMenuFunction (menu, hideElseShow, menuParent)
{
	if (hideElseShow)
	{
		menu.style.left = '-999px';
	}
	else
	{
		menu.style.left = (menuParent.offsetLeft - 1) + 'px';
	}
}

function instyle_pnav_changeStatusFunction (element, isADropdownItem, state)
{
	if (isADropdownItem)
	{
		switch (state)
		{
			case 0:
				element.className = '';
				break;
			case 2:
				element.className = 'active';
				break;
		}
	}
	else
	{
		var anchor = element.getElementsByTagName ('a').item (0);
		var em = element.getElementsByTagName ('em').item (0);
		switch (state)
		{
			case 0:
				element.style.visibility = 'visible';
				em.style.visibility = 'visible';
				break;
			case 1:
				element.style.visibility = 'visible';
				em.style.visibility = 'hidden';
				break;
			case 2:
				element.style.visibility = 'visible';
				em.style.visibility = 'hidden';
				break;
		}
	}
}

function initMakeThisHomepage(){
	var makeThisHomepage = document.getElementById("makeThisHomepage");
	if(document.all){
		makeThisHomepage.onclick = function(){
			this.style.behavior='url(#default#homepage)';
			//V6 Migration - hardcoding - sdalvi
			this.setHomePage('http://www.instyle.com');
			return false;
		}
	}else if(document.getElementById){
		makeThisHomepage.onclick = function(){
			alert('Drag the link onto your Home button to make this your Home Page.');
			return false;
		}
	}else{
		makeThisHomepage.onclick = function(){
			alert('Go to <i>Preferences</i> in the <i>Edit</i> Menu.<br />Choose <i>Navigator</i> from the list on the left.<br />Click on the <i>"Use Current Page"</i> button.');
			return false;
		}
	}
}
tii_callFunctionOnElementLoad('makeThisHomepage', initMakeThisHomepage);


function tii_stopDefaultAction (event)
{
	event.returnValue = false;
	if (typeof event.preventDefault != 'undefined')
	{
		event.preventDefault ();
	}
}





var tcdacmd="dt";

var macTest=(navigator.userAgent.toLowerCase().indexOf("macintosh") >= 0);

function IMArticle() {
	if (isInAolClient()) {
		document.location.href = "aol://9293::Here's something that may interest you from InStyle.com: <a href='" + document.location.href + "'>" + document.location.href + "</a>";
	} else {
		document.location.href = "aim:goim?message=Here's+something+that+may+interest+you+from+InStyle.com:+" + document.location.href;
	}
	return false;
}

function openWindow (url) {
	var argv = openWindow.arguments;
	var argc = argv.length;
	
	if (argc == 1) {
		var handle = window.open(url);
	} else if (argc == 2) {
		var handle = window.open(url,argv[1]);
	} else {
		var handle = window.open(url,argv[1],argv[2]);
	}
	
	handle.focus();
}

function showHeaderLogo(channelID) {

	if (channelID != 0) {
		document.getElementById('headerHomeLogo').src = "http://img2.timeinc.net/instyle/i/logo_channel.gif"
	}
	
	if (document.getElementById('headerChannelLogo' + channelID)) {
		document.getElementById('headerChannelLogo' + channelID).style.display = "";
	}

	return;
}


function showCenteredPopup(name, url, features, width, height) {
	
	// example usage:
	// showCenteredPopup("foo", "http://www.cnn.com", null, 640, 480);
	
	var top = (screen.height / 2) - height / 2;
	var left = (screen.width / 2) - width / 2;

	if (features == null || features == '') {
		features = "scrollbars=yes,toolbar=no,menubar=no,status=no,location=no";
	}

	window.open(url, name, features + ",top=" + top + ",left=" + left + ",width=" + width + ",height=" + height);

}

// this name is used as a target by links in popup windows
// that need to open in the main window
function nameThisWindow(winName) {
	if (window.opener) {
		window.opener.name=winName;
	} else {
		window.name=winName;
	}
}	

function showPopupBackButton() {
	if (history.length > 0) {
		document.write('<a href="javascript:history.back()"><img src="http://img2.timeinc.net/instyle/i/arrow_left.gif" alt="Back" border="0" style="vertical-align:middle" /> BACK</a>'); 
	}
}




var ie4Test=document.all&&(navigator.userAgent.toLowerCase().indexOf("msie") >= 0);
var dom=document.getElementById&&(navigator.userAgent.indexOf("Opera")==-1);
var macTest=(navigator.userAgent.toLowerCase().indexOf("macintosh") >= 0);
var firefoxTest=(navigator.userAgent.toLowerCase().indexOf("firefox") >= 0);
var ie      = 1;
var mac     = 2;
var firefox = 3; 
var other   = 4;

function isPrintWindow(){
   bV = parseInt(navigator.appVersion)
   if (bV >= 4) window.print()
}
 
function isEmailToFriend(ptitle,purl) {
	if(pageTitle == "") {
	    var pageTitle = escape(self.document.title);
	} else {
	    var pageTitle = escape(ptitle);
	}
	if(pageURL == "") {
	    var pageURL   = escape(self.document.URL);
	} else {
	    var pageURL   = escape(purl);
	}
	//V6 Migration - email server change - sdalvi 
    var formURL   = "http://cgi.instyle.com/cgi-bin/mail/mailurl2friend.cgi?url=" + pageURL + "&group=instyle&title=" + pageTitle + "&path=/instyle/mail/templates";
    window.open(formURL, "emailpop","height=500,width=435,resizable,scrollbars");
    return false;
}
 
function reloadOmniture(toPage) {
	var omnitureFrame = document.getElementById("pageCounter");
	if (omnitureFrame) {
		var frameSrc = omnitureFrame.src;
		var commaIndex = frameSrc.lastIndexOf(",");
		var underScoreIndex = frameSrc.lastIndexOf("_");
		if (commaIndex > -1 && underScoreIndex > -1) { 
			var currentNumber = frameSrc.substring(underScoreIndex + 1, commaIndex)
			var begURL = frameSrc.substring(0,underScoreIndex + 1);
			var endURL = frameSrc.substring(commaIndex, frameSrc.length);
			frameSrc = begURL.concat(toPage, endURL);
			omnitureFrame.src = frameSrc;
		}
	}
}

//track custom link for omniture. the following are the type of links
//-exit links: e
//-download: d
//-custom links: o 
function trackLink(lnkType, lnkObj, lnkName, account) {
	if (lnkType) {
		s_linkType = lnkType;
	}
	
	if (lnkName) {
		s_linkName = lnkName;
	}
	
	if (lnkObj) {
		s_lnk = s_co(lnkObj);
	}
	
	if (account) {
		if (typeof s_gs != "undefined") {
			s_gs(account);
		}
	}
	
	return;
	
}

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="disable"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}
//-->


siteId = "";
cmSiteId = "";

qs =document.location.href;

if(qs.indexOf("instyleweddings") >= 0){
	siteId = "3475.inw";
	cmSiteId = "cm.inw";
} else if( qs.indexOf("instyleyourlook") >= 0) {
	siteId = "3475.iyl";
	cmSiteId = "cm.iyl";
} else {
	siteId = "3475.ins";
	cmSiteId = "cm.ins";
}

		



	var adConfig = new TiiAdConfig(siteId);
	adConfig.setCmSitename(cmSiteId);
	
	if (location.search.indexOf("xid=cnn") >= 0) {
		adConfig.setPopups(false);
	}

	if (location.search.indexOf("google=yes") >= 0) {
		adConfig.setPopups(false);
	}

	if (location.search.indexOf("yahoo=yes") >= 0) {
		adConfig.setPopups(false);
	}
	// partner=yes is for CM popup control
	if (location.search.indexOf("partner=yes") >= 0) {
		adConfig.setPopups(false);
	}
// fixes IE background flickering
try {
	document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}



function adSetTarget() {} 
function htmlAdWH() {}
function adSetType() {} 



 
adConfig.setRevSciTracking(true);


adConfig.setTacodaTracking(false);

/* Search button will not work unless 3 or more characters are entered in search query -- endeca site search*/
tii_callFunctionOnWindowLoad (function() {
      var searchDivs = new Array();
      searchDivs.push(document.getElementById("sitesearch"));
      searchDivs.push(document.getElementById("searchagain"));
      for (var i=0; i < searchDivs.length; i++) {
            if (searchDivs[i]) {
                  try {
                        var form = searchDivs[i].getElementsByTagName("form")[0];
                        form.onsubmit = function(){
                              var inputs = form.getElementsByTagName("input");
                              for (var j=0; inputs[j]; j++) {
                                    if (inputs[j].getAttribute("type") == "text") {
                                          //if (inputs[j].value.length < 3) {
                                                //return false;
                                          //}
                                    }
                              }
                              return true;
                        }
                  } catch(e) {}
            }
      }
});

