var map;
var DAYS = 21;
var attackIcon48 = new GIcon();
attackIcon48.image = "http://mapmashup.googlecode.com/svn/images/48attack.png";
attackIcon48.iconSize = new GSize(48,48);
attackIcon48.iconAnchor = new GPoint(24,24);
attackIcon48.infoWindowAnchor = new GPoint(24,24);

var attackIcon24 = new GIcon();
attackIcon24.image = "24attack.png";
attackIcon24.iconSize = new GSize(24,24);
attackIcon24.iconAnchor = new GPoint(12,12);
attackIcon24.infoWindowAnchor = new GPoint(12,12);

var arrowIcon = new GIcon();
arrowIcon.iconSize = new GSize(24,24);
arrowIcon.shadowSize = new GSize(1,1);
arrowIcon.iconAnchor = new GPoint(12,12);
arrowIcon.infoWindowAnchor = new GPoint(0,0);

var degreesPerRadian = 180.0 / Math.PI;

function Init(){
	document.getElementById('videoBar').style.height = document.body.offsetHeight +'px';
	document.getElementById('map').style.height = (document.body.offsetHeight-20) +'px';
	document.getElementById("list").innerHTML = createTable();
	map = new GMap2(document.getElementById("map")); 
	map.addControl(new GLargeMapControl(),new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7,30)));
	map.addControl(new GMapTypeControl());
	map.addMapType(G_PHYSICAL_MAP);
	map.setCenter(new GLatLng(31.37350,34.40643), 10,G_PHYSICAL_MAP); 
	warDay(DAYS);
	initNews();
}

function createTable() {
	var html = '<table cellspacing="1" cellpadding="2">';
	for (i=1;i<DAYS+1;i++)
		html +='<tr><td id="d'+i+'" style="background:#e00;color:#fff;font:bold 10pt Arial;cursor:pointer;border:1px solid #000" onmouseover="this.style.border = \'1px solid #fff\'" onmouseout="this.style.border = \'1px solid #000\'" onclick="warDay('+i+')">Day '+i+'</td></tr>';
	html += '</table>';
	return html;
}

// === Returns the bearing in degrees between two points. ===
// North = 0, East = 90, South = 180, West = 270.
function bearing( from, to ) {
	var lat1 = from.latRadians();
	var lon1 = from.lngRadians();
	var lat2 = to.latRadians();
	var lon2 = to.lngRadians();
	var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );
	if ( angle < 0.0 )
	angle  += Math.PI * 2.0;
	angle = angle * degreesPerRadian;
	angle = angle.toFixed(1);
	return angle;
}

function arrowHead(points,title,content) {
	var p1=points[points.length-1];
	var p2=points[points.length-2];
	var dir = bearing(p2,p1);
	var dir = Math.round(dir/3) * 3;
	while (dir >= 120) {dir -= 120;}
	arrowIcon.image = "http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png";
	var marker = new GMarker(p1, arrowIcon);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindow("<div style='font:8pt Arial'><b>"+title+"</b><br>"+content+"</div>",{maxWidth:200});
	});	
	map.addOverlay(marker);
}

function addPolyline (points,title,content) {
	var polyLine = new GPolyline(points,"#0000ff",10);
	GEvent.addListener(polyLine, "click", function(point) {
		map.openInfoWindow(point,"<div style='font:8pt Arial'><b>"+title+":</b><br>"+content+"</div>",{maxWidth:200});
	});	
	map.addOverlay(polyLine);
}

function addPolylineArrow (points,title,content) {
	var polyLine = new GPolyline(points,"#0000ff",10);
	GEvent.addListener(polyLine, "click", function(point) {
		map.openInfoWindow(point,"<div style='font:8pt Arial'><b>"+title+"</b><br>"+content+"</div>",{maxWidth:200});
	});	
	map.addOverlay(polyLine);
	arrowHead(points,title,content);
}

function addMarker(lat, lng, title, content, icon) {
	var marker = new GMarker(new GLatLng(lat,lng),{icon:icon,title:title});
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindow("<div style='font:8pt Arial'>Location: <b>"+title+"</b><br>"+content+"</div>",{maxWidth:200});
	});	
	map.addOverlay(marker);
}

function resetTabs() {
	for(var i=1;i<DAYS+1;i++)
		document.getElementById("d"+i).style.background = "#e00";
}

function hoverTabs (_id,hover) {
	hover ?	document.getElementById(_id).style.border = "1px solid #fff" : document.getElementById(_id).style.border = "1px solid #000";
}

