function preload() { if (document.images) { if (typeof(document.F) == 'undefined'){ document.F = new Object(); } document.F.loadedImages = new Array(); var argLength = preload.arguments.length; for(arg=0;arg<argLength;arg++) { document.F.loadedImages[arg] = new Image(); document.F.loadedImages[arg].src = preload.arguments[arg]; } } }
function imageswap(daImage, daSrc){ var objStr,obj; if(document.images){ if (typeof(daImage) == 'string') { objStr = 'document.' + daImage; obj = eval(objStr); obj.src = daSrc; } else if ((typeof(daImage) == 'object') && daImage && daImage.src) { daImage.src = daSrc; } } }
var topon = new Array();
var toggleInterval = 0;
var issafari=false;
if(navigator.userAgent.indexOf("Safari")!=-1)
{
issafari=true
}
function toggle(target,onoff){
	if(document.getElementById(target)){
		if(currentdiv != undefined){
			changeclass(currentdiv + 'o','wrapper');	
			document.getElementById(currentdiv).style.display = 'none';
		}

		if(onoff == 1){	
			document.getElementById(target).style.display = 'inline';
			changeclass(target + 'o','wrapper_on');	
		} else {
			document.getElementById(target).style.display = 'none';
			changeclass(target + 'o','wrapper');	
		}
	
		currentdiv = target;
	}
}

function global_toggle (targetdiv){
	if(!topon[targetdiv]){
		topon[targetdiv] = true;
		$('#'+targetdiv).css({display: 'block'});
		$('#'+targetdiv).hide();
		$('#'+targetdiv).fadeIn('fast');
		document.getElementById(targetdiv+'_but').className = 'sel';
		toggleInterval = setInterval(function () { global_toggle(targetdiv,false) }, 60000);
	} else {
		topon[targetdiv] = false;
		clearInterval(toggleInterval);
		document.getElementById(targetdiv+'_but').className = '';
		$('#'+targetdiv).fadeOut('fast', function () { $('#'+targetdiv).css({display: 'none'}) });
	}
}

function global_mailform_check() {
	var go = true;
	var msg = 'Please double-check the following: ';
	if(document.getElementById('myusername').value == '' || document.getElementById('mydomain').value == '' || document.getElementById('mydomain').value.indexOf('.') == -1){
		msg += '\nYour e-mail address';
		go = false;
	}
	if(document.getElementById('friendusername').value == '' || document.getElementById('frienddomain').value == '' || document.getElementById('frienddomain').value.indexOf('.') == -1){
		msg += '\nYour friend\'s e-mail address';
		go = false;
	}
	if(!go){
		alert(msg);
	}
	return go;
}

function networksubmit (idx,url,title){
		if(url.indexOf('http://') == -1){
			url = 'http://www.pbs.org' + url;
		}
		if(idx == 0){
			location.href = "http://www.stumbleupon.com/submit?url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title);
		}
		if(idx == 2){
			location.href = "http://www.facebook.com/share.php?u="+encodeURIComponent(url)+"&t="+encodeURIComponent(title);
		}
		if(idx == 3){
			location.href = "http://reddit.com/submit?url="+encodeURIComponent(url);
		}
		if(idx == 4){
			location.href = "http://digg.com/submit?phase=2&url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title)+"&topic=television";
		}
		if(idx == 5){
			location.href = "http://del.icio.us/post?v=4&noui&jump=close&url="+encodeURIComponent(url)+"&title="+encodeURIComponent(title);
		}
		if(idx == 6){
			location.href = "http://twitter.com/home?status="+encodeURIComponent(title) + ' - ' +encodeURIComponent(url);
		}
}


