<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Technetra</title>
	<atom:link href="http://www.technetra.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.technetra.com</link>
	<description>Connecting Government, Industry, Education through Open Source</description>
	<pubDate>Sat, 22 Aug 2009 02:37:52 +0000</pubDate>
	<generator>http://wordpress.org/</generator>
	<language>en</language>
			<item>
		<title>Countdown 2.0: Supporting HTML5 Cache</title>
		<link>http://www.technetra.com/2009/08/17/countdown-html5-cache-version/</link>
		<comments>http://www.technetra.com/2009/08/17/countdown-html5-cache-version/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 23:08:40 +0000</pubDate>
		<dc:creator>radkins</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[codemagic]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[html5]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[iphonedevcamp]]></category>

		<category><![CDATA[iui]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[mobile]]></category>

		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=1166</guid>
		<description><![CDATA[Taking advantage of HTML5 caching in an iPhone Webapp can eliminate the need to employ cumbersome data URLs for standalone or offline style applications.]]></description>
			<content:encoded><![CDATA[<p>Taking advantage of HTML5 caching in an iPhone Webapp can eliminate the need to employ cumbersome data URLs for standalone or offline style applications. The <a href="http://www.whatwg.org/specs/web-apps/current-work/#offline">offline storage facilities of HTML5</a> have been around for the iPhone since OS 2.1 and can, for devices running recent OS releases, significantly reduce the complexity of deploying offline Web applications. Caching also provides the potential for automatic refresh when the standalone Webapp comes back online.</p>
<p>
<div>
<span style="float:left;"><div id="attachment_010" class="wp-caption aligncenter" style="width: 170px"><img src="/ipdc3/countdown_main_page_screenshot2.png" alt="Figure 1: Main Screen (in Full-Screen Mode)" width="160" height="240" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 1: Main Screen (in Full-Screen Mode)</p></div></span><span style="float:left"><div id="attachment_020" class="wp-caption aligncenter" style="width: 170px"><img src="/ipdc3/countdown_settings_page_screenshot2.png" alt="Figure 2: Settings Screen (Full-Screen)" width="160" height="240" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 2: Settings Screen (Full-Screen)</p></div></span><span style="float:left"><div id="attachment_030" class="wp-caption aligncenter" style="width: 170px"><img src="/ipdc3/countdown_date_picker_screenshot2.png" alt="Figure 3: SpinningWheel Date Picker (Full-Screen)" width="160" height="240" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 3: SpinningWheel Date Picker (Full-Screen)</p></div></span>
</div>
</p>
<p><br style="clear:both"/></p>
<p>So we &#8220;trained&#8221; the network connected version of our <a href="http://www.technetra.com/2009/08/10/countdown-iphone-webapp/">Countdown</a> Webapp to use HTML5 caching (it already used HTML5 localStorage facilities). The &#8220;training&#8221; steps were very simple:</p>
<ol>
<li>Create a manifest which lists all the resources needed by the Web application to work offline. This includes the JavaScript, CSS and image files referenced by the application and its included packages (iUI and SpinningWheel). See <a href="#listing_1">Listing 1</a>.</li>
<li>Attach the URL of this manifest to the manifest attribute of the Webapp&#8217;s HTML tag. See <a href="#listing_2">Listing 2</a>.</li>
<li>Ensure that when the manifest resource is retrieved by the browser, the manifest is served as a <code>text/cache-manifest</code> mime-type by the HTTP server. In our case this meant adding
<pre>text/cache-manifest manifest</pre>
<p>to our Apache mime.types configuration file. This is necessary for the moment since the listing of standard media types from <a href="http://www.iana.org/assignments/media-types/text/">IANA</a>, as incorporated by Apache 2.2+, does not yet include this mime-type by default.
</li>
</ol>
<p>In addition, since Countdown is designed to be a standalone application, we added an <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html"><code>apple-mobile-web-app-capable</code></a> meta tag key in order to run in full-screen mode, removing the standard Safari URL and Button bars when launched from the Home Screen.</p>
<h3>Countdown 2.0</h3>
<p>You can <a href="/ipdc3/countdown-2.0/countdown.html">try out this new version</a> of Countdown with your iPhone. Be sure to add the application to your Home Screen using the bookmark button at the bottom of the initial Safari screen. This is necessary in order actually to view the Webapp in full-screen mode. The Webapp may be partly functional under some other browsers like Firefox and Chrome (no support for the SpinningWheel date picker).</p>
<p>You can download the new project files from <a href="/ipdc3/countdown-2.0.tar.bz2">here</a>.</p>
<p>A big thanks to Sean Gilligan (co-maintainer of the iUI Framework) for suggesting these improvements to Countdown Webapp.</p>
<p><a name="listing_1"></a></p>
<h3>Listing 1: Cache Manifest for Countdown iPhone Webapp (countdown.manifest)</h3>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">CACHE MANIFEST
iui/iui.css
iui/iui.js
spinningwheel/spinningwheel.css
spinningwheel/spinningwheel.js
countdown.css
countdown.js
countdown_touch_icon.png
iui/listArrowSel.png
iui/loading.gif
iui/selection.png
iui/toolbar.png
iui/toolButton.png
iui/blueButton.png
iui/backButton.png
iui/whiteButton.png
iui/redButton.png
iui/grayButton.png
iui/listGroup.png
iui/listArrow.png
iui/pinstripes.png
iui/toggle.png
iui/toggleOn.png
iui/thumb.png
spinningwheel/sw-header.png
spinningwheel/sw-button-cancel.png
spinningwheel/sw-button-done.png
spinningwheel/sw-slot-border.png
spinningwheel/sw-alpha.png</pre></div></div>

<p><a name="listing_2"></a></p>
<h3>Listing 2: Adding manifest URL to manifest attribute of HTML tag &amp; removing top and bottom banners with <code>apple-mobile-web-app-capable</code> META tag (countdown.html)</h3>
<div class="wp_syntax">
<div class="code">
<pre class="html4strict" style="font-family:monospace;">...
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> <span style="background:#ff8;">manifest<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;countdown.manifest&quot;</span>&gt;</span></span>

  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Countdown<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-touch-icon&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;countdown_touch_icon.png&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>

    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="background:#ff8;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-mobile-web-app-capable&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yes&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></span>
...</pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/08/17/countdown-html5-cache-version/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Countdown iPhone Webapp</title>
		<link>http://www.technetra.com/2009/08/10/countdown-iphone-webapp/</link>
		<comments>http://www.technetra.com/2009/08/10/countdown-iphone-webapp/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 23:55:31 +0000</pubDate>
		<dc:creator>radkins</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[codemagic]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[html5]]></category>

		<category><![CDATA[iphone]]></category>

		<category><![CDATA[iphonedevcamp]]></category>

		<category><![CDATA[iui]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=1164</guid>
		<description><![CDATA[Countdown is an iPhone Webapp that implements a simple multi-color timer charting how many days, hours, minutes and seconds are left until a selected target event arrives. For example, this may be a fun (or frustrating) way to count how long you must wait until your next birthday. Built-in events include "Midnight" and "New Year's". There is a "Settings" screen that allows you to configure some of the parameters of the program. One of the most interesting configuration elements is a date picker that uses the hardware accelerated "SpinningWheel" from <a href="http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch/11">cubiq.org</a>.]]></description>
			<content:encoded><![CDATA[<h2>What is it?</h2>
<p>Countdown is an iPhone app <a href="http://developer.yahoo.com/hacku/hackuhandler.php?appid=us&#038;op=showhack&#038;hackid=336">started</a> at this year&#8217;s <a href="http://www.iphonedevcamp.org/">iPhoneDevCamp 3</a> which was held at Yahoo! from July 31st through August 2nd.</p>
<p>Countdown is a simple multi-color timer that charts how many days, hours, minutes and seconds are left until a selected target event arrives. For example, this may be a fun (or frustrating) way to count how long you must wait until your next birthday. Built-in events also include &#8220;Midnight&#8221; and &#8220;New Year&#8217;s&#8221;. There is a &#8220;Settings&#8221; screen that allows you to configure some of the parameters of the program. One of the most interesting configuration elements is a date picker that uses the hardware accelerated &#8220;SpinningWheel&#8221; from <a href="http://cubiq.org/spinning-wheel-on-webkit-for-iphone-ipod-touch/11">cubiq.org</a>.</p>
<div>
<span style="float:left;"><div id="attachment_010" class="wp-caption aligncenter" style="width: 170px"><img src="/ipdc3/countdown_main_page_screenshot.png" alt="Figure 1: Main Screen" width="160" height="240" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 1: Main Screen</p></div></span><span style="float:left"><div id="attachment_020" class="wp-caption aligncenter" style="width: 170px"><img src="/ipdc3/countdown_settings_page_screenshot.png" alt="Figure 2: Settings Screen" width="160" height="240" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 2: Settings Screen</p></div></span><span style="float:left"><div id="attachment_030" class="wp-caption aligncenter" style="width: 170px"><img src="/ipdc3/countdown_date_picker_screenshot.png" alt="Figure 3: SpinningWheel Date Picker" width="160" height="240" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 3: SpinningWheel Date Picker</p></div></span>
</div>
</p>
<p><br style="clear:both;"/></p>
<h2>What does the app do?</h2>
<p>Countdown illustrates</p>
<ol>
<li>Webkit techniques to build a &#8220;native-look-and-feel&#8221; iPhone Webapp using JavaScript and CSS,</li>
<li>the latest stable <a href="http://code.google.com/p/iui/">iUI (iui-0.30)</a>, and</li>
<li>integration of the latest (updated) <a href="http://cubiq.org/dropbox/sw/">SpinningWheel</a>, a powerful JavaScript tool that resembles the native Picker View widget (UIPickerView) on the iPhone. The SpinningWheel tool provides a fast and flexible user interface for many kinds of data input and visualization. It allows multiple columns or slots (we are using 3) to be defined to represent complex values like dates and other tabular data. Interaction with the widget is fully hardware accelerated.</li>
</ol>
<p>Also, we wanted to create a version of our webapp which could be installed as a stand-alone application that would not require access to a network to run. This means that all data items, including images, stylesheets and scripts, must be bundled with the application beforehand. Dynamic data, such as user-updated application settings, must be kept in local storage by the application across multiple launches and even across power cycles.</p>
<h2>What issues did we face?</h2>
<p>There were some challenges:</p>
<ol>
<li>Integration of iUI and SpinningWheel:
<p>Integrating iUI with other packages requires some understanding of how iUI manages HTML containers used for displaying successive screens on the iPhone. Essentially the CSS rules of iUI turn off any unselected, top level elements within the body of an HTML page. In order to get SpinningWheel to work properly with iUI, our application needed to define a CSS rule to ensure display of the dynamically created primary container of the SpinningWheel widget. This container has the id <code>sw-wrapper</code> and is added as a child of the screen&#8217;s body tag when the widget is opened. A short CSS rule in our application&#8217;s stylesheet (loaded after the iUI stylesheet) was enough to override iUI&#8217;s default behavior.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sw-wrapper</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This simple addition to our stylesheet enabled SpinningWheel to be used with iUI without any modification to either package.</p>
<p>In addition, we had to reposition the SpinningWheel&#8217;s view frame, <code>sw-frame</code> for our application&#8217;s layout. The values for portrait and landscape orientations that worked for Countdown were</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#sw-frame</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">112px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#sw-frame</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Using SpinningWheel with its hardware accelerated animations is a lot of fun and is a great way for a user to see and select tabular data like dates.</p>
</li>
<li>Client-side storage using HTML5:
<p>We used WebKit&#8217;s support for the <code><a href="http://dev.w3.org/html5/webstorage/">localStorage</a></code> DOM attribute of HTML5. This is W3C&#8217;s new Web Storage abstraction for JavaScript managed user data. <code>localStorage</code> supports persistence beyond the current session and is ideal (essential in the case of the stand-alone version of our application) for saving the application&#8217;s settings in a server independent manner. On the iPhone, the process of creating the stand-alone application changes the application&#8217;s domain origin to a null value. This value is then automatically used as the application&#8217;s Web Storage domain for all localStorage access, creating referential consistency.</p>
</li>
<li>Converting Countdown into a stand-alone application:
<p><i>[ Note: the following section applies to this version of the Countdown webapp which was implemented using Data URLs. HTML5 Caching provides a better implementation strategy and is covered in the follow-on article <a href="/2009/08/17/countdown-html5-cache-version/">"Countdown 2.0: Supporting HTML5 Cache"</a> ]</i></p>
<p>Converting this webapp, when implemented using Data URLs, into a stand-alone application required modification of iUI in three ways. First, iUI navigates back to screens presented earlier by updating the application&#8217;s global window location attribute with URLs from its page history cache. Due to security constraints, updating the location attribute is not allowed by Safari when running in stand-alone mode. Second, iUI uses AJAX requests to update application content. This is also forbidden by the security context imposed on a stand-alone application. This functionality can therefore be removed to save space. Third, iUI preloads images to improve performance. This is not needed in a stand-alone application.</p>
<p>To address the first of these three issues, the standalone version of our application uses an iUI package modified to allow forward and backward navigation via document section ids (using the link&#8217;s hash attribute in same way the unmodified iUI does currently for forward navigation). Countdown has only two working screens, but applications that require more screens would need to enhance this approach with a simple history queue.</p>
<p>To prevent violation of the stand-alone security context, the predefined AJAX GET and POST requests were removed from iUI. This means that all resources needed by the stand-alone application have to be bundled with the program when it is written. This is a constraint that all stand-alone webapps on the iPhone are burdened with anyway, so the need to remove AJAX from iUI was not surprising.</p>
<p>Avoiding preloading of images required only simple changes to iUI&#8217;s JavaScript and CSS.</p>
<p>Finally, converting this webapp into a stand-alone application also required constructing a simple installer. Fortunately, we were able to reuse the installer tools discussed in our earlier article <a href="http://www.technetra.com/2008/12/23/how-to-deploy-an-iphone-web-application">&#8220;How to Deploy an iPhone Web Application&#8221;</a>.</p>
<p>It is important to note that these changes to iUI were only required for building the stand-alone version of our application. For the network connected version of Countdown, both SpinningWheel and iUI could be used without any modifications.</p>
</li>
<ol>
<h2>Try Out Countdown!</h2>
<p><i>[ Please check out the new version of <a href="http://www.technetra.com/2009/08/17/countdown-html5-cache-version/">Countdown</a> that uses HTML5 caching instead of Data URLs ]</i></p>
<p>There are two versions of the Countdown application.</p>
<h3>Network connected version</h3>
<p><a href="http://www.technetra.com/ipdc3/countdown-1.0/countdown.html">Try out Countdown on your iPhone</a>.</p>
<p>This network connected version of Countdown may also work in some other browsers (Safari 4+, Firefox 2+, Chrome 3.0.197+) with limited functionality. [EXPERIMENTAL]</p>
<h3>Stand-alone version</h3>
<p><a href="http://www.technetra.com/ipdc3/countdown-1.0/countdown_installer.html">Install Countdown as a &#8220;native application&#8221; on your iPhone Home Screen</a>.</p>
<p>This installable version of Countdown may also work as a bookmark (Data URL) in some other browsers (in particular Safari 4+) with limited functionality. It does not work properly in any version of Firefox. [EXPERIMENTAL]</p>
<p><a href="http://www.technetra.com/ipdc3/countdown-1.0.tar.bz2">Download the complete Countdown application and its resources, including the stand-alone and non-stand-alone application versions</a>.</p>
<p>Note that Countdown works best on a real iPhone or simulator. However, the application can be run in a limited way on various modern browsers like Safari 4+, Firefox 3+ and Chrome/Chromium 3.0.197+. In these cases, instead of using the  (iPhone specific) SpinningWheel interface, Countdown presents a standard <code>select</code> element for date picking. Countdown also uses persistent storage when the browser (e.g., Firefox 3.5, Safari 4+) supports Web Storage. Otherwise Countdown uses a private array which is recreated for each new instance of the application.</p>
<h3>Listing 1: Countdown HTML &#8211; Network connected version (countdown.html)</h3>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; </span>
<span style="color: #00bbdd;">  &quot;http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- </span>
<span style="color: #808080; font-style: italic;">     Copyright (c) 2009 Technetra Corp</span>
<span style="color: #808080; font-style: italic;">     Licensed under The MIT License</span>
<span style="color: #808080; font-style: italic;">     Originally inspired by Danny Goodman's Countdown</span>
<span style="color: #808080; font-style: italic;">     script in &quot;JavaScript and DHTML Cookbook&quot;</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Countdown<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;apple-touch-icon&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;TOUCH_ICON&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;viewport&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;iui/iui.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;all&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;spinningwheel/spinningwheel.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;all&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;countdown.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;all&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;iui/iui.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;countdown.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;spinningwheel/spinningwheel.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> 
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- MAIN --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;toolbar&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pageTitle&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;backButton&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span> <span style="color: #000066;">onClick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.turnActionButtonOn('settingsButton','doMain');&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'settingsButton'</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#setupForm&quot;</span> <span style="color: #000066;">onClick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.turnActionButtonOff(this,'doSetup');&quot;</span>&gt;</span>Settings<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">selected</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ctr&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main_subtitles&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Today: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;today&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;divider&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;divider&quot;</span>&gt;</span> <span style="color: #ddbb00;">&amp;diams;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Start Date: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;start_date&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;divider&quot;</span>&gt;</span> <span style="color: #ddbb00;">&amp;diams;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>Event Date: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;target_date&quot;</span>&gt;</span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unit&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;countdown_box&quot;</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;days_box&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;days&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span>&gt;</span>Days<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;overlay&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;days_overlay&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hours_box&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hours&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span>&gt;</span>Hours<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;overlay&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hours_overlay&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;minutes_box&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;minutes&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span>&gt;</span>Minutes<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;overlay&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;minutes_overlay&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;seconds_box&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;seconds&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span>&gt;</span>Seconds<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;overlay&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;seconds_overlay&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;main_footer&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'update_interval_container'</span> &gt;</span>(updated every <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'update_interval_text'</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span><span style="color: #ddbb00;">&amp;nbsp;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- SETUP --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;setupForm&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Settings&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;panel&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Target Event<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>row&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Title<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title_input_field&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.setTitleFieldResources(this.value);&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span>30 <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>row&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Event<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_event&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updateEventType(this);&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;font-size:1.0em; text-align:left;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'newyears'</span>&gt;</span>New Years<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'birthday'</span>&gt;</span>Birthday<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'midnight'</span>&gt;</span>Midnight<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'other'</span>&gt;</span>Other<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'reset'</span>&gt;</span>Reset<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Countdown Details<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>row&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Update Every<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_interval&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updateInterval(this);&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;font-size:1.0em; text-align:left;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'1000'</span>&gt;</span>second<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'2000'</span>&gt;</span>2 seconds<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'60000'</span>&gt;</span>minute<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'3600000'</span>&gt;</span>hour<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'86400000'</span>&gt;</span>day<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>row&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Date Format<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_date_format&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updateDateFormat(this);&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;font-size:1.0em; text-align:left;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'mm/dd/yyyy'</span>&gt;</span>MM/DD/YYYY<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'yyyy/mm/dd'</span>&gt;</span>YYYY/MM/DD<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'dd/mm/yyyy'</span>&gt;</span>DD/MM/YYYY<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'mm-dd-yyyy'</span>&gt;</span>MM-DD-YYYY<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'yyyy-mm-dd'</span>&gt;</span>YYYY-MM-DD<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'dd-mm-yyyy'</span>&gt;</span>DD-MM-YYYY<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span>row&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Number Padding<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_padding&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updatePadding(this);&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;font-size:1.0em; text-align:left;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">' '</span>&gt;</span>none<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'0'</span>&gt;</span>0<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'-'</span>&gt;</span>-<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'&amp;hearts;'</span>&gt;</span><span style="color: #ddbb00;">&amp;hearts;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'&amp;diams;'</span>&gt;</span><span style="color: #ddbb00;">&amp;diams;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;spinning_wheel_date_container&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Event Date: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sw_date_picked&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button blueButton&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#dummy&quot;</span> <span style="color: #000066;">onClick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;SpinningWheel_AI.openEventDate();&quot;</span>&gt;</span>Change Date<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_date_container&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;row&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">label</span>&gt;</span>Event Date:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">label</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;float:right;margin-right:-27%;&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">align</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;left&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;setup_cell&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_month&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updateMonth(this);&quot;</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'-1'</span>&gt;</span>Month<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>6<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>7<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>8<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>9<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>11<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>12<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_day&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updateDay(this);&quot;</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'-1'</span>&gt;</span>Day<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>5<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>6<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>7<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>8<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>9<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>10<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>11<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>12<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>13<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>14<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>15<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>16<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>17<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>18<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>19<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>20<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>21<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>22<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>23<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>24<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>25<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>26<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>27<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>28<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>29<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>30<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>31<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">select</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;select_year&quot;</span> <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.updateYear(this);&quot;</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'-1'</span>&gt;</span>Year<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2009<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2010<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2011<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2012<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2013<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">option</span>&gt;</span>2014<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">option</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">select</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">fieldset</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- DONE! --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;counter_done&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button&quot;</span> <span style="color: #000066;">onClick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Countdown.acknowledgeDone(this);&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#dummy&quot;</span>&gt;</span>Countdown is done!<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span><span style="color: #66cc66;">/</span>&gt;</span>OK<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<h3>Listing 2: Countdown JavaScript Implementation (countdown.js)</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
  Copyright (c) 2009 Technetra Corp
  Released under The MIT License
*/</span>
<span style="color: #003366; font-weight: bold;">var</span> Countdown<span style="color: #339933;">;</span>
<span style="color: #009966; font-style: italic;">/* BEGIN SpinningWheel Application Interface */</span>
<span style="color: #003366; font-weight: bold;">var</span> SpinningWheel_AI <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
  openEventDate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_event'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> event_title <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event_title <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;Birthday&quot;</span> <span style="color: #339933;">||</span> event_title <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;Other&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  	<span style="color: #003366; font-weight: bold;">var</span> now <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  	<span style="color: #003366; font-weight: bold;">var</span> days <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  	<span style="color: #003366; font-weight: bold;">var</span> years <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  	<span style="color: #003366; font-weight: bold;">var</span> months <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Jan'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Feb'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Mar'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Apr'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'May'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Jun'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Jul'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Aug'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Sep'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Oct'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">11</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Nov'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">12</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'Dec'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">32</span><span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> 1 <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  		days<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
  	<span style="color: #009900;">&#125;</span>
&nbsp;
  	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> i <span style="color: #339933;">=</span> now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #CC0000;">4</span><span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> 1 <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  		years<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
  	<span style="color: #009900;">&#125;</span>
      SpinningWheel.<span style="color: #660066;">addSlot</span><span style="color: #009900;">&#40;</span>years<span style="color: #339933;">,</span> <span style="color: #3366CC;">'right'</span><span style="color: #339933;">,</span> Countdown.<span style="color: #660066;">get_selected_year</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      SpinningWheel.<span style="color: #660066;">addSlot</span><span style="color: #009900;">&#40;</span>months<span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">,</span> Countdown.<span style="color: #660066;">get_selected_month</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      SpinningWheel.<span style="color: #660066;">addSlot</span><span style="color: #009900;">&#40;</span>days<span style="color: #339933;">,</span> <span style="color: #3366CC;">'right'</span><span style="color: #339933;">,</span> Countdown.<span style="color: #660066;">get_selected_day</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      SpinningWheel.<span style="color: #660066;">setCancelAction</span><span style="color: #009900;">&#40;</span>SpinningWheel_AI.<span style="color: #660066;">cancel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      SpinningWheel.<span style="color: #660066;">setDoneAction</span><span style="color: #009900;">&#40;</span>Countdown.<span style="color: #660066;">updateSWDate</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  	SpinningWheel.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Please select 'Birthday' or 'Other' Event Type To Customize Date&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
  cancel<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//document.getElementById('sw_date_picked').innerHTML = 'cancelled!';</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009966; font-style: italic;">/* END SpinningWheel Application Interface */</span>
&nbsp;
<span style="color: #009966; font-style: italic;">/* Countdown Closure */</span>
Countdown <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> $ <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">var</span> $getInnerText <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>id.<span style="color: #660066;">innerText</span><span style="color: #339933;">?</span> id.<span style="color: #660066;">innerText</span> <span style="color: #339933;">:</span> id.<span style="color: #660066;">innerHTML</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">var</span> $setInnerText <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// hack for Firefox 3.5</span>
    id <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>id.<span style="color: #660066;">innerText</span><span style="color: #009900;">&#41;</span>
      id.<span style="color: #660066;">innerText</span> <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">else</span>
      id.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #003366; font-weight: bold;">var</span> MSSEC <span style="color: #339933;">=</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> MSMIN <span style="color: #339933;">=</span> 60 <span style="color: #339933;">*</span> MSSEC<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> MSHR <span style="color: #339933;">=</span> 60 <span style="color: #339933;">*</span> MSMIN<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> MSDAY <span style="color: #339933;">=</span> 24 <span style="color: #339933;">*</span> MSHR<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gMy_interval_timer<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gSelected_day<span style="color: #339933;">,</span> gSelected_month<span style="color: #339933;">,</span> gSelected_year<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gTitle_input_field <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Midnight&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gEvent_type_text <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Midnight&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gEvent_type_value <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;midnight&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gTarget_time<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gDone <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gTotal_yeardays <span style="color: #339933;">=</span> <span style="color: #CC0000;">365</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gStart_month<span style="color: #339933;">,</span> gStart_day<span style="color: #339933;">,</span> gStart_year<span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gMark_month <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>1<span style="color: #339933;">,</span> gMark_day <span style="color: #339933;">=</span> <span style="color: #339933;">-</span>1<span style="color: #339933;">,</span> gMark_year <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gDate_format <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;mm/dd/yyyy&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gPad <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gUpdate_date_mark <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gUpdate_interval <span style="color: #339933;">=</span> <span style="color: #CC0000;">2000</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gUpdate_interval_text <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;2 seconds&quot;</span><span style="color: #339933;">;</span> 
  <span style="color: #003366; font-weight: bold;">var</span> gLocalStore <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> gIs_iPhone <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>navigator.<span style="color: #660066;">userAgent</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'iphone'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=-</span>1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  window.<span style="color: #660066;">onorientationchange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">orientation</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">:</span>
          document.<span style="color: #660066;">body</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orient'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'portrait'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">case</span> 90<span style="color: #339933;">:</span>
        <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">90</span><span style="color: #339933;">:</span>
          document.<span style="color: #660066;">body</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orient'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'landscape'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      setTimeout<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Countdown.countDown()'</span><span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      setTimeout<span style="color: #009900;">&#40;</span>scrollTo<span style="color: #339933;">,</span> 100<span style="color: #339933;">,</span> 0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;load&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      initApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      window.<span style="color: #660066;">onorientationchange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      Countdown.<span style="color: #660066;">countDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// set up initial timer values, fields and overlays</span>
      gMy_interval_timer <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Countdown.countDown()'</span><span style="color: #339933;">,</span> gUpdate_interval<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> storeItem <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">,</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">localStorage</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      window.<span style="color: #660066;">localStorage</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      gLocalStore<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> retrieveItem <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> val<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">localStorage</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      val <span style="color: #339933;">=</span> window.<span style="color: #660066;">localStorage</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      val <span style="color: #339933;">=</span> gLocalStore<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> val<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> clearItems <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">localStorage</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      window.<span style="color: #660066;">localStorage</span>.<span style="color: #660066;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      gLocalStore <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> actionButton <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>btn<span style="color: #339933;">,</span> action<span style="color: #339933;">,</span> dsply<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> btn <span style="color: #339933;">==</span> <span style="color: #3366CC;">'string'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>btn <span style="color: #339933;">!=</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> $<span style="color: #009900;">&#40;</span>btn<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> dsply<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      btn.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> dsply<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>action <span style="color: #339933;">!=</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> Countdown<span style="color: #009900;">&#91;</span>action<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> store_date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>y<span style="color: #339933;">,</span> m<span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_year'</span><span style="color: #339933;">,</span> y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_month'</span><span style="color: #339933;">,</span> m<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_day'</span><span style="color: #339933;">,</span> d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> store_update_interval <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval'</span><span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval_text'</span><span style="color: #339933;">,</span> t<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> format_date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>date_fields<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> fmt <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>gDate_format<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;mm/dd/yyyy&quot;</span><span style="color: #339933;">:</span>
          fmt <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> date_fields.<span style="color: #660066;">m</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">d</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">y</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;yyyy/mm/dd&quot;</span><span style="color: #339933;">:</span>
          fmt <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> date_fields.<span style="color: #660066;">y</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">m</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">d</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;dd/mm/yyyy&quot;</span><span style="color: #339933;">:</span>
          fmt <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> date_fields.<span style="color: #660066;">d</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">m</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">y</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;mm-dd-yyyy&quot;</span><span style="color: #339933;">:</span>
          fmt <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> date_fields.<span style="color: #660066;">m</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">d</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">y</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;yyyy-mm-dd&quot;</span><span style="color: #339933;">:</span>
          fmt <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> date_fields.<span style="color: #660066;">y</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">m</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">d</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;dd-mm-yyyy&quot;</span><span style="color: #339933;">:</span>
          fmt <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> date_fields.<span style="color: #660066;">d</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">m</span><span style="color: #339933;">,</span> date_fields.<span style="color: #660066;">y</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> fmt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> setOverlay <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> tp<span style="color: #339933;">,</span> offset<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> mfactor<span style="color: #339933;">,</span> wfactor<span style="color: #339933;">;</span>
    offset <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>offset <span style="color: #339933;">&lt;</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> 0 <span style="color: #339933;">:</span> offset<span style="color: #339933;">;</span>
    offset <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>offset <span style="color: #339933;">&gt;</span> 59<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> 59 <span style="color: #339933;">:</span> offset<span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">orientation</span><span style="color: #339933;">==</span>0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      mfactor <span style="color: #339933;">=</span> 138<span style="color: #339933;">/</span><span style="color: #CC0000;">60</span><span style="color: #339933;">;</span>
      wfactor <span style="color: #339933;">=</span> <span style="color: #CC0000;">136</span><span style="color: #339933;">;</span>
      tp <span style="color: #339933;">+=</span> <span style="color: #CC0000;">52</span><span style="color: #339933;">;</span>
      height <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;58px&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
      mfactor <span style="color: #339933;">=</span> 260<span style="color: #339933;">/</span><span style="color: #CC0000;">60</span><span style="color: #339933;">;</span>
      wfactor <span style="color: #339933;">=</span> <span style="color: #CC0000;">256</span><span style="color: #339933;">;</span>
      height <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;36px&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    obj.<span style="color: #660066;">style</span>.<span style="color: #660066;">top</span> <span style="color: #339933;">=</span> tp<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
    obj.<span style="color: #660066;">style</span>.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> height<span style="color: #339933;">;</span>
    obj.<span style="color: #660066;">style</span>.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>wfactor<span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span>offset<span style="color: #339933;">*</span>mfactor<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">/* obj.innerHTML = obj.style.width; */</span>
    <span style="color: #009966; font-style: italic;">/* obj.innerHTML = tp+&quot;px&quot;; */</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> formatNum <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>num<span style="color: #339933;">,</span> len<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> d<span style="color: #339933;">,</span> padding<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> fmt <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&amp;hellip;&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>num <span style="color: #339933;">&lt;</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> fmt<span style="color: #339933;">;</span>
      fmt <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">+</span> num<span style="color: #339933;">;</span>
      d <span style="color: #339933;">=</span> len <span style="color: #339933;">-</span> fmt.<span style="color: #660066;">length</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> 
      padding <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span>d<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span>gPad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span> padding <span style="color: #339933;">+</span> fmt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> setFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>days<span style="color: #339933;">,</span> hrs<span style="color: #339933;">,</span> mins<span style="color: #339933;">,</span> secs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gUpdate_interval_text.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/minute/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        secs <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gUpdate_interval_text.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/hour/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        secs <span style="color: #339933;">=</span> mins <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gUpdate_interval_text.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/day/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        secs <span style="color: #339933;">=</span> mins <span style="color: #339933;">=</span> hrs <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      setOverlay<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;days_overlay&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;days&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offsetTop</span><span style="color: #339933;">,</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>days<span style="color: #339933;">*</span>60<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>gTotal_yeardays<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setOverlay<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hours_overlay&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hours&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offsetTop</span><span style="color: #339933;">,</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>hrs<span style="color: #339933;">*</span>60<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>24<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setOverlay<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;minutes_overlay&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;minutes&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offsetTop</span><span style="color: #339933;">,</span> mins<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setOverlay<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;seconds_overlay&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;seconds&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">offsetTop</span><span style="color: #339933;">,</span> secs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;days&quot;</span><span style="color: #339933;">,</span> formatNum<span style="color: #009900;">&#40;</span>days<span style="color: #339933;">,</span> 3<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hours&quot;</span><span style="color: #339933;">,</span> formatNum<span style="color: #009900;">&#40;</span>hrs<span style="color: #339933;">,</span> 3<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;minutes&quot;</span><span style="color: #339933;">,</span> formatNum<span style="color: #009900;">&#40;</span>mins<span style="color: #339933;">,</span> 3<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;seconds&quot;</span><span style="color: #339933;">,</span> formatNum<span style="color: #009900;">&#40;</span>secs<span style="color: #339933;">,</span> 3<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #006600; font-style: italic;">//alert(&quot;setFields, days=&quot;+days+&quot;, hrs=&quot;+hrs+&quot;, mins=&quot;+mins+&quot;, secs=&quot;+secs);</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> setupSelectElementByValue <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> o<span style="color: #339933;">;</span>
    o <span style="color: #339933;">=</span> el.<span style="color: #660066;">options</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> o.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        el.<span style="color: #660066;">selectedIndex</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>  
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> setupSelectElementByText <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> o<span style="color: #339933;">;</span>
    o <span style="color: #339933;">=</span> el.<span style="color: #660066;">options</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> o.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span> <span style="color: #339933;">==</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        el.<span style="color: #660066;">selectedIndex</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>  
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> setupDate <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>etype<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> targ_date<span style="color: #339933;">,</span> start_date<span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> now <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    start_date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>now<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    gStart_day <span style="color: #339933;">=</span> now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    gStart_month <span style="color: #339933;">=</span> now.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    gStart_year <span style="color: #339933;">=</span> now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> selected_hour <span style="color: #339933;">=</span> 1<span style="color: #339933;">,</span> selected_minute <span style="color: #339933;">=</span> 1<span style="color: #339933;">,</span> selected_second <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>etype<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;midnight&quot;</span><span style="color: #339933;">:</span>
        now.<span style="color: #660066;">setDate</span><span style="color: #009900;">&#40;</span>now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gSelected_day <span style="color: #339933;">=</span> now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gSelected_month <span style="color: #339933;">=</span> now.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
        gSelected_year <span style="color: #339933;">=</span> now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        store_date<span style="color: #009900;">&#40;</span>gSelected_year<span style="color: #339933;">,</span> gSelected_month<span style="color: #339933;">,</span> gSelected_day<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #3366CC;">&quot;newyears&quot;</span><span style="color: #339933;">:</span>
        now.<span style="color: #660066;">setFullYear</span><span style="color: #009900;">&#40;</span>now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gSelected_day <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
        gSelected_month <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
        gSelected_year <span style="color: #339933;">=</span> now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        store_date<span style="color: #009900;">&#40;</span>gSelected_year<span style="color: #339933;">,</span> gSelected_month<span style="color: #339933;">,</span> gSelected_day<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    targ_date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span>gSelected_year<span style="color: #339933;">,</span> gSelected_month<span style="color: #339933;">-</span>1<span style="color: #339933;">,</span> gSelected_day<span style="color: #339933;">,</span> selected_hour<span style="color: #339933;">-</span>1<span style="color: #339933;">,</span> selected_minute<span style="color: #339933;">-</span>1<span style="color: #339933;">,</span> selected_second<span style="color: #339933;">-</span>1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    gTotal_yeardays <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>targ_date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> start_date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span>1000<span style="color: #339933;">*</span>60<span style="color: #339933;">*</span>60<span style="color: #339933;">*</span>24<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'start_date'</span><span style="color: #339933;">,</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>gStart_month<span style="color: #339933;">+</span>1<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>gStart_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>gStart_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target_date'</span><span style="color: #339933;">,</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>gSelected_month<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>gSelected_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>gSelected_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>gIs_iPhone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      setupSelectElementByText<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_day'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gSelected_day<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setupSelectElementByText<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_month'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gSelected_month<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      setupSelectElementByText<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_year'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gSelected_year<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> targ_date<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> initApp <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pad'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gPad <span style="color: #339933;">=</span> retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pad'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'event_type_text'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gEvent_type_text <span style="color: #339933;">=</span> retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'event_type_text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'event_type_value'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gEvent_type_value <span style="color: #339933;">=</span> retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'event_type_value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gTitle_input_field <span style="color: #339933;">=</span> retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gDate_format <span style="color: #339933;">=</span> retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_day'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gSelected_day <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_day'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_month'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gSelected_month <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_month'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_year'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gSelected_year <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_year'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gUpdate_interval <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval_text'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> gUpdate_interval_text <span style="color: #339933;">=</span> retrieveItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval_text'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'device'</span><span style="color: #339933;">,</span> gIs_iPhone<span style="color: #339933;">?</span><span style="color: #3366CC;">'iphone'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'unknown'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval_text'</span><span style="color: #339933;">,</span> gUpdate_interval_text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pageTitle'</span><span style="color: #339933;">,</span> gTitle_input_field<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> gTitle_input_field<span style="color: #339933;">;</span>
    gTarget_time <span style="color: #339933;">=</span> setupDate<span style="color: #009900;">&#40;</span>gEvent_type_value<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> setEventTypeResources <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ett<span style="color: #339933;">,</span> etv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'event_type_text'</span><span style="color: #339933;">,</span> ett<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'event_type_value'</span><span style="color: #339933;">,</span> etv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    gEvent_type_text <span style="color: #339933;">=</span> ett<span style="color: #339933;">;</span>
    gEvent_type_value <span style="color: #339933;">=</span> etv<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
    get_selected_year<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> gSelected_year<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    get_selected_month<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> gSelected_month<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    get_selected_day<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> gSelected_day<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    doSetup<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">,</span> e<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gMy_interval_timer <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>gMy_interval_timer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          gMy_interval_timer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gSelected_day <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span>1 <span style="color: #339933;">&amp;&amp;</span> gSelected_month <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span>1 <span style="color: #339933;">&amp;&amp;</span> gSelected_year <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span>1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gIs_iPhone<span style="color: #009900;">&#41;</span> $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sw_date_picked'</span><span style="color: #339933;">,</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>gSelected_month<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>gSelected_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>gSelected_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_event'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gEvent_type_value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_interval'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gUpdate_interval<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gDate_format<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_padding'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gPad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>gIs_iPhone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          setupSelectElementByText<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_day'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gSelected_day<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          setupSelectElementByText<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_month'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gSelected_month<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          setupSelectElementByText<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_year'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> gSelected_year<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> Countdown.<span style="color: #660066;">setTitleFieldResources</span><span style="color: #009900;">&#40;</span>gEvent_type_text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gEvent_type_value <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;other&quot;</span> <span style="color: #339933;">||</span> gEvent_type_value <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;birthday&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gEvent_type_value <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;midnight&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
          $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    doMain<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pageTitle'</span><span style="color: #339933;">,</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> etv <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_event'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_event'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
        gTarget_time <span style="color: #339933;">=</span> setupDate<span style="color: #009900;">&#40;</span>etv<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gUpdate_date_mark <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        window.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span>0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gMy_interval_timer <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>gMy_interval_timer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        gMy_interval_timer <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Countdown.countDown()'</span><span style="color: #339933;">,</span> gUpdate_interval<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Countdown.countDown()'</span><span style="color: #339933;">,</span> 0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    countDown<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> now<span style="color: #339933;">,</span> ms<span style="color: #339933;">,</span> diff<span style="color: #339933;">,</span> daysLeft<span style="color: #339933;">,</span> hrsLeft<span style="color: #339933;">,</span> minsLeft<span style="color: #339933;">,</span> secsLeft<span style="color: #339933;">,</span> today<span style="color: #339933;">;</span>
      now <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      now_day <span style="color: #339933;">=</span> now.<span style="color: #660066;">getDate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      now_month <span style="color: #339933;">=</span> now.<span style="color: #660066;">getMonth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      now_year <span style="color: #339933;">=</span> now.<span style="color: #660066;">getFullYear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      ms <span style="color: #339933;">=</span> now.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      diff <span style="color: #339933;">=</span> gTarget_time <span style="color: #339933;">-</span> ms<span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">&lt;=</span> MSSEC <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>gDone<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        daysLeft <span style="color: #339933;">=</span> hrsLeft <span style="color: #339933;">=</span> minsLeft <span style="color: #339933;">=</span> secsLeft <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gMy_interval_timer <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>gMy_interval_timer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          gMy_interval_timer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'counter_done'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'settingsButton'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
        gDone <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        daysLeft <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">/</span> MSDAY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        diff <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span>daysLeft <span style="color: #339933;">*</span> MSDAY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        hrsLeft <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">/</span> MSHR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        diff <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span>hrsLeft <span style="color: #339933;">*</span> MSHR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        minsLeft <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">/</span> MSMIN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        diff <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span>minsLeft <span style="color: #339933;">*</span> MSMIN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        secsLeft <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>diff <span style="color: #339933;">/</span> MSSEC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gDone <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      setFields<span style="color: #009900;">&#40;</span>daysLeft<span style="color: #339933;">,</span> hrsLeft<span style="color: #339933;">,</span> minsLeft<span style="color: #339933;">,</span> secsLeft<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>now_month <span style="color: #339933;">!=</span> gMark_month <span style="color: #339933;">||</span> now_day <span style="color: #339933;">!=</span> gMark_day <span style="color: #339933;">||</span> now_year <span style="color: #339933;">!=</span> gMark_year <span style="color: #339933;">||</span> gUpdate_date_mark<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        today <span style="color: #339933;">=</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>now_month<span style="color: #339933;">+</span>1<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>now_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>now_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$getInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'today'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> today<span style="color: #009900;">&#41;</span> $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'today'</span><span style="color: #339933;">,</span> today<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        gMark_month <span style="color: #339933;">=</span> now_month<span style="color: #339933;">;</span> gMark_day <span style="color: #339933;">=</span> now_day<span style="color: #339933;">;</span> gMark_year <span style="color: #339933;">=</span> now_year<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
&nbsp;
    setTitleFieldResources<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>et<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #339933;">,</span> et<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      gTitle_input_field <span style="color: #339933;">=</span> et<span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> et<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    updateEventType<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> ett <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> etv <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
      setEventTypeResources<span style="color: #009900;">&#40;</span>ett<span style="color: #339933;">,</span> etv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// sets gEvent_type and related fields</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>etv <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;other&quot;</span> <span style="color: #339933;">||</span> etv <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;birthday&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Countdown.<span style="color: #660066;">setTitleFieldResources</span><span style="color: #009900;">&#40;</span>ett<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// sets title_input_field and related fields</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ett <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;Midnight&quot;</span> <span style="color: #339933;">||</span> ett <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;New Years&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Countdown.<span style="color: #660066;">setTitleFieldResources</span><span style="color: #009900;">&#40;</span>ett<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>etv <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;reset&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ett <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Midnight&quot;</span><span style="color: #339933;">;</span>
        etv <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;midnight&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Clearing local storage &amp; setting up default event 'Midnight'. Please reload Countdown app to see changes.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        clearItems<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Countdown.<span style="color: #660066;">setTitleFieldResources</span><span style="color: #009900;">&#40;</span>ett<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_event'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> etv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_interval'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;2000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;mm/dd/yyyy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        setupSelectElementByValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_padding'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Countdown.<span style="color: #660066;">updateInterval</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_interval'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Countdown.<span style="color: #660066;">updateDateFormat</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_date_format'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Countdown.<span style="color: #660066;">updatePadding</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'select_padding'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title_input_field'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
     gTarget_time <span style="color: #339933;">=</span> setupDate<span style="color: #009900;">&#40;</span>etv<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gIs_iPhone<span style="color: #009900;">&#41;</span> $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sw_date_picked'</span><span style="color: #339933;">,</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>gSelected_month<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>gSelected_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>gSelected_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     window.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span>0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
&nbsp;
    updateInterval<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      gUpdate_interval <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'update_interval_text'</span><span style="color: #339933;">,</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      gUpdate_interval_text <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
      store_update_interval<span style="color: #009900;">&#40;</span>gUpdate_interval<span style="color: #339933;">,</span> gUpdate_interval_text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>gMy_interval_timer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      gMy_interval_timer <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Countdown.countDown()'</span><span style="color: #339933;">,</span> gUpdate_interval<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      window.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span>0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
&nbsp;
    updateSWDate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> results <span style="color: #339933;">=</span> SpinningWheel.<span style="color: #660066;">getSelectedValues</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      gSelected_year <span style="color: #339933;">=</span> results.<span style="color: #660066;">keys</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      gSelected_month <span style="color: #339933;">=</span> results.<span style="color: #660066;">keys</span><span style="color: #009900;">&#91;</span>1<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      gSelected_day <span style="color: #339933;">=</span> results.<span style="color: #660066;">keys</span><span style="color: #009900;">&#91;</span>2<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      store_date<span style="color: #009900;">&#40;</span>gSelected_year<span style="color: #339933;">,</span> gSelected_month<span style="color: #339933;">,</span> gSelected_day<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sw_date_picked'</span><span style="color: #339933;">,</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>gSelected_month<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>gSelected_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>gSelected_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      window.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span>0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    updateDateFormat<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      gDate_format <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
      storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'date_format'</span><span style="color: #339933;">,</span> gDate_format<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>gIs_iPhone<span style="color: #009900;">&#41;</span> $setInnerText<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sw_date_picked'</span><span style="color: #339933;">,</span> format_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>gSelected_month<span style="color: #339933;">,</span> d<span style="color: #339933;">:</span>gSelected_day<span style="color: #339933;">,</span> y<span style="color: #339933;">:</span>gSelected_year<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      window.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span>0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    updateDay<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      gSelected_day <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
      storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_day'</span><span style="color: #339933;">,</span> gSelected_day<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    updateMonth<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      gSelected_month <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
      storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_month'</span><span style="color: #339933;">,</span> gSelected_month<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    updateYear<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      gSelected_year <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">text</span><span style="color: #339933;">;</span>
      storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'selected_year'</span><span style="color: #339933;">,</span> gSelected_year<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    updatePadding<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      gPad <span style="color: #339933;">=</span> obj.<span style="color: #660066;">options</span><span style="color: #009900;">&#91;</span>obj.<span style="color: #660066;">selectedIndex</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
      storeItem<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'pad'</span><span style="color: #339933;">,</span> gPad<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      window.<span style="color: #660066;">scrollTo</span><span style="color: #009900;">&#40;</span>0<span style="color: #339933;">,</span> 1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    turnActionButtonOn<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>btn<span style="color: #339933;">,</span> action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      actionButton<span style="color: #009900;">&#40;</span>btn<span style="color: #339933;">,</span> action<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;inline&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    turnActionButtonOff<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>btn<span style="color: #339933;">,</span> action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      actionButton<span style="color: #009900;">&#40;</span>btn<span style="color: #339933;">,</span> action<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    acknowledgeDone<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      obj.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'none'</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'settingsButton'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'inline'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">/* END Countdown */</span></pre></div></div>

<h3>Listing 3: Countdown Stylesheet (countdown.css)</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
  Copyright (c) 2009 Technetra Corp
  Released under The MIT License
*/</span>
body <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#cccccc</span> <span style="color: #993333;">scroll</span> <span style="color: #993333;">repeat</span> 0 <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span><span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">460px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#main_subtitles</span> <span style="color: #00AA00;">&gt;</span> span <span style="color: #00AA00;">&gt;</span> span<span style="color: #3333ff;">:first-child </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#356AA0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#main_subtitles</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.56em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#main_subtitles</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.60em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#main_subtitles</span> <span style="color: #00AA00;">&gt;</span> span <span style="color: #00AA00;">&gt;</span> br <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.divider</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#main_subtitles</span> <span style="color: #00AA00;">&gt;</span> span<span style="color: #3333ff;">:first-child </span><span style="color: #6666ff;">.divider</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#main_footer</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#main_footer</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">350px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#main_footer</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">210px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#update_interval_container</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">0.8em</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-4px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#356AA0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
table <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> table <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">50</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span> <span style="color: #993333;">solid</span> <span style="color: #993333;">gray</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.overlay</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">136px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.overlay</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">256px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#seconds_overlay</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#3F4C6B</span><span style="color: #00AA00;">;</span>
  -khtml-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span> -moz-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#minutes_overlay</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#CDEB8B</span><span style="color: #00AA00;">;</span>
  -khtml-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span> -moz-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#hours_overlay</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFFF88</span><span style="color: #00AA00;">;</span>
  -khtml-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span> -moz-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#days_overlay</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#B02B2C</span><span style="color: #00AA00;">;</span>
  -khtml-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span> -moz-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.5</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#counter_done</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">66px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">50</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  -khtml-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">;</span> -moz-opacity<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0.8</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#counter_done</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.0em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#counter_done</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">130px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">115px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.2em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ctr</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#countdown_box</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#countdown_box</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#countdown_box</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">40px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.unit</span> <span style="color: #00AA00;">&gt;</span> div <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.unit</span> <span style="color: #00AA00;">&gt;</span> div <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">58px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.unit</span> <span style="color: #00AA00;">&gt;</span> div <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #933;">204px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">36px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#days_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">60px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#hours_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">118px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#minutes_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">176px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#seconds_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">234px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#days_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#hours_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">46px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#minutes_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">82px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#seconds_box</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">118px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.unit_label</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">border-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddd</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.unit</span> span <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.unit</span> span <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">58px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.unit</span> span <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">36px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#days_box</span> span<span style="color: #00AA00;">&#91;</span>class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#B02B2C</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#seconds_box</span> span<span style="color: #00AA00;">&#91;</span>class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#3F4C6B</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#minutes_box</span> span<span style="color: #00AA00;">&#91;</span>class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#73880A</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#hours_box</span> span<span style="color: #00AA00;">&#91;</span>class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;unit_label&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#C79810</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#sw-wrapper</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;portrait&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#sw-frame</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">112px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>orient<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;landscape&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#sw-frame</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">8px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* alignment correction for Shiretoko */</span>
<span style="color: #6666ff;">.row</span> <span style="color: #00AA00;">&gt;</span> label <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
div<span style="color: #00AA00;">&#91;</span>class<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;row&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #00AA00;">&gt;</span> input<span style="color: #00AA00;">,</span>select <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">7px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>device<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;iphone&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#select_date_container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
body<span style="color: #00AA00;">&#91;</span>device<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;unknown&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #cc00cc;">#spinning_wheel_date_container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/08/10/countdown-iphone-webapp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fedora 11 Network Installation from GRUB</title>
		<link>http://www.technetra.com/2009/06/21/fedora-11-network-installation-from-grub/</link>
		<comments>http://www.technetra.com/2009/06/21/fedora-11-network-installation-from-grub/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 17:24:10 +0000</pubDate>
		<dc:creator>nilayan</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[fedora]]></category>

		<category><![CDATA[fedora11]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[installation]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=1163</guid>
		<description><![CDATA[Learn how to run a network installation of Fedora 11 using GRUB with a few simple commands.]]></description>
			<content:encoded><![CDATA[<p><a href="http://docs.fedoraproject.org/release-notes/f11/en-US/">Fedora 11 is finally out</a>. Now I want to install it on a system running Ubuntu 9.04 and dual-boot between both systems. This can easily be accomplished by configuring the <a href="http://www.gnu.org/software/grub/">GRUB boot loader</a> used by Ubuntu (and other popular Linux distributions, including Fedora). First I&#8217;ll setup a boot menu entry to launch the Fedora 11 installation program, <a href="http://fedoraproject.org/wiki/Anaconda">Anaconda</a> and then I will use Anaconda to perform a <a href="http://docs.fedoraproject.org/install-guide/f11/en-US/html/s1-begininstall-perform-nfs-x86.html">network installation</a> of Fedora 11. Note I will be using Grub as an intermediate step in the installation of Fedora and also as the final boot loader for both distributions.</p>
<p>When I want to try out or install the latest release of a Linux distribution, I prefer to use a network installation for a couple of reasons. First of all, I&#8217;m lazy &#8212; I don&#8217;t have to download the installation ISO images and then burn them to CDs or DVDs. This is a big plus. Second, its very easy to setup GRUB for a network installation. Finally, I can be more eco-friendly by not throwing out old CDs/DVDs every time a new release comes out, which is quite often with Linux distributions.</p>
<p>Basically, a network install downloads the installation packages for the Linux distribution over a network. So you&#8217;ll need a relatively fast, reliable Internet connection (e.g., broadband cable modem, DSL). If you have a slow connection, you&#8217;re better off using the CD/DVD installation method.</p>
<h2>First Steps</h2>
<p>To get started, I boot into my Ubuntu 9.04 system. I log in as <code>root</code> in a Gnome Terminal window. First, let&#8217;s modify the GRUB boot loader menu by adding an entry to boot into the Fedora 11 installation program, Anaconda. To do this, open the GRUB configuration file <code>/boot/grub/menu.lst</code> in a text editor. Now, find the first OS definition. Look for the first line that starts with the word <code>title</code>, followed by a short title/description. On my system the first OS definition looks like</p>
<pre>
title     Ubuntu 9.04, kernel 2.6.28-11
root      (hd0,2)
kernel    /boot/vmlinuz-2.6.28-11 root=UUID=a128e38d-9a45-49c3-9863-43e1b30671ac ro quiet splash
initrd    /boot/initrd.img-2.6.28-11
quiet
</pre>
<p>Let&#8217;s add the following lines just above this first OS definition.</p>
<pre>
title     Fedora 11 Installation
<span style="color:#d00;">root      (hd0,2)</span>
kernel    /boot/fedora11-vmlinuz
initrd    /boot/fedora11-initrd.img
</pre>
<p>You&#8217;ll need to change the device name on the line highlighted in <span style="color:#d00;">red</span>, to match your system&#8217;s configuration. Run the following Bash script to find the correct device name on your system and to print the resulting GRUB root command.</p>
<pre>bash -c 'A=abcdefghij D=$(mount|awk "/on \/ / {print \$1}") E=${D/*\/sd} DADDR=${A%${E:0:1}*} PART=$((${E:1}-1)) &amp;&amp; echo "root (hd${#DADDR},$PART)"'</pre>
<p>Next, we&#8217;ll download the Fedora 11 installation kernel (<code>vmlinuz</code>) and initial ramdisk (<code>initrd.img</code>) images from a Fedora mirror site. I&#8217;m using mirrors.kernel.org.</p>
<pre>
root@ubuntu:~# cd /boot
root@ubuntu:/boot# wget -q http://mirrors.kernel.org/fedora/releases/11/Fedora/i386/os/images/pxeboot/vmlinuz -O fedora11-vmlinuz
root@ubuntu:/boot# wget -q http://mirrors.kernel.org/fedora/releases/11/Fedora/i386/os/images/pxeboot/initrd.img -O fedora11-initrd.img
</pre>
<p>You should now have the two files <code>fedora11-vmlinuz</code> and <code>fedora11-initrd.img</code> in the <code>/boot</code> directory.</p>
<p>We&#8217;re ready to reboot the system. Remember to hit the &#8216;ESC&#8217; key to see the GRUB boot loader menu during the initial system startup phase. Select the entry titled &#8216;<strong>Fedora 11 Installation</strong>&#8216; to launch the Fedora 11 installation program.</p>
<p>Once the installation program has started, it will step through common configuration tasks to prepare your system for a network installation. Pay special attention to the network connection (Configure TCP/IP) and Fedora installation repository (URL Setup) configuration tasks. If you&#8217;re unfamiliar with network installations, take some time to understand the process by visiting the following pages from the Fedora Installation documentation.</p>
<ul>
<li><strong><a href="http://docs.fedoraproject.org/install-guide/f11/en-US/html/index.html">Fedora 11 Installation Guide</a></strong></li>
<li><strong><a href="http://docs.fedoraproject.org/install-guide/f11/en-US/html/s1-begininstall-perform-nfs-x86.html">Section 7.7: Performing a Network Installation</a></strong></li>
<li><strong><a href="http://docs.fedoraproject.org/install-guide/f11/en-US/html/s1-begininstall-url-x86.html">Section 7.9: Installing via FTP or HTTP</a></strong></li>
</ul>
<p>After completing the configuration steps, the actual installation process takes approximately 40 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/06/21/fedora-11-network-installation-from-grub/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hands-on with Zmanda Recovery Manager 3.0 on Ubuntu Server</title>
		<link>http://www.technetra.com/2009/05/03/hands-on-with-zmanda-recovery-manager-30-on-ubuntu-server/</link>
		<comments>http://www.technetra.com/2009/05/03/hands-on-with-zmanda-recovery-manager-30-on-ubuntu-server/#comments</comments>
		<pubDate>Sun, 03 May 2009 20:30:04 +0000</pubDate>
		<dc:creator>alolita</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[backups]]></category>

		<category><![CDATA[databases]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[technologyreview]]></category>

		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=1136</guid>
		<description><![CDATA[A hands-on review of Zmanda Recovery Manager 3.0 on Ubuntu Server.]]></description>
			<content:encoded><![CDATA[<p>In this article we present a hands-on try-out of the most important features of Zmanda Recovery Manager 3.0 (ZRM) on Ubuntu. We ran a series of backups and restores using a MySQL database for a popular multi-user WordPress blog. The primary database table (<code>wp_posts</code>) contained approximately 500K rows, averaging 2Kb per row. In order to run backups of our WordPress database, we first set up a ZRM backup server, as well as created a MySQL user account on our MySQL server host. The hardware and software configuration we used is shown in Table 1.</p>
<table class="data" style="width:100%;">
<thead>
<tr>
<th width="33%">&#160;</th>
<th width="33%">tahoe: ZRM Backup Server<br/><span style="font-size:0.8em;">(w/ Local MySQL instance)</span></th>
<th width="33%">bigsky: ZRM Backup Client<br/><span style="font-size:0.8em;">(Remote MySQL Instance)</span></th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Hostname</strong></td>
<td>tahoe</td>
<td>bigsky</td>
</tr>
<tr>
<td><strong>MySQL Server</strong></td>
<td>Community Edition v5.0.51a</td>
<td>Community Edition v5.0.67</td>
</tr>
<tr>
<td><strong>Operating System</strong></td>
<td>Ubuntu Server 8.04.1</td>
<td>Ubuntu Server 8.10</td>
</tr>
<tr>
<td><strong>Processor</strong></td>
<td>Intel Core 2 Duo 3Ghz</td>
<td>Intel Atom N230 1.6Ghz</td>
</tr>
<tr>
<td><strong>Memory</strong></td>
<td>8Gb</td>
<td>2Gb</td>
</tr>
<tr>
<td><strong>Storage</strong></td>
<td>1Tb RAID 5</td>
<td>750Gb SATA</td>
</tr>
</tbody>
<caption><strong>Table 1: Hardware / software configuration for ZRM 3.0 test drive</strong></caption>
</table>
<h2>Installing Zmanda Recovery Manager</h2>
<p>ZRM Enterprise edition provides two binary installation packages &#8212; ZRM server rapid installer (<code>ZRM-enterprise-3.0-installer.bin</code>) and ZRM client (<code>mysql-zrm-enterprise-client_3.0-1_all.deb</code>). First we will discuss the ZRM server installation, and then describe the ZRM client installation.</p>
<h3>ZRM Server Installation</h3>
<div id="attachment_1126" class="wp-caption aligncenter" style="width: 509px"><img src="/wp-content/uploads/zrm3_rapid_installer.gif" alt="Figure 2: ZMC Rapid Installer" title="Figure 2: ZMC Rapid Installer" width="499" height="129" class="size-full wp-image-1126" /><p class="wp-caption-text">Figure 2: ZMC Rapid Installer</p></div>
<p>The rapid installer is a graphical interface which steps you through installation of the server software components: the ZRM server, Zmanda Management Console and its dependencies, and ZRM command-line tools. To launch the installer, we ran the following commands on our ZRM backup server host (tahoe).</p>
<pre>
root@tahoe:~# chmod +x ZRM-enterprise-3.0-installer.bin
root@tahoe:~# ./ZRM-enterprise-3.0-installer.bin
</pre>
<p>The installation process takes only a few minutes, during which the user must select how the Zmanda Management Console web server is accessed, whether by http or by https. The installation process ends with a dialog box prompting the user to launch the ZMC.</p>
<p>To complete the ZRM server installation, we downloaded the Zmanda License Key file (zmanda_license) and placed it in &#8216;<code>/etc/zmanda/zmanda_license</code>&#8216;. We set file permissions to 644 (<code>chmod 644 /etc/zmanda/zmanda_license</code>) and changed file ownership to &#8216;root&#8217; (<code>chown root /etc/zmanda/zmanda_license</code>).</p>
<h3>ZRM Client Installation</h3>
<p>The ZRM client for Ubuntu is a Debian package that you install using standard package management tools such as <code>dpkg</code>. The ZRM client should be installed if the MySQL server being backed up (ZRM backup client) is running on a separate machine from the ZRM backup server and you want to run raw backups. To install the ZRM client, we executed the following command on our MySQL server host (bigsky).</p>
<pre>
root@bigsky:~# dpkg -i mysql-zrm-enterprise-client_3.0-1_all.deb
</pre>
<p>Note that we configured the &#8216;<code>mysql</code>&#8216; system user on our MySQL server host (bigsky) with <code>sudo</code> privileges by editing the &#8216;<code>/etc/sudoers</code>&#8216; file and adding a line &#8216;<code>mysql: ALL=(ALL) NOPASSWD: ALL</code>&#8216;. This grants the &#8216;<code>mysql</code>&#8216; user account permission to execute LVM system commands, necessary for Linux LVM-based filesystem snapshots.</p>
<p>Then we created a MySQL database user which ZRM used for backup and recovery on our MySQL server host (bigsky). Listing 2 shows the SQL statements we used to create the user account and grant privileges.</p>
<p><strong>Listing 2: SQL statements to create user account and setup privileges</strong></p>
<pre>
mysql&gt; GRANT LOCK TABLES, SELECT, FILE, CREATE, DROP, INDEX, \
    -&gt; SHUTDOWN, ALTER, INSERT, ALTER ROUTINE, CREATE ROUTINE, SUPER, RELOAD \
    -&gt; ON *.* TO 'zrmbackup'@'tahoe.local.pri' IDENTIFIED BY 'somepassword';
Query OK, 0 rows affected (0.00 sec)

mysql&gt; GRANT LOCK TABLES, SELECT, FILE, CREATE, DROP, INDEX, SHUTDOWN, \
    -&gt; ALTER, INSERT, ALTER ROUTINE, CREATE ROUTINE, SUPER, RELOAD \
    -&gt; ON *.* TO 'zrmbackup'@'bigsky.local.pri' IDENTIFIED BY 'somepassword';
Query OK, 0 rows affected (0.00 sec)

mysql&gt; FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
</pre>
<p>We set up SSH for login without passwords by using public keys for the &#8216;<code>mysql</code>&#8216; system user on our MySQL server host (bigsky). This enabled the use of SSH connections, by the default SSH copy plugin, between the ZRM backup server (tahoe) and our MySQL server host (bigsky) for backup and restore tasks.</p>
<h2>Doing backup and restore</h2>
<p>The steps below are listed out in detail to serve as an example of how backups and restores can be performed with ZRM on Ubuntu.</p>
<h3>Backup &#8212; Backup Level: Full, Backup Mode: Raw</h3>
<ol>
<li><strong>Create backup set</strong> &#8212; We created a new backup set using the &#8220;sets&#8221; screen within the &#8220;Admin&#8221; tab. In the &#8220;Create backup set&#8221; panel, we selected a ZRM userid from the &#8220;Backup Set Owner&#8221; drop-down list (<code>admin</code>). We then entered a &#8220;Backup Set Name&#8221; to identify this backup set (<code>wordpress_backup</code>). Finally, we saved the backup set configuration by clicking the &#8220;Add&#8221; button.</li>
<li><strong>Configure backup set</strong> &#8212; We clicked the &#8220;Backup&#8221; tab. Doing so gets us to the screen labeled &#8220;what&#8221;.
<ol>
<li><strong>what</strong> &#8212; We filled in values for each panel &#8212; &#8220;MySQL Server Parameters&#8221;, &#8220;MySQL User Parameters&#8221;, and &#8220;What to backup&#8221;. Then clicked the &#8220;Save&#8221; button.
<ul>
<li><em>MySQL Server Parameters</em> &#8212; select the &#8220;Server Type&#8221; (<em>MySQL server</em>), &#8220;Connection Type&#8221; (<em>Port</em>), &#8220;Port Number&#8221; (<em>3306</em>), &#8220;Host&#8221; (<em>bigsky.local.pri</em>), &#8220;MySQL Client Utilities Path&#8221; (<em>/usr/bin</em>)</li>
<li><em>MySQL User Parameters</em> &#8212; &#8220;Username&#8221; (<em>zrmbackup</em>), &#8220;Password&#8221; (<em>somepassword</em>), &#8220;SSL Options&#8221; (<em>leave blank</em>)</li>
<li><em>What to backup</em> &#8212; &#8220;Backup Source Type&#8221; (<em>Specific Database(s)</em>), &#8220;Select Database(s)&#8221; (mark checkbox next to <code>wordpress_db</code>).</li>
</ul>
</li>
<li><strong>where</strong> &#8212; In the &#8220;Backup Where Parameters&#8221; panel, we filled in values for &#8220;Destination Directory&#8221; (<em>/var/lib/mysql-zrm</em>), &#8220;Temporary Directory&#8221; (<em>/tmp</em>), and &#8220;Retention Policy&#8221; (<em>2 weeks</em>). Then clicked the &#8220;Save&#8221; button.</li>
<li><strong>when</strong> &#8212; In the &#8220;Backup Schedule&#8221; panel, we filled in values for &#8220;Backup Level&#8221; (<em>Full</em>), &#8220;Time Range&#8221; (<em>daily</em>), and &#8220;Backup Time&#8221; (<em>10Hr 15Mins</em>). Then clicked the &#8220;Add Schedule&#8221; button to save these settings.</li>
<li><strong>how</strong> &#8212; Although we did not modify the default values on this screen, you should double-check values for &#8220;Backup Mode&#8221;, &#8220;SSH User&#8221;, and &#8220;Email Address&#8221; (if you are using email notification).</li>
</ol>
</li>
<li><strong>Application configuration file backup</strong> &#8212; As part of this backup set, we wanted to preserve the WordPress configuration file &#8216;<code>wp-config.php</code>&#8216;. ZRM requires an intermediate text file that lists the full path to each configuration file to be backed up, separated by newlines. Therefore, we created &#8216;<code>/etc/mysql-zrm/wordpress_backup/app_conf_files_list</code>&#8216;, with the full path to <code>wp-config.php</code> on the first line. Next, we edited the ZRM backup set configuration file &#8216;<code>/etc/mysql-zrm/wordpress_backup/mysql-zrm.conf</code>&#8216; (on tahoe) and added the line &#8216;<code>config-file-list="/etc/mysql-zrm/wordpress_backup/app_conf_files_list"</code>&#8216;. Note that you can also dynamically generate the list of application configuration files using a pre-backup plugin script available from the Zmanda network.</li>
<li>With the steps above we had now scheduled a daily full raw backup of all the tables in the &#8216;<code>wordpress_db</code>&#8216; database every morning at 10:15am.</li>
</ol>
<div id="attachment_1127" class="wp-caption aligncenter" style="width: 460px"><img src="/wp-content/uploads/zrm3_backup_tab.gif" alt="Figure 3: ZMC Backup screen" title="Figure 3: ZMC Backup screen" width="450" height="284" class="size-full wp-image-1127" /><p class="wp-caption-text">Figure 3: ZMC Backup screen</p></div>
<h3>Backup &#8212; Backup Level: Incremental, Backup Mode: Raw</h3>
<p>Before running an incremental backup, we added some blog posts to our running WordPress instance, in effect modifying the underlying database.</p>
<ol>
<li><strong>Configure backup set</strong> &#8212; Using the &#8220;Backup Set&#8221; drop-down list at the top left corner of the ZMC, we selected &#8220;wordpress_backup&#8221;. Doing so displays the screen labeled &#8220;what&#8221; within the &#8220;Backup&#8221; tab. Next, we scheduled another backup job via the screen labeled &#8220;when&#8221;. In the &#8220;Backup Schedule&#8221; panel, we filled in values for &#8220;Backup Level&#8221; (<em>Incremental</em>), &#8220;Time Range&#8221; (<em>daily</em>), and &#8220;Backup Time&#8221; (<em>12Hr 00Mins</em>). Then we clicked the &#8220;Add Schedule&#8221; button.</li>
</ol>
<h3>Monitoring</h3>
<p>As we ran on-demand backups, we were able to track their progress using the monitoring feature available via the &#8220;Monitor&#8221; tab of the ZMC. The &#8220;Backup Run Details&#8221; pane is updated live as each phase of the backup completes.</p>
<h3>Restore</h3>
<ol>
<li><strong>Identify recovery point</strong> &#8212; Using the &#8220;db events&#8221; (viewer) within the &#8220;Report&#8221; tab of the ZMC, we clicked on the backup timestamp (TimeStamp: 21:53:24) hyperlink to begin configuring the details of the restore process. Clicking the timestamp hyperlink displayed the screen labeled &#8220;what&#8221; within the &#8220;Restore&#8221; tab.</li>
<li><strong>Configure restore settings</strong>
<ol>
<li><strong>what</strong> &#8212; Information on this screen notified us that all databases would be restored from the last successful full backup. We clicked the &#8220;Next Step&#8221; button at the bottom to proceed further.</li>
<li><strong>where</strong> &#8212; We reviewed the connectivity and user settings for the MySQL server to which the data would be restored. All the default values were left unchanged. We then clicked the &#8220;Next Step&#8221; button to proceed further.</li>
<li><strong>how</strong> &#8212; The settings on this screen such as &#8220;Temporary Directory&#8221;, &#8220;MySQL Shutdown Options&#8221;, and &#8220;Copy Plugin Parameters&#8221; specify how your data is restored. The default values were left unchanged. We clicked the &#8220;Next step&#8221; button.</li>
<li><strong>restore</strong> &#8212; Once we reviewed the restore settings on this screen, we clicked the &#8220;Restore&#8221; button to actually start the process.</li>
</ol>
</li>
<li>In a few easy steps we were able to successfully restore the WordPress database from a full raw backup.</li>
</ol>
<div id="attachment_1128" class="wp-caption aligncenter" style="width: 460px"><img src="/wp-content/uploads/zrm3_restore_tab.gif" alt="Figure 4: ZMC Restore screen" title="Figure 4: ZMC Restore screen" width="450" height="284" class="size-full wp-image-1128" /><p class="wp-caption-text">Figure 4: ZMC Restore screen</p></div>
<h3>Reports</h3>
<p>After running numerous backups and restores, the pre-defined reports we found most useful include the &#8220;Backup Status Report&#8221; and the &#8220;Application Impact Report&#8221;.</p>
<p><em>Application Impact Report</em> &#8212; Provides backup job statistics such as &#8220;Time Taken&#8221;, &#8220;Read Locks Time&#8221;, and &#8220;Flush Logs time&#8221; &#8212; all of which let you tune your backup schedules to avoid database peak usage periods.</p>
<p><em>Backup Status Report</em> &#8212; Gives you an at-a-glance status overview for every backup job that has been run. This can prove very useful for quickly tracking down error conditions across all your backup jobs.</p>
<h2>In Summary</h2>
<p>Our exercise to backup and restore a moderately sized WordPress MySQL database has demonstrated that Zmanda Recovery Manager 3.0 is a capable MySQL backup and recovery solution for the enterprise Ubuntu user. Whether you are a system administrator or a seasoned DBA, you can easily use ZRM&#8217;s friendly and functional GUI to schedule and run your MySQL data backups.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/05/03/hands-on-with-zmanda-recovery-manager-30-on-ubuntu-server/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zmanda Recovery Manager 3.0 for MySQL on Ubuntu Server</title>
		<link>http://www.technetra.com/2009/05/01/zmanda-recovery-manager-30-for-mysql-on-ubuntu-server/</link>
		<comments>http://www.technetra.com/2009/05/01/zmanda-recovery-manager-30-for-mysql-on-ubuntu-server/#comments</comments>
		<pubDate>Fri, 01 May 2009 07:12:30 +0000</pubDate>
		<dc:creator>alolita</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[backups]]></category>

		<category><![CDATA[databases]]></category>

		<category><![CDATA[enterprise]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[opensource]]></category>

		<category><![CDATA[technologyreview]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=1124</guid>
		<description><![CDATA[Zmanda brings its robust, well integrated database backup and recovery package to one of the most popular Linux distributions with its latest product release of Zmanda Recovery Manager version 3.0 for MySQL on Ubuntu.]]></description>
			<content:encoded><![CDATA[<p>Responding to growing demand for a professional level backup and recovery solution, Zmanda, a leading vendor for open source backup solutions, has introduced an Ubuntu server version of their Zmanda Recovery Manager (ZRM) for MySQL.</p>
<p>At LinuxWorld 2008 in San Francisco, 451 Group analyst Jay Lyman observed that Ubuntu will continue to gain acceptance in the enterprise as organizations increasingly use free, community-driven Linux distributions and grow their own in-house Linux expertise. As a bellwether example, Wikipedia has switched its 400 servers to Ubuntu.</p>
<p>MySQL is equally gaining in importance to the enterprise. This same Wikipedia is also powered by MySQL. Acquired by Sun in late 2007, MySQL has been propelled further and further into the big leagues. As larger enterprises adopt Ubuntu together with MySQL, the need for a robust, well integrated database backup solution only grows.</p>
<p>To meet the widest possible range of backup solution requirements, Zmanda offers three versions of ZRM for MySQL on Ubuntu: the ZRM Enterprise edition, the ZRM Cluster edition and a ZRM Community edition. In this article, we&#8217;ll take a tour of the features in the latest release of ZRM Enterprise edition 3.0 for Ubuntu Server. We&#8217;ll focus on the product&#8217;s core capabilities for database backup and recovery and then we&#8217;ll look at some new features &#8212; application configuration backup, full-text search in ZRM&#8217;s management console (ZMC) and support for 64-bit platforms.</p>
<h2>What is Zmanda Recovery Manager (ZRM)</h2>
<p>ZRM Enterprise edition 3.0 brings a feature-complete backup and recovery solution for MySQL databases to Ubuntu Server. In this section, we look at the major components of ZRM and then survey the most important product features. We&#8217;ll also describe the support options available for ZRM.</p>
<p>ZRM Enterprise edition 3.0 includes the following three components: Zmanda Management Console, a command line interface and a plugin framework.</p>
<div id="attachment_1125" class="wp-caption aligncenter" style="width: 460px"><img src="/wp-content/uploads/zrm3_login_screen.gif" alt="Figure 1: ZMC Login screen" title="Figure 1: ZMC Login screen" width="450" height="178" class="size-full wp-image-1125" /><p class="wp-caption-text">Figure 1: ZMC Login screen</p></div>
<p><strong>Zmanda Management Console (ZMC)</strong> &#8212; ZMC is a web-based console that provides an easy to use GUI wizard for essential backup and recovery tasks. ZMC controls reporting and monitoring for all tasks in ZRM. An interface with Zmanda Network enables easy access to the latest product documentation and context-sensitive help.</p>
<p>Core functions such as &#8220;Backup&#8221;, &#8220;Monitor&#8221;, &#8220;Report&#8221;, &#8220;Admin&#8221;, and &#8220;Restore&#8221; are presented as a tabbed interface in ZMC. The Backup and Restore tabs break down the respective processes into individual screens. For example, in the Backup tab you&#8217;ll see links for each step of the backup process labeled &#8220;what&#8221;, &#8220;where&#8221;, &#8220;when&#8221;, &#8220;how&#8221;, &#8220;summary&#8221;, respectively. As the user navigates through each screen, they fill in the necessary information and proceed to schedule or run the backup. Similarly, in the Restore tab, links for &#8220;what&#8221;, &#8220;where&#8221;, &#8220;how&#8221;, and &#8220;restore&#8221; are displayed at the top. The user navigates each screen to complete the recovery process. The other tabs &#8212; &#8220;Monitor&#8221;, &#8220;Report&#8221;, &#8220;Admin&#8221; &#8212; follow the same pattern, with links for related tasks under each tab.</p>
<p>Context-sensitive help is available throughout the ZMC by clicking on the question mark icon at the top left corner of each screen. Also, common error messages are hyperlinked to the Zmanda Network knowledge base, where you can find detailed information about the error message and how to resolve it.</p>
<p><strong>Command Line Interface (CLI)</strong> &#8212; The CLI provides an alternate scriptable interface to the major functionality of ZRM. Using the CLI tools, ZRM can be integrated with existing backup and recovery systems.</p>
<p><strong>Plugin Framework</strong> &#8212; ZRM&#8217;s capabilities can be extended with plugins. Pre-backup and post-backup plugins execute custom tasks before or after backup jobs. Copy plugins are used to specify the data transfer mechanism (e.g., ssh, socket) between the ZRM backup server and remote MySQL server. Filesystem snaphot plugins support NetApp SnapManager, Solaris ZFS and Veritas VxFS. Also, storage volume snapshot plugins support Linux LVM, Windows VSS, and EMC CLARiiON SnapView. Note that plugins for NetApp SnapManager, Veritas VxFS and EMC CLARiiON SnapView must be purchased separately. Other plugins are available for dynamic rescheduling of backups and binary log parsing.</p>
<h3>Core Features</h3>
<p>ZRM&#8217;s core features are database backup and recovery, monitoring, and running pre-defined and custom reports.</p>
<h4>Backup</h4>
<p>ZRM is a flexible platform that lets you to backup multiple databases and tables from one or more MySQL servers.</p>
<p>ZRM offers a variety of options for scheduling backups. You can schedule backups during planned downtime or run instantaneous hot backups without taking your MySQL server offline. You can request daily, weekly, and monthly backups from the &#8220;Backup Schedule&#8221; panel under the &#8220;Backup / When&#8221; screen of the ZMC. It is also possible to schedule hourly backups by defining multiple daily jobs. Once defined, backup schedules can be modified as needed, for example, to avoid database peak usage periods by postponing a backup job using the pre-scheduler plugin.</p>
<p>ZRM handles multiple storage engines including MyISAM, InnoDB, NDB, Archive, and Falcon. Depending on the storage engine being used by your database table, ZRM automatically selects the appropriate backup method. If you are using the InnoDB hotbackup tool from Oracle, ZRM provides seamless integration with a management console for the tool. ZRM has been tested with MySQL versions 4.1.x and 5.x. To support legacy database installations, ZRM can also work with MySQL 4.0.</p>
<p>For large databases you may want to use ZRM&#8217;s raw backup feature. Raw or physical backups are exact copies of your data. This shortens the time needed for backups as well as for restores. Calculating storage requirements ahead of time is easier since raw backups are just a copy of your database files. However, the major drawback of raw backups is that they can only be restored to the identical MySQL server version and machine architecture used to produce the original backup.</p>
<p>ZRM takes advantage of filesystem and storage volume snapshots when performing raw backups. Snapshots capture changes to your data at a given point in time without having to copy the entire filesystem or volume. As noted in the Plugin Framework section above, ZRM supports filesystem snapshots for NetApp SnapManager, Solaris ZFS, Veritas VxFS, as well as storage volume snapshots for Linux LVM, Windows VSS, and EMC CLARiiON SnapView.</p>
<p>Logical backups should be considered if you need to support multiple machine architectures and your data must be highly portable. Logical backups offer table level granularity and can be performed without taking the MySQL server offline. However, logical backups are slower because MySQL server must fetch the database structure and content and then convert the data into a logical format, usually a text file with SQL statements. Due to the conversion, storage requirements for logical backups may be larger than the size of the original data source. To offset the conversion overhead, ZRM can be configured to compress, using gzip or other compression tools, the backup images produced.</p>
<p>ZRM supports full and incremental backups. Full backups save a complete copy of your database or table, whereas incremental backups save only the changes since the last full or incremental backup.</p>
<p>Many MySQL-backed applications depend on custom configuration files. ZRM can back up these files along with application data stored in the database for quick recovery of the entire application. Examples of such applications include Wordpress, SugarCRM, and MediaWiki. In ZRM 3.0, this feature is available by manually editing the ZRM backup set configuration file <code>mysql-zrm.conf</code>.</p>
<p>To protect sensitive data, ZRM can perform secure backups of remote MySQL servers by using standard SSL encryption over-the-wire as well as by using on-disk GPG encryption. ZRM ensures backup integrity with checksums of the backup image.</p>
<h4>Recovery</h4>
<p>ZRM provides continuous data protection (CDP) by integrating filesystem snapshots as well as by tracking MySQL database binary logs. CDP backup captures all changes to your data to enable fast, point-in-time data recovery. ZMC performs point-in-time recovery using selective incremental restores derived from MySQL binary log positions. Alternatively, the user can specify a recovery point (e.g., 2008-12-23 11:15:32) via the &#8220;Restore&#8221; tab of the ZMC.</p>
<p>ZRM offers a fine granularity of control over data recovery ranging from the entire MySQL server, database, table, down to individual transactions.</p>
<p>The ZMC Visual Log Analyzer (DB events viewer) parses MySQL binary logs to drive an easy-to-use GUI for browsing the contents of incremental backups, identifying recovery points (e.g., specific transactions), and monitoring operational and security aspects of your database. Starting with ZRM 3.0, the keyword search feature in Visual Log Analyzer takes advantage of MySQL full-text searching to provide accurate results more quickly.</p>
<h4>Reporting</h4>
<p>ZRM offers a diverse range of reports to help you stay informed about the status of your backup and recovery jobs. Automated reports generated after each backup job summarize the status of the job with useful information such as backup type (e.g., logical or raw), backup level (e.g., full or incremental), performance statistics, and backup image location. If configured, ZRM will send backup reports via email in HTML or text format. Backup reports available via RSS can be used to show backup status within other applications. In addition to automated backup summary reports, multiple pre-defined reports provide commonly requested information about backup jobs. Each pre-defined report can be customized with over 30 backup and MySQL data fields to display information specific to your needs.</p>
<h2>Product Support Options</h2>
<p>Zmanda provides three levels of support (Basic, Standard, and Premium) for ZRM Enterprise edition customers. All support levels come with access to the Zmanda Network resources, security updates and feature upgrades, and with web-based technical support. Standard and Premium support levels offer telephone technical support with unlimited support incidents. Premium support adds 24&#215;7 technical support and guarantees a 3-hour incident support response time. Annual support pricing is based on the number of MySQL server instances being handled by ZRM.</p>
<h2>Conclusion</h2>
<p>ZRM 3.0 for MySQL on Ubuntu brings a polished, easy-to-use and full-featured, professional backup and recovery solution to Ubuntu, today&#8217;s most popular Linux distribution.</p>
<p>The Web-based management console lets you schedule and control backup and recovery tasks from the comfort of your favorite browser. There&#8217;s also a command line if you need it. Plugins let you extend ZRM. All the major MySQL storage engines are supported. There are also high performance options available, like raw backups and file system snapshots. Other features let you back up your application&#8217;s configuration files along with the databases it uses.</p>
<p>More advanced recovery facilities include CDP and fine grained, transaction level data recovery which can be initiated by an easy-to-use GUI log analyzer and events viewer. Details about backup and recovery jobs are easily tracked through pre-defined and ad-hoc reports. Finally, ZRM is bundled with a variety of customer assistance options ranging from Web to e-mail to telephone support.</p>
<p>With the release of ZRM 3.0, Zmanda provides features and support that meet the increasing needs of the enterprise for professional backup and recovery of MySQL on Ubuntu.</p>
<h2>Resources</h2>
<ol>
<li>Zmanda Recovery Manager (<a href="http://zmanda.com/backup-mysql.html">http://zmanda.com/backup-mysql.html</a>)</li>
<li>ZRM Wiki (<a href="http://mysqlbackup.zmanda.com/">http://mysqlbackup.zmanda.com/</a>)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/05/01/zmanda-recovery-manager-30-for-mysql-on-ubuntu-server/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Toward Cleaning Up Out-of-Date or Broken Examples In The GNU Bash Project</title>
		<link>http://www.technetra.com/2009/04/27/toward-cleaning-up-out-of-date-or-broken-examples-in-gnu-bash-project/</link>
		<comments>http://www.technetra.com/2009/04/27/toward-cleaning-up-out-of-date-or-broken-examples-in-gnu-bash-project/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 06:04:43 +0000</pubDate>
		<dc:creator>radkins</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[codemagic]]></category>

		<category><![CDATA[coprocessing]]></category>

		<category><![CDATA[gnu project]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=1049</guid>
		<description><![CDATA[Bash is an important and even critical software project. Yet it’s a shame that the project does not always keep its examples and illustrations up to date or even accurate.]]></description>
			<content:encoded><![CDATA[<p>I had great fun putting together the tutorial <a href="http://www.technetra.com/2009/04/26/discovering-web-access-latencies-using-bash-coprocessing/">Discovering Web Access Latencies Using Bash Co-Processing</a>. However, speaking about examples that demonstrate the fabulous features of <a href="http://www.gnu.org/software/bash/">GNU Bash</a>&#8230; </p>
<p>Bash is an important and even critical software project. Yet it&#8217;s a shame that the project does not always keep its examples and illustrations up to date or even accurate. The project should strive to showcase Bash&#8217;s latest features in an authoritative way. And it should prune any items that are no longer relevant or that don&#8217;t actually work. A case in point involves the <b>coproc</b> examples located in the <code>bash-4.0/examples/functions</code> directory. Now that there is support for rudimentary (i.e., single instance) coprocessing in Bash4, the old coproc examples should be updated with native implementations.</p>
<p>But wait, that&#8217;s not all. There are at least two problems with the illustration of coprocessing as currently shown in the GNU Bash project files. As seen in the coshell.README file, the synopsis for using the coproc.bash example function is:</p>
<h3>Figure 1. Excerpt from bash-4.0/examples/functions/coshell.README (DOES NOT WORK)</h3>
<pre>
...
Attached to the message you will find coprocess.bash and coshell.bash.
Here's a brief synopsis of use:

coprocess open telnet localhost
while coprocess read il ; do # &larr; PROBLEM 1
  echo "$il"
  case "$il" in
    *ogin:*)
      coprocess print 'user'
      ;;
    *ord:*)
      echo 'pass' |coprocess print --stdin
      ;;
    *$ *) # &larr; PROBLEM 2
      coprocess print 'exit'
      break
      ;;
  esac
done
coprocess close
...
</pre>
<p>The first problem with this example is that the Bash builtin <code>read</code> command, which <code>coprocess read</code> eventually calls, is by default in <b>line</b> mode which means that it normally won&#8217;t release characters for consumption until it receives a carriage return. Therefore, in this illustration, characters that are not released by a carriage return will not be seen by the body of the <code>case</code> statment and consequently the desired login and password responses will not be executed. A fix for this problem requires restructuring the program (see <a href="#figure2">Figure 2</a> below).</p>
<p>The second problem with this illustration is in the case statement itself. The &#8216;*$ *&#8217; pattern produces a syntax error because the space in the pattern needs to be escaped. This has been fixed in the version below.</p>
<p><a name="figure2"></a></p>
<h3>Figure 2. A corrected version of the coprocessing excerpt from bash-4.0/examples/functions/coshell.README</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
. .<span style="color: #000000; font-weight: bold;">/</span>coproc_orig.bash
&nbsp;
coprocess open telnet localhost
<span style="color: #666666; font-style: italic;"># initial read mode: blocks until read sees ':'</span>
<span style="color: #666666; font-style: italic;"># (responds to Login and Password prompts which</span>
<span style="color: #666666; font-style: italic;">#  are normally followed by ': ', not carriage returns)</span>
<span style="color: #000000; font-weight: bold;">while</span> coprocess <span style="color: #c20cb9; font-weight: bold;">read</span> -d: il ; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$il</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$il</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    <span style="color: #000000; font-weight: bold;">*</span>ogin<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      coprocess print <span style="color: #ff0000;">'lizbennett'</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span>ord<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'pride&amp;prejudice'</span> <span style="color: #000000; font-weight: bold;">|</span>coprocess print <span style="color: #660033;">--stdin</span>
      <span style="color: #7a0874; font-weight: bold;">break</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
coprocess print <span style="color: #ff0000;">'exit'</span>
<span style="color: #666666; font-style: italic;"># next read mode: blocks until read sees carriage return</span>
<span style="color: #000000; font-weight: bold;">while</span> coprocess <span style="color: #c20cb9; font-weight: bold;">read</span> il ; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$il</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$il</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    <span style="color: #666666; font-style: italic;"># just logs off at echo of first prompt</span>
    <span style="color: #000000; font-weight: bold;">*</span>$\ <span style="color: #7a0874; font-weight: bold;">exit</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">break</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
coprocess close</pre></td></tr></table></div>

<p>Now that we&#8217;ve fixed the example of the old approach to coprocessing, let&#8217;s put together some code to demonstrate the new way. The following is an updated &#8212; and correct <img src='http://www.technetra.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> &#8212; illustration of coprocessing as supported natively in Bash4. This example uses the new <code>coproc</code> command. It also handles user name and password input. In this example <code>coproc</code> invokes <b>telnet</b> to remotely execute a command given as a command line argument. The program can also run a stream of commands provided on stdin. Enjoy!</p>
<h3>Figure 3. Native Coprocessing Example Using Bash 4.0 <code>coproc</code> Command</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash4</span>
<span style="color: #666666; font-style: italic;"># Edit above line to point to where your Bash 4 executable lives</span>
<span style="color: #666666; font-style: italic;"># e.g., /bin/bash if you are running a distribution like Fedora 11</span>
<span style="color: #666666; font-style: italic;"># that supports the latest version of the shell</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Examples:</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#     Save this program as test_native_coproc.sh in the current directory,</span>
<span style="color: #666666; font-style: italic;">#     then run chmod +x test_native_coproc.sh,</span>
<span style="color: #666666; font-style: italic;">#     and then execute commands like the following:</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#     ./test_native_coproc.sh date</span>
<span style="color: #666666; font-style: italic;">#     echo -e &quot;date\nuname -r\nwho&quot; | ./test_native_coproc.sh -i -u darcy -p secret</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#######################################################################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># process command line arguments</span>
<span style="color: #007800;">OPTIND</span>=1
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> <span style="color: #ff0000;">&quot;ip:u:&quot;</span> c; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$c</span> <span style="color: #000000; font-weight: bold;">in</span>
    i<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">USE_STDIN</span>=y <span style="color: #000000; font-weight: bold;">;;</span>
    p<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">MYPASSWORD</span>=<span style="color: #007800;">$OPTARG</span> <span style="color: #000000; font-weight: bold;">;;</span>
    u<span style="color: #7a0874; font-weight: bold;">&#41;</span>	<span style="color: #007800;">MYUSER</span>=<span style="color: #007800;">$OPTARG</span> <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">shift</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #007800;">$OPTIND</span> - 1 <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">ARGS</span>=<span style="color: #ff0000;">&quot;$@&quot;</span>
<span style="color: #007800;">MYUSER</span>=<span style="color: #800000;">${MYUSER:-lizbennett}</span>
<span style="color: #007800;">MYPASSWORD</span>=<span style="color: #800000;">${MYPASSWORD:-pride&amp;prejudice}</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># set up telnet coprocess, log in and then execute a single command</span>
<span style="color: #666666; font-style: italic;"># or stream of commands if using stdin</span>
coproc telnet localhost
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> -d: <span style="color: #660033;">-u</span> <span style="color: #800000;">${COPROC[0]}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REPLY</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REPLY</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    <span style="color: #000000; font-weight: bold;">*</span>ogin<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MYUSER</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #800000;">${COPROC[1]}</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span>ord<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MYPASSWORD</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #800000;">${COPROC[1]}</span>
      <span style="color: #7a0874; font-weight: bold;">break</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #007800;">$USE_STDIN</span> <span style="color: #000000; font-weight: bold;">in</span>
  y<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #800000;">${COPROC[1]}</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$ARGS</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #800000;">${COPROC[1]}</span>
    <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;exit&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #800000;">${COPROC[1]}</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-u</span> <span style="color: #800000;">${COPROC[0]}</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$REPLY</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/04/27/toward-cleaning-up-out-of-date-or-broken-examples-in-gnu-bash-project/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Discovering Web Access Latencies Using Bash Co-Processing</title>
		<link>http://www.technetra.com/2009/04/26/discovering-web-access-latencies-using-bash-coprocessing/</link>
		<comments>http://www.technetra.com/2009/04/26/discovering-web-access-latencies-using-bash-coprocessing/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 14:03:03 +0000</pubDate>
		<dc:creator>radkins</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[bash]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[codemagic]]></category>

		<category><![CDATA[coprocessing]]></category>

		<category><![CDATA[dynamic scripting]]></category>

		<category><![CDATA[network latencies]]></category>

		<category><![CDATA[network programming]]></category>

		<category><![CDATA[programming]]></category>

		<category><![CDATA[scripting]]></category>

		<category><![CDATA[technical note]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=997</guid>
		<description><![CDATA[A technical note on using custom Bash script co-processing to generate and sort web access latencies for a user supplied list of hosts. It demonstrates a co-processing scheme that supports multiple, simultaneous co-processes and works in all versions of Bash.]]></description>
			<content:encoded><![CDATA[<p>This tutorial describes a Bash co-processing script <a href='#listing1'><code>latency.sh</code> (Listing 1)</a> that generates and sorts web access latencies for a user supplied list of hosts. It demonstrates a co-processing scheme that supports multiple, simultaneous co-processes and works in all versions of Bash.</p>
<p>It is an updated and parallelized version of an earlier script with a similar purpose, ffmirror.sh (see <a href='http://grulos.blogspot.com' target='_blank'>http://grulos.blogspot.com</a>). This new script uses customized Bash co-processing support for parallelization.  In addition, unlike the grulos script, this script does not require a Bash executable that has been compiled for special network redirection (that is, with compiled-in support for /dev/tcp, etc.).  You can use either tcp redirection or wget by specifying the desired mode as an argument on the command line.  This is good news for Debian and Ubuntu users because these distributions normally do not ship with net redirections enabled.  Note that while the Bash net redirection mode is a bit faster than launching and using wget, the latter may be more robust across many iterations of running the script against large lists of both existing and non-existent hosts.</p>
<p>Co-processing can reduce the performance profile of the principal work path of the script from linear, or O(n), to nearly O(1). The principal work path in our case is setting up host connections. In our implementation, collecting the latency results is still linear, but with a negligible run-time coefficient.</p>
<p><code>latency.sh</code> can be run with the default wget connection strategy:</p>
<pre>
$ ./latency.sh < myhostlist
</pre>
<p>or with the Bash network redirection strategy where available:</p>
<pre>
$ ./latency.sh tcp < myhostlist
</pre>
<p>Using the 20-entry sample host list at grulos.blogspot.com, the time to run this script on a normal desktop can be under 2 seconds, while the original code requires over 18 seconds.  This makes it feasible to run such a command under programs like /usr/bin/watch to create dynamically updating displays.</p>
<h3>Figure 1: Trial run <span style='font-weight:normal;'>(using the original sample host data from <a href='http://grulos.blogspot.com' target='_blank'>grulos.blogspot.com</a>)</span></h3>
<pre>
# time ./latency.sh tcp < new_hostlist.txt
04/26/2009 19:40:49 running tcp version
270ms www.google.com
540ms www.redhat.com
900ms www.kernel.org
940ms www.microsoft.com
940ms www.slackware.org
940ms www.w3.org
960ms www.ibm.com
990ms www.debian.org
1000ms www.wikipedia.org
1000ms www.gentoo.org
1050ms www.altavista.com
1070ms www.yahoo.com
1070ms www.dell.com
1090ms www.netbsd.org
1100ms www.freebsd.org
1220ms www.openbsd.org
1860ms www.linux.org
(not set) www.shakakalasfdksasdfasdf.com
(not set) www.oooooooos.com
(not set) www.tttttttttt.org

real	0m1.982s
user	0m0.156s
sys	0m0.160s
</pre>
<p>Note that hosts whose latencies cannot be computed, for whatever reason, are labelled as &#8216;(not set)&#8217;.</p>
<p>The Bash co-processing function presented in <a href='#listing2'>Listing 2</a> below for <code>coprocess.bash</code> is based on a similar example from the GNU Bash distribution. The difference is that this co-processing function implements a simple queuing facility to handle multiple simultaneous coprocesses. This is essential for us to be able to parallelize our web access  application. It also uses parameterized named pipes (fifos) for communicating between coprocesses.</p>
<p>The script <code>latency.sh</code> works under both Bash 3.x and Bash 4.0. It should be noted that the recent native support for co-processes in Bash 4.0 is limited to a single co-process at a time and so could not meet our need for multiple simultaneous web connections.</p>
<p><a name='listing1'></a></p>
<h3>Listing 1: <code>latency.sh</code></h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># latency.sh - Generate and sort web access latencies</span>
<span style="color: #666666; font-style: italic;">#              for a list of hosts</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Copyright (c) 2009 Technetra Corp</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    This program is free software: you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#    it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;">#    the Free Software Foundation, either version 3 of the License, or</span>
<span style="color: #666666; font-style: italic;">#    (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#    GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;">#    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;"># This is an updated and parallelized version</span>
<span style="color: #666666; font-style: italic;"># of ffmirror.sh (http://grulos.blogspot.com)</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># To run the default wget based version:</span>
<span style="color: #666666; font-style: italic;">#    ./latency.sh &lt; hostlist.txt</span>
<span style="color: #666666; font-style: italic;"># or for the tcp (Bash net redirection) version:</span>
<span style="color: #666666; font-style: italic;">#    ./latency.sh tcp &lt; hostlist.txt</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">###################################################################################</span>
&nbsp;
. .<span style="color: #000000; font-weight: bold;">/</span>coprocess.bash
&nbsp;
<span style="color: #007800;">WHICH_BACKGROUNDER</span>=<span style="color: #800000;">${1:-wget}</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$(date '+%m/%d/%Y %H:%M:%S')</span> running <span style="color: #007800;">$WHICH_BACKGROUNDER</span> version&quot;</span>
&nbsp;
chk_time <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">t</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&lt;/</span>proc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">uptime</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #007800;">t</span>=<span style="color: #800000;">${t%% *}</span>
  <span style="color: #007800;">t</span>=<span style="color: #800000;">${t/./}</span>
  <span style="color: #7a0874; font-weight: bold;">eval</span> $1=<span style="color: #007800;">$t</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
wget_backgrounder <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">host</span>=$1 a b
  <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$host</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">read</span> host
  chk_time a
  <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">--spider</span> <span style="color: #660033;">-T</span> 10 <span style="color: #660033;">-q</span> <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #007800;">$host</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> chk_time b
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$((b-a)</span>)|<span style="color: #007800;">$host</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
tcp_backgrounder <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">host</span>=$1 a b
  <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$host</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">read</span> host
  chk_time a
  <span style="color: #7a0874; font-weight: bold;">exec</span> 2<span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null 3<span style="color: #000000; font-weight: bold;">&lt;&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>tcp<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$host</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">80</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>
    <span style="color: #666666; font-style: italic;"># send a GET request and read 1st line of response</span>
    <span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;GET / HTTP/1.1<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>Host: <span style="color: #007800;">$host</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span>3 <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>
    <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #660033;">-u</span> 3 <span style="color: #660033;">-t</span> 10 <span style="color: #660033;">-a</span> response <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>  <span style="color: #7a0874; font-weight: bold;">exec</span> 3<span style="color: #000000; font-weight: bold;">&gt;&amp;</span>- <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> chk_time b
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$((b-a)</span>)|<span style="color: #007800;">$host</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;"># spin off parallel connections (the 'map' in 'MapReduce')</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #c20cb9; font-weight: bold;">hostname</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #666666; font-style: italic;"># provide hostname to wget or /dev/tcp as command-line argument</span>
  coprocess open qindex <span style="color: #800000;">${WHICH_BACKGROUNDER}</span>_backgrounder <span style="color: #ff0000;">&quot;<span style="color: #007800;">$hostname</span>&quot;</span>
  <span style="color: #666666; font-style: italic;"># alternatively, send hostname to wget or /dev/tcp via pipe:</span>
  <span style="color: #666666; font-style: italic;">#   coprocess open qindex wget_backgrounder</span>
  <span style="color: #666666; font-style: italic;">#   coprocess put $qindex &quot;$hostname&quot;</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># collect and process results (the 'reduce' in 'MapReduce')</span>
coprocess <span style="color: #c20cb9; font-weight: bold;">size</span> len
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">i</span>=<span style="color: #000000;">0</span>;i<span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #007800;">$len</span>;i++<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #666666; font-style: italic;"># read result from pipe</span>
  coprocess get <span style="color: #007800;">$i</span> c
  coprocess close <span style="color: #007800;">$i</span>
  <span style="color: #007800;">h</span>=<span style="color: #800000;">${c##*|}</span>
  <span style="color: #007800;">d</span>=<span style="color: #800000;">${c%%|*}</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> d <span style="color: #660033;">-ge</span> 0 <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;"># bucket sort variant</span>
    <span style="color: #007800;">e</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>d<span style="color: #000000; font-weight: bold;">*</span>100<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">until</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${slist[e]}</span>&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>e++<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
    slist<span style="color: #7a0874; font-weight: bold;">&#91;</span>e<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${d}</span>0ms <span style="color: #007800;">$h</span>&quot;</span> 
  <span style="color: #000000; font-weight: bold;">else</span>
    elist<span style="color: #7a0874; font-weight: bold;">&#91;</span>not_set++<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #ff0000;">&quot;(not set) <span style="color: #007800;">$h</span>&quot;</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;%sn&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${slist[@]}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #800000;">${#elist[*]}</span> <span style="color: #660033;">-ge</span> 0 <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span>
  <span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;%sn&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${elist[@]}</span>&quot;</span></pre></td></tr></table></div>

<p><a name='listing2'></a></p>
<h3>Listing 2: <code>coprocess.bash</code></h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># coprocess.bash</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    Copyright (c) 2009 Technetra Corp</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    This program is free software: you can redistribute it and/or modify</span>
<span style="color: #666666; font-style: italic;">#    it under the terms of the GNU General Public License as published by</span>
<span style="color: #666666; font-style: italic;">#    the Free Software Foundation, either version 3 of the License, or</span>
<span style="color: #666666; font-style: italic;">#    (at your option) any later version.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    This program is distributed in the hope that it will be useful,</span>
<span style="color: #666666; font-style: italic;">#    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span style="color: #666666; font-style: italic;">#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span style="color: #666666; font-style: italic;">#    GNU General Public License for more details.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    You should have received a copy of the GNU General Public License</span>
<span style="color: #666666; font-style: italic;">#    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">###################################################################################</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-i</span> FIFO_IN FIFO_OUT <span style="color: #007800;">FIFO_START</span>=60
<span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #660033;">-a</span> COPROCESSQ
&nbsp;
coprocess <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #007800;">N</span>=<span style="color: #ff0000;">&quot;$2&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">shift</span> <span style="color: #000000;">2</span>
  <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$N</span>&quot;</span> == <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:digit:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> 
      <span style="color: #007800;">FIFO_IN</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>N<span style="color: #000000; font-weight: bold;">*</span>2+FIFO_START<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #007800;">FIFO_OUT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>FIFO_IN+1<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
&nbsp;
    open<span style="color: #7a0874; font-weight: bold;">&#41;</span> 
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">M</span>=<span style="color: #800000;">${#COPROCESSQ[*]}</span>
      <span style="color: #007800;">FIFO_IN</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>M<span style="color: #000000; font-weight: bold;">*</span>2+FIFO_START<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #007800;">FIFO_OUT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>FIFO_IN+1<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">fifo</span>=<span style="color: #ff0000;">&quot;/var/tmp/coprocess.<span style="color: #007800;">$FIFO_IN</span>.<span style="color: #007800;">$FIFO_OUT</span>.$$.<span style="color: #007800;">$RANDOM</span>&quot;</span>
&nbsp;
      <span style="color: #c20cb9; font-weight: bold;">mkfifo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fifo</span>.in&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$?</span>
      <span style="color: #c20cb9; font-weight: bold;">mkfifo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fifo</span>.out&quot;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
        <span style="color: #007800;">ret</span>=<span style="color: #007800;">$?</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$fifo</span>.in&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$ret</span>
      <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
      <span style="color: #7a0874; font-weight: bold;">&#40;</span> <span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #ff0000;">&quot;rm -f <span style="color: #007800;">$fifo</span>.in <span style="color: #007800;">$fifo</span>.out&quot;</span> <span style="color: #000000;">0</span>; <span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #007800;">$fifo</span>.in <span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #007800;">$fifo</span>.out ; <span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
      COPROCESSQ<span style="color: #7a0874; font-weight: bold;">&#91;</span>M<span style="color: #7a0874; font-weight: bold;">&#93;</span>=<span style="color: #007800;">$fifo</span>
      <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$N</span>=<span style="color: #007800;">$M</span>&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;exec <span style="color: #007800;">$FIFO_IN</span>&gt;<span style="color: #007800;">$fifo</span>.in <span style="color: #007800;">$FIFO_OUT</span>&lt;<span style="color: #007800;">$fifo</span>.out&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">return</span> 0
      <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    close<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;exec <span style="color: #007800;">$FIFO_IN</span>&gt;&amp;- <span style="color: #007800;">$FIFO_OUT</span>&lt;&amp;-&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> = <span style="color: #ff0000;">&quot;-SIGPIPE&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">return</span> 1
      <span style="color: #7a0874; font-weight: bold;">return</span> 0
      <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    get<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">old_trap</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #660033;">-p</span> SIGPIPE<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #ff0000;">&quot;coprocess close <span style="color: #007800;">$N</span> -SIGPIPE&quot;</span> SIGPIPE
      <span style="color: #7a0874; font-weight: bold;">builtin</span> <span style="color: #c20cb9; font-weight: bold;">read</span> <span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;&amp;</span><span style="color: #007800;">$FIFO_OUT</span>
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">ret</span>=<span style="color: #007800;">$?</span>
      <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$old_trap</span>&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$ret</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    put<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">old_trap</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #660033;">-p</span> SIGPIPE<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">trap</span> <span style="color: #ff0000;">&quot;coprocess close <span style="color: #007800;">$N</span> -SIGPIPE&quot;</span> SIGPIPE
      <span style="color: #7a0874; font-weight: bold;">builtin</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$@&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #007800;">$FIFO_IN</span>
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">ret</span>=<span style="color: #007800;">$?</span>
      <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$old_trap</span>&quot;</span>
      <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #007800;">$ret</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
    <span style="color: #c20cb9; font-weight: bold;">size</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">M</span>=<span style="color: #800000;">${#COPROCESSQ[*]}</span>
      <span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$N</span>=<span style="color: #007800;">$M</span>&quot;</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/04/26/discovering-web-access-latencies-using-bash-coprocessing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Setup Ruby on Rails for Fedora 10 and 11</title>
		<link>http://www.technetra.com/2009/04/22/howto-setting-up-ruby-on-rails-for-fedora-10-and-11/</link>
		<comments>http://www.technetra.com/2009/04/22/howto-setting-up-ruby-on-rails-for-fedora-10-and-11/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 08:15:53 +0000</pubDate>
		<dc:creator>nilayan</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[fedora]]></category>

		<category><![CDATA[fedora10]]></category>

		<category><![CDATA[fedora11]]></category>

		<category><![CDATA[how-to]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[opensource]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[ruby]]></category>

		<category><![CDATA[rubyonrails]]></category>

		<category><![CDATA[setup]]></category>

		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=992</guid>
		<description><![CDATA[In this how-to, we will step through the process of setting up a Ruby on Rails development environment on Fedora 10 and Fedora 11 Beta.]]></description>
			<content:encoded><![CDATA[<p>In this how-to, we will step through the process of setting up a Ruby on Rails development environment on Fedora 10 and Fedora 11 Beta. To follow along, just cut and paste the commands in a terminal window.</p>
<p>The instructions in this how-to are based on a fresh installation of Fedora 10 (32-bit/64-bit) and Fedora 11 Beta  (32-bit only). During the installation process, we selected the &#8220;Software Development&#8221; package which includes the tools (e.g., gcc, svn, git, make) and libraries needed for building and compiling software.</p>
<h2>1. Development tools</h2>
<p>First, let&#8217;s check to see if you have the basic set of development tools &#8212; gcc, make and git. Although these tools are installed as part of the &#8220;Software Development&#8221; package, you can check if they are on your system by running &#8216;<code>which gcc make git</code>&#8216; at the command line.</p>
<pre>
[root@fc10 ~]# which gcc make git
/usr/lib/ccache/gcc
/usr/bin/make
/usr/bin/git
</pre>
<p>Note: On Fedora 10 64-bit systems, the full path to <code>gcc</code> is <code>/usr/bin/gcc</code>.</p>
<p>If the tools are not on your system, then you can install them by running the following command.</p>
<pre>
[root@fc10 ~]# yum install gcc make git
</pre>
<h2>2. Databases: MySQL, SQLite</h2>
<p>A typical Rails application is backed by a relational database. We will install both MySQL (v5.0.77) and SQLite (v3.5.9) for our environment. Recent versions of Rails default to using SQLite. If set up on your system, however, MySQL is also easily used.</p>
<pre>
[root@fc10 ~]# yum install mysql-server mysql-libs mysql-devel
[root@fc10 ~]# yum install sqlite sqlite-devel
</pre>
<h2>3. Ruby language</h2>
<p>Next, we&#8217;ll install the core packages for Ruby (v1.8.6.287). We&#8217;ll also need the two packages <strong>ruby-mysql</strong> and <strong>ruby-sqlite3</strong> for database access from Ruby programs.</p>
<pre>
[root@fc10 ~]# yum install ruby ruby-devel ruby-libs ruby-mode ruby-rdoc ruby-irb ruby-ri ruby-docs ruby-mysql ruby-sqlite3
</pre>
<h2>4. RubyGems</h2>
<p><a href="http://rubygems.org/">RubyGems</a> is the packaging system for Ruby applications and libraries. Each application or library is known as a <em>gem</em>. By default, gems are installed in &#8216;<code>/usr/lib/ruby/gems</code>&#8216; (&#8217;<code>/usr/lib64/ruby/gems</code>&#8216; on Fedora 10 64-bit systems). RubyGems lets you easily install and remove gems using the <code>gem</code> command. We&#8217;ll install the latest version of RubyGems (v1.3.2).</p>
<pre>
[root@fc10 ~]# wget -q http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz
[root@fc10 ~]# tar xzf rubygems-1.3.2.tgz
[root@fc10 ~]# cd rubygems-1.3.2
[root@fc10 rubygems-1.3.2]# ruby setup.rb
</pre>
<h2>5. Rails</h2>
<p>Now that we have a sparkling RubyGems toolset, the first <em>gem</em> we are going to install is the Rails (v2.3.2) web application framework. An advantage of installing Rails using the <code>gem</code> command is that package dependencies are resolved automatically.</p>
<pre>
[root@fc10 ~]# gem install rails
</pre>
<h2>6. Mongrel</h2>
<p>Rails provides <a href="http://www.webrick.org/">WEBrick</a>, a simple HTTP server that can be used to test applications during development. However, WEBrick is not suited for production environments. <a href="http://mongrel.rubyforge.org/">Mongrel</a> is a web server commonly used for Ruby web applications. A typical configuration consists of a Mongrel cluster (several Mongrel instances) behind a front-end Apache web server. We&#8217;ll install Mongrel 1.1.5.</p>
<pre>
[root@fc10 ~]# gem install mongrel mongrel_cluster
</pre>
<h2>7. JSON</h2>
<p>JSON (<a href="http://json.org/">JavaScript Object Notation</a>) is a lightweight data interchange format - a sort of &#8220;low-fat&#8221; alternative to XML. We&#8217;ll install the Ruby implementation of the JSON specification, <strong><a href="http://json.rubyforge.org/">json</a></strong> (v1.1.4). This allows the conversion of Ruby objects to JavaScript objects for use by clients running on the browser.</p>
<pre>
[root@fc10 ~]# gem install json
</pre>
<h2>8. SQLite3 Ruby</h2>
<p>The <strong><a href="http://sqlite-ruby.rubyforge.org/sqlite3/">sqlite3-ruby</a></strong> gem provides Ruby bindings for SQLite3 databases, the default database system for recent Rails environments. We&#8217;ll install version 1.2.4.</p>
<pre>
[root@fc10 ~]# gem install sqlite3-ruby
</pre>
<h2>9. Ruby MySQL</h2>
<p>The <strong>mysql</strong> gem provides a client-side MySQL API for  Ruby programs. Before we install the gem, we&#8217;ll need to create symbolic links in &#8216;<code>/usr/lib</code>&#8216; (&#8217;<code>/usr/lib64</code>&#8216; on Fedora 10 64-bit systems) to point to the MySQL client libraries installed in &#8216;<code>/usr/lib/mysql</code>&#8216; (&#8217;<code>/usr/lib64/mysql</code>&#8216; on Fedora 10 64-bit systems).</p>
<h3>Fedora 10</h3>
<pre>
[root@fc10 ~]# cd /usr/lib
[root@fc10 lib]# ln -s mysql/libmysqlclient.so
[root@fc10 lib]# ln -s mysql/libmysqlclient.so.15
[root@fc10 lib]# ln -s mysql/libmysqlclient_r.so
[root@fc10 lib]# ln -s mysql/libmysqlclient_r.so.15
</pre>
<p>Note: On Fedora 10 64-bit systems, the symbolic links should be created in &#8216;<code>/usr/lib64</code>&#8216;.</p>
<h3>Fedora 11 Beta</h3>
<pre>
[root@fc11 ~]# cd /usr/lib
[root@fc11 lib]# ln -s mysql/libmysqlclient.so
[root@fc11 lib]# ln -s mysql/libmysqlclient.so.16
[root@fc11 lib]# ln -s mysql/libmysqlclient_r.so
[root@fc11 lib]# ln -s mysql/libmysqlclient_r.so.16
</pre>
<p>Or for the brave, just run this on either Fedora 10 or 11:</p>
<pre>
[root@fc10 ~]# cd /usr/lib
[root@fc10 lib]# for f in mysql/libmysql*.so mysql/libmysql*.so.1[56]; do ln -s $f; done
</pre>
<p>Note: On Fedora 10 64-bit systems, the symbolic links should be created in &#8216;<code>/usr/lib64</code>&#8216;.</p>
<p>Now, we are ready to install the Ruby MySQL (v2.7) gem by running the following command.</p>
<pre>
[root@fc10 ~]# gem install mysql
</pre>
<h2>10. Riding the Rails</h2>
<p>Now it&#8217;s time to test your installation. A great way to do this is to follow the simple tutorial at &#8216;<a href="http://guides.rubyonrails.org/getting_started.html">Getting Started with Rails</a>&#8216;. Build the blogging application described there twice: once for SQLite3 and then again for MySQL. If the application can be built without errors, your database environments are set up properly.</p>
<p>That’s it! Your shiny new environment is waiting for you to build your next Rails application on Fedora using SQLite and MySQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/04/22/howto-setting-up-ruby-on-rails-for-fedora-10-and-11/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tutorial: Comparing Yahoo! and Google Maps APIs Side-by-Side</title>
		<link>http://www.technetra.com/2009/04/19/tutorial-comparing-yahoo-and-google-maps-apis-side-by-side/</link>
		<comments>http://www.technetra.com/2009/04/19/tutorial-comparing-yahoo-and-google-maps-apis-side-by-side/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 06:45:18 +0000</pubDate>
		<dc:creator>radkins</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[codemagic]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[maps]]></category>

		<category><![CDATA[maps api]]></category>

		<category><![CDATA[mashup]]></category>

		<category><![CDATA[tutorial]]></category>

		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=887</guid>
		<description><![CDATA[This tutorial compares the APIs of Yahoo! and Google maps by implementing a simple side-by-side map overlay rendered on a single HTML page. In this tutorial we will describe the details of using each API in JavaScript. Along the way we’ll compare a few of the differences between the two APIs.]]></description>
			<content:encoded><![CDATA[<p>This tutorial compares the APIs of Yahoo! and Google maps by implementing a simple side-by-side map overlay rendered on a single HTML page. In this tutorial we will describe the details of using each API in JavaScript. Along the way we&#8217;ll compare a few of the differences between the two APIs. This material is suitable to be incorporated as part of a computer science lab covering the AJAX interfaces to the Yahoo and Google Maps APIs.</p>
<p>Both the Yahoo! and Google Maps APIs are easy to work with. The packages are similar. Both started out being based on mapping technology provided by <a href='http://www.navteq.com'>Navteq</a>. Today Google uses Tom Tom&#8217;s <a href='http://www.teleatlas.com'>Tele Atlas</a> data, while Yahoo has continued to use Navteq. But both companies source geographic data from a variety of other partners as well. The Google Maps API seems to support a few more features, especially in navigation and map types. In addition, the Google maps generally offer greater detail and more up-to-date content, especially when rendering international regions.</p>
<p>In order to compare both packages side-by-side we initially wanted to run each Maps API together on a single page. Unfortunately, we could not load both APIs together due to namespace collisions. A workaround was to load each package into its own <a href='http://www.w3schools.com/TAGS/tag_iframe.asp'><code>iframe</code></a>.</p>
<p>With this approach we were able to develop a web page that shows an initial default geographic location, the Golden Gate Bridge, San Francisco, side-by-side in each of the Maps APIs. Each map is rendered with a sample of its package&#8217;s standard navigation controls. On each map, a marker is placed at the center when the map is initially rendered. On a <code>MouseOver</code> event, this marker will display a pop-up picture of the target location, which in our case is the Golden Gate Bridge. The pop-up image will also provide a link to its associated Wikipedia entry.
</p>
<p>The user can specify a new address for each map and is also be able to input different latitude and longitude coordinates to render a new map location. In addition, a fresh marker is placed anywhere on the map that the user clicks.</p>
<div id="attachment_010" class="wp-caption aligncenter" style="width: 650px"><img src="/mapsapis/images/comparing_maps_apis_application_screenshot.jpg" alt="Figure 1: Comparing Maps APIs Side-by-Side &#8212; Screenshot" title="Figure 1: Comparing Maps APIs Side-by-Side &#8212; Screenshot" width="640" height="710" class="size-full wp-image-010" /><p class="wp-caption-text">Figure 1: Comparing Maps APIs Side-by-Side &#8212; Screenshot</p></div>
<p style="font-size:2em;"><a href="/mapsapis/comparing_yahoo_and_google.html" target="_blank">Try this example</a></p>
<h2>Starting out with Yahoo! and Google Maps APIs</h2>
<p>An introduction to the AJAX Maps API for Yahoo! can be found at <a href="http://developer.yahoo.com/maps/ajax/">Yahoo! Maps Web Services - AJAX API Getting Started Guide</a>. An introduction to the Maps API for Google can be found at <a href="http://code.google.com/apis/maps/documentation/introduction.html">Google Maps API</a>.</p>
<p>You must obtain your own <a href='http://developer.yahoo.com/wsregapp/'>Yahoo! app ID</a> and <a href='http://code.google.com/apis/maps/signup.html'>Google key</a> in order to run the application presented in this tutorial on your own server.</p>
<h2>Overview of Our Application</h2>
<p>Our application resides in an HTML page that contains two <code>iframe</code> elements. The JavaScript application in each <code>iframe</code> can call functions in the other <code>iframe</code>. This feature is used to synchronize the two maps. Cross-frame communication is limited to using simple numeric and string values as arguments to the method calls; complex parameters such as objects cannot be supported.</p>
<div id="attachment_020" class="wp-caption aligncenter" style="width: 650px"><img src="/mapsapis/images/comparing_maps_apis_application_design.jpg" alt="Figure 1: Comparing Maps APIs Side-by-Side &#8212; Overview" title="Figure 2: Comparing Maps APIs Side-by-Side &#8212; Overview" width="640" height="534" class="size-full wp-image-020" /><p class="wp-caption-text">Figure 2: Comparing Maps APIs Side-by-Side &#8212; Overview</p></div>
<h2>Parent Page</h2>
<h3<code>IFRAME</code> layout</h3>
<p>The parent page that defines the <code>iframe</code> layout for our application, as depicted in Figure 1, is shown in the following listing:</p>
<h4>Listing 1: Parent page with <code>iframe</code> layout</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span>
<span style="color: #00bbdd;">          &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Side-by-Side Yahoo! and Google Maps<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span> 
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span> 
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 844px; background-color: #ccc;&quot;</span>&gt;</span> 
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'text-align: center; color: white;'</span>&gt;</span>
        Side-by-Side  Yahoo! and Google Map APIs
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 844px;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yahoo_map_frame.html&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;yahoo&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border: none; width: 420px; height: 800px; position: absolute;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;google_map_frame.html&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;google&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border: none; width: 420px; height: 800px; float: right;&quot;</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<h2>Map Application Walkthrough</h2>
<p>In this section we will explain various details about how our application is constructed and how it uses each Maps API package. Full listings for each API solution are presented at the <a href="#complete_listings">end of the tutorial</a>.</p>
<h3>Loading the Maps API</h3>
<p>Each <code>iframe</code> loads its own Maps API package. The following &lt;script&gt; tag loads the Google Maps API by supplying the required key and sensor flag values. The sensor flag notifies Google about whether a sensor is being used to determine the user&#8217;s location.</p>
<h4>Listing 2: Loading the Google Maps API package</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://maps.google.com/maps?file=api&amp;v=2&amp;key=[YOUR GOOGLE MAPS API KEY]&amp;sensor=[Are you using a location sensor? true or false]&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
...</pre></div></div>

<p>The Yahoo! Maps API is loaded in a similar manner but doesn&apos;t require the sensor notification parameter.</p>
<h4>Listing 3: Loading the Yahoo! Maps API package</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://api.maps.yahoo.com/ajaxymap?v=3.8&amp;appid=[YOUR YAHOO! MAPS API KEY]&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>  
...</pre></div></div>

<h3>Setting Up Globals</h3>
<p>After loading the Google or Yahoo! Maps API, each map application sets up a small number of global variables including <code>defaultGeoTargets</code>, <code>$EL</code>, and <code>myMap</code>.</p>
<p>The global variable <code>defaultGeoTargets</code> holds information about the features we want to highlight on the map. It is an array of hash literals containing address, geolocation and html values for use by the popup information windows associated with map markers.</p>
<p>Three well known landmarks will be featured on our map, the <b>Golden Gate Bridge</b> in San Francisco, the <b>Hallepoort Gate</b> in Brussels and the ancient <b>Ile de la Cite</b> of Paris. The literal array (of hash literals) assigned to <code>defaultGeoTargets</code> can easily be extended to add more landmarks. Alternatively, other data sources such as <code>JSON</code> could be used to populate the <code>defaultGeoTargets</code> array.</p>
</p>
<h4>Listing 4: <code>defaultGeoTargets</code> global function literal</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
  <span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
    <span style="color: #003366; font-weight: bold;">var</span> defaultGeoTargets <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Golden Gate Bridge, San Francisco'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">37.833</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:-</span><span style="color: #CC0000;">122.474</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">37.805</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:-</span><span style="color: #CC0000;">122.482</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Golden_Gate_Bridge' target='_blank'&gt;&lt;img src='/images/sf_bridge_small.jpg' width='160px' height='120px'&gt;&lt;/a&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Hallepoort, Brussels'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">50.834</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:</span><span style="color: #CC0000;">4.345</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">50.833</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:</span><span style="color: #CC0000;">4.344</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Halle_Gate' target='_blank'&gt;&lt;img src='/images/hallepoort_1612.jpg' width='120px' height='160px'&gt;&lt;/a&gt;&lt;span style='position: absolute;'&gt;&lt;p&gt;&amp;nbsp;Hallepoort&lt;br /&gt;&amp;nbsp;in 1612.&lt;/p&gt;&lt;/span&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Ile de la Cite, Paris'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">48.86</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:</span><span style="color: #CC0000;">2.349</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">48.85</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:</span><span style="color: #CC0000;">2.341</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Ile_de_la_Cite' target='_blank'&gt;&lt;img src='/images/ile_de_la_cite.jpg' width='200px' height='150px'&gt;&lt;/a&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
...</pre></div></div>

<p>The second global variable <code>$EL</code> is simply a convenience function for easily accessing the client JavaScript function <code>document.getElementById()</code>.</p>
<h4>Listing 5: <code>$EL</code> convenience function</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
    <span style="color: #003366; font-weight: bold;">var</span> $EL <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
...</pre></div></div>

<h3>Our Application Encapsulated as a JavaScript Function Literal</h3>
<p>The third and last of our global variables <code>myMap</code> holds our principal data structure for interfacing with the specific Maps API we have selected, Google or Yahoo!. It uses the technique of JavaScript function closure to isolate its namespace, retain state, and to export public methods to its caller. The public methods are contained in an associative array object returned and assigned to <code>myMap</code>. The public methods exported include <code>.initMap</code>, <code>.showMap</code>, <code>.reMap</code>, <code>.remoteRemap</code> and <code>.changeAddress</code>. All other methods and attributes within the closure context are effectively private. Note that the variable <code>myMap</code> is assigned the result of executing an anonymous function literal immediately after it has been read in by the browser (notice the trailing parentheses after the function literal definition). The function literal then sets up the closure context and returns the associative array of public function literals.</p>
<h4>Listing 6: How JavaScript builds the <code>myMap</code> function closure and returns a hash of public functions</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
    <span style="color: #003366; font-weight: bold;">var</span> myMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #006600; font-style: italic;">// function closure environment</span>
      <span style="color: #006600; font-style: italic;">//   private attributes</span>
      <span style="color: #006600; font-style: italic;">//   private interface adapters</span>
      <span style="color: #006600; font-style: italic;">//   private application functions</span>
      <span style="color: #006600; font-style: italic;">// return {</span>
      <span style="color: #006600; font-style: italic;">//   hash of public functions</span>
      <span style="color: #006600; font-style: italic;">// }(); &lt;--- parentheses cause immediate execution of function literal</span>
    <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h3>Private Attributes</h3>
<p>The function literal assigned to <code>myMap</code> starts out by defining several private variables including <code>map</code> and <code>targetFeatures</code>. These private variables are retained as attributes of the function closure context. In our application, they are initialized by calling the public function <code>.initMap</code> from the <code>onLoad</code> event attribute of the <code>HTML</code> <code>body</code> element. The private variable <code>map</code> will hold the basic map structure allocated by the selected underlying Maps API. The variable <code>targetFeatures</code> will be assigned a singleton associative array that contains the proximity function, <code>.isNearby</code> which we will examine in detail in the section <a href='#private_application_functions'>Private Application Functions</a> below. The variable <code>DONT_PAN</code> is used as a self-documenting constant for requesting that the <code>panAndMark</code> function temporarily turn off map panning. We will look at the function <code>panAndMark</code> in a moment.</p>
<h4>Listing 7: The private attributes of <code>myMap</code>&apos;s function closure</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
    <span style="color: #003366; font-weight: bold;">var</span> myMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> targetFeatures<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> DONT_PAN <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
...</pre></div></div>

<p><a name='private_interface_adapters'></a></p>
<h3>Private Interface Adapters</h3>
<p>The next section of <code>myMap</code> defines wrappers around the underlying Maps APIs for Yahoo and Google. These functions are adapted to each API.</p>
<p>The following table shows the relationship between our private interface adapters and the corresponding functions in the Yahoo! and Google packages.</p>
<h4>Table 1: Wrappers for selected Maps API calls</h4>
<table style="border-collapse:separate;border-spacing:4px;border:1px solid #eee;">
<tr>
<th style='font-weight: bold;' width="200">Private Interface Adapter</th>
<th style='font-weight: bold;' width="300">Yahoo! Maps API</th>
<th style='font-weight: bold;'>Google Maps API</th>
</tr>
<tr>
<td>allocMap</td>
<td>new YMap</td>
<td>new GMap2</td>
</tr>
<tr>
<td>applyUIControls</td>
<td>addTypeControl, addZoomLong, addPanControl</td>
<td>setUIToDefault, addControl</td>
</tr>
<tr>
<td>browserIsCompatible</td>
<td>return YMAPPID</td>
<td>GBrowserIsCompatible</td>
</tr>
<tr>
<td>captureEvent</td>
<td>YEvent.Capture</td>
<td>GEvent.addListener</td>
</tr>
<tr>
<td>createMarker</td>
<td>new YMarker</td>
<td>new GMarker</td>
</tr>
<tr>
<td>eraseOverlays</td>
<td>removeMarkersAll</td>
<td>clearOverlays</td>
</tr>
<tr>
<td>getZoomLevel</td>
<td>getZoomLevel</td>
<td>getZoom</td>
</tr>
<tr>
<td>makePointFromFields</td>
<td>new YGeoPoint</td>
<td>new GLatLng</td>
</tr>
<tr>
<td>mouseClickEventType</td>
<td>EventsList.MouseClick</td>
<td>&#8220;click&#8221;</td>
</tr>
<tr>
<td>mouseOverEventType</td>
<td>EventsList.MouseOver</td>
<td>&#8220;mouseover&#8221;</td>
</tr>
<tr>
<td>onClick callback</td>
<td>function(_e, _c)</td>
<td>function(overlay, point)</td>
</tr>
<tr>
<td>onEndMapDraw callback</td>
<td>getCenterLatLon</td>
<td>&#8212;</td>
</tr>
<tr>
<td>openInfoWindow</td>
<td>openSmartWindow</td>
<td>openInfoWindowHtml</td>
</tr>
<tr>
<td>pLat</td>
<td>p.Lat</td>
<td>p.y</td>
</tr>
<tr>
<td>pLon</td>
<td>p.Lon</td>
<td>p.x</td>
</tr>
<tr>
<td>panToPt</td>
<td>panToLatLon</td>
<td>panTo</td>
</tr>
<tr>
<td>zoomAndCenter</td>
<td>drawZoomAndCenter</td>
<td>getLatLng, panTo</td>
</tr>
</table>
<p>For our application, it is convenient to set default zoom level values in our interface adapter <code>zoomAndCenter</code>. This enables a common calling signature using a minimum number of arguments. It also fixes a problematic default zoom level in the Google Maps API. For example, our <code>zoomAndCenter</code> interface adapter can be called with 1 argument (the address to be resolved) from either a Yahoo! or a Google map application. In the case of the Yahoo! map application, we default a missing zoom level parameter to level 5 (city scale); for Google, we default the parameter to 13 (their zoom level for city). In contrast, a missing zoom level parameter to the underlying Maps API is defaulted to 5 for Yahoo! but is defaulted to 0 for Google. Of course, this native Google default is not very useful.</p>
<p>The interface adapter section of <code>myMap</code> for each Maps API is listed below, first for Google and then for Yahoo!.</p>
<h4>Listing 8: Interface Adapters for Google Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #009966; font-style: italic;">/* Begin Google Interface Adapters */</span>
      <span style="color: #003366; font-weight: bold;">var</span> allocMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> GMap2<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> applyUIControls <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map.<span style="color: #660066;">setUIToDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addControl</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GOverviewMapControl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// Google provides an interface to query whether the current browser is supported.</span>
      <span style="color: #006600; font-style: italic;">// A similar (but possibly unreliable) test can be simulated using the Yahoo! API.</span>
      <span style="color: #006600; font-style: italic;">// See below.</span>
      <span style="color: #003366; font-weight: bold;">var</span> browserIsCompatible <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> GBrowserIsCompatible<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> captureEvent <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> GEvent.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> createMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> GMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> eraseOverlays <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">clearOverlays</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> getZoomLevel <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">getZoom</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> makePointFromFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> GLatLng<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">,</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseClickEventType <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseOverEventType <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;mouseover&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> onClick <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>overlay<span style="color: #339933;">,</span> point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> openInfoWindow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>mrkr<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> mrkr.<span style="color: #660066;">openInfoWindowHtml</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLat <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">y</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">x</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> panToPt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">panTo</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// In Google, zooming and centering using address lookup must be implemented</span>
      <span style="color: #006600; font-style: italic;">// with an asynchronous callback attached to the .getLatLng method.</span>
      <span style="color: #006600; font-style: italic;">// While in Yahoo, the callback occurs when the endMapDraw event is fired.</span>
     <span style="color: #003366; font-weight: bold;">var</span> zoomAndCenter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> z<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GClientGeocoder<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getLatLng</span><span style="color: #009900;">&#40;</span>
          address<span style="color: #339933;">,</span>
          <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>address <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; not found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
              map.<span style="color: #660066;">setCenter</span><span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> z <span style="color: #339933;">||</span> 13<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// default to city view</span>
              panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> DONT_PAN<span style="color: #009900;">&#41;</span>
              showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              <span style="color: #006600; font-style: italic;">// alert(&quot;Current Google zoom level: &quot;+getZoomLevel());</span>
            <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #009966; font-style: italic;">/* End Google Interface Adapters */</span>
...</pre></div></div>

<h4>Listing 9: Interface Adapters for Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #009966; font-style: italic;">/* Begin Yahoo! Interface Adapters */</span>
      <span style="color: #003366; font-weight: bold;">var</span> runOnceOnEndMapDraw <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> allocMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YMap<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> applyUIControls <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map.<span style="color: #660066;">addTypeControl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addZoomLong</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addPanControl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// Google provides an interface to query whether the current browser is supported.</span>
      <span style="color: #006600; font-style: italic;">// A similar (but possibly unreliable) test can be simulated using the Yahoo! API.</span>
      <span style="color: #003366; font-weight: bold;">var</span> browserIsCompatible <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> YMAPPID<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> captureEvent <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> YEvent.<span style="color: #660066;">Capture</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> createMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> createPoint <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YGeoPoint<span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> endMapDrawEventType <span style="color: #339933;">=</span> EventsList.<span style="color: #660066;">endMapDraw</span><span style="color: #339933;">;</span> 
      <span style="color: #003366; font-weight: bold;">var</span> eraseOverlays <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">removeMarkersAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// var getZoomLevel = function() { map.getZoomLevel(); }</span>
      <span style="color: #003366; font-weight: bold;">var</span> makePointFromFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YGeoPoint<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">,</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseClickEventType <span style="color: #339933;">=</span> EventsList.<span style="color: #660066;">MouseClick</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseOverEventType <span style="color: #339933;">=</span> EventsList.<span style="color: #660066;">MouseOver</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> onClick <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>_e<span style="color: #339933;">,</span> _c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> point <span style="color: #339933;">=</span> createPoint<span style="color: #009900;">&#40;</span> _c.<span style="color: #660066;">Lat</span><span style="color: #339933;">,</span> _c.<span style="color: #660066;">Lon</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// In Yahoo!, the endMapDraw event is fired after address lookup</span>
      <span style="color: #006600; font-style: italic;">// and map centering have completed.</span>
      <span style="color: #003366; font-weight: bold;">var</span> onEndMapDraw <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>runOnceOnEndMapDraw <span style="color: #339933;">&gt;</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          runOnceOnEndMapDraw <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
          <span style="color: #003366; font-weight: bold;">var</span> point <span style="color: #339933;">=</span> map.<span style="color: #660066;">getCenterLatLon</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> DONT_PAN<span style="color: #009900;">&#41;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> openInfoWindow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>mrkr<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> mrkr.<span style="color: #660066;">openSmartWindow</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLat <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">Lat</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">Lon</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> panToPt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">panToLatLon</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> zoomAndCenter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> z<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          map.<span style="color: #660066;">drawZoomAndCenter</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> z <span style="color: #339933;">||</span> 5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// default to city view </span>
          <span style="color: #006600; font-style: italic;">// alert(&quot;Current Yahoo zoom level: &quot;+getZoomLevel());</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #009966; font-style: italic;">/* End Yahoo! Interface Adapters */</span>
...</pre></div></div>

<p><a name='private_application_functions'></a></p>
<h3>Private Application Functions</h3>
<p>The next section of our application implements more private functions that we use internally. With minor exceptions, these are the same for both the Yahoo! and Google maps APIs. The previously defined wrapper functions help maintain this close similarity.</p>
<p>Let&#8217;s look at each private function in turn.</p>
<h3><code>showPoint</code></h3>
<p><code>showPoint</code> sets the values of the fields for <b>Lattitude</b> and <b>Longitude</b> on the HTML page (see Figure 1). Note that the attribute names within a <code>point</code> object are different between Yahoo! and Google. Therefore we use the wrapping functions <code>pLat</code> and <code>pLon</code> to preserve the same high level interface across Yahoo! and Google.</p>
<h4>Listing 10: <code>showPoint</code> private function</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #003366; font-weight: bold;">var</span> showPoint <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h3><code>setFields</code></h3>
<p><code>setFields</code> sets the visible input fields for <b>Lattitude</b> and <b>Longitude</b> to new values.</code></p>
<h4>Listing 11: <code>setFields</code> private function</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #003366; font-weight: bold;">var</span> setFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> lat<span style="color: #339933;">;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> lon<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h3><code>panAndMark</code></h3>
<p><code>panAndMark</code> clears the map of any previous markers and subsequently positions the map to the point indicated by the first parameter <code>p</code>. Then a new marker is created at that point. If this marker is near the bounding box of one of the target features (e.g., Golden Gate Bridge, Hallepoort or Ile de la Cite), an information window is attached to the marker, using our wrapper function <code>openInfoWindow</code>, and will be displayed when the marker gets a <code>MouseOver</code> event. The second argument to  <code>panAndMark</code>, <code>dont_pan</code>, controls whether to pan to the given point during the function execution. Avoiding a repeat pan operation is useful when the underlying API has already centered on the desired point.</p>
<h4>Listing 12: <code>panAndMark</code> private function</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #003366; font-weight: bold;">var</span> panAndMark <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> dont_pan<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        eraseOverlays<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>dont_pan<span style="color: #009900;">&#41;</span> panToPt<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> createMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> targetFeatures.<span style="color: #660066;">isNearby</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          captureEvent<span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> mouseOverEventType<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            openInfoWindow<span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        map.<span style="color: #660066;">addOverlay</span><span style="color: #009900;">&#40;</span>marker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h3><code>setTargetFeatures</code></h3>
<p>The next private function is a bit more complex. When executed, the function literal which is assigned to <code>setTargetFeatures</code> creates a closure for its argument <code>targets</code> and exports a function literal <code>.isNearby</code> to its caller. Because of closure context, the exported function <code>.isNearby</code> continues to have access to <code>targets</code> when invoked later to test the proximity between a marker and a target. In the case of our example, the target feature list is contained in the global literal array <code>defaultGeoTargets</code>. The feature list, however, could just as easily have been obtained from an alternative source like JSON. Here, the advantage of applying closure to the argument <code>targets</code> is that the function does not need to know anything about, and is thereby decoupled from, the structure of the caller and the global environment.</p>
<p>When called, the exported function <code>.isNearby</code> simply iterates through the target list and checks to see if the given point <code>p</code> is contained within the bounding box of each target in turn. If so, the HTML string associated with that target is returned to the caller. In our example, this HTML will be rendered in the marker pop up information window when the marker is activated by a <code>MouseOver</code> event.</p>
<p>As a side effect, when the function literal is called from <code>.initMap</code>, it also sets the value of the address field in the application&#8217;s HTML body to the first element of the first target. This becomes the address which will be rendered as the initial location of the map.</p>
<h4>Listing 13: <code>setTargetFeatures</code> private function</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #003366; font-weight: bold;">var</span> setTargetFeatures <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>targets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>targets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">address</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// first element of first target is default address</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
          isNearby<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> found <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> targets.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              b <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">geobox</span><span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">E</span> <span style="color: #339933;">&amp;&amp;</span> pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> b.<span style="color: #660066;">W</span> <span style="color: #339933;">&amp;&amp;</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">N</span> <span style="color: #339933;">&amp;&amp;</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> b.<span style="color: #660066;">S</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                found <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">html</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
              <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">return</span> found<span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h3>Public Application Functions</h3>
<p>The next section of our application embodies the public interface of our application. When the JavaScript interpreter reads the function literal on the right hand side of the  assignment statement for <code>myMap</code>, it executes the function literal and assigns the returned object to <code>myMap</code>. The returned object is an associative array containing the public functions of our maps application.</p>
<h4>Listing 14: Hash of public functions (template)</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">//</span>
        <span style="color: #006600; font-style: italic;">// public functions expressed as a literal hash object</span>
        <span style="color: #006600; font-style: italic;">//</span>
        initMap<span style="color: #339933;">:</span> ...
        <span style="color: #660066;">showMap</span><span style="color: #339933;">:</span> ...
        <span style="color: #660066;">reMap</span><span style="color: #339933;">:</span> ...
        <span style="color: #660066;">remoteMap</span><span style="color: #339933;">:</span> ...
        <span style="color: #660066;">changeAddress</span><span style="color: #339933;">:</span> ...
      <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<p>The public functions are similar across both APIs. Each public function is described in the following sections.</p>
<h4><code>initMap</code> Public Function</h4>
<p>The public function <code>.initMap</code> first checks to see if the current browser is compatible with the selected Maps API. In the Google Maps API, this function is explicitly supported. In the Yahoo package, there does not appear to be a way to programmatically tell if the current browser is supported, so we have created a stub which simply echos the Yahoo! Map ID that was provided in the request to download the JavaScript maps library.</p>
<p>If the browser is found to be compatible, the <code>targetFeatures</code> object is created which defines a method to determine if a marker on the map lies within the bounding box of one of our target features. This check is invoked whenever a <code>MouseOver</code> event is raised for a marker on the map.</p>
<p>Then the following steps are executed: (1) the base map object is allocated by the selected Maps API, (2) listeners are set up for map events, and (3) a selection of standard UI controls (map navigation and zoom elements) are applied. Notice that an additional map event is needed for the Yahoo interface to capture the completion of map drawing which then allows placement of an initial marker (see below for more details).</p>
<p>Finally, the map along with an initial location and marker is displayed using a call to our own public <code>.showMap</code> function. Because <code>.showMap</code> must be invoked on an object, we use the current object reference <code>this</code> as the receiving object.</p>
<p>The Google based <code>initMap</code> function is:</p>
<h4>Listing 15: <code>initMap</code> public function for Google Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">initMap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>browserIsCompatible<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          targetFeatures <span style="color: #339933;">=</span> setTargetFeatures<span style="color: #009900;">&#40;</span>defaultGeoTargets<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          map <span style="color: #339933;">=</span> allocMap<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'map_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          captureEvent<span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span> mouseClickEventType<span style="color: #339933;">,</span> onClick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          applyUIControls<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<p>The Yahoo! based <code>initMap</code> function is:<br />
<h4>Listing 16: <code>initMap</code> public function for Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">initMap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>browserIsCompatible<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          targetFeatures <span style="color: #339933;">=</span> setTargetFeatures<span style="color: #009900;">&#40;</span>defaultGeoTargets<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          map <span style="color: #339933;">=</span> allocMap<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'map_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          captureEvent<span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span> mouseClickEventType<span style="color: #339933;">,</span> onClick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">---&gt;</span>      captureEvent<span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span> endMapDrawEventType<span style="color: #339933;">,</span> onEndMapDraw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">&lt;---</span> additional event
          applyUIControls<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<h4><code>showMap</code> Public Function</h4>
<p><code>.showMap</code> performs the address resolution, centering and zooming procedures required to display a map for an initial or a new address. <code>.showMap</code> is exported as a public function so that it can be invoked by the <code>.changeAddress</code> function of the maps application running in the other <code>iframe</code>. In this way the two iframes can be kept in sync if allowed by the <b>sync</b> checkbox. Note that our Yahoo version must set a recursion limiting switch, the <code>runOnceOnEndMapDraw</code> flag, in order to allow the <code>endMapDraw</code> callback to perform centering and marker placement.</p>
<p>Notice that for the Yahoo! API, an additional event, <code>endMapDraw</code>, must be used to draw an initial marker on the map whenever a new address is resolved. This is because, in the Yahoo! API, the center of the map can only be retrieved after the map has finished being drawn. This is an inherently asynchronous process. The Yahoo! API uses <code>drawZoomAndCenter</code> to resolve, center and zoom on an address. Then the callback registered for the <code>endMapDraw</code> event can retrieve the new map&#8217;s center and place the initial marker. The Google API uses the geocoding function <code>.getLatLng</code> to first resolve an address and then invoke a callback, given as a parameter to <code>.getLatLng</code>, to center the map and place an initial marker. These procedures are executed in the interface function <code>zoomAndCenter</code> which was shown earlier in the section <a href='#private_interface_adapters'>Private Interface Adapters</a>.</p>
<p>The Yahoo! steps involved in <code>zoomAndCenter</code> (with help from <code>.initMap</code>, <code>onEndMapDraw</code> and <code>.showMap</code>) are the following:</p>
<ul>
<li><code>.drawZoomAndCenter</code>: (1) resolve, (2) center and (3) zoom on address</li>
<li><code>endMapDraw</code> callback: (4) get center &amp; (5) place marker</li>
</ul>
<p>The Google steps in <code>zoomAndCenter</code> are the following:</p>
<ul>
<li><code>.getLatLng</code>: (1) resolve address</li>
<li><code>getLatLng</code> callback: (2) set center, (3) zoom and (4) mark</li>
</ul>
<p>The Google based <code>showMap</code> function is:</p>
<h4>Listing 17: <code>showMap</code> public function for Google Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">showMap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> address <span style="color: #339933;">||</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'address'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
          zoomAndCenter<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<p>The Yahoo! based <code>showMap</code> function is:</p>
<h4>Listing 18: <code>showMap</code> public function for Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">showMap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> address <span style="color: #339933;">||</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'address'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
<span style="color: #339933;">---&gt;</span>      runOnceOnEndMapDraw <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
          zoomAndCenter<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<p>Notice the <code>runOnceOnEndMapDraw</code> flag in the Yahoo function. As already mentioned above, <code>runOnceOnEndMapDraw</code> is used to limit the depth of recursion in the callback attached to the <code>endMapDraw</code> event.</p>
<h4><code>reMap</code> Public Function</h4>
<p><code>.reMap</code> is invoked when the user presses the <b>Set</b> button (see Figure 1). Typically the user has changed the values of the <b>latitude</b> and <b>longitude</b> input fields in order to recenter the map. <code>.reMap</code> performs the following steps: (1) sets the value of the <code>address</code> input text field to the string &#8220;CUSTOM&#8221;, (2) creates a point object (for the appropriate Maps API using our wrapper function), (3) pans to the coordinates of this point object, and (4) places a marker at the location. If the <b>sync</b> checkbox has been selected, the maps application running in the other <code>iframe</code> will be requested to pan to, mark and display the same coordinates.</p>
<p>The Google based <code>reMap</code> function is:</p>
<h4>Listing 19: <code>reMap</code> public function for Google Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">reMap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">yahoo</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">remoteRemap</span><span style="color: #009900;">&#40;</span>pLat<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pLon<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<p>And the Yahoo based <code>reMap</code> function is:</p>
<h4>Listing 20: <code>reMap</code> public function for Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">reMap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">google</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">remoteRemap</span><span style="color: #009900;">&#40;</span>pLat<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pLon<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<h4><code>remoteMap</code> Public Function</h4>
<p><code>remoteMap</code> is invoked by the maps application running in the other iframe when the user presses the <b>Set</b> button of that <code>iframe</code> to re-center the map using the current values of the <b>latitude</b> and <b>longitude</b> fields. It is invoked from the <code>.reMap</code> function of the other <code>iframe</code>. The <b>sync</b> checkbox of the other <code>iframe</code> must be selected for the cross-frame call to be made.</p>
<p>The Google and Yahoo based <code>remoteMap</code> functions are identical:</p>
<h4>Listing 21: <code>remoteMap</code> public function for Google &amp; Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">remoteRemap</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          setFields<span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
...</pre></div></div>

<h4><code>changeAddress</code> Public Function</h4>
<p><code>changeAddress</code> is invoked when the user manually changes the value of the <b>address</b> input field in order to resolve a new address and to recenter the map. If the <b>sync</b> checkbox is selected, then the <code>.showMap</code> function of the other <code>iframe</code> is also invoked in order to synchronize the two maps.</p>
<p>The Google based <code>changeAddress</code> function is:</p>
<h4>Listing 22: <code>changeAddress</code> public function for Google Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">changeAddress</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">yahoo</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<p>The Yahoo! based <code>changeAddress</code> function is:</p>
<h4>Listing 23: <code>changeAddress</code> public function for Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
        <span style="color: #660066;">changeAddress</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">google</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h3>Finishing Up With The HTML Body</h3>
<p>Our main JavaScript application is invoked when the <code>onLoad</code> event for the body tag is fired. That is, when all of the resources used by the HTML page have been loaded. When using the Google Maps API, it is recommended that the <code>onUnload</code> attribute be set to trigger a call to <code>GUnload</code> when leaving the page in order to avoid memory leaks.</p>
<p>Here is the Google version:</p>
<h4>Listing 24: <code>onLoad</code> and <code>onUnload</code> attributes in <code>body</code> tag for Google Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myMap.initMap();&quot;</span> <span style="color: #000066;">onunload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;GUnload();&quot;</span>&gt;</span> 
...</pre></div></div>

<p>Here is the Yahoo! version:</p>
<h4>Listing 25: <code>onLoad</code> attribute in <code>body</code> tag for Yahoo! Maps API</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">onload</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myMap.initMap();&quot;</span>&gt;</span> 
...</pre></div></div>

<p>The header for the HTML page within each <code>iframe</code> is adjusted for each Maps API:</p>
<p>Here&#8217;s the Google header:</p>
<h4>Listing 26: Page header for Google map</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">font</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;color: white; background: #ccc;&quot;</span>&gt;</span>Google<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">font</span>&gt;</span> Maps API<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 400px;&quot;</span>&gt;</span>
...</pre></div></div>

<p>And the Yahoo! header:</p>
<h4>Listing 27: Page header for Yahoo map</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">font</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;color: white; background: #ccc;&quot;</span>&gt;</span>Yahoo!<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">font</span>&gt;</span> Maps API<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 400px;&quot;</span>&gt;</span> 
...</pre></div></div>

<p>The address input field allows the user to change the current address rendered by the map.</p>
<h4>Listing 28: Address input field</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Address: <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span>40 <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;address&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span></span>
<span style="color: #009900;">                            <span style="color: #000066;">onChange</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myMap.changeAddress(this.value);&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
...</pre></div></div>

<p>The sync checkbox instructs the application to send any address changes to the sibling <code>iframe</code> containing the alternative Maps API.</p>
<p>Here&#8217;s the Google version:</p>
<h4>Listing 29: Sync checkbox for Google <code>iframe</code></h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sync&quot;</span>&gt;</span> Keep address synced with Yahoo! Map<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
...</pre></div></div>

<p>Here&#8217;s the Yahoo version:</p>
<h4>Listing 30: Sync checkbox for Yahoo <code>iframe</code></h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Keep address synced with Google Map <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sync&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span> 
...</pre></div></div>

<p>The following section builds a dynamic list of target features, taken from global variable <code>defaultGeoTargets</code>. These are links that can be selected by the user (see Figure 1).</p>
<h4>Listing 31: Dynamic creation of map selection links</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Mouseover the marker near
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  for (var i=0; i <span style="color: #009900;">&lt; defaultGeoTargets.length; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #009900;">    document.writeln<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&lt;li&gt;&lt;a href='javascript:myMap.changeAddress(defaultGeoTargets[&quot;</span>+i+<span style="color: #ff0000;">&quot;].address)'&gt;</span></span>&quot;+defaultGeoTargets[i].address+&quot;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>&quot;)
  }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
to show its picture. Click on map for other coordinates.<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
...</pre></div></div>

<p><b>map_canvas</b> is the HTML element that acts as a container for the map rendered by the selected Maps API. The Maps API uses the explicit dimensions of this container to size the map. In addition, style attributes may be inherited from this container by pop up information windows attached to markers. Inherited styles like font-size can conflict with layout calculations made by the Maps API for the pop up windows since these calculations are made independently of any styles actually specified for the container. See Mike Williams&apos; <a href='http://econym.org.uk/gmap/css.htm'>Fixing the &#8220;inherited CSS&#8221; problem</a> for more details.</p>
<h4>Listing 32: <code>map_canvas</code> map container element</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;map_canvas&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;width: 400px; height: 300px&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">br</span> <span style="color: #66cc66;">/</span>&gt;</span>
...</pre></div></div>

<p>The user can adjust the latitude and longitude of the center of the map by entering in new values in the respective fields below and then pressing the <b>Set</b> button. Synchronization with the Maps API of the other <code>iframe</code> is maintained if the <b>sync</b> checkbox is checked.</p>
<h4>Listing 33: Longitude, latitude input fields</h4>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">align</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;left&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://en.wikipedia.org/wiki/Latitude&quot;</span>&gt;</span>Latitude<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;18&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lat&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> &gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">align</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;left&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://en.wikipedia.org/wiki/Longitude&quot;</span>&gt;</span>Longitude<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>:<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;18&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lon&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> &gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">td</span> <span style="color: #000066;">align</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;left&quot;</span> <span style="color: #000066;">colspan</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Set&quot;</span> <span style="color: #000066;">onClick</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myMap.reMap($EL('address'));&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
...</pre></div></div>

<p><a name='complete_listings'></a></p>
<h2>Complete Listings</h2>
<p>The following listings present the complete code for each <code>iframe</code> component. The Yahoo code is shown first, followed by the Google code.</p>
<h2>Yahoo Iframe Page</h2>
<h3>(Full Listing)</h3>
<h4>Listing 34: Yahoo Maps API application</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #003366; font-weight: bold;">PUBLIC</span> <span style="color: #3366CC;">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span style="color: #3366CC;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html xmlns<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://api.maps.yahoo.com/ajaxymap?v=3.8&amp;appid=[YOUR YAHOO MAPS API KEY]&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>  
    <span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
    <span style="color: #003366; font-weight: bold;">var</span> defaultGeoTargets <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Golden Gate Bridge, San Francisco'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">37.833</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:-</span><span style="color: #CC0000;">122.474</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">37.805</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:-</span><span style="color: #CC0000;">122.482</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Golden_Gate_Bridge' target='_blank'&gt;&lt;img src='/images/sf_bridge_small.jpg' width='160px' height='120px'&gt;&lt;/a&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Hallepoort, Brussels'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">50.834</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:</span><span style="color: #CC0000;">4.345</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">50.833</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:</span><span style="color: #CC0000;">4.344</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;p style='width:200px'&gt;&lt;a href='http://en.wikipedia.org/wiki/Halle_Gate' target='_blank'&gt;&lt;img src='/mapsapis/images/hallepoort_small.jpg' width='120px' height='160px'&gt;&lt;/a&gt;&lt;span style='position: absolute;'&gt;&lt;p&gt;&amp;nbsp;Hallepoort&lt;br /&gt;&amp;nbsp;today.&lt;/p&gt;&lt;/span&gt;&lt;/p&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Ile de la Cite, Paris'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">48.86</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:</span><span style="color: #CC0000;">2.349</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">48.85</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:</span><span style="color: #CC0000;">2.341</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Ile_de_la_Cite' target='_blank'&gt;&lt;img src='/images/ile_de_la_cite.jpg' width='200px' height='150px'&gt;&lt;/a&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> $EL <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> myMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> targetFeatures<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> DONT_PAN <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009966; font-style: italic;">/* Begin Yahoo! Interface Adapters */</span>
      <span style="color: #003366; font-weight: bold;">var</span> runOnceOnEndMapDraw <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> allocMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YMap<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> applyUIControls <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map.<span style="color: #660066;">addTypeControl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addZoomLong</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addPanControl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> browserIsCompatible <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> YMAPPID<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> captureEvent <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> YEvent.<span style="color: #660066;">Capture</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> createMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> createPoint <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YGeoPoint<span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> endMapDrawEventType <span style="color: #339933;">=</span> EventsList.<span style="color: #660066;">endMapDraw</span><span style="color: #339933;">;</span> 
      <span style="color: #003366; font-weight: bold;">var</span> eraseOverlays <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">removeMarkersAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #006600; font-style: italic;">// var getZoomLevel = function() { map.getZoomLevel(); }</span>
      <span style="color: #003366; font-weight: bold;">var</span> makePointFromFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> YGeoPoint<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">,</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseClickEventType <span style="color: #339933;">=</span> EventsList.<span style="color: #660066;">MouseClick</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseOverEventType <span style="color: #339933;">=</span> EventsList.<span style="color: #660066;">MouseOver</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> onClick <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>_e<span style="color: #339933;">,</span> _c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> point <span style="color: #339933;">=</span> createPoint<span style="color: #009900;">&#40;</span> _c.<span style="color: #660066;">Lat</span><span style="color: #339933;">,</span> _c.<span style="color: #660066;">Lon</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> onEndMapDraw <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>runOnceOnEndMapDraw <span style="color: #339933;">&gt;</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          runOnceOnEndMapDraw <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
          <span style="color: #003366; font-weight: bold;">var</span> point <span style="color: #339933;">=</span> map.<span style="color: #660066;">getCenterLatLon</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> DONT_PAN<span style="color: #009900;">&#41;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> openInfoWindow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>mrkr<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> mrkr.<span style="color: #660066;">openSmartWindow</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLat <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">Lat</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">Lon</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> panToPt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">panToLatLon</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> zoomAndCenter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> z<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          map.<span style="color: #660066;">drawZoomAndCenter</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> z <span style="color: #339933;">||</span> 5<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// default to city view </span>
          <span style="color: #006600; font-style: italic;">// alert(&quot;Current Yahoo zoom level: &quot;+getZoomLevel());</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #009966; font-style: italic;">/* End Yahoo! Interface Adapters */</span>
      <span style="color: #003366; font-weight: bold;">var</span> showPoint <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> setFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> lat<span style="color: #339933;">;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> lon<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> panAndMark <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> dont_pan<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        eraseOverlays<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>dont_pan<span style="color: #009900;">&#41;</span> panToPt<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> createMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> targetFeatures.<span style="color: #660066;">isNearby</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          captureEvent<span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> mouseOverEventType<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            openInfoWindow<span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        map.<span style="color: #660066;">addOverlay</span><span style="color: #009900;">&#40;</span>marker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> setTargetFeatures <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>targets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>targets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">address</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// first element of first target is default address</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
          isNearby<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> found <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> targets.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              b <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">geobox</span><span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">E</span> <span style="color: #339933;">&amp;&amp;</span> pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> b.<span style="color: #660066;">W</span> <span style="color: #339933;">&amp;&amp;</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">N</span> <span style="color: #339933;">&amp;&amp;</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> b.<span style="color: #660066;">S</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                found <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">html</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
              <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">return</span> found<span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        initMap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>browserIsCompatible<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          targetFeatures <span style="color: #339933;">=</span> setTargetFeatures<span style="color: #009900;">&#40;</span>defaultGeoTargets<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          map <span style="color: #339933;">=</span> allocMap<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'map_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          captureEvent<span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span> mouseClickEventType<span style="color: #339933;">,</span> onClick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          captureEvent<span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span> endMapDrawEventType<span style="color: #339933;">,</span> onEndMapDraw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          applyUIControls<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        showMap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> address <span style="color: #339933;">||</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'address'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
          runOnceOnEndMapDraw <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
          zoomAndCenter<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        reMap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">google</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">remoteRemap</span><span style="color: #009900;">&#40;</span>pLat<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pLon<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        remoteRemap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          setFields<span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        changeAddress<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">google</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>body <span style="color: #000066;">onload</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;myMap.initMap();&quot;</span><span style="color: #339933;">&gt;</span> 
    <span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;&lt;</span>font style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;color: white; background: #ccc;&quot;</span><span style="color: #339933;">&gt;</span>Yahoo<span style="color: #339933;">!&lt;/</span>font<span style="color: #339933;">&gt;</span> Maps API<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>div style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;width: 400px;&quot;</span><span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Address<span style="color: #339933;">:</span> <span style="color: #339933;">&lt;</span>input size<span style="color: #339933;">=</span><span style="color: #CC0000;">40</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;address&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span> onChange<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;myMap.changeAddress(this.value);&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Keep address synced <span style="color: #000066; font-weight: bold;">with</span> Google Map <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;checkbox&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;sync&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Mouseover the marker near
<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> defaultGeoTargets.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    document.<span style="color: #660066;">writeln</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;li&gt;&lt;a href='javascript:myMap.changeAddress(defaultGeoTargets[&quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;].address)'&gt;&quot;</span><span style="color: #339933;">+</span>defaultGeoTargets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">address</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/a&gt;&lt;/li&gt;&quot;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
to show its picture. <span style="color: #660066;">Click</span> on map <span style="color: #000066; font-weight: bold;">for</span> other coordinates.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;map_canvas&quot;</span> style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;width: 400px; height: 300px&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://en.wikipedia.org/wiki/Latitude&quot;</span><span style="color: #339933;">&gt;</span>Latitude<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;:&lt;/</span>td<span style="color: #339933;">&gt;&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input size<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;18&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lat&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://en.wikipedia.org/wiki/Longitude&quot;</span><span style="color: #339933;">&gt;</span>Longitude<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;:&lt;/</span>td<span style="color: #339933;">&gt;&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input size<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;18&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lon&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;left&quot;</span> colspan<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Set&quot;</span> onClick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;myMap.reMap();&quot;</span><span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></div></div>

<h2>Google Iframe Page</h2>
<h3>(Full Listing)</h3>
<h4>Listing 35: Google Maps API application</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;!</span>DOCTYPE html <span style="color: #003366; font-weight: bold;">PUBLIC</span> <span style="color: #3366CC;">&quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;</span> <span style="color: #3366CC;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html xmlns<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>script src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://maps.google.com/maps?file=api&amp;v=2&amp;key=[YOUR GOOGLE MAPS API KEY]&amp;sensor=false&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
    <span style="color: #003366; font-weight: bold;">var</span> defaultGeoTargets <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Golden Gate Bridge, San Francisco'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">37.833</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:-</span><span style="color: #CC0000;">122.474</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">37.805</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:-</span><span style="color: #CC0000;">122.482</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Golden_Gate_Bridge' target='_blank'&gt;&lt;img src='/images/sf_bridge_small.jpg' width='160px' height='120px'&gt;&lt;/a&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Hallepoort, Brussels'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">50.834</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:</span><span style="color: #CC0000;">4.345</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">50.833</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:</span><span style="color: #CC0000;">4.344</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Halle_Gate' target='_blank'&gt;&lt;img src='/images/hallepoort_1612.jpg' width='120px' height='160px'&gt;&lt;/a&gt;&lt;span style='position: absolute;'&gt;&lt;p&gt;&amp;nbsp;Hallepoort&lt;br /&gt;&amp;nbsp;in 1612.&lt;/p&gt;&lt;/span&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#123;</span>
        address<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Ile de la Cite, Paris'</span><span style="color: #339933;">,</span>
        geobox<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> N<span style="color: #339933;">:</span><span style="color: #CC0000;">48.86</span><span style="color: #339933;">,</span> E<span style="color: #339933;">:</span><span style="color: #CC0000;">2.349</span><span style="color: #339933;">,</span> S<span style="color: #339933;">:</span><span style="color: #CC0000;">48.85</span><span style="color: #339933;">,</span> W<span style="color: #339933;">:</span><span style="color: #CC0000;">2.341</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        html<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&lt;a href='http://en.wikipedia.org/wiki/Ile_de_la_Cite' target='_blank'&gt;&lt;img src='/images/ile_de_la_cite.jpg' width='200px' height='150px'&gt;&lt;/a&gt;&quot;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> $EL <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> myMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> map<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> targetFeatures<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> DONT_PAN <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
      <span style="color: #009966; font-style: italic;">/* Begin Google Interface Adapters */</span>
      <span style="color: #003366; font-weight: bold;">var</span> allocMap <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> GMap2<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> applyUIControls <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        map.<span style="color: #660066;">setUIToDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        map.<span style="color: #660066;">addControl</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GOverviewMapControl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> browserIsCompatible <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> GBrowserIsCompatible<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> captureEvent <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> GEvent.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span>_obj<span style="color: #339933;">,</span> _event<span style="color: #339933;">,</span> _action<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> createMarker <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> GMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> eraseOverlays <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">clearOverlays</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> getZoomLevel <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">getZoom</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> makePointFromFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> GLatLng<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">,</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseClickEventType <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> mouseOverEventType <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;mouseover&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> onClick <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>overlay<span style="color: #339933;">,</span> point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> openInfoWindow <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>mrkr<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> mrkr.<span style="color: #660066;">openInfoWindowHtml</span><span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLat <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">y</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> pLon <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> p.<span style="color: #660066;">x</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> panToPt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> map.<span style="color: #660066;">panTo</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> zoomAndCenter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #339933;">,</span> z<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> GClientGeocoder<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getLatLng</span><span style="color: #009900;">&#40;</span>
          address<span style="color: #339933;">,</span>
          <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>point<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>address <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; not found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
              map.<span style="color: #660066;">setCenter</span><span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> z <span style="color: #339933;">||</span> 13<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// default to city view</span>
              panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #339933;">,</span> DONT_PAN<span style="color: #009900;">&#41;</span>
              showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              <span style="color: #006600; font-style: italic;">// alert(&quot;Current Google zoom level: &quot;+getZoomLevel());</span>
            <span style="color: #009900;">&#125;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #009966; font-style: italic;">/* End Google Interface Adapters */</span>
      <span style="color: #003366; font-weight: bold;">var</span> showPoint <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> setFields <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lat&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> lat<span style="color: #339933;">;</span>
        $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;lon&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> lon<span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> panAndMark <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> dont_pan<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        eraseOverlays<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>dont_pan<span style="color: #009900;">&#41;</span> panToPt<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> marker <span style="color: #339933;">=</span> createMarker<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> html <span style="color: #339933;">=</span> targetFeatures.<span style="color: #660066;">isNearby</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>html<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          captureEvent<span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> mouseOverEventType<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            openInfoWindow<span style="color: #009900;">&#40;</span>marker<span style="color: #339933;">,</span> html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        map.<span style="color: #660066;">addOverlay</span><span style="color: #009900;">&#40;</span>marker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #003366; font-weight: bold;">var</span> setTargetFeatures <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>targets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>targets<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">address</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// first element of first target is default address</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
          isNearby<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> found <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> targets.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              b <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">geobox</span><span style="color: #339933;">;</span>
              <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">E</span> <span style="color: #339933;">&amp;&amp;</span> pLon<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> b.<span style="color: #660066;">W</span> <span style="color: #339933;">&amp;&amp;</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> b.<span style="color: #660066;">N</span> <span style="color: #339933;">&amp;&amp;</span> pLat<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> b.<span style="color: #660066;">S</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> target <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                found <span style="color: #339933;">=</span> targets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">html</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
              <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">return</span> found<span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        initMap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>browserIsCompatible<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          targetFeatures <span style="color: #339933;">=</span> setTargetFeatures<span style="color: #009900;">&#40;</span>defaultGeoTargets<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          map <span style="color: #339933;">=</span> allocMap<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'map_canvas'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          captureEvent<span style="color: #009900;">&#40;</span>map<span style="color: #339933;">,</span> mouseClickEventType<span style="color: #339933;">,</span> onClick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          applyUIControls<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        showMap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>address<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> address <span style="color: #339933;">||</span> $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'address'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
          zoomAndCenter<span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        reMap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">yahoo</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">remoteRemap</span><span style="color: #009900;">&#40;</span>pLat<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pLon<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        remoteRemap<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          $EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;address&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;CUSTOM&quot;</span><span style="color: #339933;">;</span>
          setFields<span style="color: #009900;">&#40;</span>lat<span style="color: #339933;">,</span> lon<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          point <span style="color: #339933;">=</span> makePointFromFields<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          panAndMark<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          showPoint<span style="color: #009900;">&#40;</span>point<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        changeAddress<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>map<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$EL<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sync'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">checked</span><span style="color: #009900;">&#41;</span> parent.<span style="color: #660066;">yahoo</span>.<span style="color: #660066;">myMap</span>.<span style="color: #660066;">showMap</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>body <span style="color: #000066;">onload</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;myMap.initMap();&quot;</span> <span style="color: #000066;">onunload</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;GUnload();&quot;</span><span style="color: #339933;">&gt;</span> 
    <span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;&lt;</span>font style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;color: white; background: #ccc;&quot;</span><span style="color: #339933;">&gt;</span>Google<span style="color: #339933;">&lt;/</span>font<span style="color: #339933;">&gt;</span> Maps API<span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>div style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;width: 400px;&quot;</span><span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Address<span style="color: #339933;">:</span> <span style="color: #339933;">&lt;</span>input size<span style="color: #339933;">=</span><span style="color: #CC0000;">40</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;address&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span> onChange<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;myMap.changeAddress(this.value);&quot;</span><span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;checkbox&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;sync&quot;</span><span style="color: #339933;">&gt;</span> Keep address synced <span style="color: #000066; font-weight: bold;">with</span> Yahoo<span style="color: #339933;">!</span> Map<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>Mouseover the marker near
<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> defaultGeoTargets.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    document.<span style="color: #660066;">writeln</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;li&gt;&lt;a href='javascript:myMap.changeAddress(defaultGeoTargets[&quot;</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;].address)'&gt;&quot;</span><span style="color: #339933;">+</span>defaultGeoTargets<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">address</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&lt;/a&gt;&lt;/li&gt;&quot;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
to show its picture. <span style="color: #660066;">Click</span> on map <span style="color: #000066; font-weight: bold;">for</span> other coordinates.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;map_canvas&quot;</span> style<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;width: 400px; height: 300px&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>br <span style="color: #339933;">/&gt;</span>
    <span style="color: #339933;">&lt;</span>table<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://en.wikipedia.org/wiki/Latitude&quot;</span><span style="color: #339933;">&gt;</span>Latitude<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;:&lt;/</span>td<span style="color: #339933;">&gt;&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input size<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;18&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lat&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;left&quot;</span><span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;http://en.wikipedia.org/wiki/Longitude&quot;</span><span style="color: #339933;">&gt;</span>Longitude<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;:&lt;/</span>td<span style="color: #339933;">&gt;&lt;</span>td<span style="color: #339933;">&gt;&lt;</span>input size<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;18&quot;</span> type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text&quot;</span> id<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;lon&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;</span>
      <span style="color: #339933;">&lt;</span>tr<span style="color: #339933;">&gt;&lt;</span>td align<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;left&quot;</span> colspan<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;2&quot;</span><span style="color: #339933;">&gt;&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;Set&quot;</span> onClick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;myMap.reMap($EL('address'));&quot;</span><span style="color: #339933;">&gt;&lt;/</span>td<span style="color: #339933;">&gt;&lt;/</span>tr<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>table<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/04/19/tutorial-comparing-yahoo-and-google-maps-apis-side-by-side/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The State of Open Source in India</title>
		<link>http://www.technetra.com/2009/03/08/the-state-of-open-source-in-india/</link>
		<comments>http://www.technetra.com/2009/03/08/the-state-of-open-source-in-india/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 19:24:53 +0000</pubDate>
		<dc:creator>alolita</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[india]]></category>

		<category><![CDATA[opensource]]></category>

		<guid isPermaLink="false">http://www.technetra.com/?p=881</guid>
		<description><![CDATA[Over the past decade open source software has become popular with technology users in India. The benefits of open source - affordability, availability of source code and freedom of choice - have made open source a preferred platform for many innovative Indian organizations and individuals who want to harness the power of high quality software which can be freely adapted to their own requirements.]]></description>
			<content:encoded><![CDATA[<p>Over the past decade open source software has become popular with technology users in India. The benefits of open source - affordability, availability of source code and freedom of choice - have made open source a preferred platform for many innovative Indian organizations and individuals who want to harness the power of high quality software which can be freely adapted to their own requirements.</p>
<h2>What&#8217;s Happening Today</h2>
<p>India has a diverse range of interest groups promoting the adoption of open source software. Major motivators for these groups include politics and special interests, government programs, outsourcing service requirements, and education as well as skills training. Global issues such as software patents vs. freedom of knowledge and adoption of open standards have also become pivots around which local organizations and activists promote free and open source software.</p>
<p>An example where the national government has acted as a key motivator is its initiative to setup a <a href="http://www.nrcfoss.org.in/">National Resource Centre for Free and Open Source Software</a> (NRCFOSS) in April 2005. NRCFOSS is a joint venture between an university-based research lab (AU-KBC Centre) and the Centre for Development of Advanced Computing (C-DAC). This step recognizes the fact that free and open source software is here to stay and it represents a paradigm shift in computing that is poised to change the Indian IT industry.</p>
<p>Another example of government initiative is the formation in 2007 of the <a href="http://www.iotawb.org/">Institute for Open Technologies and Applications</a> (IOTA) as a joint venture between the state of West Bengal, Jadavpur University and open source industry players (Sun Microsystems and Red Hat). IOTA&#8217;s mandate is to promote open source software in government and academia. IOTA provides information on open source software and open standards to organizations looking to understand how open source can fit into their IT infrastructure. IOTA also offers training on Linux and Open Office.</p>
<h2>Dynamics</h2>
<p>Information Technology has provided India&#8217;s economy with an unprecedented boom by creating jobs, expanding purchasing power and bringing in a wave of financial independence to the middle class.  According to a <a href="http://www.nasscom.in/Nasscom/templates/NormalPage.aspx?id=54255">NASSCOM report</a>, the Indian software industry grossed about US$52 billion in exports in 2007-2008. With wealth accumulated over the past several decades from outsourced and off-shored projects, India&#8217;s IT companies have built large shops with deep expertise about the software they need to support - from COBOL during Y2K to SAP, Oracle and Microsoft products today.</p>
<p>Increasingly, international projects demand expertise in open source technologies as well. Project requirements include Linux, MySQL, Apache and many other open technology stacks. Such requirements have driven these groups to create and train thousands of engineers with, for example, in-depth LAMP expertise. Wipro, a representative large-scale outsourcing firm, claims Linux as a strong focus area with its teams contributing to various Linux forums through 64-bit enhancements and kernel bug-fixes. Wipro has developed sophisticated embedded Linux expertise through many projects. An example is porting an embedded digital set-top-box reference platform to embedded Linux to support development of digital set-top boxes and personal video recorders.</p>
<p>Government organizations, at the national and state levels, have been using open source software to produce internal applications. Recently, e-government procurements have begun to allow open source software to be part of vendor provided solutions. This in turn has fueled multinationals, such as IBM, HP, Novell and Red Hat, to bid open source software on large e-government projects in order to meet requirements for affordability, localization and freedom from vendor lock-in.</p>
<p>In response, academia has started training in LAMP technologies to provide skilled labor for outsourcers and multinationals.</p>
<p>Another important dynamic in driving open source adoption in India involves the efforts of free software groups, open source community members and special interest groups. These groups engage in advocacy as well as offer training and support at the grassroots level to small and medium businesses and to students and new users.</p>
<p>India&#8217;s IT landscape is influenced by special interest groups where some groups are pro- and some are anti- open source. Government agencies frequently play both sides and hence most decisions are taken on a project by project basis and not as part of a national agenda promoting open source. The IT industry has acquired high quality open source engineering experience but its expertise is applied mostly to for-hire software export projects.</p>
<h2>Contributing to Open Source</h2>
<p>Active open source communities in India include <a href="http://www.indlinux.org/">IndLinux</a> (localization), <a href="http://anjuta.sourceforge.net/">Anjuta</a> (IDE), OpenOffice (localization and features) and Fedora (localization). <a href="http://google-opensource.blogspot.com/2008/04/two-top-10s-for-google-summer-of-code.html">Google&#8217;s Summer of Code</a> has also spurred active participation in dozens of projects such as BlueZ, Boost C++, CodeHaus, CCAN, CopperMine, Drupal, Etherboot, Fedora, FFmpeg, FreeBSD, Geeklog, Gentoo, GNOME, GNU Hurd, Joomla, KDE, OpenPrinting, Mono, Mozilla, MySQL, NUIG, OAR, OLPC, OpenAFS, OpenMoko, OpenMRS, OpenStreetMap, OpenSUSE, OSGeo, Perl, Python, Zope etc. In 2008, India was second to the US in number of students participating in the program.</p>
<p>Nonetheless, the number of contributions is still relatively low from India. With thousands of engineers and users from outsourcing companies, government agencies, localization groups, multinationals and universities working on open source applications and projects, contributions including bug fixes, patches, localized software, plug-ins, add-ons do get submitted upstream to the global projects. However contributions are often made anonymously since Indian outsourcers are usually under client agreements which inhibit acknowledgement or ownership of any software developed under contract.</p>
<h2>Conclusion</h2>
<p>Open source is becoming more mainstream in the Indian economy. A variety of interests on the part of government, industry and academia are encouraging adoption of open source software in India. Demand for open source has followed the increase in demand for information technologies in all sectors. Liberalization in procurement policy has also contributed to the demand for open source solutions. Industry, academia and community groups are providing training for open source software skills. All of these trends indicate that India is poised to begin to leverage open source software in a bigger way.</p>
<p>While most open source software is still used internally in Indian organizations, the potential for significant contributions back to global open source projects is increasing. Growth in contributions may accelerate when the need to scratch an itch (or many itches) to support local needs grows. As scalable and affordable automation using open technologies becomes embedded in the processes of managing and supporting the needs of more than a billion people, useful and significant contributions from India will begin to pour into the global commons of open source software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.technetra.com/2009/03/08/the-state-of-open-source-in-india/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
