// Copyright (c) 2009, ScheduleOnce LTD.
//
// ==UserScript==
// @name	  ScheduleOnce Google Calendar Add-on 
// @namespace     http://www.scheduleonce.com
// @description   The Google Calendar Add-on is a small browser extension that allows you to use ScheduleOnce directly from your Google Calendar..
// @include       http://www.google.com/calendar/*
// @include       https://www.google.com/calendar/*
// ==/UserScript==

var baseURL="http://www.scheduleonce.com/";(function(){var C='function SOswitchMenu() {var el = document.getElementById(\'bodyDiv\');if ( el.style.display != "none" ) {	el.style.display = \'none\';}else {	el.style.display = \'\';}var el2 = document.getElementById(\'h2\');if ( el2.className == "calHeader goog-zippy-expanded normalText" ) {	el2.className = "calHeader goog-zippy-collapsed normalText";return;}if ( el2.className == "calHeader goog-zippy-collapsed normalText" ) {	el2.className = "calHeader goog-zippy-expanded normalText";return;}}';addGlobalScript(C);var B="function SOframeReload() {var f = document.getElementById('soFrame');f.src = f.src;}";addGlobalScript(B);var G=window.document.getElementById("guser").getElementsByTagName("b")[0];var x=G.innerText.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi)[0];var a=baseURL+"UserMeetings.aspx?email="+x;var l=window.document.getElementById("dp_0_b1");var m=window.document.createElement("div");m.className="nb_0";m.style.paddingTop="12px";var c=window.document.createElement("div");var v=window.document.createElement("div");v.className="t1 chromeColor";var t=window.document.createElement("div");t.className="t2 chromeColor";c.style.width="100%";c.style.height="2px";c.appendChild(v);c.appendChild(t);var p=window.document.createElement("h2");var F=window.document.createElement("img");var u=window.document.createTextNode(" ScheduleOnce ");p.title="ScheduleOnce Google Calendar Add-on";p.className="calHeader goog-zippy-expanded normalText";p.id="h2";p.setAttribute("tabindex","0");F.className="h zippy-arrow";F.setAttribute("unselectable","on");F.src="//calendar.google.com/googlecalendar/images/blank.gif";p.attachEvent("onclick",SOswitchMenu);p.appendChild(F);p.appendChild(u);var k=window.document.createElement("div");var A=window.document.createElement("div");var i=window.document.createElement("img");A.className="calHeader textAlignRight";A.style.height="16px";i.src=baseURL+"images/refresh.png";i.title="Refresh meeting list";i.style.marginRight="5px";i.attachEvent("onclick",SOframeReload);A.appendChild(i);var r=window.document.createElement("div");r.className="floatLeft";r.appendChild(p);k.appendChild(r);k.appendChild(A);var o=window.document.createElement("div");var E=window.document.createElement("div");var q=window.document.createElement("div");q.className="calendarsBottom";o.className="sidetable chromeColor";o.id="bodyDiv";o.style.padding="0pt 2px 1px";o.style.clear="both";var g=window.document.createElement("table");var d=window.document.createElement("tbody");var n=window.document.createElement("tr");var w=window.document.createElement("td");var e=window.document.createElement("div");var h=window.document.createElement("div");e.className="calList";h.className="calListRaw";var D=window.document.createElement("iframe");D.id="soFrame";D.name="soFrame";D.setAttribute("src",a);D.setAttribute("width","158");D.setAttribute("height","100");D.setAttribute("frameborder","0");D.setAttribute("marginheight","0");D.setAttribute("marginwidth","0");e.appendChild(D);w.appendChild(e);n.appendChild(w);d.appendChild(n);g.cellSpacing="0";g.cellPadding="0";g.style.tableLayout="fixed";g.style.width="100%";g.appendChild(d);var z=window.document.createElement("div");var s=window.document.createElement("span");var b=window.document.createTextNode("+ New meeting");s.title="Create a new meeting with ScheduleOne";z.className="callistLink textAlignRight";s.className="lk";s.onclick=openSOURL;s.appendChild(b);z.appendChild(s);var y=window.document.createElement("div");var f=window.document.createElement("span");var j=window.document.createTextNode("Help");f.title="ScheduleOnce help";y.className="callistLink floatLeft";f.className="lk";f.onclick=openHelpURL;f.appendChild(j);y.appendChild(f);q.appendChild(y);q.appendChild(z);E.appendChild(g);o.appendChild(E);o.appendChild(q);m.appendChild(c);m.appendChild(k);m.appendChild(o);l.parentNode.insertBefore(m,l.nextSibling)})();function openSOURL(){var a=baseURL+"NewMeeting.aspx?source=GC";window.open(a,"ScheduleOnceNM","chrome=yes,dependent=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,width=1024,height=600")}function openHelpURL(){var a=baseURL+"OrganizerHelp.aspx";PRO_openInTab(a,1)}function addGlobalScript(b){var a=document.getElementsByTagName("body")[0].appendChild(document.createElement("script"));a.setAttribute("language","javascript");a.setAttribute("type","text/javascript");a.text=b};
