// Register to know when the map is initialized (so you can add icons)
Sigalert.controls.MapControl.onInitComplete.subscribe(AddSponsorPushpins);

var GoMap;
var iIdCounter = 1;

function
AddSponsorPushpins(oMap)
{
	GoMap = oMap;

/*
	AddPushpin(LATLON, 0, "IMG.png", "HEAD", "TEXT", "LINK", "_TARGET");
	AddPushpin(LATLON, 1, "IMG.png", "HEAD", "TEXT", "LINK", "_TARGET");
	AddPushpin(LATLON, 2, "IMG_sm.png", "HEAD", "TEXT", "LINK", "_TARGET");
	AddPushpin(LATLON, 3, "IMG_sm.png", "HEAD", "TEXT", "LINK", "_TARGET");
*/

	AddPushpin(37.326, -121.951, 0, "camera.gif", "Hwy 280/880 San Jose", "", "http://www.ktvu.com/wxcam/22357604/detail.html", "_top");
	AddPushpin(37.326, -121.951, 1, "camera.gif", "Hwy 280/880 San Jose", "", "http://www.ktvu.com/wxcam/22357604/detail.html", "_top");
	AddPushpin(37.326, -121.951, 2, "camera_sm.gif", "Hwy 280/880 San Jose", "", "http://www.ktvu.com/wxcam/22357604/detail.html", "_top");
	AddPushpin(37.326, -121.951, 3, "camera_sm.gif", "Hwy 280/880 San Jose", "", "http://www.ktvu.com/wxcam/22357604/detail.html", "_top");


	AddPushpin(37.353, -121.88, 0, "camera.gif", "Hwy 101 North of Mckee RD in San Jose", "", "http://www.ktvu.com/wxcam/22347096/detail.html", "_top");
	AddPushpin(37.353, -121.88, 1, "camera.gif", "Hwy 101 North of Mckee RD in San Jose", "", "http://www.ktvu.com/wxcam/22347096/detail.html", "_top");
	AddPushpin(37.353, -121.88, 2, "camera_sm.gif", "Hwy 101 North of Mckee RD in San Jose", "", "http://www.ktvu.com/wxcam/22347096/detail.html", "_top");
	AddPushpin(37.353, -121.88, 3, "camera_sm.gif", "Hwy 101 North of Mckee RD in San Jose", "", "http://www.ktvu.com/wxcam/22347096/detail.html", "_top");

	AddPushpin(37.335, -121.885, 0, "camera.gif", "Downtown San Jose", "", "http://www.ktvu.com/wxcam/22347069/detail.html", "_top");
	AddPushpin(37.335, -121.885, 1, "camera.gif", "Downtown San Jose", "", "http://www.ktvu.com/wxcam/22347069/detail.html", "_top");
	AddPushpin(37.335, -121.885, 2, "camera_sm.gif", "Downtown San Jose", "", "http://www.ktvu.com/wxcam/22347069/detail.html", "_top");
	AddPushpin(37.335, -121.885, 3, "camera_sm.gif", "Downtown San Jose", "", "http://www.ktvu.com/wxcam/22347069/detail.html", "_top");

	AddPushpin(37.86857134790854, -122.29379300998818, 0, "camera.gif", "Emeryville Cam", "", "http://www.ktvu.com/wxcam/22347104/detail.html", "_top");
	AddPushpin(37.87167829547719, -122.29046156034518, 1, "camera.gif", "Emeryville Cam", "", "http://www.ktvu.com/wxcam/22347104/detail.html", "_top");
	AddPushpin(37.8754064581691, -122.28379866105917, 2, "camera_sm.gif", "Emeryville Cam", "", "http://www.ktvu.com/wxcam/22347104/detail.html", "_top");
	AddPushpin(37.876649136789, -122.2681212509744, 3, "camera_sm.gif", "Emeryville Cam", "", "http://www.ktvu.com/wxcam/22347104/detail.html", "_top");

	AddPushpin(37.961101679120006, -122.06647056375928, 0, "camera.gif", "I-680 Southbound Cam", "", "http://www.ktvu.com/traffic/1852744/detail.html", "_top");
	AddPushpin(37.96296350044812, -122.07254556016714, 1, "camera.gif", "I-680 Southbound Cam", "", "http://www.ktvu.com/traffic/1852744/detail.html", "_top");
	AddPushpin(37.97599491698086, -122.0862632939913, 2, "camera_sm.gif", "I-680 Southbound Cam", "", "http://www.ktvu.com/traffic/1852744/detail.html", "_top");
	AddPushpin(37.963584096980355, -122.09566974004213, 3, "camera_sm.gif", "I-680 Southbound Cam", "", "http://www.ktvu.com/traffic/1852744/detail.html", "_top");

	AddPushpin(37.961101679120006, -122.03903509611098, 0, "camera.gif", "I-680 Northbound Cam", "", "http://www.ktvu.com/traffic/1853152/detail.html", "_top");
	AddPushpin(37.962342898627284, -122.03335203495524, 1, "camera.gif", "I-680 Northbound Cam", "", "http://www.ktvu.com/traffic/1853152/detail.html", "_top");
	AddPushpin(37.971030842847895, -122.0219859126438, 2, "camera_sm.gif", "I-680 Northbound Cam", "", "http://www.ktvu.com/traffic/1853152/detail.html", "_top");
	AddPushpin(37.96854867884605, -122.01101172558448, 3, "camera_sm.gif", "I-680 Northbound Cam", "", "http://www.ktvu.com/traffic/1853152/detail.html", "_top");

	AddPushpin(38.00422165063711, -122.55247027638657, 0, "camera.gif", "San Rafael Cam", "", "http://www.ktvu.com/wxcam/22357645/detail.html", "_top");
	AddPushpin(38.0088733575356, -122.56168075481136, 1, "camera.gif", "San Rafael Cam", "", "http://www.ktvu.com/wxcam/22357645/detail.html", "_top");
	AddPushpin(38.000810209779516, -122.56599204258467, 2, "camera_sm.gif", "San Rafael Cam", "", "http://www.ktvu.com/wxcam/22357645/detail.html", "_top");
	AddPushpin(38.010733956968814, -122.57853397065246, 3, "camera_sm.gif", "San Rafael Cam", "", "http://www.ktvu.com/wxcam/22357645/detail.html", "_top");

	AddPushpin(37.847129809205015, -122.21423015380807, 0, "camera.gif", "Hwy 24 Caldecott Tunnel Cam", "", "http://www.ktvu.com/wxcam/22728843/detail.html", "_top");
	AddPushpin(37.8505484469051, -122.20266806387058, 1, "camera.gif", "Hwy 24 Caldecott Tunnel Cam", "", "http://www.ktvu.com/wxcam/22728843/detail.html", "_top");
	AddPushpin(37.84557583014289, -122.20070838760998, 2, "camera_sm.gif", "Hwy 24 Caldecott Tunnel Cam", "", "http://www.ktvu.com/wxcam/22728843/detail.html", "_top");
	AddPushpin(37.839359583687084, -122.1865987185337, 3, "camera_sm.gif", "Hwy 24 Caldecott Tunnel Cam", "", "http://www.ktvu.com/wxcam/22728843/detail.html", "_top");

	AddPushpin(37.793031920232444, -122.24048981570003, 0, "camera.gif", "KTVU Tower Cam", "", "http://www.ktvu.com/traffic/22357472/detail.html", "_top");
	AddPushpin(37.792720897284404, -122.23559062504854, 1, "camera.gif", "KTVU Tower Cam", "", "http://www.ktvu.com/traffic/22357472/detail.html", "_top");
	AddPushpin(37.7970750984123, -122.24774061786422, 2, "camera_sm.gif", "KTVU Tower Cam", "", "http://www.ktvu.com/traffic/22357472/detail.html", "_top");
	AddPushpin(37.7970750984123, -122.23990191282184, 3, "camera_sm.gif", "KTVU Tower Cam", "", "http://www.ktvu.com/traffic/22357472/detail.html", "_top");

	AddPushpin(37.566882026298714, -121.91831903845838, 0, "camera.gif", "Sunol Grade Cam", "", "http://www.ktvu.com/wxcam/22347106/detail.html", "_top");
	AddPushpin(37.56844190913703, -121.92282629385775, 1, "camera.gif", "Sunol Grade Cam", "", "http://www.ktvu.com/wxcam/22347106/detail.html", "_top");
	AddPushpin(37.572809405830114, -121.9279214521353, 2, "camera_sm.gif", "Sunol Grade Cam", "", "http://www.ktvu.com/wxcam/22347106/detail.html", "_top");
	AddPushpin(37.572809405830114, -121.93576015717768, 3, "camera_sm.gif", "Sunol Grade Cam", "", "http://www.ktvu.com/wxcam/22347106/detail.html", "_top");

	AddPushpin(37.41479164826674, -121.94849805287154, 0, "camera.gif", "Highway 237 Cam", "", "http://www.ktvu.com/traffic/2055729/detail.html", "_top");
	AddPushpin(37.41166537112274, -121.9486940204976, 1, "camera.gif", "Highway 237 Cam", "", "http://www.ktvu.com/traffic/2055729/detail.html", "_top");
	AddPushpin(37.40791366485812, -121.94203112121158, 2, "camera_sm.gif", "Highway 237 Cam", "", "http://www.ktvu.com/traffic/2055729/detail.html", "_top");
	AddPushpin(37.40791366485812, -121.92321822910986, 3, "camera_sm.gif", "Highway 237 Cam", "", "http://www.ktvu.com/traffic/2055729/detail.html", "_top");

        AddPushpin(37.73858, -122.20757, 0, "camera.gif", "I-880 at 66th Ave. Cam", "", "http://www.ktvu.com/wxcam/22357657/detail.html", "_top");
        AddPushpin(37.73485, -122.21286, 1, "camera.gif", "I-880 at 66th Ave. Cam", "", "http://www.ktvu.com/wxcam/22357657/detail.html", "_top");
        AddPushpin(37.73485, -122.22266, 2, "camera_sm.gif", "I-880 at 66th Ave. Cam", "", "http://www.ktvu.com/wxcam/22357657/detail.html", "_top");
        AddPushpin(37.73236, -122.23363, 3, "camera_sm.gif", "I-880 at 66th Ave. Cam", "", "http://www.ktvu.com/wxcam/22357657/detail.html", "_top");

}

function
AddPushpin(lat, lon, z, strIcon, strHeadline, strText, strLink, strLinkTarget)
{
	varstrTextString = '';
	if(strText != '') {
		strTextString = "<p>" + strText + "</p>";
	} else {
		strTextString = '';
	}
	GoMap.addPushpinWithFangPopup("idTirePushpin" + iIdCounter++, 
		lat, lon, z, 
		"http://www.ktvu.com/images/sponsors/KTVU-traffic/" + strIcon, 
		"<p><a href='"+ strLink +"' target='"+ strLinkTarget+ "'><strong>" + strHeadline + "</strong></a></p>"+ strTextString, 
		true);	//JB: Due to a bug in the map object on the live servers, leave this value true for now.
}

