// Correctly handle PNG transparency in Win IE 5.5 or higher.
// Credit = http://homepage.ntlworld.com/bobosola. Updated 2006-06-22
function correctPNG() {
	for(var i=document.images.length-1; i>=0; i--) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
		 }
	}
}

var user_agent = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

function detect(string) {
	place = user_agent.indexOf(string) + 1;
	thestring = string;
	/* alert (thestring+' ('+place+')'); */
	return place;
}

function detect_user_agent() {
	/* alert (user_agent); */

	if (detect('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	} else if (detect('safari')) {
		browser = "Safari";
	} else if (detect('omniweb')) {
		browser = "OmniWeb";
	} else if (detect('opera')) {
		browser = "Opera";
	} else if (detect('webtv')) {
		browser = "WebTV";
	} else if (detect('icab')) {
		browser = "iCab";
	} else if (detect('msie')) {
		browser = "Internet Explorer";
	}
	else if (!detect('compatible')) {
		browser = "Netscape Navigator";
		version = user_agent.charAt(8);
	} else {
		browser = "An unknown browser";
	}

	if (!version) {
		version = user_agent.charAt(place + thestring.length);
	}

	if (!OS) {
		if (detect('linux')) {
			OS = "Linux";
		} else if (detect('x11')) {
			OS = "Unix";
		} else if (detect('mac')) {
			OS = "Mac";
		} else if (detect('win')) {
			OS = "Windows";
		} else {
			OS = "an unknown operating system";
		}
	}
	/* alert (	'UserAgent: '+browser+
			'\nVer: '+version+
			'\nOS: '+OS); */
}

detect_user_agent();

/**
 * Google Maps
 */

function loadGoogleMap() {
	if (GBrowserIsCompatible()) {
		var dev_station_travel_map = new GMap2(document.getElementById("dev_station_travel_map"));
		dev_station_travel_map.addControl(new GSmallMapControl());
		dev_station_travel_map.setCenter(new GLatLng(51.5058, -0.1180), 15);

		// Create our "tiny" marker icon
		var icon = new GIcon();

		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);

		var point = new GLatLng(51.5065, -0.1154);

		dev_station_travel_map.addOverlay(new GMarker(point, icon));
	}
}

/**
 * The following are used to show & hide blocks of content on pages
 */

function show_item(id, className) {
	var a = document.getElementById(className);
	var bios = a.getElementsByTagName('div');
	for(var i = 0; i<bios.length; i++) {
		if(bios[i].className == className) {
			bios[i].style.display='none';
		}
	}
	document.getElementById(id).style.display='block';
}

function show_hotel(id) {
	show_item(id, 'dev_station_hotels');
}

function show_speaker(id) {
	show_item(id, 'dev_station_speakers');
}

function show_travel(id) {
	show_item(id, 'dev_station_travel');
}

function show_agenda(id) {
	show_item(id, 'dev_station_agenda');
}

function show_venue_image(id) {
	show_item(id, 'dev_station_venue_image');
}
