// JavaScript Document - from http://www.quirksmode.org/js/detect.html
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

// Revised Webcams code
// Keith Gibbs - Networked Information Services - 9/19/05

function displaySony(camera, size) {
	var sonymap = { //any Sony cameras must be added to this map as well as to the changeXXXCams functions below. Note: Sony cams must have a seperate .html file for use in the iframes for IE/Win
		'medcam': 'http://155.41.140.126/',
		'sph': 'http://155.41.145.37/',
		'eastbound': 'http://168.122.98.2/',
		'westbound': 'http://168.122.98.3/',
		'southeast': 'http://155.41.209.57/',
		//'fitrec': 'http://168.122.98.18/',
		'gsu': 'http://168.122.98.34/'
	};
	var result = "";
	var caption = "";
	
	var names = {
		'medcam': 'Medical Campus &mdash; Main Quad',
		'eastbound': 'I90 &amp; Storrow Drive Looking East',
		'westbound': 'I90 &amp; Storrow Drive Looking West',
		'southeast': 'I93&mdash;Southeast Expressway',	
		//'fitrec': 'Climbing Wall &mdash; FitRec Center',
		'gsu': 'The Link'
	};
	
	if(size != "small") {
		caption = "<h2>" + names[camera] + "</h2>";
		}


	if (size == "small") { // if small, display a static thumbnail
		result+= ("<img src=\""+sonymap[camera]+"oneshotimage.jpg\" width=\"160\" height=\"112\" alt=\"Reload if no image is displayed\">"); 
	}
	else if (size == "largethumb") {
		result+= ("<img src=\""+sonymap[camera]+"oneshotimage.jpg\" width=\"320\" height=\"240\">"); 
	}
	else if ((size == "large")&&(browser == "Internet Explorer")&&(OS == "Windows")) { // if the browser is IE for Windows use the Java applet for the large version within an iframe (since IE doesn't like doing java without a document.write)
	//	result+= "<iframe scrolling=\"no\" src=\"/today/common/includes/webcams/"+camera+".html\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" width=\"320\" height=\"240\"></iframe>";
	//CTW Edit date is 4/21/2009 ... incorrect directory
	//CTW:  7/27/2009 -->Correcting to subdirectory
	result+= "<iframe scrolling=\"no\" src=\"/today/common/includes/webcams/cams/"+camera+".html\" hspace=\"0\" vspace=\"0\" frameborder=\"0\" width=\"320\" height=\"240\"></iframe>";
	// End CTW edit
	}
	else if ((size == "large")&&(browser == "Netscape Navigator")) { // if the browser is Firefox/Mozilla/Netscape, use the mjpeg push for the large version
		result+= ("<img src=\""+sonymap[camera]+"image?speed=0\" width=\"320\" height=\"240\" alt=\"Reload if no image is displayed\">");
//		result= ("<img src=\""+sonymap[camera]+"image?speed=0\" width=\"555\" height=\"417\" alt=\"Reload if no image is displayed\">");
	}
	else { // if the browser is anything else show them a static image for the large version
		result+= ("<img src=\""+sonymap[camera]+"oneshotimage.jpg\" width=\"320\" height=\"240\" alt=\"Reload if no image is displayed\">"); 
	}
//	document.getElementById(""+camera+"-image").innerHTML=(result);
	document.getElementById("activecam").innerHTML=result;
	document.getElementById("caption").innerHTML=caption;

	return result;

	}

function displayAxis(camera, size) {
	var axismap = { // Axis cams need to be added to this map
		'marsh': 'http://plazacam.bu.edu/',
		'sph': 'http://155.41.145.37/'
	};
	var result = "";
	var caption = "";
	
	var names = {
		'marsh': 'Marsh Plaza',
		'sph': 'School of Public Health/BUMC'
	};
	
	if(size != "small") {
		caption = "<h2>" + names[camera] + "</h2>";
	}

	if (size == "small") { // if it is a thumbnail
		result+= "<img src=\""+axismap[camera]+"jpg/image.jpg\" width=\"160\" height=\"112\" alt=\"Press Reload if no image is displayed\">";
	}
	else if (size == "largethumb") {
		result+= "<img class=\"camera\" src=\""+axismap[camera]+"jpg/image.jpg\" width=\"320\" height=\"240\" >";
	}
	else if ((browser == "Internet Explorer")&&(OS == "Windows")&&(size == "large")) {  //detects for ActiveX - compatible browser
	    result+= "<OBJECT ID=\"AxisCamControl\" CLASSID=\"CLSID:917623D1-D8E5-11D2-BE8B-00104B06BDE3\" WIDTH=\"320\" HEIGHT=\"240\" CODEBASE=\"http://128.197.197.250/activex/AxisCamControl.cab#Version=1,0,2,15\">";
    	result+= "<PARAM NAME=DisplaySoundPanel VALUE=0>";
    	result+= "<PARAM NAME=URL VALUE=\""+axismap[camera]+"axis-cgi/mjpg/video.cgi?camera=1&resolution=352x240\">";
    	result+= "</OBJECT>";
	}
	else if ((browser == "Netscape Navigator")&&(size == "large")) { //detects for Netscape/Mozilla/Firefox - uses mjpeg push
		result+= "<img class=\"camera\" src=\""+axismap[camera]+"axis-cgi/mjpg/video.cgi?camera=1&resolution=352x240\" width=\"320\" height=\"240\" ALT=\"Press Reload if no image is displayed\">";
	}
	else { //worst case scenerio fallback - a still image
		result+= "<img class=\"camera\" src=\""+axismap[camera]+"jpg/image.jpg\" width=\"320\" height=\"240\" alt=\"Press Reload if no image is displayed\">";
	}
//	document.getElementById(""+camera+"cam-image").innerHTML=(result);
	document.getElementById("activecam").innerHTML=(result);
	document.getElementById("caption").innerHTML=(caption);
	return result;
}


function changeCampusCams(view) {
   if (view == 1) {
	  displaySony('medcam','large');
   }
   else if (view == 2) {
	  displayAxis("sph","large");
   }	  
   else if (view == 3) {
	  displayAxis("marsh","large");
	}	
   else if (view == 4) {
	  displaySony("gsu","large");
	}	
   else if (view == 5) {
	  displaySony("eastbound","large");
   }
   else if (view == 6) {
	  displaySony("westbound","large");
   }   	  
   else if (view == 7) {
	  displaySony("southeast","large");
   }   	   	  

}

function showStill(view) {
   if (view == 1) {
	  displaySony('medcam','largethumb');
   }   	  
   else if (view == 2) {
	  displayAxis("sph","largethumb");
   }	  
   else if (view == 3) {
	  displayAxis("marsh","largethumb");
	}	
   else if (view == 4) {
	  displaySony("gsu","largethumb");
	}	
   else if (view == 5) {
	  displaySony("eastbound","largethumb");
   }
   else if (view == 6) {
	  displaySony("westbound","largethumb");
   }   	  
   else if (view == 7) {
	  displaySony("southeast","largethumb");
   }   	   	  

}