<!--{{{-->
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml' />
<!--}}}-->
Background: #fff
Foreground: #000
PrimaryPale: #8cf
PrimaryLight: #18f
PrimaryMid: #04b
PrimaryDark: #014
SecondaryPale: #ffc
SecondaryLight: #fe8
SecondaryMid: #db4
SecondaryDark: #841
TertiaryPale: #eee
TertiaryLight: #ccc
TertiaryMid: #999
TertiaryDark: #666
Error: #f88
/*{{{*/
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}

a {color:[[ColorPalette::PrimaryMid]];}
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
a img {border:0;}

h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}

.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}

.header {background:[[ColorPalette::PrimaryMid]];}
.headerShadow {color:[[ColorPalette::Foreground]];}
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
.headerForeground {color:[[ColorPalette::Background]];}
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}

.tabSelected{color:[[ColorPalette::PrimaryDark]];
	background:[[ColorPalette::TertiaryPale]];
	border-left:1px solid [[ColorPalette::TertiaryLight]];
	border-top:1px solid [[ColorPalette::TertiaryLight]];
	border-right:1px solid [[ColorPalette::TertiaryLight]];
}
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
.tabContents .button {border:0;}

#sidebar {}
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}

.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
	border:1px solid [[ColorPalette::PrimaryMid]];}
.wizardStep.wizardStepDone {background:[[ColorPalette::TertiaryLight]];}
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
	border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
	border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}

.wizard .notChanged {background:transparent;}
.wizard .changedLocally {background:#80ff80;}
.wizard .changedServer {background:#8080ff;}
.wizard .changedBoth {background:#ff8080;}
.wizard .notFound {background:#ffff80;}
.wizard .putToServer {background:#ff80ff;}
.wizard .gotFromServer {background:#80ffff;}

#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}

.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}

.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}

.tiddler .defaultCommand {font-weight:bold;}

.shadow .title {color:[[ColorPalette::TertiaryDark]];}

.title {color:[[ColorPalette::SecondaryDark]];}
.subtitle {color:[[ColorPalette::TertiaryDark]];}

.toolbar {color:[[ColorPalette::PrimaryMid]];}
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}

.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
.tagging .button, .tagged .button {border:none;}

.footer {color:[[ColorPalette::TertiaryLight]];}
.selected .footer {color:[[ColorPalette::TertiaryMid]];}

.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
.sparktick {background:[[ColorPalette::PrimaryDark]];}

.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
.lowlight {background:[[ColorPalette::TertiaryLight]];}

.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}

.imageLink, #displayArea .imageLink {background:transparent;}

.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}

.viewer .listTitle {list-style-type:none; margin-left:-2em;}
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}

.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}

.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
.viewer code {color:[[ColorPalette::SecondaryDark]];}
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}

.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}

.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
.editorFooter {color:[[ColorPalette::TertiaryMid]];}
.readOnly {background:[[ColorPalette::TertiaryPale]];}

#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity=60)';}
/*}}}*/
/*{{{*/
* html .tiddler {height:1%;}

body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}

h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
h4,h5,h6 {margin-top:1em;}
h1 {font-size:1.35em;}
h2 {font-size:1.25em;}
h3 {font-size:1.1em;}
h4 {font-size:1em;}
h5 {font-size:.9em;}

hr {height:1px;}

a {text-decoration:none;}

dt {font-weight:bold;}

ol {list-style-type:decimal;}
ol ol {list-style-type:lower-alpha;}
ol ol ol {list-style-type:lower-roman;}
ol ol ol ol {list-style-type:decimal;}
ol ol ol ol ol {list-style-type:lower-alpha;}
ol ol ol ol ol ol {list-style-type:lower-roman;}
ol ol ol ol ol ol ol {list-style-type:decimal;}

.txtOptionInput {width:11em;}

#contentWrapper .chkOptionInput {border:0;}

.externalLink {text-decoration:underline;}

.indent {margin-left:3em;}
.outdent {margin-left:3em; text-indent:-3em;}
code.escaped {white-space:nowrap;}

.tiddlyLinkExisting {font-weight:bold;}
.tiddlyLinkNonExisting {font-style:italic;}

/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}

#mainMenu .tiddlyLinkExisting,
	#mainMenu .tiddlyLinkNonExisting,
	#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}

.header {position:relative;}
.header a:hover {background:transparent;}
.headerShadow {position:relative; padding:4.5em 0 1em 1em; left:-1px; top:-1px;}
.headerForeground {position:absolute; padding:4.5em 0 1em 1em; left:0px; top:0px;}

.siteTitle {font-size:3em;}
.siteSubtitle {font-size:1.2em;}

#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}

#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
#sidebarOptions {padding-top:0.3em;}
#sidebarOptions a {margin:0 0.2em; padding:0.2em 0.3em; display:block;}
#sidebarOptions input {margin:0.4em 0.5em;}
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
#sidebarOptions .sliderPanel input {margin:0 0 0.3em 0;}
#sidebarTabs .tabContents {width:15em; overflow:hidden;}

.wizard {padding:0.1em 1em 0 2em;}
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0; margin:0.4em 0 0.2em;}
.wizardStep {padding:1em 1em 1em 1em;}
.wizard .button {margin:0.5em 0 0; font-size:1.2em;}
.wizardFooter {padding:0.8em 0.4em 0.8em 0;}
.wizardFooter .status {padding:0 0.4em; margin-left:1em;}
.wizard .button {padding:0.1em 0.2em;}

#messageArea {position:fixed; top:2em; right:0; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
.messageToolbar {display:block; text-align:right; padding:0.2em;}
#messageArea a {text-decoration:underline;}

.tiddlerPopupButton {padding:0.2em;}
.popupTiddler {position: absolute; z-index:300; padding:1em; margin:0;}

.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
.popup .popupMessage {padding:0.4em;}
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0;}
.popup li.disabled {padding:0.4em;}
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
.listBreak {font-size:1px; line-height:1px;}
.listBreak div {margin:2px 0;}

.tabset {padding:1em 0 0 0.5em;}
.tab {margin:0 0 0 0.25em; padding:2px;}
.tabContents {padding:0.5em;}
.tabContents ul, .tabContents ol {margin:0; padding:0;}
.txtMainTab .tabContents li {list-style:none;}
.tabContents li.listLink { margin-left:.75em;}

#contentWrapper {display:block;}
#splashScreen {display:none;}

#displayArea {margin:1em 17em 0 14em;}

.toolbar {text-align:right; font-size:.9em;}

.tiddler {padding:1em 1em 0;}

.missing .viewer,.missing .title {font-style:italic;}

.title {font-size:1.6em; font-weight:bold;}

.missing .subtitle {display:none;}
.subtitle {font-size:1.1em;}

.tiddler .button {padding:0.2em 0.4em;}

.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
.isTag .tagging {display:block;}
.tagged {margin:0.5em; float:right;}
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
.tagClear {clear:both;}

.footer {font-size:.9em;}
.footer li {display:inline;}

.annotation {padding:0.5em; margin:0.5em;}

* html .viewer pre {width:99%; padding:0 0 1em 0;}
.viewer {line-height:1.4em; padding-top:0.5em;}
.viewer .button {margin:0 0.25em; padding:0 0.25em;}
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}

.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}

.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
.viewer code {font-size:1.2em; line-height:1.4em;}

.editor {font-size:1.1em;}
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
.editorFooter {padding:0.25em 0; font-size:.9em;}
.editorFooter .button {padding-top:0px; padding-bottom:0px;}

.fieldsetFix {border:0; padding:0; margin:1px 0px;}

.sparkline {line-height:1em;}
.sparktick {outline:0;}

.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
.zoomer div {padding:1em;}

* html #backstage {width:99%;}
* html #backstageArea {width:99%;}
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em;}
#backstageToolbar {position:relative;}
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em;}
#backstageButton {display:none; position:absolute; z-index:175; top:0; right:0;}
#backstageButton a {padding:0.1em 0.4em; margin:0.1em;}
#backstage {position:relative; width:100%; z-index:50;}
#backstagePanel {display:none; z-index:100; position:absolute; width:90%; margin-left:3em; padding:1em;}
.backstagePanelFooter {padding-top:0.2em; float:right;}
.backstagePanelFooter a {padding:0.2em 0.4em;}
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}

