/*!
* MapIt (jQuery powered google map) Plugin
* version: 0.0.1 (05-11-2011)
* @requires jQuery v1.5.2 or later
* @requires jQuery v1.8.12 or later
* 
* Documentation:
* 		http://www.lifeinthegrid.com/mapit
*
* Copyright 2011 Cory Lamle, Ryan Heideman <cory@lifeinthegrid.com, ryan@lifeinthegrid.com>
* 
* Dual licensed under the MIT licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html 
*/

mapit.pro = function () { var e = { navBarLocation: "left", showInfoBar: !1, showDetails: !1, showDetailsIcon: !1, markerIcon: null }, h = null, f = null, j = null, b = { a: "", b: "", c: "" }; this.init = function (c, d) { f = c; j = $.extend({}, e, d); var a = f.get_controlIds().idExt; b.a = "mapit-infobar-title" + a; b.b = "mapit-infobar-content" + a; b.c = "mapit-list" + a }; this.loadOptionsFromXml = function (c, d) { h = c; var a = d.attr("navbarlocation"), i = d.attr("showinfobar"), g = d.attr("showdetails"), b = d.attr("showdetailsicon"), f = d.attr("markericon"); if (a && a.length > 0) e.navBarLocation = a; if (i && i.length > 0) e.showInfoBar = i.toLowerCase() == "true"; if (g && g.length > 0) e.showDetails = g.toLowerCase() == "true"; if (b && b.length > 0) e.showDetailsIcon = b.toLowerCase() == "true"; if (f && f.length > 0) e.markerIcon = f }; this.getOptions = function () { return j }; this.getContainerClass = function () { var c = ""; e.showInfoBar && (c += "mapit-3column"); return c }; this.setLinkAttrs = function (c, d) { var a = "", b = c.attr("markericon"), g = d.attr("markericon"); g && (b = g); b && b.length > 0 && (a += "marker='" + b + "'"); return a }; this.buildHtml = function (c) { var d = ""; c == 1 && e.showInfoBar ? (d += "<div class='mapit-infobar ui-widget-content ui-corner-top'>", d += "<h3 class='mapit-infobar-title ui-helper-reset ui-state-default ui-state-default ui-corner-top header'><span id='" + b.a + "'>&nbsp;</span></h3>", d += "<div id='" + b.b + "' class='mapit-infobar-content'>", d += "</div></div>") : c == 2 && (d += "<div id='" + b.c + "' class='mapit-list'></div>"); return d }; this.updateMarker = function (c, d) { if (e.markerIcon) c.icon = e.markerIcon; var a = jQuery(d).attr("marker"); if (a && a.length > 0) c.icon = a; return c }; this.showInfo = function (c, d) { if (e.showInfoBar) { var a = jQuery(h).find("location[id='" + d.id + "']"); jQuery("#" + b.a).html(c.data.loc); jQuery("#" + b.a).attr("title", c.data.loc); jQuery("#" + b.b).html(a.find("infobar").text()) } }; this.showCategory = function (c) { var d = f.get_controlIds().mapEmbedId; if (e.showDetails) { var c = jQuery(h).find("category[id='" + c + "']"), a = ""; jQuery(c).find("location").each(function (c) { var b = jQuery(this); a += "<div class='mapit-list-item ui-widget ui-widget-content ui-corner-all'>"; a += "<table cellpadding='0' cellspacing='0'><tr>"; a += e.showDetailsIcon ? "<td class='mapit-list-item-col1 mapit-list-item-icon'><img src='" + b.attr("markericon") + "' /></td>" : "<td class='mapit-list-item-col1'><span class='mapit-list-item-num'>" + (c + 1) + ".</span></td>"; a += "<td class='mapit-list-item-col2'>"; a += "<div><a href='javascript:void(0);' onclick='javascript:jQuery(\"#" + b.attr("id") + '").click();document.getElementById("' + d + "\").scrollIntoView();'>" + b.attr("name") + "</a></div>"; a += "<div class='mapit-list-item-address'>" + b.attr("address") + "</div>"; a += "<div class='mapit-list-item-address'>" + b.attr("city") + ", " + b.attr("province") + " " + b.attr("code") + "</div>"; a += "</td>"; c = b.attr("address") + ", " + b.attr("city") + ", " + b.attr("province") + " " + b.attr("code"); a += "<td class='mapit-list-item-col3'>"; a += "<a href='http://maps.google.com/maps?saddr=&daddr=" + escape(c) + "' target='_blank' class='mapit-list-item-directions'>Get Directions</a>"; a += "</td>"; a += "</tr></table>"; a += "</div>" }); a += ""; jQuery("#" + b.c).html(a) } } };
