/*!
* 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 
*/

var n = null; mapit = function (h, i) { function k(a, c) { f && f.showInfo(a, c); e.j(a, c) } function v(a, c) { var b = "<div class='mapit-accordion' id='" + c + "'>", d = !1; $(a).find("category").each(function (a) { var e = $(this), j = e.attr("id"); j || (j = c + "-cat" + a, e.attr("id", j)); a == 0 && (p = j); b += "<h3 id='" + j + "'><a href='#'>" + $(this).attr("name") + "</a></h3>"; b += "<div>"; var l = !1, g = $(this).attr("isdefault"); !d && g && g.toLowerCase() == "true" && (r = a, p = j, l = !0); $(this).find("location").each(function (a) { var c = $(this), m = c.attr("id"); m || (m = j + "-loc" + a, c.attr("id", m)); var a = !0, g = c.attr("showdirectionslink"); g && g.toLowerCase() == "false" && (a = !1); b += "<a href='javascript:void(0);' id='" + m + "' name='loc' class='mapit-accordion-link' data='" + c.attr("address") + "|" + c.attr("city") + "|" + c.attr("province") + "|" + c.attr("code") + "|" + c.attr("cordinates") + "' " + (a ? "showdirectionslink='true' " : "showdirectionslink='false' ") + (f ? f.setLinkAttrs(e, c) + " " : "") + (l && !d ? "isdefault='true'>" : ">") + c.attr("name") + "</a>"; l && !d && (d = !0) }); b += "</div>" }); b += "</div>"; return b } function w(a) { var c = a.attr("title"), b = a.attr("zoomlevel"), e = a.attr("panx"), m = a.attr("pany"), g = a.attr("usecdn"), j = a.attr("theme"), l = a.attr("accordionanimation"), h = a.attr("themeversion"), i = a.attr("themeurl"), k = a.attr("startcordinates"); if (c && c.length > 0) d.title = c; if (b && b.length > 0) d.zoomlevel = b; if (e && e.length > 0) d.panx = e; if (m && m.length > 0) d.pany = m; if (k && k.length > 0) d.startCordinates = k; if (g && g.length > 0) d.useCDN = g.toLowerCase() == "true"; if (j && j.length > 0) d.theme = j; if (h && h.length > 0) d.themeVersion = h; if (i && i.length > 0) d.themeUrl = i; if (l && l.length > 0) d.accordionAnimation = l.toLowerCase() == "true" || l.toLowerCase() == "false" ? eval(l) == !0 : l; f && f.loadOptionsFromXml(q, a) } function s(a, c) { var b = "<div class='mapit" + (f ? " " + f.getContainerClass() : "") + "'>"; d.title.length > 0 && (b += "<div class='mapit-title ui-accordion-header ui-state-active ui-corner-top header'>" + d.title + "</div>"); b += "<div id='" + g.contentId + "' class='mapit-content'>"; b += v(a, g.accordionId); b += "<div id='" + g.mapContentId + "' class='mapit-map-content'>"; b += "<div id='" + g.mapEmbedId + "' class='mapit-embed'></div>"; b += "</div>"; f && (b += f.buildHtml(1)); b += "<div style='clear:both;'></div>"; b += "</div>"; f && (b += f.buildHtml(2)); b += "</div>"; c.html(b); mapit.globals.c.push(g.accordionId); $("#" + g.accordionId).accordion({ fillSpace: !0, animated: d.accordionAnimation, active: r, change: function (a, b) { f && f.showCategory(b.newHeader.context.id) } }); e.i(g.accordionId, g.mapEmbedId, d.startCordinates); f && f.showCategory(p) } function x(a, c) { q = a; w($("map", a)); d.useCDN ? (t(d.theme, d.themeVersion), setTimeout(function () { s(a, c) }, 250)) : s(a, c) } function t(a, c) { var a = a || d.theme, c = c || d.themeVersion, b = d.themeUrl.replace("{0}", c).replace("{1}", a), e = document.getElementById("mapitcss"); e != n ? $(e).attr("href") != b && ($(e).attr("href", b), setTimeout(function () { for (var a = 0; a < mapit.globals.c.length; a++) $("#" + mapit.globals.c[a]).accordion("resize") }, 500)) : $(document.createElement("link")).attr({ href: b, id: "mapitcss", media: "screen", type: "text/css", rel: "stylesheet" }).appendTo("head") } h = h || {}; i = i || {}; typeof h == "object" && (i = h, h = "initialize"); var u = { xmlConfig: "data-universities.xml", cacheXml: !0, title: "", zoomlevel: 8, panx: 0, pany: 0, useCDN: !1, startCordinates: "", accordionAnimation: !0, theme: "cupertino", themeVersion: "1.8.12", themeUrl: "http://ajax.googleapis.com/ajax/libs/jqueryui/{0}/themes/{1}/jquery-ui.css" }, q = n, d = $.extend({}, u, i), f = mapit.pro ? new mapit.pro(this, i) : n, r = 0, p = ""; mapit.globals.d++; var o = mapit.globals.d > 1 ? mapit.globals.d : "", g = { contentId: "mapit-content" + o, accordionId: "mapit-accordion" + o, mapContentId: "mapit-map-content" + o, mapEmbedId: "mapit-map-embed" + o, idExt: o }; this.get_controlIds = function () { return g }; f && f.init(this, i); this.init = function (a) { $.ajax({ l: u.cacheXml, type: "GET", url: d.xmlConfig, dataType: "xml", success: function (c) { x(c, a) } }) }; this.applyTheme = function (a, c) { t(a, c) }; this.getOptions = function () { return d }; this.m = function () { return q }; var e = { a: n, b: n, f: [], e: n, i: function (a, c, b) { b = b.split(","); e.a = new google.maps.Map(document.getElementById(c), { zoom: d.zoomlevel, center: new google.maps.LatLng(parseFloat(b[0]), parseFloat(b[1])), mapTypeId: google.maps.MapTypeId.TERRAIN }); typeof e.a.panBy == "function" && e.a.panBy(d.panx, d.pany); e.b = new google.maps.InfoWindow; google.maps.event.addListener(e.a, "click", e.g); var f, g; $("#" + a + " a[name='loc']").each(function (a, b) { var c = $(b).attr("data").split("|"); c.push($(b).html()); var d = c[4].split(","), h = { map: e.a, id: b.id, data: c, k: $(b).attr("showdirectionslink"), position: new google.maps.LatLng(parseFloat(d[0]), parseFloat(d[1])) }, i = e.h(h, b); $(b).click(function () { k(i, h) }); c = $(b).attr("isdefault"); if (f == n || c && c.toLowerCase() == "true") f = i, g = h }); f && k(f, g) }, h: function (a, c) { var b = new google.maps.Marker(a); b.id = a.id; b.data = { loc: a.data[5], addr: a.data[0], city: a.data[1], state: a.data[2], zip: a.data[3] }; google.maps.event.addListener(b, "click", function () { k(b, a) }); $(document.getElementById(a.id)).bind("click", function () { k(b, a) }); e.f.push(b); e.e = b; f && f.updateMarker(b, c); return b }, j: function (a, c) { var b = a.data.addr + "<br/>" + a.data.city + ", " + a.data.state + " " + a.data.zip, d = "<a href='http://maps.google.com/maps?saddr=&daddr=" + escape(a.data.addr + ", " + a.data.city + ", " + a.data.state + " " + a.data.zip) + "' target='_blank' class='mapit-bubble-directions'>Get Directions...</a>"; $(document.getElementById(a.id)).html(); e.b.setContent("<span class='mapit-bubble-title'>" + a.data.loc + "</span><br/><span class='mapit-bubble-address'>" + b + "</span>" + (c.k.toLowerCase() == "false" ? "" : "<br/>" + d)); e.b.open(e.a, a) }, g: function () { e.b.close() } } }; mapit.globals = { d: 0, c: [] }; (function (h) { h.fn.mapit = function (i, k) { return this.each(function () { $this = h(this); this.mapit = new mapit(i, k); this.mapit.init($this) }) } })(jQuery);



