function adsDiv(oDiv, sSrc, nWidth, nHeight)
{
	this.div = oDiv;
	this.src = sSrc;
	this.Width = nWidth;
	this.Height = nHeight;
}

function getGlobalInt(globalValue, defValue)
{
	globalValue = Number(globalValue);
	if(isNaN(globalValue))
		globalValue = defValue;
	return globalValue;
}

function getGlobalString(globalValue, defValue)
{
	if(globalValue)
	{
	  globalValue = unescape(globalValue.toString());
	  globalValue = globalValue.replace(/</g, '&lt;');
	  globalValue = globalValue.replace(/>/g, '&gt;');
	  return globalValue;
	}
	return defValue;
}

function include_ads()
{
	var at = getGlobalInt(window.jt_adType, 0);
	var aw = getGlobalInt(window.jt_adWidth, 0);
	var ah = getGlobalInt(window.jt_adHeight, 0);

	var cr = getGlobalString(window.jt_clrBorder, '');
	var cb = getGlobalString(window.jt_clrBackground, '');
	var cl = getGlobalString(window.jt_clrLink, '');
	var ct = getGlobalString(window.jt_clrText, '');
	var cu = getGlobalString(window.jt_clrURL, '');

	var d = new Date();
	var divContainerID = "JTAdsContainer" + d.getTime();
	var i = '';
	while(o = document.getElementById(divContainerID.concat(i)))
		i++;
	divContainerID = divContainerID.concat(i);
	sWidth = ""
	sHeight = "";
	if(aw > 0)
		sWidth = ' width="'+aw+'" ';
	if(ah > 0)
		sHeight = ' height="'+ah+'" ';
	document.write('<div id="'+divContainerID+'"></div>');
//	document.write('<div id="'+divContainerID+'"><iframe src="javascript:void(0)" name="'+divContainerID+'" '+sWidth+sHeight+' scrolling="no" frameborder="0" allowtransparency="true" hspace="0" vspace="0" marginheight="0" marginwidth="0"></iframe></div>');
	var divContainer = document.getElementById(divContainerID);

	var script_filename = 'http://jtpool.juicetorrent.com/get-ads-frame.php?c=' + divContainerID + '&at=' + at + '&cr=' + escape(cr) + '&cb=' + escape(cb) + '&cl=' + escape(cl) + '&ct=' + escape(ct) + '&cu=' + escape(cu);
	jt_adsDivs.push(new adsDiv(divContainer, script_filename, aw, ah));

	return false;
}

function jt_show_ads()
{
	jtw = window.jt_Widget || false;
	if(jtw)
		jtw.show_all_ads();
}

if(!window.jt_adsDivs)
	jt_adsDivs = new Array();

include_ads();
jt_show_ads();
