var addthis_config = { data_use_flash: false }
var map1;

function map1_initialize() {
	if (GBrowserIsCompatible()) {
		function createMarker(point, info, i) {
			var icbIcon = new GIcon(G_DEFAULT_ICON);
			icbIcon.image = "http://ecdahl.webfactional.com/icb/icb_marker.png";

			markerOptions = {icon:icbIcon};
			var marker = new GMarker(point, markerOptions);

			GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(info.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/class='external'/g, "target='_blank'"));});
			if (i == 0) GEvent.trigger(marker, "click");
			return marker;
		}

		map1 = new GMap2(document.getElementById('showmap'), {size: new GSize(658,495)});
		map1.addControl(new GSmallMapControl());
		map1.addControl(new GMenuMapTypeControl());
		map1.setCenter(new GLatLng(0, 0), 0);

		var latlngbounds = new GLatLngBounds();
		for (var i = 0; i < latlng1.length; i++) {
			latlngbounds.extend(latlng1[i]);
			map1.addOverlay(createMarker(latlng1[i], mkinfo1[i], i));
		}
		map1.setCenter(latlngbounds.getCenter(), map1.getBoundsZoomLevel(latlngbounds));
	}
}

function show(element) {
	document.getElementById('navmap').className = "";
	document.getElementById('showmap').style.display = "none";
	document.getElementById('navphotos').className = "";
	document.getElementById('showphotos').style.display = "none";
	document.getElementById('navcomment').className = "";
	document.getElementById('showcomment').style.display = "none";
	document.getElementById('nav'+element).className = "selected";
	document.getElementById('show'+element).style.display = "block";
	if (element == "comment") document.getElementById('comment_form').name.focus();
}

function getUUIDApplet() {
	if (document.applets && document.applets[0]) {
		return document.applets[0].getUUID();
	} else {
		return document.uuidapplet.getUUID();
	}
}

function rate(rating) {
	try {
		var uuid = String(getUUIDApplet());
		if (uuid.length != 36 || uuid.substring(23, 24) != "-") uuid = "000000000000";
		document.getElementById('rating_trigger').href = "/icb_rating/" + rating + "_" + uuid + "/?iframe";
		document.getElementById('rating_ul').className = "rating star" + rating.substring(rating.length - 1);
		$('#rating_trigger').trigger('click');
	} catch (e) { }
}

function setRate(rating) {
	try {
		var uuid = String(getUUIDApplet());
		if (uuid.length != 36 || uuid.substring(23, 24) != "-") uuid = "000000000000";
		else uuid = uuid.substring(24);
		var rate = "";
		for (var i = 0; i < rating.length; i = i + 2) {
			if (rating[i] == uuid) rate = rating[i + 1];
		}
		document.getElementById('rating_ul').className = "rating star" + rate;
	} catch (e) { }
}

$(document).ready(function() {
	if (typeof $(document).fancybox == 'function') {
		$('a.group').fancybox({ 'hideOnContentClick': false, 'frameWidth': 640, 'frameHeight': 480 });
		$('a.rating_popup').fancybox({ 'hideOnContentClick': false, 'frameWidth': 300, 'frameHeight': 100 });
	}
	$('a.external').click(function() {
		window.open(this.href);
		return false;
	});
});
