try {
	document.execCommand('BackgroundImageCache', false, true);
}
catch(e) {}

function queryString(key) {
	query = window.location.search.substring(1);
	qry = query.split("&");
	for (i=0;i<qry.length;i++) {
		kname = qry[i].split("=");
		if (kname[0] == key) {
			return kname[1];
		}
	}
}

$(document).ready(function() {
	if ($('html').hasClass('ie6')) {
		$.ifixpng('/images/tt/pngfix.gif');
		$('#footer img, .w_info img').ifixpng();
		IE6PFix();
	}
	ConvertNav();
	$('#tt').cluetip({
		dropShadow: false,
		width: '400px'
	});
	RoomMaps();
	Members();
});

function AddTypeFace() {
	$('#content h1, #content h2, #content h3, #content h4, #content h5').addClass('typeface-js');
	$('#content .info h3').removeClass('typeface-js');
}

function IE6PFix() {
	$('p[class!="float_left"][class!="float_right"] *[class*="float"]').parent('p').addClass('ie6pfix');
}

function ConvertNav() {
	var suffix = '';
	if ($('html').hasClass('ie6'))
		suffix = '__ie6';
	var map = $('ul.map');
	if (map.length > 0) {
		map.each(function() {
			var currMap = $(this);
			$(this).after('<div id="'+$(this).attr('id')+'_map" class="map"><span><img src="/images/tt/'+$(this).attr('id')+'_map'+suffix+'.png" alt="" usemap="#map_'+$(this).attr('id')+'_map" /></span></div>');
			var mapDiv = $('#'+$(this).attr('id')+'_map');
			var mapItems = $(this).find('li');
			var mapAreaStr = '';
			mapItems.each(function() {
				if ($(this).hasClass('current'))
					mapDiv.find('span').addClass($(this).attr('id'));
				coords = $(this).attr('class').replace(/current|coords_| /g,'');
				coords = coords.replace(/-/g,',');
				mapItem = $(this).children('a');
				mapAreaStr += ('<area shape="poly" coords="'+coords+'" id="map_'+mapItem.html().replace(/ /g,'').toLowerCase()+'" href="'+mapItem.attr('href')+'" alt="'+mapItem.html()+'" title="'+mapItem.html()+'" />');
			});
			mapDiv.after('<map name="map_'+mapDiv.attr('id')+'" id="map_'+mapDiv.attr('id')+'">'+mapAreaStr+'</map>');
			var mapImage = mapDiv.find('img');
			var mapAreas = $('#map_'+mapDiv.attr('id')).find('area');
			mapDiv.css('background-image','url('+mapImage.attr('src')+')');
			mapImage.attr('src','/images/tt/pngfix.gif')
			mapAreas.each(function() {
				$(this).mouseover(function() {
					mapImage.attr('src','/images/tt/'+currMap.attr('id')+'_map_'+$(this).attr('id').split('_')[1]+suffix+'.png');
				}).mouseout(function() {
					mapImage.attr('src','/images/tt/pngfix.gif');
				});
			});
		});
	}
}

function RoomMaps() {
	var map = $('#room');
	if (map.length == 1) {
		var mapImage = map.find('img');
		var mapAreas = map.find('area');
		var wrapperInfo = $('#w_info');
		wrapperInfo.find('.links').append('<a href="#Close" class="close">Close</a>');
		map.css('background-image','url('+mapImage.attr('src')+')');
		mapImage.attr('src','/images/tt/pngfix.gif')
		mapAreas.each(function() {
			var currArea = $(this);
			$(this).mouseover(function() {
				mapImage.attr('src','/images/tt/rooms/'+$(this).parent('map').attr('id').split('_')[1]+'_hover-'+currArea.attr('href').split('#i_')[1]+'.png');
			}).mouseout(function() {
				mapImage.attr('src','/images/tt/pngfix.gif');
			}).click(function(e) {
				wrapperInfo.addClass('current');
				$('.w_info').each(function() {
					$(this).addClass('hidden');
					if ($(this).attr('id') == currArea.attr('href').split('#')[1]) {
						$(this).removeClass('hidden');
						$(this).find('.close').click(function(e) {
							wrapperInfo.removeClass('current');
							e.preventDefault();
						});
					}
				});
				e.preventDefault();
			});
		});
	}
}

function Members() {
	var memberLinks = $('.members_nav a');
	var memberDivs = $('.member');
	var hash = "" + window.location;
	hash = hash.split('#')[1];
	$(memberLinks+'[href*='+hash+']').addClass('current');
	$('.member[id='+hash+']').addClass('current');
	memberLinks.click(function(e){
		memberLinks.each(function(){
			$(this).removeClass('current');
		});
		memberDivs.each(function(){
			$(this).removeClass('current');
		});
		$(this).addClass('current');
		var hash = $(this).attr('href').split('#');
		$('.member[id='+hash[1]+']').addClass('current');
	});
}