// javascript functions for NOVA "Storm That Drowned a City" Web site
// http://www.pbs.org/nova/
// copyright (c) 2005 NOVA/WGBH Educational Foundation

// last modified 051116

function how_window() {
	newwin = window.open("how-flash.html", "how_window",'toolbar=0,location=0,directories=0,scrollbars=1,status=0,menubar=0,resizable=1,width=735,height=540');
	window.self.name = "cfl_parent";
}

function anat_window() {
	newwin = window.open("anat-flash.html", "anat_window",'toolbar=0,location=0,directories=0,scrollbars=1,status=0,menubar=0,resizable=1,width=735,height=540');
	window.self.name = "cfl_parent";
}

function proo_window() {
	newwin = window.open("proo-flash.html", "proo_window", 
		'toolbar=0,location=0,directories=0,scrollbars=1,status=0,menubar=0,resizable=1,width=790,height=556');
	window.self.name = "proo_parent";
}

function vide_window(which_window) {
  newwin = window.open(which_window, "vide_window", 
'toolbar=0,location=0,directories=0,scrollbars=1,status=0,menubar=0,resizable=1,width=640,height=640');
window.self.name = "cfl_parent";
}

function no_points() {
	// data points for New Orleans Katrina flooded area
	
    var points_set = [];
    points_set = [-0.0405,0.069,
    				-0.0330,0.069,
     				-0.0330,0.072,
     				-0.0110,0.070,
     				0.0304,0.076,
     				0.0500,0.080,
     				0.0710,0.0855,			
     				0.0900,0.094,
     				0.1110,0.104,
      				0.1300,0.118,
     				0.1500,0.1345,
     				0.1670,0.154,
     				0.2000,0.195,
     				0.22504806518554688,0.20103336679802908,
     				0.22333145141601562,0.19019719912443023,
     				0.2204132080078125,0.18203218703713648,
     				0.22830963134765625,0.12545230107534877,
     				0.2602386474609375,0.09633297829032017,
     				0.2506256103515625,0.09038920700620068,
     				0.1737213134765625,0.060367714924339566,
     				0.12737274169921875,0.049962106619723556,
     				0.059051513671875,0.041042145198574076,
     				0.059051513671875,0.030634510389521807,
     				0.14728546142578125,0.0005949347661200477,
     				0.17406463623046875,-0.01308946541123035,
     				0.18848419189453125,-0.028263501084150988,
     				0.2039337158203125,-0.054153959705818266,
     				0.18161773681640625,-0.062190297923123694,
     				0.15621185302734375,-0.028561054323272828,
     				0.11363983154296875,-0.019039791862869748,
     				0.0542449951171875,0.009221088814442169,
     				0.03467559814453125,0.01606198905069789,
     				0.023345947265625,0.016954245667839984,
     				0.0144195556640625,0.011005716883492056,
     				0.010471343994140625,-0.003420943986455427,
					0.007724761962890625,-0.010709434476495971,
					0.003604888916015625,-0.016064584153863137,
					-0.01064300537109375,-0.02439538991722401,
					-0.021114349365234375,-0.02618065331520114,
					-0.026607513427734375,-0.026478200328092782,
					-0.035533905029296875,-0.02201508853287848,
					-0.03948211669921875,0.003123367806981747,
					-0.04978179931640625,0.011154434442758543,
					-0.06677627563476562,0.010856999101662268,
					-0.07518768310546875,0.023645914893382525,
					-0.06746292114257812,0.03167532296324538,
					-0.059223175048828125,0.034054282167357286,
					-0.0542449951171875,0.036730543143544736,
					-0.049953460693359375,0.035987144552883876,
					-0.048236846923828125,0.03464901306282542,
					-0.043430328369140625,0.03509505889666187,
					-0.0405,0.069
    				];
	return points_set; 
}

function no_fixed() {
	// draws data points fixed on New Orleans
    var map = new GMap(document.getElementById("map"));
    var m_center = new GPoint(-90.08102416992188, 29.952554831950962);

    map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
    map.centerAndZoom(m_center, 8);
    
    var points = [];
    var points_offset = no_points();

    for (var i=0; i < (points_offset.length/2); i++) {
    	points.push(new GPoint((m_center.x + points_offset[2 * i]),(m_center.y + points_offset[(2 * i) + 1])));
    }
    
    map.addOverlay(new GPolyline(points, "#0000ff", 2, 0.5));

}

function no_portable() {
	// draws data points centered on map, regardless of map center location
    var map = new GMap(document.getElementById("map"));
    var m_center = new GPoint(-90.0010241699, 30.032554831951);

    GEvent.addListener(map, "moveend", function() {
    	map.clearOverlays();
		var ncurr = map.getCenterLatLng();
		var npoints = [];
    	var points_offset = no_points();
		
		for (var i=0; i < (points_offset.length/2); i++) {
			// npoints.push(new GPoint((ncurr.x + points_offset[2 * i]),(ncurr.y + points_offset[(2 * i) + 1])));
			npoints.push(new GPoint((ncurr.x + points_offset[2 * i] - 0.08),(ncurr.y + points_offset[(2 * i) + 1] - 0.08)));
		}

		
		map.addOverlay(new GPolyline(npoints, "#0000ff", 2, 0.5));
	});

    map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
    map.centerAndZoom(m_center, 13);
    
    var points = [];
    var points_offset = no_points();
    

    for (var i=0; i < (points_offset.length/2); i++) {
    	points.push(new GPoint((m_center.x + points_offset[2 * i]),(m_center.y + points_offset[(2 * i) + 1])));
    }
    
    map.addOverlay(new GPolyline(points, "#0000ff", 2, 0.5));

}