function initNews() {
	var newsFeed = new google.feeds.FeedControl();
	newsFeed.addFeed("http://rss.cnn.com/rss/cnn_world.rss", "CNN");
	newsFeed.addFeed("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml", "BBC");
	newsFeed.addFeed("http://feeds.reuters.com/reuters/topNews?format=xml", "Reuters");
	newsFeed.addFeed("http://english.aljazeera.net/NR/exeres/4D6139CD-6BB5-438A-8F33-96A7F25F40AF.htm?ArticleGuid=55ABE840-AC30-41D2-BDC9-06BBE2A36665", "Aljazeera");
	newsFeed.addFeed("http://www.nytimes.com/services/xml/rss/nyt/International.xml", "NY Times");
	newsFeed.setLinkTarget(google.feeds.LINK_TARGET_BLANK);
	newsFeed.setNumEntries(3);
	newsFeed.draw(document.getElementById("news"), {drawMode : google.feeds.FeedControl.DRAW_MODE_TABBED});
}

function warDay(day) {
	map.clearOverlays();
	if (day == 1) {
		addMarker(31.501288,34.438705, "Gaza City", "Hamas Police Academy, Presidential compound and Hamas Security compund attacked by Israeli air stikes", attackIcon48);
		addMarker(31.355396,34.302063, "Khan Younis", "Air stricks in the city of Khan Younis", attackIcon48);
		addMarker(31.273269,34.253998, "Rafah", "Air stricks at Rafah crossing", attackIcon48);
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);	
		addMarker(31.535530,34.535007, "Beit Hanoun", "Air stricks on Hamas Security compund", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Air stricks on Hamas Security compund", attackIcon24);
		addMarker(31.428780,34.598007, "Netivot", "Hamas Rocket kills one Israeli", attackIcon24);
		document.getElementById("pd").innerHTML = "150";
		document.getElementById("pi").innerHTML = "400";
		document.getElementById("id").innerHTML = "1";
		document.getElementById("ii").innerHTML = "0";
	}
	else if (day == 2) {
		addMarker(31.501288,34.438705, "Gaza City", "Islamic University, Mosque, Al-Asqa TV and Government Offices attacked in Israeli Air strike", attackIcon48);
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.258449,34.255886, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.529385,34.481106, "Jabaliya", "Palestinian Civilians killed", attackIcon24);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		document.getElementById("pd").innerHTML = "300";
		document.getElementById("pi").innerHTML = "900";
		document.getElementById("id").innerHTML = "1";
		document.getElementById("ii").innerHTML = "0";	
	}
	else if (day == 3) {
		addMarker(31.501288,34.438705, "Gaza City", "Hamas Interior Ministry attacked", attackIcon48);
		addMarker(31.355396,34.302063, "Khan Younis", "Khna Younis Refugee camp attacked killing civilians", attackIcon48);
		addMarker(31.258449,34.255886, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.529385,34.481106, "Jabaliya", "Palestinian Civilians killed", attackIcon24);
		addMarker(31.535296,34.491233, "Tel Zatar", "Hamas HQ attacked", attackIcon24);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		addMarker(31.819814,34.669247, "Ashdod", "Hamas Rocket attack", attackIcon24);
		addMarker(31.514752,34.588051, "Sderot", "Hamas Rocket attack", attackIcon24);
		addMarker(31.473182,34.496899, "Nahal Oz", "Hamas Rocket attack", attackIcon24);
		addMarker(31.281485,34.444542, "Eshkol", "Hamas Rocket attack", attackIcon24);
		document.getElementById("pd").innerHTML = "335";
		document.getElementById("pi").innerHTML = "1400";
		document.getElementById("id").innerHTML = "4";
		document.getElementById("ii").innerHTML = "7";	
	}
	else if (day == 4) {
		addMarker(31.501288,34.438705, "Gaza City", "Hamas Government buildings attacked", attackIcon48);
		addMarker(31.355396,34.302063, "Khan Younis", "Air stricks at Khan Younis", attackIcon24);
		addMarker(31.416475,34.351501, "Dayr al-Balah", "Air stricks at Dayr al-Balah", attackIcon24);
		addMarker(31.514752,34.588051, "Sderot", "Hamas Rocket attack", attackIcon24);
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);		
		document.getElementById("pd").innerHTML = "360";
		document.getElementById("pi").innerHTML = "1400";
		document.getElementById("id").innerHTML = "4";
		document.getElementById("ii").innerHTML = "7";
	}
	else if (day == 5) {
		addMarker(31.501288,34.438705, "Gaza City", "Israeli Air strikes in Gaza City", attackIcon24);
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.473182,34.496899, "Eshbol", "Hamas Rocket attack", attackIcon24);
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);
		document.getElementById("pd").innerHTML = "390";
		document.getElementById("pi").innerHTML = "1600";
		document.getElementById("id").innerHTML = "4";
		document.getElementById("ii").innerHTML = "7";
	}
	else if (day == 6) {
		addMarker(31.501288,34.438705, "Gaza City", "Hamas Government buildings attacked", attackIcon24);
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		addMarker(31.819814,34.669247, "Ashdod", "Hamas Rocket attack", attackIcon24);
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);
		document.getElementById("pd").innerHTML = "400";
		document.getElementById("pi").innerHTML = "1700";
		document.getElementById("id").innerHTML = "4";
		document.getElementById("ii").innerHTML = "7";
	}
	else if (day == 7) {
		addMarker(31.501288,34.438705, "Gaza City", "Hamas Clinics and Mosques attacked", attackIcon24);
		addMarker(31.355396,34.302063, "Khan Younis", "Air stricks at Khan Younis, Palestinian Children killed", attackIcon24);		
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		document.getElementById("pd").innerHTML = "420";
		document.getElementById("pi").innerHTML = "1850";
		document.getElementById("id").innerHTML = "4";
		document.getElementById("ii").innerHTML = "9";
	}
	else if (day == 8) {
		addMarker(31.507727,34.487114, "Northern Gaza", "Attacked by artilary, air strikes and Naval vessels", attackIcon48);
		addMarker(31.527337,34.538612, "Northern Gaza", "Attacked by artilary, air strikes and Naval vessels", attackIcon48);
		addMarker(31.535530,34.535007, "Beit Hanoun", "Israeli soldiers clash with Hamas", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Israeli soldiers clash with Hamas", attackIcon24);
		addPolylineArrow([new GLatLng(31.5716,34.5547),new GLatLng(31.5528,34.5376)],"Israeli Ground Assault","Israeli tanks enter North Gaza after artilary bombardment");
		addPolylineArrow([new GLatLng(31.4539,34.4909),new GLatLng(31.4715,34.4627)],"Israeli Ground Assault","Israeli tanks enter South Gaza after artilary bombardment");
		document.getElementById("pd").innerHTML = "420";
		document.getElementById("pi").innerHTML = "1850";
		document.getElementById("id").innerHTML = "4";
		document.getElementById("ii").innerHTML = "9";
	}
	else if (day == 9) {
		addMarker(31.501288,34.438705, "Gaza City", "Gaza city attacked, civilians killed", attackIcon48);
		addMarker(31.355396,34.302063, "Khan Younis", "Air stricks at Khan Younis", attackIcon24);
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.469433,34.410552, "Netzarim", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.472068,34.432868, "Zeitoun", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.535530,34.535007, "Beit Hanoun", "Israeli soldiers clash with Hamas", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.514752,34.588051, "Sderot", "Hamas Rocket attack", attackIcon24);	
		addPolylineArrow([new GLatLng(31.5716,34.5547),new GLatLng(31.5528,34.5376)],"Israeli Ground Assault","Israeli tanks enter South Gaza attacking in the cities of Beit Hanoun and Beit Lahiyah");
		addPolylineArrow([new GLatLng(31.4609,34.4778),new GLatLng(31.4937,34.4078)],"Israeli Ground Assault","Israeli tanks reach the coast of Gaza splitting Gaza strip");
		addPolylineArrow([new GLatLng(31.2404,34.3124),new GLatLng(31.2768,34.2897)],"Israeli Ground Assault","Israeli tanks enter near Rafah crossing");	
		document.getElementById("pd").innerHTML = "455";
		document.getElementById("pi").innerHTML = "2300";
		document.getElementById("id").innerHTML = "5";
		document.getElementById("ii").innerHTML = "9";
	}
	else if (day == 10) {
		addMarker(31.501288,34.438705, "Gaza City", "Gaza city attacked, more civilians killed", attackIcon48);
		addMarker(31.251552,34.258804, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.258449,34.255886, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);
		addMarker(31.469433,34.410552, "Netzarim", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.472068,34.432868, "Zeitoun", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.529385,34.481106, "Jabaliya", "Israeli soldiers clash with Hamas", attackIcon24);		
		addMarker(31.535530,34.535007, "Beit Hanoun", "Israeli soldiers clash with Hamas", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Israeli soldiers clash with Hamas", attackIcon24);	
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Assault","Israeli tanks reach the coast of Gaza splitting Gaza strip south of Gaza city");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Assault","Israeli tanks reach the coast north of rafah sealing off Rafah crossing from rest of Gaza strip");
		document.getElementById("pd").innerHTML = "510";
		document.getElementById("pi").innerHTML = "2300";
		document.getElementById("id").innerHTML = "5";
		document.getElementById("ii").innerHTML = "62";
	}
	else if (day == 11) {
		addMarker(31.501288,34.438705, "Gaza City", "Gaza city attacked, Refugees sheltering in UN schools, flighting between Hamas and Israeli troops", attackIcon48);
		addMarker(31.416475,34.351501, "Dayr al-Balah", "Attacks from Israeli Naval vessels", attackIcon24);		
		addMarker(31.355396,34.302063, "Khan Younis", "Heavy Israeli artillary firing", attackIcon24);
		addMarker(31.258449,34.255886, "Rafah", "Air stricks on Tunnels connecting Rafah and Egypt", attackIcon24);	
		addMarker(31.472068,34.432868, "Zeitoun", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.529385,34.481106, "Jabaliya", "Israeli soldiers clash with Hamas", attackIcon24);		
		addMarker(31.535530,34.535007, "Beit Hanoun", "Israeli soldiers clash with Hamas", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Israeli soldiers clash with Hamas", attackIcon24);	
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Assault","Israeli tanks reach the coast of Gaza splitting Gaza strip south of Gaza city");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Assault","Israeli tanks reach the coast north of rafah sealing off Rafah crossing from rest of Gaza strip");	
		document.getElementById("pd").innerHTML = "600";
		document.getElementById("pi").innerHTML = "2400";
		document.getElementById("id").innerHTML = "8";
		document.getElementById("ii").innerHTML = "62";
	}
	else if (day == 12) {
		addMarker(31.501288,34.438705, "Gaza City", "Gaza city attacked, Refugees sheltering in UN schools, flighting between Hamas and Israeli troops", attackIcon48);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Israeli soldiers clash with Hamas", attackIcon24);	
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);		
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "660";
		document.getElementById("pi").innerHTML = "2800";
		document.getElementById("id").innerHTML = "10";
		document.getElementById("ii").innerHTML = "62";
	}
	else if (day == 13) {
		addMarker(31.501288,34.438705, "Gaza City", "Israelis attack Gaza city, Palestinians take shelter in UN Schools", attackIcon48);
		addMarker(31.355396,34.302063, "Khan Younis", "Israeli tanks enters Khan Younis, Palestinians take shelter in UN Schools", attackIcon48);
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon48);
		addMarker(31.529385,34.481106, "Jabaliya", "Heavy fighting between Israels and Gaza", attackIcon48);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		addMarker(31.819814,34.669247, "Ashdod", "Hamas Rocket attack", attackIcon24);
		addMarker(33.035723,35.115051, "Nahariya", "Rocket attack from Lebanon", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "690";
		document.getElementById("pi").innerHTML = "3000";
		document.getElementById("id").innerHTML = "10";
		document.getElementById("ii").innerHTML = "62";
	}	
	else if (day == 14) {
		addMarker(31.501288,34.438705, "Gaza City", "Air stricks around Gaza city", attackIcon48);
		addMarker(31.49675,34.473038, "Gaza City", "Israelis fight with Hamas on the outskirts of Gaza city", attackIcon24);		
		addMarker(31.416475,34.351501, "Dayr al-Balah", "Air stricks at Dayr al-Balah", attackIcon24);
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Civilians killed in bombings", attackIcon24);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		addMarker(31.819814,34.669247, "Ashdod", "Hamas Rocket attack", attackIcon24);
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "760";
		document.getElementById("pi").innerHTML = "3100";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "62";
	}
	else if (day == 15) {
		addMarker(31.501288,34.438705, "Gaza City", "Air stricks around Gaza city", attackIcon48);
		addMarker(31.49675,34.473038, "Gaza City", "Israelis fight with Hamas on the outskirts of Gaza city", attackIcon24);
		addMarker(31.539627,34.463768, "Gaza City", "Israelis fight with Hamas on the outskirts of Gaza city", attackIcon24);	
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addMarker(31.568883,34.473896, "Gaza Coast", "Heavy fighting between Israelis and Hamas", attackIcon24);
		addMarker(31.675736,34.564877, "Ashkelon", "Hamas Rocket attack", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "800";
		document.getElementById("pi").innerHTML = "3100";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "62";
	}
	else if (day == 16) {
		addMarker(31.501288,34.438705, "Gaza City", "Heavy fighting around Gaza city", attackIcon48);
		addMarker(31.49675,34.473038, "Gaza City", "Mosque bombed on the outskirts of Gaza city", attackIcon24);	
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addMarker(31.547819,34.503765, "Beit Lahiyah", "Civilians killed in bombings", attackIcon24);
		addMarker(31.514752,34.588051, "Sderot", "Hamas Rocket attack", attackIcon24);
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "850";
		document.getElementById("pi").innerHTML = "3200";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "62";
	}
	else if (day == 17) {
		addMarker(31.501288,34.438705, "Gaza City", "Heavy fighting and shelling around Gaza city", attackIcon48);
		addMarker(31.49836,34.440079, "Sheikh Ajleen", "Heavy fighting between Israelis and Hamas", attackIcon24);	
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "885";
		document.getElementById("pi").innerHTML = "3900";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "70";
	}
	else if (day == 18) {
		addMarker(31.501288,34.438705, "Gaza City", "Heavy fighting and shelling around Gaza city", attackIcon48);
		addMarker(31.475524,34.437332, "Tel al-Hawa", "Heavy fighting between Israelis and Hamas", attackIcon24);	
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "910";
		document.getElementById("pi").innerHTML = "4300";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "70";
	}
	else if (day == 19) {
		addMarker(31.501288,34.438705, "Gaza City", "Heavy fighting and shelling around Gaza city", attackIcon48);	
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addMarker(31.250965,34.797134, "Beersheba", "Hamas Rocket attack", attackIcon24);		
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");			
		document.getElementById("pd").innerHTML = "1010";
		document.getElementById("pi").innerHTML = "4700";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "70";
	}
	else if (day == 20) {
		addMarker(31.501288,34.438705, "Gaza City", "UN Headquarter and Hospital in Gaza attacked", attackIcon48);
		addMarker(31.475524,34.437332, "Tel al-Hawa", "Heavy fighting between Israelis and Hamas", attackIcon24);	
		addMarker(31.49675,34.473038, "Gaza City", "Israelis fight with Hamas on the outskirts of Gaza city", attackIcon24);
		addMarker(31.539627,34.463768, "Gaza City", "Israelis fight with Hamas on the outskirts of Gaza city", attackIcon24);		
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "1010";
		document.getElementById("pi").innerHTML = "4700";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "70";
	}
	else if (day == 21) {
		addMarker(31.475524,34.437332, "Tel al-Hawa", "Heavy fighting between Israelis and Hamas", attackIcon24);
		addMarker(31.529385,34.481106, "Jabaliya", "Heavy fighting between Israels and Gaza", attackIcon24);		
		addMarker(31.49675,34.473038, "Gaza City", "Israelis fight with Hamas on the outskirts of Gaza city", attackIcon24);		
		addMarker(31.258449,34.255886, "Rafah", "More Tunnels attacked near Rafah and Egypt", attackIcon24);
		addPolyline([new GLatLng(31.4533,34.4579),new GLatLng(31.4937,34.4023)],"Israeli Ground Forces","");
		addPolyline([new GLatLng(31.2545,34.3247),new GLatLng(31.3672,34.2719)],"Israeli Ground Forces","");	
		document.getElementById("pd").innerHTML = "1130";
		document.getElementById("pi").innerHTML = "5100";
		document.getElementById("id").innerHTML = "13";
		document.getElementById("ii").innerHTML = "80";
	}	
	resetTabs();
	document.getElementById("d"+day).style.background = "#000";	
} 

function LoadVideoBar() {
  var videoBar;
  var barContainer = document.getElementById("videoBar");

  var options = {
	largeResultSet : true,
	autoExecuteList : {
	  cycleTime : GSvideoBar.CYCLE_TIME_SMALL,
	  cycleMode : GSvideoBar.CYCLE_MODE_LINEAR,
	  executeList : [ "aljazeera gaza", "bbc gaza", "children gaza", "gaza attack", "gaza protest"]
	}
  }

  videoBar = new GSvideoBar(barContainer, GSvideoBar.PLAYER_ROOT_FLOATING, options);
}
GSearch.setOnLoadCallback(LoadVideoBar);