// Gizmo 15: This is the Original Version that we wish would work
// Iraq War Quotes: Bush, Cheney, Rumsfeld, Rice, others
// By Steve Stoft, Dan Kirshner & Tim Wood - zFacts.com
var quotes_15="zfacts.com/giz/G15/quotes2.php";
var facts_15="zfacts.com/giz/G15/facts.php";
valid_15();
function valid_15() {
udat_15();
getQuote_15(1, "The war: \"Something <b>under $50 billion</b> for the cost.\"|Rumsfeld|01/19/2003|Now <b>over $325 billion</b>. Every year costs more.");
m=valid_15;
var rpage="http://zfacts.com/p/252.html";
var oops=0;
var linkDiv=document.getElementById('IWQ');
if(!linkDiv ||(typeof(linkDiv)=='undefined')) {
alert("Need id='IWQ' in Link to zfacts.com/p/252.html\nSee http://zfacts.com/p/364.html for Help.");
return;
}
var linked=linkDiv.innerHTML;
if(linkDiv!=null)
{ if(linkDiv.getAttribute("href")!=rpage) oops=1;
if(linked.toLowerCase().indexOf('iraq') < 0) oops=2;
if(linkDiv.nodeName!='A') oops=3;
}
else oops=4;
if(0) {
alert("Need link to zfacts.com/p/252.html\nSee http://zfacts.com/p/364.html for Help.");
return;
}
var paramDiv=document.getElementById('IWQz');
if(paramDiv &&(typeof(paramDiv)!='undefined')) {
var paramList=paramDiv.getAttribute("ref");
if(paramList &&(paramList.length > 2))
loadPrams_15(paramList);
}
setUp_15('IWQ');
getDiv_15('init');
speed_15('init', pram_15('speed'));
info_15('controls');
info_15('offOnly');
looper_15(0);
}
function loadPrams_15(pString) {
pNames=['speed', 'size', 'cQ', 'cF', 'cL', 'cB'];
var params=pString.split(',');
for(var i=0; i<params.length; i++) {
var peqv=params[i].replace(/ /g, '');
peqv=peqv.split('=');
var pram=peqv[0]; var val=peqv[1];
for(var j=0; j<pNames.length; j++) {
if(pram.toLowerCase()==pNames[j].toLowerCase())
pram_15(pNames[j], val);
}
}
}
function pram_15(name, val) {
var my=pram_15;
if(typeof(my.init)=='undefined') {
my.size=5;
my.speed=5;
my.cQ='#FFF';
my.cF='#FCC';
my.cL='#CCF';
my.cB='#900';
my.init=1;
}
if(typeof(val)!='undefined') eval('my.' +name+ '=val;');
else return eval('my.' +name);
}
var loop_15;
function looper_15(what) {
var my=looper_15;
if(typeof(my.init)=='undefined') { my.init=1;
my.waiting=0;
my.way=1;
my.going=1; }
if(typeof(what)=='undefined') what='undef';
if(what!='undef') {
clearTimeout(loop_15);
if(typeof(waitLoop_15)!='undefined') clearTimeout(waitLoop_15);
my.waiting=0;
}
if(! my.waiting) {
var slow=0;
var nxt=what;
if(what==-1) my.way=-1;
if(inStr(what, '1,0,9')) my.way=1;
if(what=='go') { nxt='skip'; slow=1; }
if(inStr(what, 'undef,goNow')) nxt=my.way;
if(inStr(what, '1,0,-1,go,goNow')) my.going=1;
if(what=='pause') my.going=1 - my.going;
if(what=='pause' && my.going) nxt=my.way;
if(inStr(what, 'stop,9')) my.going=0;
if(my.going) getDiv_15.pause.innerHTML='Stop';
else getDiv_15.pause.innerHTML='Go';
if(inStr(nxt, '-1,1,0,9'))
my.qN=nextQN(nxt);
if(! my.going && !(nxt==9)) return;
}
quote=getQuote_15(my.qN);
if(quote==-1) {
my.waiting=1;
waitLoop_15=setTimeout("looper_15();", 300);
}
else {
my.waiting=0;
if(! slow) processQuote(my.qN, quote);
if(! my.going) return;
var sf=1; if(slow) sf=1.6;
var qDelay=speed_15('get', 'qLen')/sf;
var fDelay=speed_15('get', 'fLen')/sf;
setTimeout("showFact();", qDelay);
loop_15=setTimeout("looper_15();", qDelay+fDelay);
}
}
function nextQN(dN) {
var my=nextQN;
var look=0;
my.shrtList=0;
if(dN=='lookAhead') { dN=my.way; var qN=my.qN; var look=1; }
else {
my.way=1; if(dN==-1) my.way=-1;
}
if(typeof(qSet)=='undefined')
my.qSet=new Array(4,5,8,9,13,14,15,16,24,27,28,29,30,33,39,46,49,50,54);
var L=my.qSet.length;
var maxQN=getQuote_15.maxQ;
if(dN==0) my.qN=1;
if(dN==1) { my.qN ++;
if(my.qN > maxQN) my.qN=1; }
if(dN==-1){ my.qN --;
if(my.qN < 1) my.qN=maxQN; }
if(dN==9) my.qN=maxQN;
if(my.shrtList) {
var sqn=shorti(my.qN);
if(dN==0) my.qN=sqn=0;
if(dN==9) my.qN=sqn=L-1;
if(dN==1) { sqn=Math.ceil(sqn); if(sqn>L) sqn=0; }
if(dN==-1) { sqn=Math.floor(sqn); if(sqn<0) sqn=L-1; }
my.qN=my.qSet[sqn];
}
if(look) { var ahead=my.qN; my.qN=qN; return ahead }
return my.qN;
function shorti(qn) {
for(i=0; i<L; i++) {
if(qn < my.qSet[i]) return(i-.5);
if(qn==my.qSet[i]) return i;
}
return i+0.5;
}
}
function processQuote(n, quotePlus) {
var my=processQuote;
if(n=='qN') return my.qN;
if(n=='qLen') return my.qLen;
if(n=='fLen') return my.fLen;
if(n=='WhoDate') {
getDiv_15.who.innerHTML=my.who +'<br>'+ my.date;
setTimeout('showFact();', 2000);
return;
}
my.qN=n;
var qData=quotePlus.split('|');
var quote=qData[0];
my.qLen=quote.length;
showFact("&nbsp;");
putQuoteInDiv(quote);
slideQuote_15('start');
my.who='<b>'+qData[1]+'</b>';
var mdy=qData[2].split('/');
my.date=mdy[0] + ' / ' + mdy[2];
my.fact=qData[3];
my.fLen=my.fact.length;
}
function showFact(fact) {
if(typeof(fact)=='undefined') fact=processQuote.fact
getDiv_15.fact.innerHTML=fact;
}
function putQuoteInDiv(quote) {
if(slideQuote_15('topDiv')==2)
var bottomDiv=getDiv_15.quote;
else
var bottomDiv=getDiv_15.quote2;
var code=quote.match(/^.;/);
if(code) quote=quote.substr(2);
bottomDiv.innerHTML=quote;
if(code=='B;') bottomDiv.style.fontFamily='arial';
else bottomDiv.style.fontFamily='verdana,helvetica,arial';
}
function slideQuote_15(what) {
var my=slideQuote_15;
my.Ymax=35;
if(typeof(what)!='undefined') {
if(typeof(my.topDivN)=='undefined') {
my.topDivN=2; my.hiVis=1;
my.topDiv=getDiv_15.quote2.style;
my.botDiv=getDiv_15.quote.style;
my.yLow=my.Ymax;
}
if(what=='topDiv') return my.topDivN;
if(what=='start') {
my.botDiv.visibility='visible';
my.topDiv.visibility='hidden';
}
else return;
}
my.botDiv.top=my.yLow + 'px';
if(my.yLow==0) {
my.topDivN=3 - my.topDivN;
var tmp=my.topDiv;
my.topDiv=my.botDiv; my.botDiv=tmp;
my.yLow=my.Ymax;
processQuote('WhoDate');
} else {
if(my.yLow > 20) my.yLow=my.yLow -10;
else if(my.yLow > 10) my.yLow=my.yLow -4;
else if(my.yLow > 3) my.yLow=my.yLow -2;
else my.yLow--;
setTimeout("slideQuote_15();", 50);
}
}
function speed_15(what, val) {
var my=speed_15;
if(what=='init') {
my.spd=val*1;
my.m=[2.7, 1.7, 1.35, 1.15, 1, .85, .7, .5, .1];
}
else if(what=='inc') {
my.spd=Math.min(my.spd+1,9);
looper_15('goNow');
}
else if(what=='dec') my.spd=Math.max(my.spd-1,1);
else if(what=='get') {
var Len=processQuote(val)
var s=my.m[my.spd-1];
if(val=='qLen')
return 800 + s *(900 + 2800 * Len/50);
else
return 1100 + s * 2800 * Len/50;
}
getDiv_15.speed.innerHTML="\xA0" + my.spd + "\xA0";
}
function onOffCBs(x) {
var my=onOffCBs;
if(typeof(my.state)=='undefined') { my.state='off'; my.busy=0; my.offWait=0; }
if(x=='offNow') my.D='off';
switch(x) {
case 'on':
case 'off':
my.D=x;
if(my.offWait) { clearTimeout(my.offWait); my.offWait=0; }
if(my.D==my.state) {
return;
}
if(x=='off') {
my.offWait=setTimeout("onOffCBs('set0');", 1300);
return;
}
case 'offNow':
case 'set0':
case 'setB':
if(my.D==my.state) return;
if(my.busy) {
setTimeout("onOffCBs('setB');", 300);
return;
}
my.busy=1;
var D=my.D;
my.state=D;
info_15(D);
my.busy=0;
}
}
function setUp_15(ID) {
my=setUp_15;
var cQ=pram_15('cQ');
var cF=pram_15('cF');
var cL=pram_15('cL');
var cB=pram_15('cB');
var cCBG='#9BA';
var cCBT='#FFC';
var cIC='background-color:#ACB; '
var cLSty='background-color:' +cL+ '; ';
var cIBG='#FFd';
var cIB='#060';
var tapeBG='background-color:' +cCBG+ '; ';
var tapeBtn='background-color:' +cCBT+ '; border:1px solid ' +cCBG+ '; cursor:hand; cursor:pointer; ';
var mbp0='margin:0; border:0; padding:0; ';
var fSz=12, lHt=16;
var wd=350, LWd=60, rmWd=3, lmWd=5;
var ht=55, qHt=36, fHt=16
var fontFam='font-family:arial,\'sans sarif\';' ;
var fontFamBig='font-family:verdana,helvetica,arial;' ;
var fontTapeCntrl='font-family:verdana,helvetica,arial;' ;
if(pram_15.size==3) {
fSz=11; lHt=15;
wd=308; LWd=54; rmWd=2, lmWd=3;
ht=48; qHt=30; fHt=15;
var fontFam='font-family:Times,\'Times New Roman\',sarif;' ;
var fontFamBig='font-family:arial,\'sans serif\';' ;
}
var fontSize='font-size:' +fSz+ 'px; line-height:' +lHt+ 'px; ';
var Fwd='width:' +wd+ 'px; ';
var F2wd='width:' +(wd-2)+ 'px; ';
var Lwd='width:' +LWd+ 'px; ';
var Qwd='width:' +(wd-2-LWd-rmWd-lmWd-rmWd)+ 'px; ';
var MRwd='margin:0 ' +rmWd +'px 0 0;'
var MLwd='width:' +lmWd+ 'px; ';
var Fht='height:' +ht+ 'px; ';
var Qht='height:' +qHt+ 'px; ';
var Rht='height:' +fHt+ 'px; ';
var iBox='line-height:' +(lHt-2) +'px; height:' +(fHt-2) +'px; bottom:1px; font-family:courier; font-weight:bold; color:#FFF; background-color:#33F;';
var outerBox=document.createElement('div');
Giz=document.getElementById(ID);
Giz.parentNode.replaceChild(outerBox, Giz);
var gizTag='<div id="box_15" '
+ 'style="' +Fwd+Fht+ ' position:relative; text-align:left;'
+ mbp0 + fontSize + fontFam
+ 'background-color:' +cB+ ';"'
+ 'onmouseover="onOffCBs(\'on\')" onmouseout="onOffCBs(\'off\')"></div>'
outerBox.innerHTML=gizTag;
var box=document.getElementById('box_15');
content=""
+ '<div id="popUp_15" style="position:absolute; visibility:hidden; top:' +ht+ 'px; left:0px; '
+ Fwd +mbp0 +' background-color:' +cIB+'; text-align:left; z-index:99; opacity:1.0; -moz-opacity:1.0; filter:Alpha(opacity=100);">'
+ '<div id="CBs_15" style="' +F2wd +Rht +fontSize +mbp0 +'top:0px; left:1px; ' +tapeBG+ '; '
+ 'visibility:hidden; overflow:hidden;">'
+ '<div style="float:right; ' +mbp0 +'">&nbsp;'
+ '<span style="'+tapeBtn +'font-weight:bold;" onclick="info_15(\'fact\')">\xA0\xA0more info\xA0\xA0</span>'
+ '<span style="'+tapeBtn +iBox +'" onclick="info_15(\'about\')">i</span>'
+ '</div>'
+ '<div style="float:left; ' +mbp0 +'text-align:right;">'
+ '<span style="'+tapeBtn+'" onclick="speed_15(\'dec\')">\xA0Slower\xA0</span>'
+ '<span id="speed_15" style="background-color:#FFF;"></span>'
+ '<span style="'+tapeBtn+'" onclick="speed_15(\'inc\')">\xA0Faster\xA0</span>'
+ '</div>'
+ '<div style="float:left; ' +mbp0 +fontTapeCntrl +'font-weight:bold;">'
+ '<span style="'+tapeBG+'"> &nbsp; </span>'
+ '<span style="'+tapeBtn+'" onclick="looper_15(0)">|<</span>'
+ '<span style="'+tapeBtn+'" onclick="looper_15(-1)">\xA0<\xA0</span>'
+ '<span id="pause_15" style="'+tapeBtn+'font-weight:normal;" onclick="looper_15(\'pause\')">Stop</span>'
+ '<span style="'+tapeBtn+'" onclick="looper_15(1)">\xA0>\xA0</span>'
+ '<span style="'+tapeBtn+'" onclick="looper_15(9)">>|</span>'
+ '</div>'
+ '</div>'
+ '<div id="info_15" style="' +F2wd +mbp0 +'top:0px; left:1px; background-color:' +cIBG +';">'
+ '<div id="iText_15" style="width:' +(wd-2-4-3) +'px; position:relative; top:3px; left:4px;"></div>'
+ '<div style="width:100px; height:4px; ' +mbp0 +'font-size:0px; line-height:0px;">&nbsp;</div>'
+ '</div>'
+ '<div style="' +Fwd +mbp0 +'height:1px; font-size:0px; line-height:0px;">&nbsp;</div>'
+ '</div>'
+ '<div id="qtBox_15" style="' +F2wd +mbp0 +Qht +'position:relative; top:1px; left:1px; background-color:'+cQ+'; text-align:left; overflow:hidden;">'
+ '<div id="who_15" style="float:left; ' +Lwd +Qht +mbp0 +cLSty+ '; text-align:right;">Who<br>Date</div>'
+ '<div style="float:left; ' +MLwd +MRwd +Qht +cLSty + 'border:0px; padding:0px;"></div>'
+ '<div style="float:left; position:relative; ' +Qwd +Qht +mbp0 +fontFamBig +'text-align:left;">'
+ '<div id="quote_15" style="position:absolute; '+mbp0+'">Quote</div>'
+ '<div id="quote2_15" style="position:absolute; '+mbp0+'">Quote</div>'
+ '</div>'
+ '</div>'
+ '<div id="fBox_15" style="' +F2wd +Rht + 'position:relative; top:2px; left:1px; background-color:' +cF+ '; '
+ mbp0+ 'overflow:hidden;">'
+ '<div id="i_15" style="position:absolute; left:2px; ' +iBox +'">i</div>'
+ '<div style="float:left; '+Lwd +Rht +mbp0 +cLSty + 'text-align:right; color:#333;"><b>Fact:</b></div>'
+ '<div style="float:left; ' +MLwd +MRwd +Rht +cLSty + 'border:0px; padding:0px;"></div>'
+ '<div id="fact_15" style="float:left; width:'+(wd-LWd-12)+'px; text-align:left;">This is a Fact.</div>'
+ "</div>"
+ '';
box.innerHTML=content;
my.infoControlDiv=""
+ '<div style="float:right; position:relative; top:-3px; right:-3px; font-weight:bold; cursor:hand; cursor:pointer;">'
+ '<span onclick="info_15(BACK)" style="' +cIC+ '">&nbsp;back&nbsp;</span>&nbsp;'
+ '<span onclick="onOffCBs(\'offNow\')" style="' +cIC+ '">&nbsp;X&nbsp;</span>&nbsp;'
+ '<span onclick="info_15(MORE)" style="' +cIC+ '">&nbsp;more&nbsp;</span>'
+ '</div>';
}
function getDiv_15(which) {
var my=getDiv_15;
if(which!='init') return;
my.box=document.getElementById('box_15');
my.qtBox=document.getElementById('qtBox_15');
my.quote=document.getElementById('quote_15');
my.quote2=document.getElementById('quote2_15');
my.who=document.getElementById('who_15');
my.popUp=document.getElementById('popUp_15');
my.info=document.getElementById('info_15');
my.iText=document.getElementById('iText_15');
my.fBox=document.getElementById('fBox_15');
my.i=document.getElementById('i_15');
my.fact=document.getElementById('fact_15');
my.CBs=document.getElementById('CBs_15');
my.speed=document.getElementById('speed_15');
my.pause=document.getElementById('pause_15');
}
function info_15(what) {
var my=info_15;
switch(what) {
case 'on':
looper_15('stop');
getDiv_15.i.innerHTML='';
showInfo_15(0, 'controls');
return;
case 'off':
showInfo_15(0, 'off');
getDiv_15.i.innerHTML='i';
looper_15('go')
return;
case 'offOnly':
showInfo_15(0, 'off');
getDiv_15.i.innerHTML='i';
return;
case 'controls':
showInfo_15(0, 'controls');
return;
case 'about':
case 'fact':
case 'quote':
case 'fSource':
case 'qSource':
looper_15('stop')
var qN=processQuote('qN');
if(what=='about') qN=0;
showInfo_15(qN, what);
}
}
function showInfo_15(n, what, info) {
my=showInfo_15;
switch(what) {
case 'ready':
break;
case 'off':
getDiv_15.popUp.style.visibility='hidden';
getDiv_15.CBs.style.visibility='hidden';
getDiv_15.CBs.style.position='absolute';
getDiv_15.iText.innerHTML='';
return;
case 'controls':
getDiv_15.popUp.style.visibility='visible';
getDiv_15.CBs.style.position='relative';
getDiv_15.CBs.style.visibility='visible';
getDiv_15.info.style.position='absolute';
getDiv_15.info.style.visibility='hidden';
getDiv_15.iText.innerHTML='';
return;
default:
my.what=what;
getInfo_15(n, 'get');
return;
}
getDiv_15.CBs.style.position='absolute';
getDiv_15.CBs.style.visibility='hidden';
getDiv_15.info.style.position='relative';
getDiv_15.info.style.visibility='visible';
var UC=info.split('|');
var moreInfo, backInfo, Text="";
switch(my.what) {
case 'about':
moreInfo='fact'; backInfo='controls';
Text=UC[0]; break
case 'fact':
moreInfo='quote'; backInfo='controls';
Text='<b>Full Fact:</b> &nbsp; ' + UC[3];
break;
case 'quote':
moreInfo='fSource'; backInfo='fact';
Text='<b>Full Quote:</b> &nbsp; ' + UC[1];
break;
case 'fSource':
moreInfo='qSource'; backInfo='quote';
Text=url_15(n, 'Fact Source: ', UC[2]);
break;
case 'qSource':
moreInfo='controls'; backInfo='fSource';
Text=url_15(n, 'Quote Source: ', UC[0]);
}
moreInfo="'" +moreInfo+ "'";
backInfo="'" +backInfo+ "'";
var cntrls=setUp_15.infoControlDiv;
cntrls=cntrls.replace(/MORE/, moreInfo);
cntrls=cntrls.replace(/BACK/, backInfo);
getDiv_15.iText.innerHTML=cntrls + Text;
}
function getInfo_15(n, what, info) {
var my=getInfo_15;
if(typeof(my.qInfo)=='undefined') { my.qInfo=new Array(); }
if(what=='get') {
if(typeof(my.qInfo[n])!='undefined') {
showInfo_15(n, 'ready', my.qInfo[n]);
return;
} else {
loadJSA(facts_15, n);
return;
}
} else if(what=='new') {
my.qInfo[n]=info;
showInfo_15(n, 'ready', info);
}
else alert('problem in getInfo');
}
function loadJSA(file, ndx) {
var my=loadJSA;
if(typeof(my.n)=='undefined') my.n=1;
var sid='JSAsync' +(my.n ++);
var head=document.getElementsByTagName('head').item(0);
var script=document.createElement('script');
script.src="http://" +file+ "?sid=" +sid+ "&index=" +ndx;
script.type='text/javascript';
script.id=sid;
head.appendChild(script);
}
function url_15(n, label, url) {
var nc=64;
var ml='';
var daurl='<b>' +label+ '</b>' + url;
while(daurl.length > nc) {
for(i=nc-1; i>0; i--) {
var c=daurl.substr(i,1);
if(c=='/' | c==' ') { break; }
}
if(i<3) break;
ml=ml + daurl.substr(0,i+1) +'<br>';
daurl=daurl.substr(i+1);
}
return ml + daurl;
}
function getQuote_15(n, quote) {
var my=getQuote_15;
if(typeof(my.init)=='undefined') {
my.init=1;
my.nn=0;
my.URL=quotes_15;
my.quotes=new Array();
loadJSA(my.URL, 'max');
}
if(n=='max') {
if(typeof(my.maxQ)=='undefined') return 2;
else return my.maxQ;
}
if(typeof(quote)!='undefined') {
my.quotes[n]=quote;
return;
}
if(undef(n)) {
my.quotes[n]='fetched';
loadJSA(my.URL, n);
return -1;
}
else if(my.quotes[n]=='fetched') {
return -1;}
else {
getNextQ();
return my.quotes[n];
}
function getNextQ() {
var nextN=nextQN('lookAhead');
if(undef(nextN))
loadJSA(my.URL, nextN);
}
function undef(n) {
if(typeof(my.quotes[n])=='undefined') return 1; else return 0;
}
}
function inStr(needle, hay) {
needle=needle+'';
hay=','+hay+',';
w=hay.indexOf(','+needle+',');
if(w==-1) return 0;
return 1;
}
function pop_15(w,h,url)
{ var purl='http://'+url;
FN=window.open(purl,'FN','resizable=yes,scrollbars=yes,width='+w+',height='+h+',left=0,screenX=0,top=0,screenY=0');
FN.focus();
}
function udat_15() {
	var file = 'http://zfacts.com/giz/udat/rec.php?gizName=G15iwq';
//	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.
}