function makenav() {
var idx = 0;
var lastidx = 0;
	
  $(document).ready(function(){
   	$("#next").click(function () {
	idx++;
	if(idx > 5){
		idx = 0;
		lastidx = 5;
	} else {
		lastidx = idx - 1;
	}
  	$("#on"+lastidx).fadeOut(500);
	$("#on"+idx).fadeIn(2000);
  });
  
  $("#back").click(function () {
  	idx--;
	if(idx < 0){
		idx = 5;
		lastidx = 0;
	} else {
		lastidx = idx + 1;
	}
  	$("#on"+lastidx).fadeOut(500);
	$("#on"+idx).fadeIn(2000);
  });
});
	
	
topon['global_email'] = false;
topon['global_share'] = false;

document.write('<div id="top_gtop"><div id="sbox"><ul class="gtop_main"><li><a href="javascript:void(0);" onclick="global_toggle(\'global_email\');" id="global_email_but"> E-MAIL/SHARE THIS PAGE <img src="\/wgbh\/pages\/frontline\/art\/08global\/mail.png" width="20" height="20" alt="E-MAIL THIS PAGE" align="middle" \/><\/a><\/li><li><form action="/wgbh/pages/frontline/gsearch.html" method="get" name="searchform"> &nbsp; SEARCH <input type="text" name="q" class="gtop_sbx" \/><input type="image" alt="submit" width="20" height="20" src="\/wgbh\/pages\/frontline\/art\/08global\/searchbutton.png" style="vertical-align: middle;"\/><\/form><\/li><\/ul><\/div>');
document.write('<ul class="gtop_main"><li><span>ALSO ON FRONTLINE<\/span><\/li><li id="back"><img src="\/wgbh\/pages\/frontline\/art\/09global\/topbar_back.gif" width="12" height="39" alt="previous"><\/li><li><span class="title" id="on0"><a href="\/wgbh\/pages\/frontline\/closetohome\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2803.jpg" \/> Close to Home<\/a><\/span><span class="title" id="on1" style="display:none"><a href="\/wgbh\/pages\/frontline\/warning\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2802.jpg" \/> The Warning<\/a><\/span><span class="title" id="on2" style="display:none"><a href="\/wgbh\/pages\/frontline\/obamaswar\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2801.jpg" \/> Obama\'s War<\/a><\/span><span class="title" id="on3" style="display:none"><a href="\/wgbh\/pages\/frontline\/breakingthebank\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2715.jpg" \/> Breaking the Bank<\/a><\/span><span class="title" id="on4" style="display: none"><a href="\/wgbh\/pages\/frontline\/madoff\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2714.jpg" \/> The Madoff Affair<\/a><\/span><span class="title" id="on5" style="display: none"><a href="\/wgbh\/pages\/frontline\/released\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2713.jpg" \/> The Released<\/a><\/span><span class="title" id="on6" style="display: none"><a href="\/wgbh\/pages\/frontline\/poisonedwaters\/" class="none"><img src="\/wgbh\/pages\/frontline\/art\/09global\/2712.jpg" \/> Poisoned Waters<\/a><\/span></li><li id="next" style="position: absolute; left: 370px; top: 29px;"><img src="\/wgbh\/pages\/frontline\/art\/09global\/topbar_next.gif" width="12" height="39" alt="next" \/><\/li><\/ul><\/div>');
document.write('<div id="global_email"><div class="gtop_mailform">');
document.write('<form action="http:\/\/www.pbs.org\/cgi-registry\/tell_a_friend.cgi" onsubmit="return global_mailform_check();" method="post">');
document.write('<input type="hidden" name="url_to_send" value="'+location.href+'" \/>');
document.write('<input type="hidden" name="location" value="'+location.pathname+'" \/>');
document.write('<input type="hidden" name="subjectline" value="You have been sent a link from FRONTLINE" \/>');
document.write('<input type="hidden" name="error_template" value="\/wgbh\/pages\/frontline\/us\/mailfrienderror.html" \/>');
document.write('<p>Your e-mail address<br \/>');
document.write('<input type="text" name="myusername" maxlength="30" value="" class="gtop_mail" id="myusername" \/>&nbsp;<span>@<\/span>&nbsp;<input type="text" name="mydomain" id="mydomain" class="gtop_mail" maxlength="30" value="" \/><\/p>');
document.write('<p>Your friend\'s e-mail address<br \/><input type="text" name="friendusername" id="friendusername" class="gtop_mail" maxlength="30" value="" \/>&nbsp;<span>@<\/span>&nbsp;<input type="text" name="frienddomain" id="frienddomain" class="gtop_mail" maxlength="30" value="" \/><\/p><p>brief message (optional)');
document.write('<br \/><textarea name="content" rows="3" class="gtop_mailwide" ><\/textarea><\/p>');
document.write('<p><input type="image" alt="submit" style="float: right;" width="20" height="20" src="\/wgbh\/pages\/frontline\/art\/08global\/searchbutton.png"\/><span>Information you supply on this page will only be used to send this link.<\/span><\/p>');
document.write('<\/form>');
document.write('<hr>');
document.write('<div class="gtop_share">');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(6,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social6.gif" width="16" height="16" alt="twitter" \/>TWITTER<\/a><\/p>');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(0,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social3.gif" width="16" height="16" alt="STUMBLEUPON" \/>STUMBLEUPON<\/a><\/p>');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(1,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social5.gif" width="16" height="16" alt="slashdot" \/>SLASHDOT<\/a><\/p>');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(2,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social4.gif" width="16" height="16" alt="facebook" \/>facebook<\/a><\/p>');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(3,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social2.png" width="16" height="16" alt="reddit" \/>reddit<\/a><\/p>');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(4,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social1.gif" width="16" height="16" alt="digg" \/>DIGG<\/a><\/p>');
document.write('<p><a href="javascript:void(0)" onclick="networksubmit(5,location.href,document.title);"><img src="/wgbh/pages/frontline/art/08global/p_social0.gif" width="16" height="16" alt="del.icio.us" \/>DEL.ICIO.US<\/a><\/p>');
document.write('<\/div><\/div><\/div>');
}

function videoplayer_open (full) {
	var a;
if(navigator.appName.indexOf("Microsoft")!=-1)
{
a=window['bigplaya_id']
}
else
{
a=document['bigplaya_id']
}
var newheight = (full)? '430px':'90px';
if(full){
	newheight = '430px';
}

a.style.height= newheight;
}

function videoplayer_close (full) {
	var a;
if(navigator.appName.indexOf("Microsoft")!=-1)
{
a=window['bigplaya_id']
}
else
{
a=document['bigplaya_id']
}

a.style.height='30px';

}

function genericvideoplayer(stayopen,clipid,baseurl,pkgcode,cachetitle,usecache) {
	var h = {};
	h.pap_url = location.href;
	h.clipid = clipid;
	h.brandcode = 'frol';
	h.pkgcode = pkgcode;
	h.cachetitle = cachetitle;
	h.mainurl = baseurl;
	if(usecache){
		h.pap_usecache = true;
	}
	if(issafari){
		h.pap_safari = 1;
	}
	var myheight = 30;
	if(stayopen){
		h.loadnow = true;
		myheight = 430;
	} else {
		h.compressedmode = true
		h.compressed = true
	}
	_papobject.embedSWF('http://www.pbs.org/wgbh/pages/frontline/includes/swf/combinedc.swf','videospace','100%',myheight,'9',null, h,{ wmode:"opaque",allowFullScreen:"true",allowScriptAccess:"always" },{ id:'bigplaya_id', name:'bigplaya_nm' });
}
