$.fn.tinymce = function(options) {
    return this.each(function() {
        preString = "<";
	preString += "div class='jqHTML_frame' style='width:"+$(this).css("width")+"px;height:" + ($(this).css("height")+20) + "px;'>";
        postString = "<";
	postString += "/div>";
        $(this).wrap(preString + postString);
        tinyMCE.addMCEControl(document.getElementById(this.id), this.id);
    });
}

function maps(parameters)
{
	var center = new google.maps.LatLng(parameters.latitude, parameters.longitude);

	var options = {
		zoom: 14,
		center: center,
		mapTypeControl: true,
		navigationControl: true,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}

	var map_id = 'map_' + parameters.id;
	var map = new google.maps.Map(document.getElementById(map_id), options);

	var infowindow = new google.maps.InfoWindow({
		content: '<span class="mapAdd"><b>' + parameters.name + '</b><br />' + parameters.address1 + '<br />' + parameters.city + ', ' + parameters.state + ' ' + parameters.zip + ' ' + parameters.country + '<br />',
		size: new google.maps.Size(190, 50)
	});

	var marker = new google.maps.Marker({
		position: center,
		map: map,
		title: parameters.name
	});

	infowindow.open(map, marker);

	google.maps.event.addListener(marker, 'click', function(){
		infowindow.open(map, marker);
	});
}

function maps_v2(latitude, longitude, name, street, citystatezip)
{
	if(GBrowserIsCompatible())
	{
		mapdiv = document.getElementById("map");
		if(!mapdiv)
		{
			return;
		}

		map = new GMap2(mapdiv);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		var point = new GLatLng(latitude, longitude);
		map.setCenter(point, 14);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		var textInfo = "<span class=\"mapAdd\"><b>" + name + "<\/b><br \/>" + street + "<br \/>" + citystatezip + "<br \/>";
		map.openInfoWindowHtml(point, textInfo);
	}
}

function initMCE()
{
	tinyMCE.init({
		mode : "none",
		theme : "advanced",
		plugins : "advlink,visualchars,table,style,save,preview,contextmenu,autosave,advimage,paste,xhtmlxtras",
		theme_advanced_buttons1 : "save,separator,cut,copy,pastetext,pasteword,selectall,separator,bold,italic,underline,styleprops,separator,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo",
		theme_advanced_buttons2 : "tablecontrols,separator,link,unlink,image,hr,charmap",
		theme_advanced_buttons3 : "formatselect,fontselect,fontsizeselect,separator,visualaid,visualchars,removeformat,cleanup,help,separator,code,preview",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "center",
		theme_advanced_path_location : "bottom",
		extended_valid_elements : "b/strong,i/em,h1,h2,h3,a[name|href|target|title|onclick|class|style],img[style|class|src|border=0|alt=|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],div[class|align|style],u",
		content_css : "/css/tinymce.css",
		save_enabledwhendirty : true,
		plugin_preview_width :  800,
		plugin_preview_height :  600,
		plugin_preview_pageurl :  "/templates/default.html",
		remove_script_host :  false,
		remove_linebreaks : false,
		apply_source_formatting : true,
		relative_urls : false
	});
}
initMCE();

$(document).ready(function(){
	$('#ContentContent').tinymce();
	$('.tinymce').tinymce();
});