.whenBackstage {display:none;}
.backstageVisible .whenBackstage {display:block;}
/*}}}*/
/***
StyleSheet for use when a translation requires any css style changes.
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which need larger font sizes.
***/
/*{{{*/
body {font-size:0.8em;}
#sidebarOptions {font-size:1.05em;}
#sidebarOptions a {font-style:normal;}
#sidebarOptions .sliderPanel {font-size:0.95em;}
.subtitle {font-size:0.8em;}
.viewer table.listView {font-size:0.95em;}
/*}}}*/
/*{{{*/
@media print {
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton, #backstageArea {display: none !important;}
#displayArea {margin: 1em 1em 0em;}
noscript {display:none;} /* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
}
/*}}}*/
<!--{{{-->
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
<div class='headerShadow'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
<div class='headerForeground'>
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
</div>
</div>
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
<div id='sidebar'>
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
</div>
<div id='displayArea'>
<div id='messageArea'></div>
<div id='tiddlerDisplay'></div>
</div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::ViewToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
<div class='tagging' macro='tagging'></div>
<div class='tagged' macro='tags'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
<!--{{{-->
<div class='toolbar' macro='toolbar [[ToolbarCommands::EditToolbar]]'></div>
<div class='title' macro='view title'></div>
<div class='editor' macro='edit title'></div>
<div macro='annotations'></div>
<div class='editor' macro='edit text'></div>
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser excludeLists'></span></div>
<!--}}}-->
To get started with this blank [[TiddlyWiki]], you'll need to modify the following tiddlers:
* [[SiteTitle]] & [[SiteSubtitle]]: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
* [[MainMenu]]: The menu (usually on the left)
* [[DefaultTiddlers]]: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
You'll also need to enter your username for signing your edits: <<option txtUserName>>
These [[InterfaceOptions]] for customising [[TiddlyWiki]] are saved in your browser

Your username for signing your edits. Write it as a [[WikiWord]] (eg [[JoeBloggs]])

<<option txtUserName>>
<<option chkSaveBackups>> [[SaveBackups]]
<<option chkAutoSave>> [[AutoSave]]
<<option chkRegExpSearch>> [[RegExpSearch]]
<<option chkCaseSensitiveSearch>> [[CaseSensitiveSearch]]
<<option chkAnimate>> [[EnableAnimations]]

----
Also see [[AdvancedOptions]]
<<importTiddlers>>
<!--{{{-->

<div class='carbontool'>
<div class='header ss'>[[Logo]]</div>
<div class='divider'></div>
<div class='banner' id='toolTop'>
<div class='toolTitle'>CARBON FOOTPRINT CALCULATOR</div>
<div class='toolSubTitle'>HOW MUCH IS YOUR MEETING CONTRIBUTING TO THE CARBON FOOTPRINT OF THE WORLD?</div>

</div>
<div class='curbCO2'>
<div class='container  curvedCorners ss'>
<h1>READY TO CURB YOUR CO2?</h1>
<div class='message'>When you are ready, go ahead and enter all the relevant details about your meeting. Please enter and let the calculator tell you exactly what your footprint is. You will also get some facts to give you a better understanding of what a number can mean and a perspective that you can appreciate. Note everything you submit will be logged.</div>
</div>
</div>

<div class='divider'></div>
<div class='bottomTool'>
<div macro='CarbonFootprintForm'></div>
  <div class='explanation'>
    <div class='container  curvedCorners'>
      <div class='middle' id='journeySummaryArea'>
      <h1>How does this work?</h1>
      <p>I have been made my <a  target='_blank' href='http://osmosoft.com'>Osmosoft</a> using an open source product called <a target='_blank' href='http://tiddlywiki.com'>TiddlyWiki</a>. 
[[InternalMessage]]
      <p>I work out the locations you give me as best as I can using Google. 
      I will do my best, but for greatest accuracy I would recommend you use a postcode. 
      If you do not know the postcode give me as much information as you can about the place, eg. for Birmingham in the United States set your location as "Birmingham,  United States", otherwise I might give you false information and a bit of a fright! 
      </p><p>
      To give you an idea of the relative importance of one single kilogram of CO2, 
      the total amount of carbon the UK will emit today will be about 25 Kg per person. So if you are over 25kg you should start to worry.
      By 2050 if we are to meet UK climate change reduction targets and look after our planet a maximum of 5kg per person would be needed. It makes that 25kg seem easier hey?
      </p><p>
     [[ExplanationFooter]]
      </p>
      </div>
    </div>
     <div class='divider'></div>
  </div>
 
</div>
[[Footer]]
</div>
<div macro='roundedCorners ".curvedCorners,.formHeader .content,.formFooter .content"'></div>
<div macro='applyTransparency ".ss"'></div>
<div id='displayArea' >
<div id='messageArea'></div>
<div id='tiddlerDisplay'  style='display:none;'></div>
</div>
<!--}}}-->
!Credits
* The lovely design is thanks to the work of Amit Dave, a friend of Osmosoft
* tree.png bought from http://www.istockphoto.com/
<!--{{{-->
<div class='title' macro='view title'></div>
<div class='viewer' macro='view text wikified'></div>
<div class='tagClear'></div>
<!--}}}-->
.reduceCO2banner {text-align:center;}
.icon_breaths{background-image:url(images/icons/breaths_small.gif);}
.icon_google{background-image:url(images/icons/google_small.gif);}
.icon_pc{background-image:url(images/icons/pc_small.gif);}
.icon_kettle{background-image:url(images/icons/kettle_small.gif);}
.icon_bthomehub {background-image:url(images/icons/bthomehub_small.gif);}
.icon_circumnavigate {background-image:url(images/icons/circumnavigate_small.gif);}
.icon_madehomehubs {background-image:url(images/icons/madehomehubs_small.gif);}
.icon_BT_CF {background-image:url(images/icons/BT_CF_small.gif);}
.icon_BT_travel {background-image:url(images/icons/BT_travel_small.gif);}
.icon_co2today {background-image:url(images/icons/co2today_small.gif);}
.icon_co2_2050 {background-image:url(images/icons/co2_2050_small.gif);}

#magic {display:none;}
.shareArea .codeLink {background-color:white;
position:absolute;
right:20px;
top:-20px;}
.shareArea .codeArea {background-color:white;padding:20px;}
.shareArea {
padding:20px;
position:absolute;
right:0;
top:20px;}
.shareArea textarea {width:100%;}
/* rounded corners */
.ie6 .carbonArea .curvedcorners-tl {left:-10px;}
.ie6 .formFooter .content {margin-bottom:0px;padding:0px;}
.ie6 .carbonArea .curvedcorners-bl {left:-10px; bottom:10px;}
.ie6 .carbonArea .curvedcorners-br {right:10px; bottom:10px;}
.ie6  .curvedcorners-top {left:10px;top:2px;}
.ie6  .curvedcorners-bottom {bottom:-3px;left:10px;}
.ie6 .formFooter .content {margin-left:10px;}
.ie6 .formFooter ul {margin-left:0px;}
.ie6 .carbonArea .divider {width:580px;}
.ie6 .formFooter .content {width:590px;padding:10px;}
.ie6 .resultsBox {margin-left:0px;}


.carbonArea  .curvedcorners-top,.carbonArea .curvedcorners-bottom {width:610px;}
.explanation  .curvedcorners-top,.explanation .curvedcorners-bottom{width:290px;}
.curbCO2 .curvedcorners-top,.curbCO2 .curvedcorners-bottom {width:930px;}
.carbonArea form {position:relative;}


/*rest*/
.participant {clear:both;}

.iconsArea h2 {color:black;}
.ie6 .factsArea { left: 30px;}
.ie6 #factArea {margin-left:15px;}
#factArea{background-color:white;
color:#4981C8;
display:inline;
margin-right:0;
margin-top:17px;
position:absolute;
right:0;
width:420px;}
.fact {}
#factArea .fact {padding:5px;font-size:22px;margin-top:20px;position:relative;}

.icon {background-position:center center;background-repeat:no-repeat;margin-top:10px;width:50px;margin-right:20px;height:50px;float:left;bottom:0;position:relative;}
.summaryBox {color:white;
float:right;
width:900px;}
.banner .toolTitle {background-color:white;}
.resultsBox {margin-left:20px;margin-top:20px;float:left;position:relative;margin-right:50px;}

.resultsBox .intro {color:white;display:block;font-size:14px;font-weight:bold;margin-bottom:10px;}
.resultsBox .value {background-color:white;float:left;
color:#4981C8;
font-size:64px;
padding-bottom:5px;
padding-left:5px;
padding-right:5px;
padding-top:5px;}
.resultsBox .units {color:white;float:left;
display:block;
font-size:30px;
font-weight:bold;margin-left:10px;
margin-top:70px;}

.carbontool .header .toolTitle {float:left;}
.formHeader .content {height:100px;}
.ie6 .resultsBox {margin-left:10px;}
.formHeader .content,.formFooter .content {background-color:#E4E4E4;bottom:0;

margin-bottom:-5px;
margin-left:4px;
position:relative;

}
.curbCO2 h1 {background-image:url(images/readytocurb.png);height:50px;text-indent:-9999px;background-color:#E4E4E4;}
.listHeading .who {background-image:url(images/who.png);}
.listHeading .from{background-image:url(images/from.png);}
.listHeading .by {background-image:url(images/by.png);}
.listHeading .who,.listHeading .from, .listHeading .by {background-repeat:no-repeat;float:left;color:white;font-size:24px;height:31px;text-align:right;}
.journeyLegArea .journey {display:block;float:left;}

li .participantFrom span,.participantName span {display:block;height:110px;}

.participantFrom_ {margin-left:15px;}
.participantMode_ {margin-left:15px;}
.participantMode_ select{margin-left:5px;}

.participantMode_ select {width:205px;}
.journeyLegArea .mode{margin-left:15px;}
.journeyLegArea .mode,.journeyLegArea .from {float:left;}
.journeyLegArea {clear:both;display:block;margin-left:171px;position:relative;}
.carbonArea, .innerFrame,.bottom, .calculator{position:relative;}
.explanation h1,.explanation h2 {color:#192868;background:none;font-size:24px;}
.journeyLegArea input, .journeyLegArea select {display:block;}
li .participantMode{float:left;width:200px;}
.formFooter .content .footer {clear:both;}
.carbontool .header img {
float:right;
margin-right:27px;
margin-top:19px;
}
.explanation .middle {padding:10px;}
h2,h3 {border:none;}
.formFooter .content {padding:15px;background-color:#E4E4E4;margin-bottom:-5px;}
.explanation .container {margin:15px;background-color:#E4E4E4;margin-bottom:25px;}
.curbCO2 .container,.formHeader .footer,.formHeader .content{background-color:#E4E4E4;}
.listHeading .from, .listHeading .who,li .participantName, li .participantFrom{width:142px;margin-right:30px;display:block;float:left;}
.listHeading .by{width:201px;}

li .participantMode select,.journeyLegArea  .mode select {width:180px;}
.formFooter ul {list-style-image:none;list-style-position:outside;list-style-type:none;margin-left:-40px;}
.meeting1 h1 {color:#BD5A9A;background:none;}
.formFooter h1 {color:#2D77AB;background:none;background-image:url(images/divider_horizontal.gif);background-position:center bottom;background-repeat:repeat-x;margin-bottom:20px;}
body {font-family:tahoma;}
.carbontool {width:960px;margin:auto;}
.carbontool .header {background-image:url(images/topbanner.png);
height:83px;
margin-left:-5px;
margin-right:5px;
width:960px;}
.carbontool .header img {float:right;}
#magic {position:absolute;top:0px;right:100px;}
.carbontool .banner {height:326px;width:952px;position:relative;background-image:url(images/tree.png);background-repeat:no-repeat;}
.toolTitle {background-image:url(images/cfclogo.gif);
height:54px;margin-left:-10px;
overflow:hidden;position:relative;
text-indent:-999px;top:10px;width:402px;}
.toolSubTitle {margin-top:20px;font-weight:bold;width:352px;background-color:white;padding:5px;}
.curbCO2 {margin-left:-8px;padding:8px;}
.curbCO2 .container {height:70px;position:relative;z-index:3;}
.curbCO2 .message {background-color:#E4E4E4;background-position:left center;background-repeat:no-repeat;display:block;float:left;margin-left:0px;margin-top:9px;padding-left:20px;width:501px;}
.calculator {width:633px;float:left;margin-left:-14px;}
.explanation {margin-right:-10px;width:339px;float:left;margin-left:8px;overflow:hidden;}
.formHeader,.formFooter {padding:10px;position:relative;}
.meeting1, .meeting2 .formHeader .formFooter, .curbCO2 .container{z-index:2;padding:15px;}
.meeting1 {background-image:url(images/vertical_divider.gif);background-position:right center;background-repeat:no-repeat;float:left;margin-top:8px;padding-right:20px;width:310px;}
.meeting2 {display:block;float:left;width:201px;margin-top:20px;}
.divider {clear:both;}
.meetinglocation,.meetingReturn {text-align:center;}
.meetinglocation .ac_input {text-align:center;}
.curbCO2 h1 {float:left;width:321px;margin-left:22px;}
.ie6 .curbCO2 h1 {margin-left:2px;}
.bottom {clear:both;}

.header {background:none;}
.separator {clear:both;height:10px;}
h1,.title{border:none;font-size:1.3em;margin:0.2em 0;
padding:0.2em;}
h1,h2,h3,h4,h5,.title {color:white;}
a {color:black;text-decoration:underline;}
.clearform {margin-left:10px;}
.generator{margin-right:30px;}
.ie6 .generator{margin-right:39px;}
.clearform, .addParticipant {margin-left:1px;}
.ie6 .addParticipant {margin-left:-8px;}
.loadData, .clearform {padding:2px;}
.loadData,.generator,.addParticipant ,.addJourneyLeg,.deleteParticipant, .clearform {background-color:#2D77AB;border:none;color:white;font-weight:bold;height:20px;}
.deleteParticipant {background-color:red;color:white;}
a:hover {text-decoration:none;background:none;color:black; }
.generator {height:50px;width:200px;float:right;}
.addJourneyLeg {height:20px;}
.ie6 .editLegArea {margin-right:39px;}
.editLegArea {float:right;margin-right:33px;}
.addParticipant {float:left;position:relative;}
.padme {padding:5px;}
.suffix {font-style:italic;}

table {border-spacing:0px;width:100%;}
td {}
thead td {background-color:rgb(200,200,220);}
thead td {border-right:none;}
.explanation .journeyDetails,.explanation .carbonContributorsArea,.explanation .surveyBox {position:relative;background-color:white;padding:5px;margin-top:10px;}
/*JQUERY plugins CSS goes here */
.ac_results {
	padding: 0px;
	border: 1px solid black;
	background-color: white;
	overflow: hidden;
	z-index: 99999;
}

.ac_results ul {
	width: 100%;
	list-style-position: outside;
	list-style: none;
	padding: 0;
	margin: 0;
}

.ac_results li {
	margin: 0px;
	padding: 2px 5px;
	cursor: default;
	display: block;
	/* 
	if width will be 100% horizontal scrollbar will apear 
	when scroll mode will be used
	*/
	/*width: 100%;*/
	font: menu;
	font-size: 12px;
	/* 
	it is very important, if line-height not setted or setted 
	in relative units scroll will be broken in firefox
	*/
	line-height: 16px;
	overflow: hidden;
}

.ac_loading {
	background: white url('indicator.gif') right center no-repeat;
}

.ac_odd {
	background-color: #eee;
}

.ac_over {
	background-color: #0A246A;
	color: white;
}
.formFooter {clear:both;}

.summaryBox {background-color:white;
bottom:25px;
color:black;
left:0px;
margin-right:20px;
opacity:0.9;filter: alpha(opacity = 80);zoom:1;
position:absolute;
width:910px;
}
.summaryBox .iconsArea {z-index:100;padding:10px;}

.carbonArea {width:637px;}
explanation {margin-top:-5px;}
/* ie 6 stuff */
.ie6 .carbonArea {}
.ie6 .curbCO2 {}
.ie6 .explanation {width:346px;margin-top:-4px;margin-left:-4px;}
/*
.ie6 .carbonArea .formFooter ul {margin-left:0px;}
.ie6 .carbonArea {margin-top:10px;}

.ie6 .explanation {margin-top:5px;}

.ie6 .carbonArea .curvedcorners-bottom,.ie6 .carbonArea .curvedcorners-top {left:50px;width:520px;}

.ie6 .carbonArea .curvedcorners-top {top:0px;}
.ie6 .carbonArea .curvedcorners-bottom {bottom:-5px;}

.ie6 .curvedcorners-top,.ie6 .curvedcorners-bottom {width:100%;}
.ie6 .curbCO2 .curvedcorners-top,.ie6 .curbCO2 .curvedcorners-bottom {width:880px;}
.ie6 .curbCO2 .curvedcorners-top{top:-1px;}
.ie6 .curbCO2 .curvedcorners-bottom{bottom:-4px;}
.ie6 .explanation .curvedcorners-bottom ,.ie6 .explanation .curvedcorners-top{width:225px;}
.ie6  .curvedcorners-right ,.ie6 .curvedcorners-left {top:10px;bottom:10px;}
*/



[img[v2-btlogo-ani.gif]]
[[Calculator|CarbonFootprintCalculator]]
[[About]]


Made by <a href="http://jonrobson.me.uk">Jon Robson</a> for <a href="http://osmosoft.com">Osmosoft</a>. 
Design by <a href="http://adcreates.wordpress.com/">Amit Dave</a>.
/***
|''Name''|CarbonFootprintPlugin|
|''Description''|Allows you to check your carbon footprint against your travel.|
|''Author''|Jon Robson|
|''Version''|0.8|
|''Date''|Nov 2008|
|''Status''|@@experimental@@;|
|''License''|BSD|
|''CoreVersion''|<...>|
|''Documentation''|<...>|
|''Keywords''|carbon footprint|travel|

***/
/*
2088533116?1667330592?678784619?1852798830?543585637?1814641210?1248816764?2085384046?1685024380?2087742561?1852121128?1819242087?761815413?1814063470?1952805486?1635019119?1851878441?2088520565?1634492704?1282764144?1970437244?1953653097?1847601262?1635019119?1851878432?1918986604?696024131?1634559346?1869488200?1768384620?1634624627?740314465?1818327411?1767996540?1953653097?1847601262?1635019119?1851878432?1918986604?696024144?1701732718?1730945101?1634492793?1936286076?2088006241?1768824872?1851880553?1869504876?544366953?1814658172?1281453671?1801549673?740314465?1818327411?1767996540?1953653097?1847601262?1635019119?1851878432?1918986604?696024139?1969319009?541881709?1886745212?2087742561?1852121128?1936224114?1949132897?1970020457?1853121906?1851880553?1869504876?696024130?1920298597?1769765987?1634869288?1970170734?1870097952?1718969708?696024139?1869898016?1265200737?1650551925?740314465?1818327411?1767996540?1886151022?1696606316?1869506349?1751217516?543780468?1701998177?1953066862?1634478460?2085445987?1635068960?1130916206?1635548276?1918986606?539520609?1953066862?1634476146?1634298921?2088519791?1852252235?1869506348?541288553?1851882620?1886151022?1696606323?1752134260?761815413?1814063470?1952805486?1635019119?1851878441?2088522601?1852268912?1869768060?2087742561?1852121128?1936224114?1949132897?1970020457?1853121906?1851880553?1869504876?696024139?1969319009?541881709?1886745212?2087742561?1852121128?1819242087?761815413?1814063470?1952805486?1635019119?1851878441?976899183?1852075886
*/
config.macros.CarbonFootprintForm ={
  ajaxUrl:"http://ajax.googleapis.com/ajax/services/search/local?v=1.0&q="
  //ajaxUrl:"/CarbonCalculator/proxy.php?url=http%3A//ajax.googleapis.com/ajax/services/search/local%3Fv%3D1.0%26q%3D"
  //ajaxUrl:"http://www.jonrobson.me.uk/proxy.php?url=http%3A//ajax.googleapis.com/ajax/services/search/local%3Fv%3D1.0%26q%3D"
  ,kgco2perkm:{
    "car (unknown fuel)":0.2028,
    "plane (domestic)": 0.1710,
    "plane (short-haul international)": 0.0983,
    "plane (long-haul international)":0.1122,
    "plane (other)": 0.12716,
    "train (national rail)":0.0577,
    "train (international eg.Eurostar)": 0.0177,
    "train (light rail and tram)": 0.0834,
    "tube (eg. London Underground)":0.0780,
    "train (other)": 0.0592
  }
  ,thesameco2couldhavebeenused:{
    "breaths":{prefix:"... you could have produced the same amount through breathing ", kgMultiplier:1/0.000982, suffix: " times",decimals:0}, //http://wiki.answers.com/Q/How_much_co2_is_emitted_per_breath
    "kettle": {prefix:"... you could have boiled ", kgMultiplier: 1/0.0015, suffix:" kettles",decimals:0},//http://technology.timesonline.co.uk/tol/news/tech_and_web/article5489134.ece
    "google": {prefix:"... you could have performed ", kgMultiplier: 1/0.0002, suffix:" google searches", reference:'http://googleblog.blogspot.com/2009/01/powering-google-search.html',decimals:0},
    "pc": {prefix: "... you could have run a PC for ", kgMultiplier:1/(0.06*24), suffix: " days",decimals:0 },//http://technology.timesonline.co.uk/tol/news/tech_and_web/article5489134.ece
    "circumnavigate": {prefix:"... you could have circumnavigated the globe in a plane ",kgMultiplier:1/4496.43295, suffix:" times."}, //world is 40,075.16 kilometers in a plane 0.1122kg co2 per km
    
      "madehomehubs":{prefix:"...could have manufactured and distributed ", kgMultiplier:1/18, suffix:" BT homehubs"},
    "bthomehub":{prefix:"... you could have run a BT homehub for ", kgMultiplier:1/44,suffix:" years"},
    "co2today":{prefix:"... you have contributed the same amount as ", kgMultiplier:1/25,suffix:" people will today (the total UK emissions today will correspond to about 25kg of Co2 per person)"},
    "co2_2050":{prefix:"... you have contributed the same amount as ", kgMultiplier:1/5,suffix:" people will in 2050 in a single day (based on UK climate change reduction targets)"}
  }
  

  ,poundsperkm:{
    "car (unknown fuel)":.09,
    "plane (domestic)": .12,
    "plane (short-haul international)": .12,
    "plane (long-haul international)":.12,
    "plane (other)": .12,
    "train (national rail)":.50,
    "train (international eg.Eurostar)": .50,
    "train (light rail and tram)": .50,
    "tube (eg. London Underground)":.21,
    "train (other)":.50
  }
  ,"search-cache": {
    
  }
  ,codemsg: "Copy and paste the code below and then you will be able to retrieve your trip by clicking on the 'load from code' link in the bottom right of the calculator."
  ,_transportHTML: ""
  ,_generateTransportHTML: function(){
      var transportData = config.macros.CarbonFootprintForm.kgco2perkm;
      var transportOptionsHtml = "";
      for(var i in transportData){
        transportOptionsHtml += "<option value=\""+ i+"\">"+ i +" ("+transportData[i]+" kg co2 per km)</option>";
      }
      this._transportHTML = transportOptionsHtml;
  }
  ,addJourneyLeg: function(place,location,transport){
    var macro =config.macros.CarbonFootprintForm;
    var lingo =macro.lingo;
    var options = this._transportHTML;
    jQuery(".journeyLegArea",place).append("<span class='journey'><span class='from'>"+lingo.legLocation+"<input type='text' name='via'/></span><span class='mode'>"+lingo.legMode+"<select name='viaTransport'>"+options+"</select></span></span>");
    var journeys =jQuery(".journey",place);
    var lastJourney =journeys[journeys.length-1];
    

    if(location)jQuery("input[name=via]",lastJourney).val(location);
    if(transport)jQuery("select[name=viaTransport]",lastJourney).val(transport);
    macro.afterAddJourneyLeg(place);

  }
  ,lingo: {
    "name": "name",
    "legLocation":"to (city/postcode)",
    "legMode":"by",
    "travelFrom":"is travelling from (city/postcode)",
    "addleg": "add leg to journey",
    "meeting": "Meeting",
    "participants": "participants",
    "meetingPretext": "",
    "meetingPrompt": "Where is the meeting? (city/postcode)",
    "meetingReturn": "Is this a return journey?",
    "transportDescriptionMode": "mode of transport used to get to destination",
    "travelEnd": "to the meeting",
    "toolinfo": "",
    "yourfootprintis":"Your Carbon Footprint is",
    "meetingheading":"Some perspective..",
    "withsamecarbon": ""
  }
  ,templates: {
  }
  
  ,addParticipant: function(place){
    var lingo =config.macros.CarbonFootprintForm.lingo;
    var macro =config.macros.CarbonFootprintForm;
    var transportOptionsHtml = this._transportHTML;
    var id= Math.random();
    var participantId = "participant_"+id;

    var html = "<li class='participant' id=\""+participantId+"\">"+
      "<span class='participantName_'>"+
        "<input id='cf_person_"+id+"' type='text' name='participant'/>"+
      "</span>"+
      "<span class='participantFrom_'>"+
        "<input type='text' name='location'  id='cf_location_"+id+"'/>"+
      "</span>"+
      "<span class='participantMode_'>"+
        "<select name='transport'  id='cf_tranport_"+id+"'>"+transportOptionsHtml+"</select>"+
      "</span>"+
      "<span class='journeyLegArea'></span>"+
      "<span class='editLegArea'>"+lingo.travelEnd+" <input type='button' class='addJourneyLeg' value='"+lingo.addleg+"'/><input type='button' class='deleteParticipant' value='X'/></span></li>";
    jQuery(".participantArea",place).append(html);

    var participantEl = document.getElementById(participantId);
    jQuery(".addJourneyLeg",participantEl).click(function(e){
      
      var participant = jQuery(this).parent().parent();
      config.macros.CarbonFootprintForm.addJourneyLeg(participant);
    })
    jQuery(".deleteParticipant",participantEl).click(function(e){
      //delete  first
      var journeys = jQuery(".journeyLegArea .journey",jQuery(this).parent().parent());
      if(journeys.length ==0)jQuery(this).parent().parent().remove();
      else jQuery(journeys[journeys.length-1]).remove()
    });
    
     macro.afterAddParticipant(jQuery(".participantArea",place));
  }
  ,constructForm: function(place,tiddler){

    var macro =config.macros.CarbonFootprintForm;
    var lingo =config.macros.CarbonFootprintForm.lingo;
    var frame = "<div class='calculator'></div>"
    var html =macro.templates.basicFrame;
    var shareArea =     "<a href='#' class='codeLink' style='display:none'>Share</a>"+
        "<div class='codeArea' style='display:none'>" +config.macros.CarbonFootprintForm.codemsg +" <br\><textarea class='code' ></textarea> <a href='javascript:void' class='hider'>hide</a> </div>";
      
    var carbonForm = "<form>"+
          "<div class='formHeader'>"+
            "<div class='content'>"+
              "<div class='meeting1'>"+
                "<h1>"+lingo.meeting+"</h1>"+
                "<div class='meetingpretext'>"+lingo.meetingPretext +
                "</div>"+
              "</div>"+
              "<div class='meeting2'>"+
                "<div class='meetinglocation'>"+lingo.meetingPrompt+
                  "<div><input type='text' name='meeting_location'/></div>"+
                "</div>"+
                "<div class='meetingReturn'>"+lingo.meetingReturn+"<input type='checkbox' name='isReturn' checked/></div>"+
              "</div>"+
            "</div>"+
          "</div>"+
          "<div class='formFooter'>"+
          "<div class='content'>"+
              "<h1>"+lingo.participants+"</h1>"+
              "<div>"+
                 "<ul class='participantArea'>"+
                    "<li class='listHeading'><div class='who'>Who?</div><div class='from'>From?</div><div class='by'>By?</div></li>"+
                    "<li><span class='participantName'><span>"+macro.lingo.name+":</span></span><span class='participantFrom'><span>"+lingo.travelFrom+":</span></span><span class='participantMode'><span>"+ lingo.transportDescriptionMode +"</span></span></li>"+
                    "<li class='divider'></li>"+
                  "</ul>"+
              "</div>"+
              "<input type='button' class='addParticipant' value='add participant'/>"+
              "<div class='separator'></div>"+
              "<input type='button' class='generator' value='CALCULATE'>"+
              "<div class='footer'><a href='#' class='loadData'>Load from code</a><a href='#' class='clearform'>New meeting</a></div>"+
          "</div>"+
          "</div>"+
        "</form>";
        /* 
           

              
                          
      
  */
        

    
    jQuery(place).append(html);
    var resultElement= macro.getResultsBox();
    jQuery(resultElement).append(macro.templates.resultScreen);
    jQuery(".carbonArea").html(carbonForm);
    jQuery(".shareArea").html(shareArea);
    jQuery(".clearform",place).click(function(e){
      if(tiddler){
        story.closeTiddler(tiddler.title);
        story.displayTiddler(null,tiddler.title);
      }
      refreshAll();
      
    });
    var macro = config.macros.CarbonFootprintForm;
    
    macro.afterConstructForm(place);
    //alert(html);
   
  }
  ,handler: function(place,macroName,params,wikifier,paramString,tiddler){
    var cff = config.macros.CarbonFootprintForm;
    
    this._generateTransportHTML();
     
    config.macros.CarbonFootprintForm.constructForm(place,tiddler);
    
    config.macros.CarbonFootprintForm.addParticipant(place);
    var options = {url:cff.ajaxUrl};
    
    jQuery(".loadData",place).click(function(e){
      config.macros.CarbonFootprintForm.loadData(place,options);
    })
    
    
    jQuery(".addParticipant",place).click(function(){config.macros.CarbonFootprintForm.addParticipant(place);});
    jQuery(".generator",place).click(function(){config.macros.CarbonFootprintForm.calculate(place,options);});
  }
  ,get_google_search_term: function(term){
    return term;
  }
  ,calculate:function(place,options){
    /* for debugging */    
    var macro = config.macros.CarbonFootprintForm;
    var startLocation = macro.get_google_search_term(jQuery("input[name=meeting_location]",place).val());
    var isReturn = jQuery("input[name=isReturn]:checked",place);
    if(isReturn.length> 0){
      options.returnjourney = true;
    }
    else{
      options.returnjourney = false;
    }
    options.calculatedParticipants = 0;
    //jQuery(".resultScreen",place).html("please wait...");
    var resultElement= macro.getResultsBox();
    jQuery(".generator",place).val("please wait..")
    jQuery(".resultsBox",resultElement).html("please wait...");
    var theurl = options.url+startLocation;
    if(!macro["search-cache"][startLocation]){
      ajaxReq({url:theurl, error: function(e){console.log("error time");alert("an error occurred.. "+e);}, success:function(r){
      console.log("success time");
        var geo = macro.getLngLatFromGoogleResponse(startLocation, r);
       console.log(geo,"...");
        if(!geo){
          alert("Couldn't find "+ startLocation + " check this is a valid postcode.");
          jQuery(".resultsBox",place).html("error occurred: invalid address " + startLocation);
          jQuery(".generator",place).val("CALCULATE")
        }
        var lon = geo.lng
        var lat = geo.lat;
        macro.calculateDistances(place,lon,lat,startLocation,options);

      }});
      
    }
    else{
      var lon = macro["search-cache"][startLocation].lng;
      var lat = macro["search-cache"][startLocation].lat;
      macro.calculateDistances(place,lon,lat,startLocation,options);
    }

    
  }
  ,printSummary: function(place,result){
    var macro = config.macros.CarbonFootprintForm;
    var codeString = result.codeString;
    var lingo = macro.lingo;
    var totalKms = result.totalKms;
    var totalKmsPerson =result.totalKmsPerson;
    var carbonCalculator = config.macros.CarbonFootprintForm.kgco2perkm;
    var costCalculator = config.macros.CarbonFootprintForm.poundsperkm;
    var summaryHtml= "<div class='journeyDetails'><h2>Journey Summary</h2> <table class='carbonFootprintTable'><thead><tr><td>Mode Transport</td><td>Kms</td><td>carbon footprint (kg co2)</td><td>journey cost (&#163;)</td></tr></thead>";
    var grandTotalKms = 0;
    var totalcft = 0;
    var totalcost = 0;


    for(var modeTransport in totalKms){
        var transportKms = totalKms[modeTransport];
        grandTotalKms += transportKms;
        var cft = carbonCalculator[modeTransport] * transportKms;
        var journey_cost = costCalculator[modeTransport] * transportKms;
        totalcft+= cft;
        totalcost += journey_cost;
        summaryHtml += "<td>"+modeTransport+"</td><td>"+transportKms.toFixed(1) +"</td><td>"+cft.toFixed(1)+"</td><td>"+journey_cost.toFixed(1)+"</td></tr>";
    }

    var iconHtml = "<h2>"+lingo.meetingheading+"</h2><div class='pretext'>"+lingo.withsamecarbon+"</div>";
    var facts =config.macros.CarbonFootprintForm.thesameco2couldhavebeenused;
    var factsHtml = "";
    for(i in facts){ 
      var fact = facts[i];
      var damage = fact.kgMultiplier * totalcft;
      var decimals = fact.decimals || 2;
      if(fact.decimals ===0) decimals = 0;
      var damage=damage.toFixed(decimals);
      if(damage != 0){
        factsHtml += "<div class='fact' name='fact_"+i+"'><span>"+ fact.prefix + damage + fact.suffix+"</span></div>";
        iconHtml +="<div class=\"icon icon_"+i+"\" updates='fact_"+i+"'></div>";
      }
    }
    iconHtml += "<div class='divider'></div>"


    summaryHtml += "<tr class='total'><td>*</td><td>"+grandTotalKms.toFixed(1)+"</td><td>"+totalcft.toFixed(1)+"</td><td>"+totalcost.toFixed(1)+"</td></tr></table></div>";
    
    var ccHtml ="<div class='carbonContributorsArea'><h2>Carbon contributors</h2>"+
    "<table><thead><tr><td>name</td><td>carbon for this meeting (kg co2)</td></tr></thead>";
    for(var name in totalKmsPerson){
      var kgperson = totalKmsPerson[name];
      var as_percentage = kgperson/totalcft * 100;
      
      ccHtml += "<tr><td>"+name+"</td><td>"+kgperson.toFixed(1)+" ("+as_percentage.toFixed(1)+"%)</td></tr>";
    }

    ccHtml += "</table></div>";
    var active;
    var resultElement= macro.getResultsBox();
    var iconArea = macro.getIconArea(resultElement);
    var factsArea = macro.getFactsArea(resultElement);
  
    var summaryArea = macro.getSummaryArea(resultElement)
    jQuery(summaryArea).html(summaryHtml +ccHtml);
    
    jQuery(iconArea).html(iconHtml);

    jQuery(factsArea).html(factsHtml);

    jQuery(".fact",factsArea).css({display:"none"});

    jQuery(".icon",iconArea).mouseover(function(e){
      var update = jQuery(this).attr("updates");
      if(active){
        jQuery("[name="+active+"]",factsArea).css({display:"none"});
        active = false;
      }
      
      jQuery("[name="+update+"]",factsArea).css({display:""});
    });
    jQuery(".icon",iconArea).mouseout(
    function(e){
      var update = jQuery(this).attr("updates");
      if(active != update)jQuery("[name="+update+"]").css({display:"none"});
    }
    );
    jQuery(".icon",iconArea).click(function(){
      var update = jQuery(this).attr("updates");
      active = update;
    })
    jQuery(".resultsBox",resultElement).html("<span class='intro'>"+lingo.yourfootprintis+"</span><span class='value'>"+totalcft.toFixed(1) + "</span> <span class='units'>kg co2</span>");
     jQuery(".generator",place).val("CALCULATE")
     var link = jQuery(".codeLink",resultElement);
    link.css({"display":""});
    var codeStringEncoded = jQuery.encoding.strToBe32s(result.codeString).join("?");
    result.codeStringEncoded = codeStringEncoded;
    var updateShareArea = function(place){  
      jQuery(".shareArea textarea",place).val(codeStringEncoded);
    }
    var codePopUp = function(){
      //console.log(result.codeString);
      updateShareArea(resultElement)
      jQuery(".codeArea",resultElement).css({"display":""});
    }
    updateShareArea(resultElement)
    link.click(codePopUp);
    jQuery(".hider",resultElement).click(function(){
      jQuery(".codeArea",resultElement).css({"display":"none"});
    })
    result.totalCarbon =totalcft;
    result.totalCost = totalcost
    
    
    
    macro.afterGenerate(resultElement,result);
  }

  ,displayReport: function(){
    
  }
  ,generateReport: function(place,name,transport,remaining_legs,destLat,destLng,result,options){
    /*
    result is a json in the form:
    {
      codeString: <string representing all data in form values separated by |>
      totalKms:{
        <transport mode>: kms
      }
      totalKmsPerson:{
        <id>: kms
      }
        journeys:{
          <id>: ['leg1',leg2',leg3']
        }
      
    }
    
    */

    //return;
    
     var carbonCalculator = config.macros.CarbonFootprintForm.kgco2perkm;
      var codeString = result.codeString;
      
      var totalKms = result.totalKms;
      var totalKmsPerson = result.totalKmsPerson;
      var cff = config.macros.CarbonFootprintForm;
      if(remaining_legs.length==0) {
        options.calculatedParticipants +=1;
        if(options.calculatedParticipants>=options.numParticipants)config.macros.CarbonFootprintForm.printSummary(place,result);
        return;
      }
      var macro = config.macros.CarbonFootprintForm;
      var postcode = macro.get_google_search_term(remaining_legs[remaining_legs.length-1]);
      if(!postcode) return;
      if(!transport[transport.length-1]) return;
      //console.log("params",transport,remaining_legs);
      ajaxReq({params:{transport:transport,name:name,legs:remaining_legs,destLat:destLat,destLng:destLng},url:cff.ajaxUrl+postcode, success:function(r){
        var transports = this.params['transport'];
        var remaining_legs =this.params.legs;
        var postcode = remaining_legs[remaining_legs.length-1];
        
        var transport = transports[transports.length-1]
        //console.log("Calculating distance from",postcode,"to",destLat,destLng,"by",transport);
        remaining_legs =remaining_legs.slice(0,remaining_legs.length-1);
        var remaining_transport = transports.slice(0,transports.length-1);
        
        var nameParticipant = this.params['name'];      
        var geo = macro.getLngLatFromGoogleResponse(postcode, r);
        var kmTravelled = config.macros.CarbonFootprintForm.calculateKm(this.params.destLat,this.params.destLng,geo.lat,geo.lng);
        if(options.returnjourney){
          kmTravelled *=2;
        }
        if(!totalKms[transport])totalKms[transport]= 0;
        totalKms[transport] += kmTravelled;
        totalKmsPerson[nameParticipant] += (carbonCalculator[transport]* kmTravelled);
        config.macros.CarbonFootprintForm.generateReport(place,name,remaining_transport,remaining_legs,geo.lat,geo.lng,result,options); //calculate remaining legs.
      },fail:function(){alert("something went wrong.. make sure you are connected to the internet..");}});
    
  }
  ,getLngLatFromGoogleResponse: function(name, response){
      var macro = config.macros.CarbonFootprintForm;
      if(!response){
        throw "Tried to query geodata for given location but got nothing back for the handler!";
      }
      var data = eval("("+response+")");
      var topResult = data["responseData"].results[0];
      if(!topResult){
        alert("Couldn't find "+ postcode + " check this is a valid postcode.");
      }
      var lng = topResult.lng
      var lat = topResult.lat;

      macro["search-cache"][name] = {"lng":lng,"lat":lat};
      return macro["search-cache"][name];
  }
  ,loadData: function(place,options){
    var macro =config.macros.CarbonFootprintForm;
    var p = prompt("Please paste your unique code into the box below.");
    p = jQuery.encoding.be32sToStr(p.split("?"));
    jQuery(".journeyLegArea").html("");
    //console.log(p);
    var linesData = p.split("::");
    var rows = linesData.length;
    var actualRows = jQuery(".participant",place).length;
    var neededRows =rows- actualRows-1;
    for(var i=0; i < neededRows;i++){
      config.macros.CarbonFootprintForm.addParticipant(place);
    }
    
    actualRows = jQuery(".participant",place);
    for(var i=0; i < rows-1; i++){
      var lineData =linesData[i].split("||");
      var name = lineData[0];
      var location = lineData[1];
      var transport = lineData[2];
      var row =actualRows[i];
      jQuery("input[name=participant]",row).val(name);
      jQuery("input[name=location]",row).val(location);
      jQuery("option[value="+transport+"]",row).attr("selected", "selected");
      
      var legIndex = 3;
      while(lineData[legIndex]){
        var location =lineData[legIndex];
        var transport = lineData[legIndex+1];
        macro.addJourneyLeg(row,location,transport);
        legIndex += 2;
      }
      
    }
    jQuery("input[name=meeting_location]").val(linesData[linesData.length-1]);
    macro.calculate(place,options);
  }
  
  ,calculateDistances: function(place,fromLng,fromLat,startLocation,options){
    var participants = jQuery(".participant",place);
    var result ={totalKms:{},codeString:startLocation,totalKmsPerson:{},meetingLocation:startLocation};
    var totalKms = {};
    var codeString=result.codeString;
    var num_journeys = 0;
    var allJourneys = {};
    var numberValidParticipants =  0;
    for(var i=0; i < participants.length; i++){
      
      var participant = participants[i];
      var name = jQuery("input[name=participant]",participant).val() || "person " + parseInt(i+1);
      if(!result.totalKmsPerson[name])result.totalKmsPerson[name] = 0;
      var postcode = jQuery("input[name=location]",participant).val();
      var transport = jQuery("select[name=transport]",participant).val();
      var legs = jQuery("input[name=via]",participant);
      var transportlegs = jQuery("select[name=viaTransport]",participant);
      var thisCodeString =  name+"||"+postcode+"||"+transport;
      var legs_to_destination = [];
      var transport_to_destination= [];
      transport_to_destination.push(transport);
      legs_to_destination.push(postcode);
      for(var j=0; j < legs.length;j++){
        var leg = jQuery(legs[j]).val();
        var transportLeg = jQuery(transportlegs[j]).val();
        if(leg){
          legs_to_destination.push(leg);
          thisCodeString += "||"+leg + "||"+transportLeg;
          transport_to_destination.push(transportLeg);
        }
      
      }
      var aJourney = legs_to_destination.concat(startLocation);
      if(name)allJourneys[name] = aJourney;
      codeString = thisCodeString + "::"+ codeString;
      result.codeString = codeString;
      if(postcode){
       numberValidParticipants +=1; config.macros.CarbonFootprintForm.generateReport(place,name,transport_to_destination,legs_to_destination,fromLat,fromLng,result,options); 
        num_journeys +=1;
      }
    }

    result.journeys = allJourneys;
    
    options.numParticipants=numberValidParticipants;
    if(num_journeys ==0){
      alert("please enter at least one location for one of your participants!");
    }
    //console.log(codeString);
    
    
  }
  ,calculateKm: function(fromLat,fromLng, lat,lng){
    if(fromLat == lat && fromLng == lng) return 0;
    var a1 = Math.PI /180 * (fromLat);
    var b1 = Math.PI /180 * (fromLng);
    var a2 = Math.PI /180 * (lat);
    var b2 = Math.PI /180 * (lng);
    var radius =  6378; //in km
    return Math.acos(Math.cos(a1)*Math.cos(b1)*Math.cos(a2)*Math.cos(b2) + Math.cos(a1)*Math.sin(b1)*Math.cos(a2)*Math.sin(b2) + Math.sin(a1)*Math.sin(a2)) * radius;
  }
  ,afterConstructForm: function(place){
    //an empty function you can override with customisations
  }
  ,afterGenerate: function(place,result){
     //an empty function you can override with customisations
  }
  ,afterAddJourneyLeg: function(place){
    
  }
  ,afterAddParticipant: function(place){
    //an empty function you can override with customisations
  }
  ,getResultsBox: function(place,options){
    return jQuery(".resultScreen",place)[0];
  }
  ,getIconArea: function(place){
    return jQuery(".iconsArea",place)[0];
  }
  ,getFactsArea: function(place){
    return jQuery(".factsArea",place)[0]
  }
  ,getSummaryArea: function(place){
    return jQuery(".summaryArea",place)[0]
  }
  
};

jQuery("body").append("<a id='magic'>magic button</a>");
(function($) {

	$.fn.konami = function(callback, code) {
		if(code == undefined) code = "38,38,40,40,37,39,37,39,66,65";
		
		return this.each(function() {
			var kkeys = [];
			$(this).keydown(function(e){
				kkeys.push( e.keyCode );
				if ( kkeys.toString().indexOf( code ) >= 0 ){
					$(this).unbind('keydown', arguments.callee);
					callback(e);
				}
			}, true);
		});
	}

})(jQuery);


var konamicode =function(){
  var place = jQuery(".calculator")[0];
  config.macros.CarbonFootprintForm.printSummary(place,({totalKms:{'car (unknown fuel)':101510.7659342878, 'plane (long-haul international)':73667.27872696871}, codeString:"Verminous Skumm||Tokyo||plane (long-haul international)::Captain Pollution||San Francisco||car (unknown fuel)||Vancouver, Canada||plane (long-haul international)||Cape town, South Africa||car (unknown fuel)||Paris||plane (long-haul international)::Sky Sludge||Beijing||plane (long-haul international)||Moscow||car (unknown fuel)||Cape Town, South Africa||car (unknown fuel)||New York||car (unknown fuel)::Looten Plunder||Moscow||plane (long-haul international)||Rome, Italy||car (unknown fuel)::Duke Nukem||Manila||plane (long-haul international)||Kuala Lumpur||car (unknown fuel)::copenhagen", totalKmsPerson:{'Duke Nukem':4474.155011353305, 'Looten Plunder':1156.1358435757438, 'Sky Sludge':13032.255849480058, 'Captain Pollution':8237.229918122099, 'Verminous Skumm':1952.075382108249}, meetingLocation:"copenhagen", journeys:{'Duke Nukem':["Manila", "Kuala Lumpur", "copenhagen"], 'Looten Plunder':["Moscow", "Rome, Italy", "copenhagen"], 'Sky Sludge':["Beijing", "Moscow", "Cape Town, South Africa", "New York", "copenhagen"], 'Captain Pollution':["San Francisco", "Vancouver, Canada", "Cape town, South Africa", "Paris", "copenhagen"], 'Verminous Skumm':["Tokyo", "copenhagen"]}, codeStringEncoded:"1449489005?1768845173?1931498347?1970105724?2085908331?2037349500?1886151022?1696606316?1869506349?1751217516?543780468?1701998177?1953066862?1634478394?977494384?1952541038?542142316?1819636841?1869511804?1398894112?1181901166?1667855203?1870429283?1634869288?1970170734?1870097952?1718969708?696024150?1634624367?1970693490?740311905?1851876449?2088530028?1634624800?678195054?1731029089?1970020457?1853121906?1851880553?1869504876?696024131?1634755872?1953462126?740316015?1970563104?1097233001?1667333244?1667330592?678784619?1852798830?543585637?1814658172?1348563561?1937538160?1818324581?539520111?1852255592?1635085344?1768846437?1919836532?1768910433?1814641210?1399552288?1399616868?1734704252?1113942378?1768843132?2087742561?1852121128?1819242087?761815413?1814063470?1952805486?1635019119?1851878441?2088521071?1935896439?2088526689?1914710133?1852534383?2003705958?1969581097?2088518497?1885675604?1870097964?542338933?1952981057?1718774115?1635548259?1634869288?1970170734?1870097952?1718969708?696024142?1702305881?1869769596?2086887794?539522414?1802399607?1847617141?1701587258?978087791?1952804384?1349285230?1684370044?2085449587?1668249468?2087742561?1852121128?1819242087?761815413?1814063470?1952805486?1635019119?1851878441?2088522351?1835346976?1232363884?2038201443?1634869288?1970170734?1870097952?1718969708?691681860?1969972512?1316318053?1836874829?1634625900?1635548272?1818324581?539520111?1852255592?1635085344?1768846437?1919836532?1768910433?1814658172?1265983852?1629506677?1836086642?2088526689?1914710133?1852534383?2003705958?1969581097?976905071?1885695592?1634166126", totalCarbon:28851.852004639455, totalCost:17976.04238132215}));
};
jQuery(document).konami(konamicode);
jQuery("#magic").click(konamicode);




config.macros.CarbonFootprintForm.templates.resultScreen ="<div class='resultsBox'></div>"+
"<div class='summaryBox'>"+
  "<div class='factsArea'></div>"+  
  "<div class='iconsArea'></div>"+  
  "<div class='carbonContributorsArea'></div>"+
  "<div class='summaryArea'></div>"+
"</div>"+
"<div class='shareArea'></div>";

config.macros.CarbonFootprintForm.templates.basicFrame= "<div class='calculator'>"+
              "<div class='top'>"+
                "<div class='resultScreen'></div>"+
              "</div>"+
              "<div class='bottom'>"+
                "<div class='innerFrame'>"+
                    "<div class='carbonArea'></div>"+
                "</div>"+
              "</div>"+
            "</div>";
/***
|''Requires''|CarbonFootprintPlugin|
***/
//{{{
	if(config.browser.isIE && config.browser.ieVersion[1] =='6.0'){
	  jQuery("body").addClass("ie6");
	}
	
	config.macros.CarbonFootprintForm.afterGeneratePerspective = function(place, result){
		var logo = jQuery(".toolTitle");
	  jQuery(".carbontool .header").prepend("<div class='toolTitle'>"+logo.html()+"</div>");
	  logo.remove();
	  jQuery(".toolSubTitle").remove();
		jQuery(".summaryBox").css({display:""});
	  jQuery("#factArea").css({display:""});
		jQuery(".curbCO2").remove();


	  jQuery(".icon").hover(function(){
	      var filename = jQuery(this).attr("updates");

	      if(filename){
	        filename = "images/icons/"+filename.replace("fact_","")+".gif";
	      }
	      jQuery(this).css({"background-image":"url("+filename+")"});
	    },
	    function(){
	      var filename = jQuery(this).attr("updates");
	      if(filename){
	        filename = "images/icons/"+filename.replace("fact_","")+"_small.gif";
	      }
	      jQuery(this).css({"background-image":"url("+filename+")"});
	  })
	  jQuery('html, body').animate({scrollTop:0}, 'slow');
	};
	config.macros.CarbonFootprintForm.afterGenerate = config.macros.CarbonFootprintForm.afterGeneratePerspective;  
	
	 config.macros.CarbonFootprintForm.getResultsBox = function(){
	   return document.getElementById("toolTop");
	 }
	 config.macros.CarbonFootprintForm.getSummaryArea = function(){ 
	   return document.getElementById("journeySummaryArea");
	 }

	 config.macros.CarbonFootprintForm.getFactsArea = function(){ 
	   return document.getElementById("factArea");
	 }
	Tiddler.prototype.autoLinkWikiWords = function(){return true;};
	config.macros.CarbonFootprintForm.templates.resultScreen ="<div class='resultTop'><div class='resultsBox'></div><div id='factArea' style='display:none;'></div></div>"+
	"<div class='summaryBox' style='display:none;'>"+
	  "<div class='iconsArea'></div>"+  
	"</div>"+
	"<div class='shareArea'></div>";

config.macros.roundedCorners = {
	handler: function(place,macroName,params){
		jQuery(params[0]).corner();
	}
}

config.macros.applyTransparency = {
	handler: function(place, macroName, params) {
		jQuery(params[0]).supersleight();
	}
}
jQuery.fn.supersleight = function(settings) {
	settings = jQuery.extend({
		imgs: true,
		backgrounds: true,
		shim: 'images/transparent.gif',
		apply_positioning: true
	}, settings);
	
	return this.each(function(){
		if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4) {
			jQuery(this).find('*').andSelf().each(function(i,obj) {
				var self = jQuery(obj);
				// background pngs
				if (settings.backgrounds && self.css('background-image').match(/\.png/i) !== null) {
					var bg = self.css('background-image');
					var src = bg.substring(5,bg.length-2);
					var mode = (self.css('background-repeat') == 'no-repeat' ? 'crop' : 'scale');
					var styles = {
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')",
						'background-image': 'url('+settings.shim+')'
					};
					self.css(styles);
				};
				// image elements
				if (settings.imgs && self.is('img[src$=png]')){
					var styles = {
						'width': self.width() + 'px',
						'height': self.height() + 'px',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + self.attr('src') + "', sizingMethod='scale')"
					};
					self.css(styles).attr('src', settings.shim);
				};
				// apply position to 'active' elements
				if (settings.apply_positioning && self.is('a, input') && (self.css('position') === '' || self.css('position') == 'static')){
					self.css('position', 'relative');
				};
			});
		};
	});
};

/*!
 * jQuery corner plugin: simple corner rounding
 * Examples and documentation at: http://jquery.malsup.com/corner/
 * version 2.03 (05-DEC-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */

/**
 *  corner() takes a single string argument:  $('#myDiv').corner("effect corners width")
 *
 *  effect:  name of the effect to apply, such as round, bevel, notch, bite, etc (default is round). 
 *  corners: one or more of: top, bottom, tr, tl, br, or bl. 
 *           by default, all four corners are adorned. 
 *  width:   width of the effect; in the case of rounded corners this is the radius. 
 *           specify this value using the px suffix such as 10px (and yes, it must be pixels).
 *
 * @author Dave Methvin (http://methvin.com/jquery/jq-corner.html)
 * @author Mike Alsup   (http://jquery.malsup.com/corner/)
 */
;(function($) { 

var ua = navigator.userAgent;
var moz = $.browser.mozilla && /gecko/i.test(ua);
var webkit = $.browser.safari && /Safari\/[5-9]/.test(ua);

var expr = $.browser.msie && (function() {
    var div = document.createElement('div');
    try { div.style.setExpression('width','0+0'); div.style.removeExpression('width'); }
    catch(e) { return false; }
    return true;
})();
    
function sz(el, p) { 
    return parseInt($.css(el,p))||0; 
};
function hex2(s) {
    var s = parseInt(s).toString(16);
    return ( s.length < 2 ) ? '0'+s : s;
};
function gpc(node) {
    for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
        var v = $.css(node,'backgroundColor');
        if (v == 'rgba(0, 0, 0, 0)')
            continue; // webkit
        if (v.indexOf('rgb') >= 0) { 
            var rgb = v.match(/\d+/g); 
            return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
        }
        if ( v && v != 'transparent' )
            return v;
    }
    return '#ffffff';
};

function getWidth(fx, i, width) {
    switch(fx) {
    case 'round':  return Math.round(width*(1-Math.cos(Math.asin(i/width))));
    case 'cool':   return Math.round(width*(1+Math.cos(Math.asin(i/width))));
    case 'sharp':  return Math.round(width*(1-Math.cos(Math.acos(i/width))));
    case 'bite':   return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
    case 'slide':  return Math.round(width*(Math.atan2(i,width/i)));
    case 'jut':    return Math.round(width*(Math.atan2(width,(width-i-1))));
    case 'curl':   return Math.round(width*(Math.atan(i)));
    case 'tear':   return Math.round(width*(Math.cos(i)));
    case 'wicked': return Math.round(width*(Math.tan(i)));
    case 'long':   return Math.round(width*(Math.sqrt(i)));
    case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
    case 'dog':    return (i&1) ? (i+1) : width;
    case 'dog2':   return (i&2) ? (i+1) : width;
    case 'dog3':   return (i&3) ? (i+1) : width;
    case 'fray':   return (i%2)*width;
    case 'notch':  return width; 
    case 'bevel':  return i+1;
    }
};

$.fn.corner = function(options) {
    // in 1.3+ we can fix mistakes with the ready state
	if (this.length == 0) {
        if (!$.isReady && this.selector) {
            var s = this.selector, c = this.context;
            $(function() {
                $(s,c).corner(options);
            });
        }
        return this;
	}

    return this.each(function(index){
		var $this = $(this);
		var o = [ options || '', $this.attr($.fn.corner.defaults.metaAttr) || ''].join(' ').toLowerCase();
		//var o = (options || $this.attr($.fn.corner.defaults.metaAttr) || '').toLowerCase();
		var keep = /keep/.test(o);                       // keep borders?
		var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]);  // corner color
		var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]);  // strip color
		var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
		var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
		var fx = ((o.match(re)||['round'])[0]);
		var edges = { T:0, B:1 };
		var opts = {
			TL:  /top|tl|left/.test(o),       TR:  /top|tr|right/.test(o),
			BL:  /bottom|bl|left/.test(o),    BR:  /bottom|br|right/.test(o)
		};
		if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
			opts = { TL:1, TR:1, BL:1, BR:1 };
			
		// support native rounding
		if ($.fn.corner.defaults.useNative && fx == 'round' && (moz || webkit) && !cc && !sc) {
			if (opts.TL)
				$this.css(moz ? '-moz-border-radius-topleft' : '-webkit-border-top-left-radius', width + 'px');
			if (opts.TR)
				$this.css(moz ? '-moz-border-radius-topright' : '-webkit-border-top-right-radius', width + 'px');
			if (opts.BL)
				$this.css(moz ? '-moz-border-radius-bottomleft' : '-webkit-border-bottom-left-radius', width + 'px');
			if (opts.BR)
				$this.css(moz ? '-moz-border-radius-bottomright' : '-webkit-border-bottom-right-radius', width + 'px');
			return;
		}
			
		var strip = document.createElement('div');
		strip.style.overflow = 'hidden';
		strip.style.height = '1px';
		strip.style.backgroundColor = sc || 'transparent';
		strip.style.borderStyle = 'solid';
	
        var pad = {
            T: parseInt($.css(this,'paddingTop'))||0,     R: parseInt($.css(this,'paddingRight'))||0,
            B: parseInt($.css(this,'paddingBottom'))||0,  L: parseInt($.css(this,'paddingLeft'))||0
        };

        if (typeof this.style.zoom != undefined) this.style.zoom = 1; // force 'hasLayout' in IE
        if (!keep) this.style.border = 'none';
        strip.style.borderColor = cc || gpc(this.parentNode);
        var cssHeight = $.curCSS(this, 'height');

        for (var j in edges) {
            var bot = edges[j];
            // only add stips if needed
            if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
                strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
                var d = document.createElement('div');
                $(d).addClass('jquery-corner');
                var ds = d.style;

                bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);

                if (bot && cssHeight != 'auto') {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.bottom = ds.left = ds.padding = ds.margin = '0';
                    if (expr)
                        ds.setExpression('width', 'this.parentNode.offsetWidth');
                    else
                        ds.width = '100%';
                }
                else if (!bot && $.browser.msie) {
                    if ($.css(this,'position') == 'static')
                        this.style.position = 'relative';
                    ds.position = 'absolute';
                    ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
                    
                    // fix ie6 problem when blocked element has a border width
                    if (expr) {
                        var bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
                        ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"');
                    }
                    else
                        ds.width = '100%';
                }
                else {
                	ds.position = 'relative';
                    ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' : 
                                        (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';                
                }

                for (var i=0; i < width; i++) {
                    var w = Math.max(0,getWidth(fx,i, width));
                    var e = strip.cloneNode(false);
                    e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
                    bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
                }
            }
        }
    });
};

$.fn.uncorner = function() { 
	if (moz || webkit)
		this.css(moz ? '-moz-border-radius' : '-webkit-border-radius', 0);
	$('div.jquery-corner', this).remove();
	return this;
};

// expose options
$.fn.corner.defaults = {
	useNative: true, // true if plugin should attempt to use native browser support for border radius rounding
	metaAttr:  'data-corner' // name of meta attribute to use for options
};
    
})(jQuery);