/* GLOBAL FUNCTIONS */
function fbs_click(u, t) { if(!u) { u=location.href; } if(!t) { t=document.title; } urchinTracker('/share/facebook');window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false; }

/* cross browser object referencing */
function eff_EleObjs(e) { if(typeof(e)=='string') { if(document.getElementById) { e=document.getElementById(e); } else if(document.all) { e=document.all[e]; } else { e=null; } } return e; }

function WTPO_writeToLayer(code_string,layer_id){ eff_EleObjs(layer_id).innerHTML=code_string; }
function WTPO_HideLayer(layer_id) { eff_EleObjs(layer_id).style.display='none'; }
function WTPO_ShowLayer(layer_id) { eff_EleObjs(layer_id).style.display='block'; }

function ffe_LoadScript(url) {
  if (document.createElement && document.getElementsByTagName) {
  	var s = document.createElement('script');var h = document.getElementsByTagName('head');
  	if (s && h.length) { s.src = url;h[0].appendChild(s); }
  }
}

/* page loading alert */
IE5=NN6=false;
if(document.all)IE5=true;
else if(document.getElementById)NN6=true;
var ffe_pl_w = 375;
var ffe_pl_h = 350;
var myObj;

function ffe_pl_Init(pl_w, pl_h) {
	myObj = eff_EleObjs('ffe_page_loading').style;
	if(pl_w) { ffe_pl_w = pl_w;ffe_pl_h = pl_h; }
	if(WC_browserAcceptsCookies() && !WC_readCookie('ffe_pl_viewed')) {
		WTPO_writeToLayer('<div id="ffe_pl_bg"><img src="/images/5.0/icon_loading_flower.gif" width="35" height="35" alt="A lot of wacky loading going on..." border="0" style="margin:15px 0px 0px 0px;"></div><div id="ffe_pl_content"><div id="ffe_pl_inner"><h3>Page wireframe loading...</h3><div>We\'re loading all that wacky wireframe stuff into your browser for the first time so wait a couple of seconds... pretty please!<br/><br/>All must bow to the Bean!<div><img src="/images/5.0/logo_wc_bean.gif" width="125" height="127" alt="" border="0" vspace="5"></div></div><div class="ffe_pl_cl"><a href="javascript:ffe_pl_End();"><b>click to manually close alert</b></a></div></div></div>','ffe_page_loading');
		WTPO_ShowLayer('ffe_page_loading');
		ffe_pl_rePos();
		WC_setCookie('ffe_pl_viewed', 'yes', 720000, '/');
	}
}




function ffe_pl_rePos() {
	if(NN6) { xc=Math.round((window.innerWidth/2)-(ffe_pl_w/2));yc=Math.round((window.innerHeight/2)-(ffe_pl_h/2));	}
	else { xc=Math.round((document.body.clientWidth/2)-(ffe_pl_w/2));yc=Math.round((document.body.clientHeight/2)-(ffe_pl_h/2));}
	myObj.left = xc + "px";
	myObj.top = yc + "px";
}

function ffe_pl_End() {	WTPO_HideLayer('ffe_page_loading'); }

/* browser detection */
var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS";},searchString:function(data){for(var i=0;i<data.length;i++){var dataString=data[i].string;var dataProp=data[i].prop;this.versionSearchString=data[i].versionSearch||data[i].identity;if(dataString){if(dataString.indexOf(data[i].subString)!=-1)
return data[i].identity;}
else if(dataProp)
return data[i].identity;}},searchVersion:function(dataString){var index=dataString.indexOf(this.versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+this.versionSearchString.length+1));},dataBrowser:[{string:navigator.userAgent,subString:"OmniWeb",versionSearch:"OmniWeb/",identity:"OmniWeb"},{string:navigator.vendor,subString:"Apple",identity:"Safari"},{prop:window.opera,identity:"Opera"},{string:navigator.vendor,subString:"iCab",identity:"iCab"},{string:navigator.vendor,subString:"KDE",identity:"Konqueror"},{string:navigator.userAgent,subString:"Firefox",identity:"Firefox"},{string:navigator.vendor,subString:"Camino",identity:"Camino"},{string:navigator.userAgent,subString:"Netscape",identity:"Netscape"},{string:navigator.userAgent,subString:"MSIE",identity:"Explorer",versionSearch:"MSIE"},{string:navigator.userAgent,subString:"Gecko",identity:"Mozilla",versionSearch:"rv"},{string:navigator.userAgent,subString:"Mozilla",identity:"Netscape",versionSearch:"Mozilla"}],dataOS:[{string:navigator.platform,subString:"Win",identity:"Windows"},{string:navigator.platform,subString:"Mac",identity:"Mac"},{string:navigator.platform,subString:"Linux",identity:"Linux"}]};
BrowserDetect.init();

