/// VERSION 1.00
/**
* Copyright (c) 2010 Habit Industries, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
(function(){if(window.streamJs){var _streamJs=window.streamJs}var streamJs=window.streamJs={_apiKey:false,_init:false,_prefix:"_hs_",_url:"http://www.habitstream.com/api/service/http",_urlSite:false,_version:1,init:function(apiKey){if(false===streamJs._init){streamJs._apiKey=apiKey;streamJs._urlSite=streamJs._getSiteUrl();streamJs._init=true}},call:function(method,parameters,callback){var endpoint=streamJs._url;parameters.format="json";parameters.key=streamJs._apiKey;parameters.method=method;parameters.version=streamJs._version;if(undefined!==callback){parameters.callback=callback}var url=streamJs._buildUrl(endpoint,parameters);streamJs._require(url)},isOkStatus:function(data){return(undefined!==data)&&(undefined!==data.stat)&&("ok"===data.stat)},_buildUrl:function(base,params){var first=(0>base.indexOf('?'))?true:false;for(var key in params){if(first){base+=("?"+key+"="+params[key]);first=false}else{base+=("&"+key+"="+params[key])}}return base},_getUrlParam:function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regexS="[\\?&#]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(null===results){return""}else{return results[1]}},_getSiteUrl:function(){var params={};var url=window.location.href;var hash=url.indexOf('#');if(-1<hash){url=url.substring(0,hash)}var pieces=url.split('?');if(1<pieces.length){url=pieces[0];var pairs=pieces[1].split('&');for(var i in pairs){var pair=pairs[i].split('=');var preLength=streamJs._prefix.length;if(pair[0].length<preLength||streamJs._prefix!==pair[0].substr(0,preLength)){if(1<pair.length){params[pair[0]]=pair[1]}}}url=streamJs._buildUrl(url,params)}return url},_require:function(libraryName){var head=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=libraryName;head.appendChild(newScript)},_requireScript:function(script){var body=window.document.getElementsByTagName('body')[0];var newScript=window.document.createElement('script');newScript.text=script;newScript.type='text/javascript';body.appendChild(newScript)}}})();