var hastimeline = true;
var issafari=false;
var xmlbase = '/wgbh/pages/frontline/xml/finance/timeline/';
var currentcode = '';
if(navigator.userAgent.indexOf("Safari")!=-1)
{
issafari=true
}

function videogen(stayopen,clipid) {
	var h = {};
	h.pap_url = location.href;
	h.clipid = (clipid != undefined)? clipid:'frol02o74f';
	h.brandcode = 'frol';
	h.pkgcode = '2708';
	h.timelinefile = 'timeline0217';
	h.cachetitle = 'Inside the Meltdown';
	h.mainurl = '/wgbh/pages/frontline/meltdown/';
//	h.disablerelated = true;
	if(issafari){
		h.pap_safari = 1;
	}
	var myheight = 30;
	if(stayopen){
		h.loadnow = true;
		myheight = 500;
	} else {
		h.compressedmode = true
		h.compressed = true
	}
	if(!hastimeline){
		h.disabletimeline = true;
	}
	_papobject.embedSWF('http://www.pbs.org/wgbh/pages/frontline/includes/swf/finance6.swf','videospace','100%',myheight,'9',null, h,{ wmode:"opaque",allowFullScreen:"true",allowScriptAccess:"always" },{ id:'bigplaya_id', name:'bigplaya_nm' });
}

function videosettimeline (tf) {
	hastimeline = tf;
}

function videoplayer_open (full) {
	var a;
if(navigator.appName.indexOf("Microsoft")!=-1)
{
a=window['bigplaya_id']
}
else
{
a=document['bigplaya_id']
}
var newheight = (full)? '500px':'90px';
if(full){
	newheight = (hastimeline)? '500px':'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 timeline_lower (targetcode) {
	if(targetcode == 'a11'){
		$("#textarea").fadeOut("slow");
	} else {
		if(currentcode != targetcode){
			var final;
			$.ajax({
				type: "GET",
				url:  xmlbase + targetcode + ".xml",
				dataType: "xml",
				success: function(xml) {
					final = $(xml).find('bod').text();
					$("#textarea").fadeOut("slow", function () {
						$("#textarea").html(final);
						$("#textarea").fadeIn("slow");
					});
				}
			});
			currentcode = targetcode;
		}
	}
}

function timeline_build (){
	var h = {};
	h.xmlfile = 'timeline0217';
	_papobject.embedSWF('http://www.pbs.org/wgbh/pages/frontline/includes/swf/timeline.swf','cronarea','100%',420,'9',null, h,{ wmode:"opaque",allowScriptAccess:"always",allowFullScreen:true },{ id:'cronarea_id', name:'cronarea_nm' });
}	