/* COOKIE HANDLING CODE */
function WC_browserAcceptsCookies(){var WC_acceptsCookies=false;if(document.cookie==''){document.cookie='WC_acceptsCookies=yes';if(document.cookie.indexOf('WC_acceptsCookies=yes')!=-1){WC_acceptsCookies=true;}}else{WC_acceptsCookies=true;}
return(WC_acceptsCookies);}
function WC_setCookie(name,value,hours,path,domain,secure){if(WC_browserAcceptsCookies()){var numHours=0;var not_NN2=(navigator&&navigator.appName&&(navigator.appName=='Netscape')&&navigator.appVersion&&(parseInt(navigator.appVersion)==2))?false:true;if(hours&&not_NN2){if((typeof(hours)=='string')&&Date.parse(hours)){numHours=hours;}else if(typeof(hours)=='number'){numHours=(new Date((new Date()).getTime()+hours*3600000)).toGMTString();}}
document.cookie=name+'='+escape(value)+((numHours)?(';expires='+numHours):'')+((path)?';path='+path:'')+((domain)?';domain='+domain:'')+((secure&&(secure==true))?'; secure':'');}}
function WC_readCookie(name){if(document.cookie==''){return false;}else{var firstChar,lastChar;var theBigCookie=document.cookie;firstChar=theBigCookie.indexOf(name);var NN2Hack=firstChar+name.length;if((firstChar!=-1)&&(theBigCookie.charAt(NN2Hack)=='=')){firstChar+=name.length+1;lastChar=theBigCookie.indexOf(';',firstChar);if(lastChar==-1)lastChar=theBigCookie.length;return unescape(theBigCookie.substring(firstChar,lastChar));}else{return false;}}}
function WC_killCookie(name,path,domain){var theValue=WC_readCookie(name);if(theValue){document.cookie=name+'='+theValue+'; expires=Fri, 13-Apr-1970 00:00:00 GMT'+((path)?';path='+path:'')+((domain)?';domain='+domain:'');}}

/* JSON.ORG CODE */
if(!Object.prototype.toJSONString){Array.prototype.toJSONString=function(){var a=[],i,l=this.length,v;for(i=0;i<l;i+=1){v=this[i];switch(typeof v){case'object':if(v){if(typeof v.toJSONString==='function'){a.push(v.toJSONString());}}else{a.push('null');}
break;case'string':case'number':case'boolean':a.push(v.toJSONString());}}
return'['+a.join(',')+']';};Boolean.prototype.toJSONString=function(){return String(this);};Date.prototype.toJSONString=function(){function f(n){return n<10?'0'+n:n;}
return'"'+this.getFullYear()+'-'+
f(this.getMonth()+1)+'-'+
f(this.getDate())+'T'+
f(this.getHours())+':'+
f(this.getMinutes())+':'+
f(this.getSeconds())+'"';};Number.prototype.toJSONString=function(){return isFinite(this)?String(this):'null';};Object.prototype.toJSONString=function(){var a=[],k,v;for(k in this){if(this.hasOwnProperty(k)){v=this[k];switch(typeof v){case'object':if(v){if(typeof v.toJSONString==='function'){a.push(k.toJSONString()+':'+v.toJSONString());}}else{a.push(k.toJSONString()+':null');}
break;case'string':case'number':case'boolean':a.push(k.toJSONString()+':'+v.toJSONString());}}}
return'{'+a.join(',')+'}';};(function(s){var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};s.parseJSON=function(filter){var j;function walk(k,v){var i;if(v&&typeof v==='object'){for(i in v){if(v.hasOwnProperty(i)){v[i]=walk(i,v[i]);}}}
return filter(k,v);}
if(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)){try{j=eval('('+this+')');}catch(e){throw new SyntaxError('parseJSON');}}else{throw new SyntaxError('parseJSON');}
if(typeof filter==='function'){j=walk('',j);}
return j;};s.toJSONString=function(){if(/["\\\x00-\x1f]/.test(this)){return'"'+this.replace(/([\x00-\x1f\\"])/g,function(a,b){var c=m[b];if(c){return c;}
c=b.charCodeAt();return'\\u00'+
Math.floor(c/16).toString(16)+
(c%16).toString(16);})+'"';}
return'"'+this+'"';};})(String.prototype);}

/* start wackiness */
var wackyUser = {

    data: {},

    load: function () {
		var the_cookie = WC_readCookie('wackyUser_CSI');
        if (the_cookie) { this.data = unescape(the_cookie).parseJSON(); }
        return this.data;
    },

    save: function (expires, path) {        
		var d = expires || 720000;
        var p = path || '/';
		WC_setCookie('wackyUser_CSI', escape(this.data.toJSONString()), d, p);
    }
	
}

wackyUser.load();

/* wacky domain */
var ffe_doc_domain = '';
if(location.hostname.indexOf('wackycoffee.com')>0) { ffe_doc_domain = 'wackycoffee.com'; }
if(location.hostname.indexOf('65.23.158.72')>0) { ffe_doc_domain = '65.23.158.72'; }
if(ffe_doc_domain) { document.domain = ffe_doc_domain;}
