/* tools
 
@author Jacob at Goby
 @version 09/02/11
@svn goby_-150
*/

function cloneArray(node)
{var indexStack=[];for(var i=0;i<node.length;i++)
indexStack.push(node[i]);return indexStack;}
Number.prototype.toHexStr=function()
{var s="",v;for(var i=7;i>=0;i--){v=(this>>>(i*4))&0xf;s+=v.toString(16);}
return s;}
Number.prototype.toRad=function()
{return this*Math.PI/180;}
function isInteger(s)
{if(s)
return(s.toString().search(/^-?[0-9]+$/)==0);}
function isString(s)
{return(s.replace!=null&&s.match!=null?true:false);}
String.prototype.truncate=function(len,etc,words,mid)
{if(this.length>len)
{var str=this.toString();if(words)
{var str=str.substring(0,len+1);var str=str.replace(/\s+?(\S+)?$/,'');}
if(mid)
return str.substring(0,len/2)+etc+str.substring(-len/2);else
return str.substring(0,len)+etc;}
else
return this;}
String.prototype.replaceAll=function(FindString,ReplaceString)
{var NewString=this.toString();while(NewString.match(FindString))
{var oldeString=NewString.toString();NewString=NewString.replace(FindString,ReplaceString);if(NewString==oldeString)
return NewString;}
return NewString;}
String.prototype.lpad=function(padString,length)
{var str=this;while(str.length<length)
str=padString+str;return str;}
String.prototype.rpad=function(padString,length)
{var str=this;while(str.length<length)
str=str+padString;return str;}
String.prototype.htmlentities=function()
{var output='';var char_='';var len=this.length;for(i=0;i<len;i++)
{var char_=this.charCodeAt(i);if((char_>47&&char_<58)||(char_>62&&char_<127))
output+=this.charAt(i);else
output+="&#"+char_+";";}
return output;}
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.ltrim=function(){return this.replace(/^\s+/,"");}
String.prototype.rtrim=function(){return this.replace(/\s+$/,"");}
String.prototype.pluralize=function()
{return this.toString()+"s";}
String.prototype.urlEncode=function()
{var string=this.toString();string=string.toLowerCase();string=string.replaceAll("-","+");string=string.replaceAll("/","-");string=string.replaceAll(", ","-");string=string.replaceAll(",","-");string=string.replaceAll(" ","-");var nonword=/([^a-z0-9\+\-\'\&\(\)])+/g;string=string.replace(nonword,"");var space=/([\-]{2,99})+/g;string=string.replace(space,"-");return string;}
String.prototype.urlDecode=function()
{var utftext=unescape(this.toString());var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++;}
else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;}
else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}}
string=string.replaceAll("-"," ");return string;}
String.prototype.toSHA1=function()
{var msg=this.toString();var K=[0x5a827999,0x6ed9eba1,0x8f1bbcdc,0xca62c1d6];msg+=String.fromCharCode(0x80);var l=msg.length/4+2;var N=Math.ceil(l/16);var M=new Array(N);for(var i=0;i<N;i++){M[i]=new Array(16);for(var j=0;j<16;j++){M[i][j]=(msg.charCodeAt(i*64+j*4)<<24)|(msg.charCodeAt(i*64+j*4+1)<<16)|(msg.charCodeAt(i*64+j*4+2)<<8)|(msg.charCodeAt(i*64+j*4+3));}}
M[N-1][14]=((msg.length-1)*8)/Math.pow(2,32);M[N-1][14]=Math.floor(M[N-1][14])
M[N-1][15]=((msg.length-1)*8)&0xffffffff;var H0=0x67452301;var H1=0xefcdab89;var H2=0x98badcfe;var H3=0x10325476;var H4=0xc3d2e1f0;var W=new Array(80);var a,b,c,d,e;for(var i=0;i<N;i++){for(var t=0;t<16;t++)W[t]=M[i][t];for(var t=16;t<80;t++)W[t]=ROTL(W[t-3]^W[t-8]^W[t-14]^W[t-16],1);a=H0;b=H1;c=H2;d=H3;e=H4;for(var t=0;t<80;t++){var s=Math.floor(t/20);var T=(ROTL(a,5)+f(s,b,c,d)+e+K[s]+W[t])&0xffffffff;e=d;d=c;c=ROTL(b,30);b=a;a=T;}
H0=(H0+a)&0xffffffff;H1=(H1+b)&0xffffffff;H2=(H2+c)&0xffffffff;H3=(H3+d)&0xffffffff;H4=(H4+e)&0xffffffff;}
return H0.toHexStr()+H1.toHexStr()+H2.toHexStr()+H3.toHexStr()+H4.toHexStr();}
function f(s,x,y,z)
{switch(s){case 0:return(x&y)^(~x&z);case 1:return x^y^z;case 2:return(x&y)^(x&z)^(y&z);case 3:return x^y^z;}}
function ROTL(x,n)
{return(x<<n)|(x>>>(32-n));}
Date.prototype.getTimestamp=function()
{return this.getTime()/1000;}
Date.prototype.dayCodesShort={1:"mon",2:"tues",3:"weds",4:"thurs",5:"fri",6:"sat",0:"sun"}
Date.prototype.dayCodes={1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday",0:"sunday"}
Date.prototype.renderRealTime=function()
{return new EggTimer(this);}
Date.prototype.sameDay=function(date)
{if(!date)
return false;if(date.getMonth()==this.getMonth()&&date.getDate()==this.getDate()&&date.getFullYear()==this.getFullYear())
return true;else
return false;}
Date.prototype.monthShortCodes={0:"jan",1:"feb",2:"mar",3:"apr",4:"may",5:"jun",6:"jul",7:"aug",8:"sep",9:"oct",10:"nov",11:"dec"}
Date.prototype.monthLongCodes={0:"January",1:"February",2:"March",3:"April",4:"May",5:"June",6:"July",7:"August",8:"September",9:"October",10:"November",11:"December"};Date.prototype.formatTime=function()
{return this.getHour()+":"+this.getMinute()+this.getMeridian();}
Date.prototype.format=function(format)
{if(format=="link")
return this.getLZMonth()+" "+this.getLZDay()+" "+this.getFullYear();if(format=="m/d/y r")
{return this.getMonth()+"/"+this.getDate()+"/"+this.getYear()+" "+this.formatTime();}
var today=new Date();if(this.sameDay(today))
return(format=="oldway"?(today.getMonthShort()+" "+today.getDate()).toString():"today, "+(today.getMonthShort()+" "+today.getDate()).toString());if(format=="oldway")
return(this.getMonthShort()+" "+this.getDate()).toString();else if(format=='short')
return(this.getWeekday(true)+", "+this.getMonthShort()+" "+this.getDate()).toString();else if(format)
return(this.getWeekday()+", "+this.getMonthShort()+" "+this.getDate()).toString();else
return(this.getMonthShort()+" "+this.getDate()).toString();}
Date.prototype.getWeekday=function(sht)
{var today=new Date();if(this.sameDay(new Date()))
return"today";if(sht)
return this.dayCodesShort[this.getDay()]
else
return this.dayCodes[this.getDay()]}
Date.prototype.getLZDay=function()
{return this.getDate().toString().lpad('0',2);}
Date.prototype.getLZMonth=function()
{return((this.getMonth()+1).toString()).lpad('0',2);}
Date.prototype.getMonthShort=function()
{return this.monthShortCodes[this.getMonth()];}
function SlideShow(container,ctrl)
{this.container=container;this.controls=ctrl;this.container.items=[];var i=0;for(var index in this.container.childNodes)
{var item=this.container.childNodes[index];if(item.tagName=="LI")
{this.container.items.push(item);item.index=i++;$(item).css("position","absolute");$(item).hide();}}
this.current=this.container.items.shift();this.container.items.unshift(this.current);$(this.current).show();this.activateControls();this.showControls();objects.push(this);}
SlideShow.prototype={selectNext:function()
{var length=this.container.items.length-1;var index=this.current.index;var cur=index+1
if(cur>length)
cur=0;this.selectNode(cur);},selectPrev:function()
{var length=this.container.items.length-1;var index=this.current.index;var cur=index-1
if(cur<0)
cur=length;this.selectNode(cur);},showControls:function()
{$(this.controls).hover(function()
{$(this).children().show();},function()
{$(this).children().hide();});},selectNode:function(id)
{var node=this.container.items[id];if(node)
{$(this.current).fadeOut(250);$(node).fadeIn(250);this.current=node;}},activateControls:function()
{for(var index in this.controls.childNodes)
{var item=this.controls.childNodes[index];if(item.tagName=="A")
{$(item).data("slideshow",this);$(item).click(function()
{var slide=$(this).data('slideshow');if($(this).hasClass("prev"))
{slide.selectPrev();}
else if($(this).hasClass("next"))
{slide.selectNext();}});}}}}
var browser={IE:1,FIREFOX:2,OPERA:3,SAFARI:4,DEFAULT:5,IE_SIX:6,IE_SEVEN:7,IE_EIGHT:8,CHROME:9}
navigator.isIE=function(){return navigator.isBrowser(browser.IE)?true:navigator.isBrowser(browser.IE_SIX)?true:navigator.isBrowser(browser.IE_SEVEN)?true:navigator.isBrowser(browser.IE_EIGHT)?true:false;}
navigator.isValid=function()
{return true;}
navigator.isBrowser=function(code)
{if(this.getBrowserCode()==code)
return true;else
return false;}
navigator.getBrowserName=function()
{switch(this.getBrowserCode())
{case browser.IE:return"Microsoft Internet Explorer";break;case browser.IE_SIX:return"Internet Explorer 6";break;case browser.IE_SEVEN:return"Internet Explorer 7";break;case browser.IE_EIGHT:return"Internet Explorer 8";break;case browser.FIREFOX:return"Mozilla Firefox";break;case browser.OPERA:return"Opera";break;case browser.SAFARI:return"Safari";break;case browser.CHROME:return"Chrome";break;default:return"browser";}}
navigator.getBrowserCode=function()
{var userAgent=this.userAgent.toString();var appname=this.appName.toString();if(userAgent.match("MSIE [8]{1}"))
return browser.IE_EIGHT;else if(userAgent.match("MSIE [7]{1}"))
return browser.IE_SEVEN;else if(userAgent.match("MSIE [6]{1}"))
return browser.IE_SIX;else if(userAgent.match("MSIE [345]{1}"))
return browser.IE;else if(userAgent.match("Opera"))
return browser.OPERA;else if(userAgent.match("Chrome"))
return browser.CHROME;else if(userAgent.match("Safari"))
return browser.SAFARI;else if(userAgent.match("(?:Firefox|Gecko)"))
return browser.FIREFOX;else
return browser.DEFAULT;}
function browserDetect()
{var location=window.location.toString();if(!location.match("unsupportedBrowser"))
{if((navigator==undefined)||(!navigator.isValid()))
{window.open(Goby.conf('path.base')+"/unsupportedBrowser","_self");}}}
browserDetect();function BinaryTree(index)
{this.index=index;}
BinaryTree.prototype.add=function(node)
{if(!this.trunk)
{this.trunk={right:null,left:null,data:[]};this.trunk[this.index]=node[this.index]
this.trunk.data.push(node);}
else
this.addRecurse(node,this.trunk);}
BinaryTree.prototype.addRecurse=function(item,node)
{var itemIndex=item[this.index];var nodeIndex=node[this.index];if(itemIndex==nodeIndex)
{node.data.push(item);}
else if(itemIndex<nodeIndex)
{if(node.right)
this.addRecurse(item,node.right);else
{node.right={right:null,left:null,data:[],parent:node};node.right[this.index]=item[this.index];node.right.data.push(item);}}
else
{if(node.left)
this.addRecurse(item,node.left);else
{node.left={right:null,left:null,data:[],parent:node};node.left[this.index]=item[this.index];node.left.data.push(item);}}}
BinaryTree.prototype.isBalanced=function(node)
{return false;}
BinaryTree.prototype.balance=function()
{}
BinaryTree.prototype.balanceNode=function()
{}
BinaryTree.prototype.rotateLeft=function(p)
{var r=p.right;p.right=r.left;if(r.left!=null)
r.left.parent=p;r.parent=p.parent;if(p.parent==null)
root=r;else if(p.parent.left==p)
p.parent.left=r;else
p.parent.right=r;r.left=p;p.parent=r;}
BinaryTree.prototype.deleteNode=function()
{}
BinaryTree.prototype.getNode=function(value)
{if(this.trunk)
return this.getNodeRecurse(value,this.trunk);else
return false;}
BinaryTree.prototype.toStack=function(params)
{this.returnType="stack";return this.iterator(params);}
BinaryTree.prototype.toQueue=function(params)
{this.returnType="queue";return this.iterator(params);}
BinaryTree.prototype.iterator=function(params)
{this.result=null;this.i=0;this.result=[];switch(params.type)
{case"lt":this.getLesser(params.value,this.trunk);break;case"eq":this.getNodeRecurse(params.value,this.trunk);break;case"span":this.getSpan({hi:params.hi,lo:params.lo},this.trunk);break;case"gt":default:this.getGreater(params.value,this.trunk);}
var result=this.result;return result;}
BinaryTree.prototype.getSpan=function(params,node)
{if(node==null)
return false;this.i++;if((node[this.index]<params.hi)&&(node[this.index]>params.lo))
{this.getSpan(params,node.left);this.getSpan(params,node.right);this.iterate(node);}
else if(node.left)
{this.getSpan(params,node.left);}
else if(node.right)
{this.getSpan(params,node.right);}
else
return false;}
BinaryTree.prototype.getLesser=function(value,node)
{if(node==null)
return false;this.i++;if(value<node[this.index])
{this.getLesser(value,node.right);}
else
{this.iterate(node);this.getLesser(value,node.right);this.getLesser(value,node.left);}}
BinaryTree.prototype.getGreater=function(value,node)
{if(node==null)
return false;this.i++;if(value>node[this.index])
{this.getGreater(value,node.left);}
else
{this.iterate(node);this.getGreater(value,node.left);this.getGreater(value,node.right);}}
BinaryTree.prototype.getNodeRecurse=function(value,node)
{if(node==null)
return false;var result=false;if(node[this.index]==value)
{return this.iterate(node);}
if(node[this.index]>value)
{node.right[this.index];result=this.getNodeRecurse(value,node.right);}
if(node[this.index]<value)
result=this.getNodeRecurse(value,node.left);return result;}
BinaryTree.prototype.doIteration=function(node)
{}
BinaryTree.prototype.iterate=function(node)
{switch(this.returnType)
{case"stack":this.result.push(node);break;case"queue":this.result.unshift(node);break;default:this.doIteration(node);}}
function ImportScript()
{this.files=[];this.pointer=null;this.source=[];this.scripts=[];this.callback=[];this.request=[];this.head=null;this.queue=[];this.displayable=false;if(document.importScripts==null)
document.importScripts=[];document.importScripts.push(this);objects.push(this);}
ImportScript.prototype={getHead:function()
{if(this.head==null)
this.head=document.getElementsByTagName('head')[0];return this.head;},importFile:function(filename,params)
{if(!this.scripts[filename])
{this.scripts[filename]=new ScriptObject(filename,params,this);this.scripts[filename].fetchScript();return true;}
else
return false;},isLoaded:function(filename)
{return this.scripts[filename]!=null?true:false;},importStyle:function(filename)
{if(!this.scripts[filename])
this.scripts[filename]=new StyleObject(filename,this);else
return false;},importCode:function(code,label)
{if(!this.scripts[label])
{this.scripts[label]=new CodeObject(label,code,this);}
else
{}},removeScript:function(label)
{if(this.scripts[label])
{this.scripts[label]._destruct();this.scripts[label]=null;}},queueScript:function(script)
{if(script.inline)
{script.runScript();}
else
this.queue.push(script);},isDisplayable:function(script)
{if(script.async)
return true;return(this.displayable?true:false);},loadScript:function(script)
{if(this.isDisplayable(script))
script.runScript();else
this.queueScript(script);},loadQueuedScripts:function()
{this.displayable=true;while(this.queue.length>0)
this.queue.pop().runScript();},_destruct:function()
{for(var i in this.scripts)
this.scripts[i]._destruct();for(var index in this)
this[index]=null;killself(this);}}
function ScriptObject(filename,params,mgr)
{this.remote=false;this.mgr=mgr;var data=[];this.pointer=filename;this.inline=false;this.filename=filename;this.code=null;if(params!=null)
for(var i in params)
this[i]=params[i];}
ScriptObject.prototype={async:false,fetchScript:function()
{var data={};if(this.remote)
this.loadScript('remote');else
{this.request=new AjaxRequest(this.filename,{object:this,method:"loadScript"},data,"GET");this.request.makeRequest({noExec:1});}},runScript:function()
{var script=document.createElement("script");script.async=true;script.setAttribute('async',true);script.type="text/javascript";if(this.remote)
{script.src=renderResourceLink(RSC.ASSET,this.filename);}
else
{var script=document.createElement("script");script.text=this.source;}
if(this.inline)
{var head=this.mgr.getHead();head.appendChild(script);}
else
{if(this.container)
{this.container.appendChild(script);}
else
{var s=document.getElementsByTagName('script')[0];if(s!=null)
s.parentNode.insertBefore(script,s)
else
document.body.appendChild(script);}}
this.code=script;this.fireCallback();},fireCallback:function(script)
{if(this.callback)
{try
{this.times=0;this.callbackWrapper(this.code);}
catch(e)
{konsole.log('imported script callback',e);}}},callbackWrapper:function(params)
{try
{if(this.callback.object!=null)
this.callback.object[this.callback.method](this.code);else if(this.callback.fnc!=null)
this.callback.fnc(this.code);else if(this.callback.replace!=null)
eval(this.callback+"(this.code)");}
catch(e)
{if(this.times<20)
{var ldr=this;setTimeout(function(){ldr.callbackWrapper()},200);this.times++;}}},loadScript:function(data)
{this.source=data;this.mgr.loadScript(this);},_destruct:function()
{if(this.code!=null)
this.code.parentNode.removeChild(this.code);for(var i in this)
if(i!="mgr")
this[i]=null;}}
function CodeObject(label,code,mgr)
{this.mgr=mgr;this.pointer=label;this.filename=label;this.loadScript(code);}
CodeObject.prototype=new ScriptObject();function StyleObject(label,mgr)
{this.mgr=mgr;this.pointer=label;this.filename=label;this.remote=true;this.runScript();}
StyleObject.prototype=new ScriptObject();StyleObject.prototype.runScript=function()
{var script=document.createElement("link");script.href=renderResourceLink(RSC.ASSET,this.filename);script.type="text/css";script.rel="stylesheet";document.body.appendChild(script);}
function ImagePreloader(source,container,params)
{params.src=source;params.container=container;return this._construct(params);}
ImagePreloader.prototype={constraints:{"height":320,"width":240,'isBG':false,"loaderSource":"getImg=loaders/image_loader.gif","callback":null},_construct:function(params)
{var node=new Image();if(!Goby.has('imageLoad'))
Goby.set('imageLoad',new ILoad);for(var i in this)
node[i]=this[i];node.init(params);return node;},init:function(params)
{var container=params.container;this.src=params.src;this.loaderStyle=(params.loaderStyle?params.loaderStyle:'loader_image');this.container=params.container;this.callback=params.callback;$(this.container).addClass(this.loaderStyle);if(this.container.tagName=="IMG")
{this.container.alt='loading';this.container.src=Goby.conf('path.base')+"/getImg=loaders/image_loader.gif";}
var node=this;if(navigator.isIE())
this.timeout=window.setTimeout(function(){node.load()},500);Goby.get('imageLoad').add(this);if(this.isLoaded())
{this.load();}
else
{this.onabort=function(){this.error();}
this.onerror=function(){this.error();}
this.onload=function(){this.load();}}},_destruct:function()
{killself(this);},isLoaded:function()
{},error:function()
{if(this.src!=renderResourceLink(RSC.IMAGE,"getErrorImage_"+this.width+"x"+this.height))
this.src=renderResourceLink(RSC.IMAGE,"getErrorImage_"+this.width+"x"+this.height);},load:function()
{if(!this.container)
return null;if(this.container.tagName=="IMG")
this.container.src=this.src;else
this.container.appendChild(this);$(this.container).removeClass(this.loaderStyle);Goby.get('imageLoad').load(this);if(this.callback!=null)
{try{this.callback.object[this.callback.method](this);}
catch(e){}}
this.container=null;this._destruct();}}
function ILoad()
{objects.push(this);}
ILoad.prototype={finished:{},images:{},_destruct:function()
{for(var i in this.finished)
{this.finished[i]._destruct();this.finished[i]=null;}},add:function(image)
{if(this.finished[image.src])
image.load();else
{if(this.images[image.src]==null)
this.images[image.src]=[];this.images[image.src].push(this);}},load:function(image)
{if(image!=null&&image.src)
{this.finished[image.src]=image;var images=this.images[image.src];while(images.length>0)
images.pop().load();}},update:function()
{}}
function ProfileImage(src,ctr)
{this.container=ctr;this.src=src;this.init();}
ProfileImage.prototype={init:function()
{this.preloader=ImagePreloader
(this.src,this.container,{loaderStyle:"loader_profile",callback:{object:this,method:"load"}});},load:function(img)
{var w=$(img.parentNode).innerWidth();var m=(w-img.width)/2;this.img=img;if(this.loaderStyle)
$(this.container).removeClass(this.loaderStyle);$(img).css({'margin':m});}}
var tlog=false;var PV={URL:1,LABEL:2}
function trackSearchEvent(params,useLabel)
{var category=PAGE_ID+"_search_bar";var label=params[0];try
{if(params[1]!=undefined)
{var params2=new Array(category,label,params[1]);if(useLabel)
params2['useLabel']=true;trackEvent(params2);}
else
{var params2=new Array(category,label);trackEvent(params2);}}
catch(e)
{}}
function trackOffsite(result)
{try
{_gaq.push(['_trackPageview','/v/result_click_conversion/']);}
catch(e)
{}}
function trackEvent(params,pageview)
{try
{if(params[2]!=undefined)
{if(window.tlog)
konsole.log('trackEvent',[params[0],params[1],params[2]]);_gaq.push(['_trackEvent',params[0],params[1],params[2]]);}
else
{if(window.tlog)
konsole.log('trackEvent',[params[0],params[1]]);_gaq.push(['_trackEvent',params[0],params[1]]);}
if(pageview)
{if(pageview==PV.LABEL)
{if(window.tlog)
konsole.log('trackPageView',[params[1]]);_gaq.push(['_trackPageview','/v/'+params[1]]);}
else
{_gaq.push(['_trackPageview',$p=(Goby.has("PAGE_URL")?Goby.get("PAGE_URL"):'')]);if(window.tlog)
konsole.log('trackPageView',$p);}}}
catch(e)
{konsole.log("trackEvent params:",params,pageview," exception:",e);}}
function trackCustomVar(params)
{try
{if(params[3]!=undefined)
{if(window.tlog)
konsole.log('_setCustomVar',[params[0],params[1],params[2],params[3]]);_gaq.push(['_setCustomVar',params[0],params[1],params[2],params[3]]);}
else if(params[2]!=undefined)
{if(window.tlog)
konsole.log('_setCustomVar',[params[0],params[1],params[2]]);_gaq.push(['_setCustomVar',params[0],params[1],params[2]]);}}
catch(e)
{konsole.log("trackCustomVar params:",params," exception:",e);}}
var RSC={ASSET:'a',IMAGE:'i',IMAGE_PRX:'ir'}
function renderResourceLink(type,path)
{if(path.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/))
{return path;}
switch(type)
{case RSC.ASSET:if(!Goby.conf('assets'))
return path;id="a";break;case RSC.IMAGE_PRX:if(!Goby.conf('img.enum')&&!Goby.conf('assets'))
return Goby.conf('img.server')+path;id="ir";break;case RSC.IMAGE:if(!Goby.conf('assets')&&!Goby.conf('img.enum'))
return Goby.conf('img.server')+path;id="i";break;}
var code=id+((path.length+1)%3).toString();var fullpath=("http://"+code+"."+Goby.conf('img.domain')+"/"+path).toString();return fullpath;}
function getClear()
{var clear=document.createElement("div");clear.className="clear";return clear;}
Number.prototype.formatPrice=function()
{return"$"+this.toString();}
function compileThumbnail(src,type,size,isFullsize,isGoogle)
{if(!src)
return;if(type)
{var sizeHash=Goby.conf('img.size');var size=sizeHash[type];}
else
var size=size;var reg=/getGoogleImage_([0-9]+)x([0-9]+)/;if(src.match(reg))
return src.replace(reg,'getGoogleImage_'+size);var reg=/getThumbnail_([0-9]+)x([0-9]+)/;if(src.match(reg))
return src.replace(reg,'getThumbnail_'+size);var reg=/getCategoryImage_([0-9]+)x([0-9]+)/;if(src.match(reg))
return src.replace(reg,'getCategoryImage_'+size);if(isGoogle)
{var path="getGoogleImage"+(size!=null?"_"+size:'')+"/"+src;}
else
{var reg=/getThumbnail_([0-9]+)x([0-9]+)/;if(src.match(reg))
return src.replace(reg,'getThumbnail_'+size);var path="getThumbnail"+(size!=null?"_"+size:'')+"="+src.toString().replace("http://",'');}
return renderResourceLink(RSC.IMAGE_PRX,path);}
function getPageTitle(params,page)
{if(params.locationType==null)
params.locationType="UNKNOWN";if((!params.locationName)&&(!params.locationLabel))
{params.locationName=Goby.conf('loc.us.name');params.locationType="COUNTRY";}
switch(page)
{case"location":default:if(params.lat&&params.lng)
{if(params.locationLabel!=null)
var locationParams=params.locationLabel;else
var locationParams=params.lat+"&deg; / "+params.lng+"&deg;";}
else
var locationParams=params.locationName;switch(params.locationType)
{case"ZIPCODE":case"CITY":case"ADDRESS":var delimeter=" near ";break;case"COUNTY":case"COUNTRY":case"REGION":case"STATE":default:var delimeter=" in ";}
var query=(params.categoryName?params.categoryName.toLowerCase():'')+
(params.categoryName&&locationParams?delimeter:'')+
(locationParams?locationParams.toLowerCase():'')+
(params.dateID&&params.dateID!="anytime"?" for "+params.dateName.toString().toLowerCase():"");}
return query;}
function serializeLink(params)
{var data={};if(params.location)
{data.locationType=params.location.type;data.locationName=params.location.getFullName();data.locationID=params.location.id;}
if(params.category)
{data.categoryID=params.category.id;data.categoryName=params.category.name;}
if(params.date)
{data.dateID=params.date.getFormatted();}
if(data.entity)
{data.entityID=params.result.getID();}
return getFormattedUrl(data,(data.entity?'entity':'default'));}
function getFormattedUrl(params,page)
{if(params.locationType==null)
params.locationType="UNKNOWN";if(!params.locationName)
{params.locationName=Goby.conf('loc.us.name');params.locationType="COUNTRY";}
switch(page)
{case"entity":if(params.entityID!=null)
var entityParams="/e-"+params.entityID;else if(params.resultID!=null)
var entityParams="/r-"+params.resultID;case"location":case"category":default:if(params.lat&&params.lng)
var locationParams=params.lat+"x"+params.lng;else
var locationParams=params.locationName.urlEncode();switch(params.locationType)
{case"COUNTY":case"COUNTRY":case"REGION":case"STATE":var delimeter="--in--";break;case"ZIPCODE":case"CITY":case"ADDRESS":default:var delimeter="--near--";}
var query=(params.categoryName?params.categoryName.urlEncode():'')+
((params.categoryName)&&(locationParams)?delimeter:'')+
(locationParams?locationParams:'')+
(entityParams?entityParams:'')+
(params.dateID&&params.dateID!="anytime"?"/date-"+stampToString(params.dateID).urlEncode():"");}
return Goby.conf('path.base')+"/"+query;}
function stampToString(date)
{if(date.match(/^([0-9]{8,12})$/))
{var start=new Date(date*1000);return start.format('link');}
else if(date.match(/^([0-9]{8,12})x([0-9]+)$/))
{var match=date.match(/^([0-9]{8,12})x([0-9]+)$/);var start=new Date(match[1]*1000);var end=new Date(match[2]*1000);return start.format('link')+'  to  '+end.format('link');}
else
return date;}
function displayException(e){}
function killself(obj)
{try
{if(!navigator.isIE())
delete obj;else
obj=null;}
catch(e)
{obj=null;}}
function writeStyle(style){}
function _initSitemapLinks(){}
function getDistance(corA,corB)
{try
{if((corA.lat==undefined)||(corA.lng==undefined))
return-1;var lat1=parseFloat(corA.lat);var lon1=parseFloat(corA.lng);var lat2=parseFloat(corB.lat);var lon2=parseFloat(corB.lng);var destLat=lat1;var destLon=lon1;var srcLat=lat2;var srcLon=lon2;var d=(Math.acos(Math.sin(srcLat.toRad())*Math.sin(destLat.toRad())+
Math.cos(srcLat.toRad())*Math.cos(destLat.toRad())*Math.cos((destLon-srcLon).toRad()))*3956);}
catch(e)
{return-1;}
return d;}
if(typeof XMLHttpRequest=="undefined")
XMLHttpRequest=function(){try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch(e){}
try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch(e){}
try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){}
try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}
throw new Error("This browser does not support XMLHttpRequest or XMLHTTP.")};function AjaxRequest(url,callback,data,requestType)
{if(url==null)
return;if(!requestType)
requestType="GET";this.setURL(url);this.setCallback(callback);this.setRequestType(requestType);if(data)
this.hashToRequestParams(data);this.defaultLoaderStyle="default_loader";this.headers={"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"};}
AjaxRequest.prototype={parentSize:false,stream:false,isJQuery:false,appendLoader:false,noExec:0,loader:null,terminal:false,setLoader:function(loaderClass,loaderStyles,parentElement)
{loader=document.createElement("div");loader.className=(loaderClass!=undefined?loaderClass:this.defaultLoaderStyle);if(loaderStyles)
for(index in loaderStyles)
loader.style[index]=extraStyles[index];if(parentElement)this.setLoaderParent(parentElement);this.loader=loader;return this.loader;},setLoaderTxt:function(string)
{this.loaderText=string;},setLoaderIterator:function(params)
{this.loaderInterval=(params.interval?params.interval:100);this.loaderData=params.data;this.loaderIterator=true;this.loaderTitle=params.title;this.loaderMethod=params.method;return this.loader;this.loaderData=params.data;},removeLoader:function()
{if(this.loader)
{if(this.loaderIterator)
clearInterval(this.loadInterval);try{if(this.isJQuery)
$(this.loader).remove();else
this.loaderParent.removeChild(this.loader);}catch(e){}
this.loader=null;}},setURL:function(url)
{try
{if(Goby!=null)
{if(!url.match(Goby.conf('path.ajax')))
{this.url=Goby.conf('path.ajax')+url;return;}}}
catch(e)
{}
this.url=url;},setCallback:function(callback)
{if(callback.method)
{this.callbackMethod=callback.method;this.callbackObject=callback.object;}
else if(callback.match)
this.callbackMethod=callback;else
this.callbackMethod=false;},setLoaderParent:function(element)
{if(element)
{this.loaderParent=element;return this.loaderParent;}
else
this.loaderParent=document.body;},displayLoader:function()
{if(!this.loader)
this.loader=this.setLoader();if(this.loaderIterator)
{var loaderTitle=document.createElement("h3");loaderTitle.innerHTML=this.loaderTitle;this.loader.appendChild(loaderTitle);var iteratorDiv=document.createElement("span");var iteratorIco=document.createElement("div");this.loader.appendChild(iteratorIco);this.loader.appendChild(iteratorDiv);var ajax=this;this.loadInterval=setInterval(function()
{var data=ajax.loaderData.pop();if(data.status==1)
iteratorIco.className="good";else
iteratorIco.className="bad";iteratorDiv.innerHTML=data.text;ajax.loaderData.unshift(data);},this.loaderInterval);}
if(this.loaderText)
{this.loader.innerHTML=this.loaderText;}
if((this.isJQuery)&&(this.loaderParent))
{if(this.appendLoader)
this.loaderParent.append(this.loader);else
this.loaderParent.prepend(this.loader);}
else
{if(!this.loaderParent)this.loaderParent=document.body;if(this.matchParentHeight)
$(this.loader).css("height",$(this.loaderParent).outerHeight());if(this.parentSize)
{$(this.loader).css("height",$(this.loaderParent).outerHeight());$(this.loader).css("width",$(this.loaderParent).outerWidth());}
if(this.appendLoader)
{this.loaderParent.appendChild(this.loader);}
else
{this.loaderParent.insertBefore(this.loader,this.loaderParent.firstChild);}}},setRequestType:function(value)
{switch(value)
{case"GET":this.requestType="GET";break;case"POST":default:this.requestType="POST";}},setAdtlParams:function(params)
{if(params!==undefined)
{if(params.useLoader)
{if(params.append)this.appendLoader=true;if(params.isJQuery)this.isJQuery=true;if(params.loaderParent)this.setLoaderParent(params.loaderParent);if(params.loaderClass)this.setLoader(params.loaderClass,params.loaderStyles);if(params.loaderText)this.setLoaderTxt(params.loaderText);if(params.loaderIterator)this.setLoaderIterator(params.loaderIterator);if(params.matchParentHeight)this.matchParentHeight=true;if(params.parentSize)this.parentSize=true;this.displayLoader();}
this.stream=(params.stream!=null?params.stream:false);if(params.noExec)
this.noExec=1;}},makeRequest:function(params)
{if(!this.url)
return false;if(params)
this.setAdtlParams(params);var ajax=new XMLHttpRequest();this.terminal=false;switch(this.requestType)
{case"POST":ajax.open(this.requestType,this.url,true);break;case"GET":var url=this.url;if(this.params!=""){url+="?"+this.params;}
ajax.open(this.requestType,url,true);break;}
for(index in this.headers)
ajax.setRequestHeader(index,this.headers[index]);if(this.requestType=="POST")
ajax.send(this.params);var obj=this;this.ajax=ajax;var date=new Date();if(navigator.isBrowser(browser.IE_SIX))
this.compliantRequest();else
this.goodRequest();if(this.requestType=="GET")
ajax.send(null);return true;},recurseRequest:function(data,baseStack)
{for(var key in data)
{var indexStack=cloneArray(baseStack);indexStack.push(key);if(data[key]==null)
{continue;}
else if(data[key].replace!=null||data[key].toRad!=null)
{var index=indexStack[0];for(var i=1;i<indexStack.length;i++)
index+="["+indexStack[i]+"]";this.params+=index+"="+data[key]+"&";}
else
{this.recurseRequest(data[key],indexStack);}}},hashToRequestParams:function(data)
{var params="";this.params='';this.recurseRequest(data,[]);var params=this.params;return params;},addHeader:function(header,content)
{this.headers[header]=content;},logout:function()
{window.open(Goby.conf('path.base')+"/logout/","_self");},terminateRequest:function(callback)
{this.removeLoader();if(callback)
{if(this.callbackMethod)
{var data={error:{message:"We were unable to process your request",hint:"sorry :(",type:"MAX_EXECUTION"}};if(this.callbackObject)
this.callbackObject[this.callbackMethod](data);else
window[this.callbackMethod](data);}}
this.ajax.abort();this.terminal=true;},showTimer:function(time)
{if(document.getElementById("timer")==null)
{var timerArea=document.createElement("div");timerArea.id="timer";timerArea.onclick=function()
{$(this).remove();}}
else
{var timerArea=document.getElementById("timer");}
timerArea.innerHTML=time;$("body").prepend(timerArea);},_destruct:function()
{for(var i in this)
this[i]=null;killself(this);},isTerminal:function()
{if(this.terminal==true)
{this._destruct();return true;}
else
return false;},compliantRequest:function()
{this.resultbuffer=0;var ajax=this.ajax;this.amt=0;var object=this;this.ajaxInterval=setInterval(function()
{object.amt=object.amt+50;if(object.terminal)
{object.removeLoader();clearInterval(object.ajaxInterval);}
try
{if((typeof object.ajax.readyState=="undefined")||(object.ajax.readyState==null))
{return false;}}
catch(e)
{return false;}
if((object.ajax==null)||(object.ajax.readyState==null))
return false;if(object.ajax.readyState==4&&object.ajax.status==200)
{if(object!=null)
object.removeLoader();clearInterval(object.ajaxInterval);var json=object.ajax.responseText;try
{if(json)
{if(!object.noExec)
{if(object.stream)
{var json=object.ajax.responseText.substring(object.resultbuffer);}
else
var json=object.ajax.responseText;var data=eval(jsoni(json));}
else
var data=object.ajax.responseText.substring(object.resultbuffer);}
else
{var data=null;}}
catch(e)
{}
if(data=="logout")
object.logout();if(object.callbackMethod)
{if(object.callbackObject)
object.callbackObject[object.callbackMethod](data);else
window[object.callbackMethod](data);}
object.terminal=true;}
else if(object.ajax.readyState==4)
{object.terminateRequest();}
if(object.terminal)
object.ajax.abort();},50);if(this.requestType=="GET")
ajax.send(null);},goodRequest:function()
{var ajax=this.ajax;ajax.object=this;ajax.onreadystatechange=function()
{if(this.object.terminal)
this.abort();if(this.object.terminal)
{this.object.removeLoader();clearInterval(this.object.ajaxInterval);}
try
{if((typeof this.readyState=="undefined")||(this.readyState==null))
return false;}
catch(e)
{return false;}
if(this.readyState==4&&this.status==200)
{if(this.object!=null)
this.object.removeLoader();if(!this.responseText)
return this.object.terminateRequest();try
{if(this.responseText)
{if(!this.object.noExec)
var data=eval('jsoni('+this.responseText+")");else
var data=this.responseText;}
else
var data=null;}
catch(e)
{Goby.reportError(e);return;}
if(data=="logout")
this.object.logout();try
{if(this.object.callbackMethod)
{if(this.object.callbackObject)
this.object.callbackObject[this.object.callbackMethod](data);else
eval(this.object.callbackMethod+"(data)"+";");}}
catch(e){Goby.reportError(e);}
this.object.terminal=true;}
else if(this.readyState==4)
this.object.terminateRequest();if(this.object.terminal)
this.abort();}}}
function Ajax(url,callback,data,requestType,params)
{if(!requestType)
requestType="GET";this.setURL(url);this.setCallback(callback);this.setRequestType(requestType);if(data)
this.hashToRequestParams(data);this.defaultLoaderStyle="default_loader";objects.push(this);this.headers={"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"};return this.makeRequest(params);}
Ajax.prototype=new AjaxRequest(null);Ajax.prototype.setURL=function(url)
{this.url=url;}
function jsoni(json){return json;}
function _rmGame(container)
{$(container).html("");}
function _initGame(container)
{if(container!=null)
{$(container).html("<embed src=\""+Goby.conf('path.game')+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"425\" height=\"310\"  wmode=\"transparent\"></embed><small id=\"game_instructions\">Use the left and right <strong>arrows</strong> to move &amp; the <strong>space bar</strong> to fire. Thank you for your patience.</small>");}}
function _initFortuneCookie(container)
{return new FortuneCookie(container);}
function FortuneCookie(container)
{var cookie=document.createElement("div");objects.push(this);cookie.id="cookie";$(cookie).css({'background':"url("+Goby.conf('path.img')+"/cookies/cookie_start.png)"});cookie.handler=this;$(cookie).toggle(function()
{var handler=$(this).attr('handler');var request=new AjaxRequest(AJAX_PATH+"result_requests.php",{object:handler,method:"revealFortune"},{action:"getFortuneCookie"},"GET");request.makeRequest();},function()
{$item=$(this);$item.css({'width':'200','background':"url("+Goby.conf('path.img')+"/cookies/cookie_start.png)"});});$(cookie).appendTo(container);this.cookie=cookie;}
FortuneCookie.prototype.revealFortune=function(data)
{$item=$(this.cookie);$item.css({'width':"359px",'background':"url("+data.image+")"});}
FortuneCookie.prototype._destruct=function()
{for(var i in this)
this[i]=null;killself(this)}
FACEBOOK_PERMS="email,user_location,offline_access,publish_stream";var FB=null;var FacebookWrapper=function(){this.loader=null;this.queue=[];}
FacebookWrapper.prototype={isLoaded:function()
{return(FB!=null?true:false);},getAppID:function()
{return Goby.conf("facebook").appid;},callback:function(data)
{window.Facebook=this;window.fbAsyncInit=function()
{FB.init({appId:Facebook.getAppID(),status:true,cookie:true,xfbml:true,channelUrl:Goby.conf('url.goby')+'/channel.html'});origPostTarget=FB.Content.postTarget;Facebook.FB=FB;Facebook.loaded(FB);window.FB=FB;FB.Content.postTarget=function(opts)
{FB.Array.forEach(opts.params,function(val,key){if(typeof val=="object"||typeof val=="array"){opts.params[key]=FB.JSON.stringify(val);}});origPostTarget(opts);};FB.getLoginStatus(function(response){if(response.session){}});};},loaded:function(fb)
{while(this.queue.length>0)
{var node=this.queue.pop();var param=node.params;this[node.method](param[0],param[1],param[2]);}
this.loader=null;},load:function(params)
{this.queue.push(params);try
{var node=document.getElementById('fb-root');if(!node)
{var node=new Div({id:'fb-root'});document.body.appendChild(node);}
Goby.get("scriptLoader").importFile("http://connect.facebook.net/en_US/all.js",{remote:true,async:true,callback:{object:this,method:'callback'},container:node});}
catch(e)
{konsole.log(e);}},logout:function(event,callback)
{if(!this.isLoaded())
return this.load({method:'logout',params:[event,callback]});FB.getLoginStatus(function(response){if(response.authResponse){FB.logout(function()
{$.get(Goby.conf('path.ajax')+"/user/facebookLogout",{'action':'facebookLogout'},function(e){window.location.reload();});});}else{$.get(Goby.conf('path.ajax')+"/user/facebookLogout",{'action':'facebookLogout'},function(e){window.location.reload();});}});},promptLogin:function(event,callback)
{if(!this.isLoaded())
return this.load({method:'promptLogin',params:[event,callback]});if(event!=null)
event.preventDefault();trackEvent([PAGE_ID,"facebook_sign_in_start"]);FB.login(function(response){$.post(Goby.conf('path.ajax')+"/user/facebookLogin",{'fb':true},function(result)
{if(result)
{if(Goby.get('customer'))
{konsole.log("Facebook auth completed on existing session");trackEvent([PAGE_ID,'auth_facebook_success'],2);}
else
{if(result.firstFacebookLogin)
{trackEvent([PAGE_ID,'join_facebook_success'],2);}
var ltb;if(ltb=Goby.get("loginToolbar"))
{if(ltb.loginpopup)
ltb.loginpopup.close();ltb.login(result,true);ltb.extractCallback();if(ltb.login_callback)
ltb.login_callback.call();}}
if(callback){callback.call();}}
else
{trackEvent([PAGE_ID,'join_facebook_canceled']);}},"json");},{perms:FACEBOOK_PERMS});},promptLogout:function()
{if(!this.isLoaded())
return this.load({method:'promptLogout',params:[]});logging_out=true;if(event!=null)
event.preventDefault();FB.logout(function()
{$.get(Goby.conf('path.ajax')+"/user/facebookLogout",{'action':'facebookLogout'},function(e){window.location.reload();});});},post:function(result)
{if(!this.isLoaded())
return this.load({method:'post',params:[result]});var link=serializeLink({location:result.resultSet.getLocation(),category:result.resultSet.getCategory()});this.postRaw({link:link,locationName:result.resultSet.locationName,categoryName:result.resultSet.categoryName,resultTitle:result.facets.title,description:result.facets.description});},postRaw:function(params)
{if(!this.isLoaded())
return this.load({method:'postRaw',params:[params]});var attachment={'name':'Check out more '+params.categoryName+' near '+params.locationName+'','href':link,'caption':'{*actor*} found \''+params.title+'\' using Goby, what will you find?','description':params.description};var action_links=[{'text':'Find more on Goby','href':link}];trackEvent([PAGE_ID,'share_facebook_start']);FB.Connect.streamPublish('Great find on Goby!',attachment,action_links,null,'What do you think of \''+params.title+'\'?',null,function(post_id,e,data){if(post_id!=null){konsole.log("posted "+post_id+" to facebook with message:",data.user_message);trackEvent([PAGE_ID,'share_facebook_success'],2);}else if(e){konsole.log("error posting to facebook.");trackEvent([PAGE_ID,'share_facebook_failed']);}else{konsole.log("post to facebook canceled by user.");trackEvent([PAGE_ID,'share_facebook_canceled']);}},true);},postShoutbox:function(params,callback)
{if(!this.isLoaded())
return this.load({method:'postShoutbox',params:[params,callback]});FB.ui(params,callback);},postEntity:function(params)
{if(!this.isLoaded())
return this.load({method:'postEntity',params:[params]});var action_links=[{'text':'Find more on Goby','href':Goby.conf('url.goby')}];var msg=params.post||'Great find on Goby!';var prompt='Tell your friends about \''+params.title+'\'.';trackEvent([PAGE_ID,'share_facebook_start']);var params={method:'stream.publish',display:'popup',message:msg,attachment:{name:params.title,href:params.link,caption:"via Goby.com"}};try
{FB.ui(params,function(response){if(response&&response.post_id){konsole.log('Post published:',response);var pp={provider:'facebook',postID:response.post_id,message:msg};FB.api('/'+response.post_id+'?fields=message',function(result)
{if(result&&result.id!=null)
{trackEvent([PAGE_ID,'share_facebook_success'],2);}else if(e){trackEvent([PAGE_ID,'share_facebook_failed']);}else{trackEvent([PAGE_ID,'share_facebook_canceled']);}});}else{konsole.log('Post NOT published');}});}
catch(e)
{konsole.log(e);}}}
function postToNewsFeed(result){Facebook.post(result);}
function postToNewsFeedRaw(params){Facebook.postRaw(params)}
function postEntityToNewsFeed(params){Facebook.postEntity(params)}
var exc={ERROR_NO_RESULTS:300,ERROR_FATAL:301,ERROR_HARVEST:400,ERROR_HARVEST_WITH_RESULTS:401}
function Exception(error)
{for(i in error)
this[i]=error[i];this.body=document.createElement("div");$(this.body).addClass("bubble_body");var header=document.createElement("h5");this.content=document.createElement("p");header.innerHTML=this.message;this.content.text=this.hint;this.header=header;objects.push(this);this.body.appendChild(header);this.body.appendChild(this.content);}
Exception.prototype.display=function(wrapper,noCookie)
{noCookie=true;this.container=document.createElement("div");this.container.className="exception";if(!noCookie)
{this.stem=document.createElement("div");$(this.stem).addClass("bubble_stem");this.container.appendChild(this.stem);}
this.container.appendChild(this.body);if(this.type===exc.ERROR_NO_RESULTS)
{var allCategories=document.createElement("a");$allCategories=$(allCategories);$allCategories.addClass("allCategories");$allCategories.text("browse all categories");$allCategories.appendTo(this.header);$allCategories.click(function()
{(Goby.has('searchbox')?Goby.get('searchbox').getField('what').openPanel():'');});$allCategories.show();}
switch(this.type)
{case exc.ERROR_HARVEST:this.content.innerHTML="";var span1=document.createTextNode("Please try hitting the search button again in ");var span2=document.createTextNode(" seconds");this.timer=document.createElement("span");this.timer.innerHTML='60';this.content.appendChild(span1);this.content.appendChild(this.timer);this.content.appendChild(span2);var gameContainer=document.createElement("div");gameContainer.id="gameContainer";_initGame(gameContainer);this.body.appendChild(gameContainer);this.activateTimer();break;case exc.ERROR_HARVEST_WITH_RESULTS:break;default:if(!noCookie)
{var cookieContainer=document.createElement("div");cookieContainer.id="cookieContainer";this.fortuneCookie=new FortuneCookie(cookieContainer);this.body.appendChild(cookieContainer);}
break;}
if(this.tandem)
{var closeLink=document.createElement("a");closeLink.title="[close]";$(closeLink).addClass("closeLink");closeLink.appendChild(document.createTextNode("[X]"));closeLink.handler=this;closeLink.onclick=function()
{this.handler.close();}
$(this.body).prepend(closeLink);}
$(wrapper).prepend(this.container);}
Exception.prototype.activateTimer=function()
{var handler=this;this.timerInt=setInterval(function()
{var count=parseInt(handler.timer.innerHTML)
handler.timer.innerHTML=count-1;if(count<2)
{handler.content.innerHTML="The results should be harvested by now!";clearInterval(handler.timerInt);}},1000);}
Exception.prototype._destruct=function()
{for(var i in this)
this[i]=null;killself(this);}
Exception.prototype.close=function()
{$(this.container).fadeOut(500,$(this.container).remove());}
function Parameter(type,source,object){this.__run(type,source,object)}
Parameter.prototype=Class({inherits:null,_construct:function(type,source,object)
{this.declared=false;this.location=(source?source:window.location).toString();this.type=type;if(object!=null)
this.data=object;else
this.data=this.serialize();},methods:{deserialize:function()
{switch(this.type)
{case"page":var data=(this.data+1);break;case"sort":var data=this.data.label+":"+this.data.dir;break;case"source":var data=this.data;break;case"section":var data=this.data;break;case"filters":var filterset=[];for(var index in this.data)
{if(this.data[index].join!=null)
var filterData=this.data[index].join(",");else
var filterData=this.data[index];if(filterData)
filterset.push(index+":"+filterData);}
var data=filterset.join("|");break;}
return this.type+"="+data;},isDeclared:function()
{return this.declared;},diff:function(parameter)
{var diffData=parameter.serialize();switch(this.type)
{case"page":return(this.data!=diffData?true:false);break;case"sort":if((this.data.label!=diffData.label)||(this.data.dir!=diffData.dir))
return true;else
return false;break;case"source":return(diffData!=this.data)?true:false;break;case"section":return(diffData!=this.data)?true:false;break;case"filters":function diff(dataSetA,dataSetB)
{if(dataSetA==null&&dataSetB==null)
return false;if
((dataSetA!=null&&dataSetB==null)||(dataSetA==null&&dataSetB!=null))
return true;if(dataSetA.deserialize()!=dataSetB.deserialize())
return true;else
return false;return false;}
if(diff(this,parameter))
return true;return false;break;}},serialize:function()
{if(this.data!=null)
return this.data;var value=(value!=null?value:this.location).toString();switch(this.type)
{case"source":var data=value.match("source=([^\&]+)");if(data!=null)
{this.declared=true;return data[1];}
else
return null;break;case"section":var data=value.match("section=([^\&]+)");if(data!=null)
{this.declared=true;return data[1];}
else
return null;break;case"sort":if(value==null)
{return{'label':"relevance",'dir':"ASC"}}
var data=value.match("sort=([a-zA-Z]{1,9}):((?:ASC|DESC)?)[&]??");if(!data)
data=value.match("sort=([a-zA-Z]{1,9})[&]??");if((data)&&!(data[1]=="relevance"&&data[2]=="ASC"))
{this.declared=true;var parameter={label:(data[1]!=null?data[1]:null),dir:(data[2]!=null?data[2]:"ASC")};}
else
{this.declared=false;var parameter={label:"relevance",dir:"ASC"}}
return parameter;break;case"page":var data=value.match("page=([^&][0-9]*)[&]??");if(data!=null&&(data[1]>1))
{this.declared=true;return data[1]-1;}
else
return 0;break;case"filters":var data=value.match("filters=([^&]{1,100})[&]??");if((data!=null)&&(data[1]!=null))
{var filters=data[1];var filterSet=filters.split("|");parameter=[];for(var i in filterSet)
{var item=filterSet[i].split(":");var name=item[0];var value=item[1].urlDecode();if(value.match(","))
var v=value.split(",");else if(value.match("-"))
var v=value.split("-");else
var v=value;parameter[name]=v;}
this.declared=true;return parameter;}
else
{this.declared=false;return[];}
break;}}}});window.useParameters=[];window.deserializeParameters=function()
{var darray=[];for(var i in this.parameters)
{darray.push(this.parameters[i].deserialize());}
return darray.join("&");}
window.setParameter=function(param)
{if(param&&this.parameters!=null)
this.parameters[param.type]=param;}
window.setParameters=function(types)
{if(types)
{this.useParameters=types;this.parameters={};for(i in types)
{var param=types[i];this.parameters[param]=new Parameter(types[i].toString());}}
else
{this.useParameters=['page','filters','sort'];this.parameters={'page':new Parameter("page"),'filters':new Parameter("filters"),'sort':new Parameter("sort")};}
this.loque=this.location.toString();this.tmp=this.location.toString();}
window.compareParameter=function(type)
{return(this.parameters[type].diff(new Parameter(type)));};window.setHistoryStorage=function()
{if(navigator.isIE())
{var ifrm=document.createElement("iframe");this.iframe=ifrm;ifrm.name="ajaxhistory";ifrm.style.display="none";document.body.appendChild(ifrm);}}
window.areDeclared=function()
{for(var i in this.parameters)
if(this.parameters[i].isDeclared())
return true;return false;}
window.compareParameters=function()
{if((this.loque==this.location.toString())||(this.tmp==this.location.toString()))
{return false;}
else
{}
var update=false;for(i in this.useParameters)
{var usedParam=this.useParameters[i];switch(usedParam){case'page':if(window.compareParameter("page"))
{this.parameters.page=new Parameter("page");update=true;}
break;case'section':if(window.compareParameter("section"))
{this.parameters.section=new Parameter("section");update=true;}
break;case'sort':if(window.compareParameter("sort"))
{this.parameters.sort=new Parameter("sort");update=true;}
break;case'filters':if(window.compareParameter("filters"))
{this.parameters.filters=new Parameter("filters");var serialized=this.parameters.filters.serialize();update=true;}
break;}}
this.loque=window.location.toString();this.tmp=window.location.toString();return update}
window.bookmarkPage=function(parameters)
{var param=this.compileLink(parameters);window.open(param.hash,"_self");return param;}
window.compileLink=function(parameters,anchor)
{var dset=[];for(var i in this.parameters)
{if(i==null||!this.parameters[i].deserialize)
{this.parameters[i]=null;continue;}
if((parameters!=null)&&(parameters[i]))
this.parameters[i]=parameters[i];dset.push(this.parameters[i].deserialize());}
if(anchor)
{var remote=anchor.href.match("([^#]+?)#");}
var remote=(remote!=null&&remote[1]!=null?remote[1]:'')
var hash=dset.join("&");if(hash)
{var result={href:remote+"#"+hash,hash:"#"+hash}
this.tmp=result.toString();if(anchor)
anchor.href=result.hash;if(navigator.isIE())
this.updateIframe(hash);return result;}
else
{return{'href':anchor.href,'hash':anchor.hash}}}
window.mergeParameters=function(anchor)
{var dset=[];if(anchor.href_old!=null)
anchor.href=anchor.href_old;for(var i in this.parameters)
{var param=new Parameter(i,anchor.href);if(param.isDeclared())
{dset.push(param.deserialize());this.parameters[i]=param;}
else
dset.push(this.parameters[i].deserialize());}
var remote=anchor.href.match("([^#]{0,100})#");var remote=(remote!=null&&remote[1]!=null?remote[1]:'')
var hash=dset.join("&");var result=remote+"#"+hash;anchor.href_old=anchor.href;this.tmp=result.toString();if(navigator.isIE())
this.updateIframe(hash);return result;}
window.onFrameLoaded=function(json)
{this.location.hash=json.hash;if(window.compareParameters())
{if(this.resultSet!=null)
{try
{var data={};for(var i in this.parameters)
data[i]=this.parameters[i].serialize();this.resultSet.getResults(data);}
catch(e)
{}}}}
window.updateIframe=function(hash)
{if(navigator.isIE())
{if(this.iframe)
{var title="title="+document.title.toString().urlEncode();this.iframe.src=Goby.conf('path.ajax')+"draw.php?"+hash+"&"+title;}}}
window.stopComparing=function()
{clearInterval(this.diffInterval);}
window.getResultSet=function()
{if(this.resultSet!=null)
return this.resultSet;else
return null;}
window.unsetResultSet=function(resultSet)
{this.resultSet=null;}
window.setResultSet=function(resultSet)
{this.resultSet=resultSet;this.makeAnchorsCompatable();if(!navigator.isIE())
this.startComparing(resultSet);}
window.serializeParameters=function()
{var data={};for(var i in this.parameters)
data[i]=this.parameters[i].serialize();return data;}
window.startComparing=function(resultSet)
{this.diffInterval=this.setInterval(function()
{if(this.compareParameters()&&this.resultSet!=null)
{this.resultSet.getResults(this.serializeParameters());}},1000);}
window._destruct=function()
{this.parameters=null;this.clearInterval(this.diffInterval);}
window.getParameters=function()
{if(this.parameters==null)
parameters=this.setParameters(this.useParameters);else
parameters=this.parameters;if(parameters)
return parameters;else
return 0;}
window.fetchParameter=function(label)
{return new Parameter(label);}
window.getParameter=function(label)
{var parameters=this.getParameters();if(parameters[label]!=null)
return this.parameters[label];else
return false;}
window.setPage=function()
{this.parameters.page=new Parameter();}
window.getPage=function()
{this.getParameter('page').serialize();}
window.getSort=function()
{this.getParameter('sort').serialize();}
window.getFilters=function()
{this.getParameter('filters').serialize();}
window.getSection=function()
{this.getParameter('section').serialize();}
var aras;window.makeAnchorsCompatable=function()
{$("a").each(function()
{try
{if((this.href.toString().match("#"))||(this.href.toString().match("#"+Goby.conf('path.anchor')))||(this.hash=="#")||(this.hash==(Goby.conf('base.anchor'))))
{$(this).bind("click.parameter",function(e)
{var data=window.compileLink(null,this);});}}
catch(e)
{konsole.log(e);}});}
window.getPageOffset=function(){return $(this).scrollTop();}
function preserveParameters(anchor)
{$(anchor).mouseover(function(e){var data=window.compileLink(null,this);});}
var Slidable=function(params){this.__run(params);}
Slidable.prototype=Class({_construct:function(params)
{this.$container=$(params.container);this.$area=$(params.area);this.origin=params.origin?params.origin:this.getOrigin();this.offset={y:params.offset,fix:10};this.height=this.getHeight();objects.push(this);},inherits:null,vars:{locked:false,mapY:-1,cnt:0,origin:0,scrollIdleDelay:400,mouseDown:false,lastScrollMS:0},methods:{getLimitY:function(){return this.$container.height()},getHeight:function(){return this.$area.height()+this.offset.y;},getScrollY:function()
{return window.getPageOffset();},show:function()
{this.toggleLock(false);this.$area.show();},hide:function()
{this.toggleLock(true);this.$area.hide();},toggle:function()
{this.origin=this.getOrigin(true);this.check();},toggleLock:function(lock)
{this.locked=lock;if(!lock)
this.check();},getOrigin:function(frc)
{return parseInt(this.$container.offset().top);},check:function()
{if(this.locked)
return false;var scrollY=this.getScrollY();var originY=this.getOrigin();if(originY>scrollY)
{this.mapY=0;var newPos='static';}
else
{var diff=(scrollY-originY)+this.getHeight();var limitY=this.getLimitY();var newPos="fixed";}
if(newPos=="fixed")
{if(diff>limitY)
{this.mapY=limitY-diff;this.$area.css("top",this.mapY);}
else if(this.mapY)
{this.mapY=0;this.$area.css("top",10);}}
if(this.position!=newPos)
{this.$area.removeClass(this.position);this.position=newPos;this.$area.addClass(this.position);}},_destruct:function()
{$(window).unbind('scroll.'+this.$area.attr('id'));this.$area=null;this.$container=null;},init:function()
{this.check();var mui=this;$(window).bind('scroll.'+this.$area.attr('id'),function(){mui.check();});},mouseCheck:function(on)
{if(on)
{var mui=this;$(window).bind('mousemove.'+this.$area.attr('id'),function(){mui.check();});}
else
$(window).unbind('mousemove.'+this.$area.attr('id'));}}});function _initSlidableObject(params)
{return new Slidable(params);}
function PopupMgr()
{objects.push(this);}
PopupMgr.prototype={popups:[],closeAllBut:function(item)
{for(var j=0;j<this.popups.length;j++)
if(this.popups[j]!==item)
{if(this.popups[j]==null)
{this.popups[j]=null;}
else if((!this.popups[j].isClosed())&&(!this.popups[j].isProtected))
{this.popups[j].close();}
else
{}}},add:function(item)
{this.popups.push(item);}}
var popupMgr=new PopupMgr;function Popup(params)
{if(params==null)
return false;if(params.isProtected!=null&&params.isProtected)
{}
else if(popupMgr!=null)
popupMgr.add(this);this.key="popup"+Math.round(Math.random()*1000);for(var i in params)
this[i]=params[i];}
Popup.prototype={stem:null,id:null,label:null,isCloser:false,isProtected:false,shell:null,ratio:0.5,fixed:false,closerText:"close",wrapperClass:null,noClick:false,blindColor:"#004d7b",slidable:false,follow:false,isShell:true,verifyClose:null,isMask:false,mask:"#wrapper",maskOpacity:0,prepend:false,useBlind:false,blindClass:"pageBlind",automargin:true,closed:false,getNode:function()
{if(this.shell!=null)
return this.shell.content.center;else
return this.content;},isClosed:function()
{return this.closed;},hide:function()
{if(this.useBlind&&this.blind!=null)
{this.blind._destruct();this.blind=null;}
else if(this.isMask)
{if(navigator.isIE())
{}
else
$(this.mask).fadeTo(250,1);}
if(this.isShell)
{if(this.slidable)
{$(this.shell).slideUp(600);var obj=this;var timeout=setTimeout(function(){obj.wipeout();},600);return false;}
else
{if(this.shell!=null)
{if(this.shell.parentNode!=null)
this.shell.parentNode.removeChild(this.shell);else
$(this.shell).remove();}}}
else
{if(this.content!=null)
{if(this.content.parentNode!=null)
this.content.parentNode.removeChild(this.content);else
this.content=null;}}
$(document).unbind("keyup."+this.key);this.closed=true;if(this.verifyClose!=null)
this.verifyClose.destruct();},wipeout:function()
{$(this.shell).remove();this.closed=true;if(this.verifyClose!=null)
this.verifyClose.destruct();},close:function()
{this.hide();this.closed=true;},getClass:function()
{if(this.customClass)
{return(this.wrapperClass!=null?this.wrapperClass:'');}
else if(this.isMask)
return"popup-mask "+(this.wrapperClass!=null?this.wrapperClass:'');else
return"popup "+(this.wrapperClass!=null?this.wrapperClass:'');},display:function()
{if(!this.isProtected)
popupMgr.closeAllBut(this);this.content.container=this.container;this.closed=false;if(this.isShell)
{var shell=this.createShell();if(this.slidable)
$(shell).hide();if(this.prepend)
$(this.container).prepend(shell);else
this.container.appendChild(shell);if(this.slidable)
$(shell).slideDown(600);}
else
{if(this.prepend)
$(this.container).prepend(this.content);else
this.container.appendChild(this.content);}
if(!this.isShell)
{$(this.content).addClass(this.getClass());}
if(this.isMask)
this.bindMask();if(this.useBlind)
{this.blindPage();}
else if(this.isMask)
{if(navigator.isIE())
{}
else
$(this.mask).fadeTo(250,this.maskOpacity);}
else
this.positionContent();if((this.fixed)||(this.isCloser))
{if(this.isCloser)
{var closer=document.createElement("a");closer.popup=this;closer.onclick=function(e)
{this.popup.close();}
var closebutton=document.createElement("div");var closeText=document.createElement("div");$(closebutton).addClass("closeButton");closer.className="closer";closeText.innerHTML=(this.closerText?this.closerText:"close");closeText.className="closeText"
closer.appendChild(closebutton);$(closer).append(closeText);this.closerNode=closer;$(this.getArea()).prepend(closer);}
if(this.isShell)
{var node=this.getWrapper();if(this.slidable)
{var row=node.insertRow(node.rows.length);var cell=document.createElement("td");cell.colSpan=3;cell.appendChild(closer);row.appendChild(cell);}}
else
var node=this.getNode();}
if((!this.noClick))
{if(this.isShell)
var node=this.getWrapper();else
var node=this.getNode();if(this.wrappers)
safeWrappers=this.wrappers;else
{var safeWrappers=[];safeWrappers[node.id]=node;}
this.verifyClose=new keywordCloser(safeWrappers,{object:this,method:"close"});this.verifyClose.initStgClick(100);}
if(this.follow)
this.makeFollowable();return this.content;},createShell:function()
{this.shell=document.createElement("table");this.shell.id=this.content.id.toString();$(this.shell).addClass(this.getClass());$(this.shell).addClass("popup_"+this.position);var rows=[];rows.push('top');if(this.label)
rows.push('label');rows.push('content');rows.push('bot');var cols=['left','center','right'];for(var i=0;i<rows.length;i++)
{var name=rows[i];this.shell.insertRow(i);var row=this.shell.insertRow(i);for(var j=0;j<cols.length;j++)
{row[cols[j]]=row.insertCell(j);}
this.shell[name]=row;}
if(this.label)
{this.shell.label.center.className="label";this.shell.label.left.className="label-left";this.shell.label.right.className="label-right";this.shell.label.center.appendChild(this.label);}
this.shell.bot.center.className="bot";this.shell.bot.left.className="corner bot-left";this.shell.bot.right.className="corner bot-right";this.shell.top.center.className="top";this.shell.top.left.className="corner top-left";this.shell.top.right.className="corner top-right";this.shell.content.center.className="content";this.shell.content.left.className="left";this.shell.content.right.className="right";var popContent=this.shell.content.center;popContent.appendChild(this.content);if(this.stem)
{var stem=document.createElement("div");$(stem).addClass("stem");this.stemArea=stem;switch(this.position)
{case"left":this.shell.content.right.appendChild(stem);break;case"right":this.shell.content.left.appendChild(stem);break;case"bottom":this.shell.top.center.appendChild(stem);break;case"top":default:this.shell.bot.center.appendChild(stem);}}
this.content.id=null;return this.shell;},getArea:function()
{if(this.shell)
return this.shell.content.center;else
return this.getNode();},getWrapper:function()
{return this.shell;},positionContent:function()
{if(this.isShell)
var area=this.getWrapper();else
var area=this.getNode();var height=$(area).outerHeight();var width=$(area).outerWidth();var shell=this.getWrapper();var stemHeight=0;var stemWidth=0;switch(this.position)
{case"none":return false;var offset=0;var xoffset=0;break;case"top":var stemHeight=$(this.stemArea).outerHeight()/2;var offset=Math.round(((height)-(height*2))-(stemHeight?stemHeight:8));var xoffset=Math.round(((width+$(this.container).outerWidth())-(width*2))*this.ratio);break;case"nudge_right":if(this.stemArea)
{var stemHeight=$(this.stemArea).outerHeight()/2;var stemWidth=$(this.stemArea).outerWidth()*2;var stemOffset=(h-stemHeight)-(shell.label?$(shell.label).outerHeight():0);}
var w=$(area).innerWidth();var pw=$(area.parentNode).innerWidth();var offset=0;var xoffset=-(Math.abs(w-pw));break;case"left":if(this.stemArea)
{var stemHeight=$(this.stemArea).outerHeight()/2;var stemWidth=$(this.stemArea).outerWidth()*2;var stemOffset=(h-stemHeight)-(shell.label?$(shell.label).outerHeight():0);}
var h=height*this.ratio;var w=$(area).outerWidth();var offset=Math.round(h-(h*2));var xoffset=w-(w*2)-stemWidth;break;case"right":var w=$(area.parentNode).outerWidth();var h=(height*this.ratio);var offset=Math.round(h-(h*2));if(this.stemArea)
{var stemHeight=$(this.stemArea).outerHeight()/2;var stemWidth=$(this.stemArea).outerWidth()*2;var stemOffset=(h-stemHeight)-(shell.label?$(shell.label).outerHeight():0);}
var xoffset=w+stemWidth;break;case"center":break;default:var offset=Math.round(((height)-(height*2)*this.ratio)-32);var xoffset=width;}
if((this.stemArea)&&(stemOffset))
$(this.stemArea).css("marginTop",stemOffset+"px");if(this.automargin)
$(area).css("marginTop",offset+"px");try
{$(area).css("marginLeft",xoffset+"px");}
catch(e)
{}},bindMask:function()
{var width=$(this.getWrapper()).innerWidth();$(this.getWrapper()).css({position:'fixed',left:'50%',marginLeft:(width-width*2)/2});return false;var scrollX=(window.pageXOffset!=null?window.pageXOffset:document.body.scrollLeft);var scrollY=(window.pageYOffset!=null?window.pageYOffset:document.body.scrollTop);this.blind=document.createElement("div");$(this.blind).addClass(this.blindClass);this.recalcPosition();var y=$(window).height()+scrollY;var x=$(window).width()+scrollX;},recalcPosition:function()
{var top=($(window).height()-$(this.getWrapper()).outerHeight())/2;$(this.getWrapper()).css('top',top);},blindPage:function()
{document.popup=this;if(this.isCloser)
{$(document).bind("keyup."+this.key,function(e)
{if(e.which==keys.ESCAPE)
{this.popup.close();}});}
this.blind=document.createElement("div");$(this.blind).addClass(this.blindClass);this.blind.popup=this;this.blind.ot=parseInt();$(this.blind).css({position:'fixed',opacity:(Goby.conf('blind.opacity')?Goby.conf('blind.opacity'):1-this.maskOpacity),zIndex:10000});this.blind.adjust=function(resize)
{var top=this.ot;topValue=0;if(top>0)
{var scrollY=(window.pageYOffset!=null?window.pageYOffset:document.body.scrollY);var topValue=(top-scrollY>0?top-scrollY:0);$(this).css({"top":topValue});}
this.popup.recalcPosition();if(resize||(topValue!=this.lst))
{var y=$(window).height();var x=$(window).width();$(this).css({width:x,height:y-topValue});}
this.lst=topValue;}
this.blind._destruct=function()
{$(window).unbind('scroll.blind');$(window).unbind('resize.blind');this.parentNode.removeChild(this);}
this.blind.adjust(1);window.blind=this.blind;$(window).bind('scroll.blind',(function(){if(this.blind!=null){this.blind.adjust(0)}}));$(window).bind('resize.blind',(function(){if(this.blind!=null){this.blind.adjust(1)}}));if(this.isShell)
var area=this.getWrapper();else
var area=this.getNode();$(area).css({zIndex:10001});var popup=this;this.recalcPosition();this.container.insertBefore(this.blind,area);},makeFollowable:function()
{}}
function Overlay(params)
{this.stem=null;this.id=null;this.label=null;this.isCloser=false;this.isProtected=false;this.shell=null;this.ratio=0.5;this.fixed=true;this.closerText="close";this.wrapperClass=null;this.noClick=true;this.blindColor="#fff";this.slidable=false;this.follow=false;this.isShell=true;this.verifyClose=null;this.isMask=true;this.mask="#wrapper";this.maskOpacity=0.9;this.prepend=false;this.useBlind=true;this.blindClass="pageBlind";this.automargin=true;this.container=document.body;if(params.isProtected!=null&&params.isProtected)
{}
else if(popupMgr!=null)
popupMgr.add(this);this.key="popup"+Math.round(Math.random()*1000);for(var i in params)
this[i]=params[i];}
Overlay.prototype=new Popup(null);function PopupMask(params,node)
{this.container=document.body;if(params.isProtected==null||!params.isProtected)
if(popupMgr!=null)
popupMgr.add(this);this.key="popup"+Math.round(Math.random()*1000);for(var i in params)
this[i]=params[i];}
PopupMask.prototype=new Popup(null);PopupMask.prototype.isMask=true;PopupMask.prototype.isCloser=true;PopupMask.prototype.noClick=true;PopupMask.prototype.fixed=true;PopupMask.prototype.maskOpacity=0.90;PopupMask.prototype.opacity=0.90;PopupMask.prototype.useBlind=true;TabMgr=function(params,sel)
{if(params!=null)
{this._construct(params,sel);}}
TabMgr.prototype={_construct:function(params,selected)
{if(params.container!=null)
this.container=params.container;else if(params.containerID)
this.container=document.getElementById(params.containerID);else
this.container=document.createElement("div");if(params.style)
Goby.get("scriptLoader").importStyle(Goby.conf('path.css')+params.style);if(params.tabList!=null)
this.tabList=params.tabList;else if(params.tabListID!=null)
{this.tabList=document.getElementById(params.tabListID);}
else if(params.menu=="select")
{this.tabList=new Div();}
else
{this.tabList=new UL({className:"portal-tabs"});}
if(params.location)
this.location=new Location(params.location);objects.push(this);if(params.menu=="select")
this.initSelects(params.tabs);else
this.initTabs(params.tabs);if(selected)
this.displayTab(this.getTabByID(params.currentTab));},getParam:function(index)
{return(this.params!=null&&this.params[index]!=null?this.params[index]:false);},getContainer:function()
{return this.container;},hide:function(){$(this.container).hide();},show:function(){$(this.container).show();},getTabByID:function(id)
{return this.tabs[id];},getTabContainer:function()
{return this.tabList;},_destruct:function()
{var count=0;for(var i in this.tabs)
this.tabs[i]._destruct();for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct)
this[i]._destruct();else
this[i]=null;count++;}}
killself(this);},currentMenu:null,selectTab:function(option)
{this.displayTab(option.tab);},initSelects:function(tabs)
{var list=this.getTabContainer();var selector=new Selector({container:list,className:"selectGhost",id:"TabGhost"},{callbackObject:this,callbackMethod:'selectTab'});selector.addOption(null,{value:-1,label:"SELECT A CATEGORY"});for(var i in tabs)
{var tabData=tabs[i];var name=tabData.title;var option=selector.addOption(null,{value:i,label:tabData.title});var params=tabData.params;params.mgr=this;params.link=option;params.title=name;params.id=i;this.tabs[i]=new window[tabData.object](params);option.tab=this.tabs[i];}
selector.display();this.selector=selector;},getSelector:function()
{return this.selector;},initTabs:function(tabs)
{var list=this.getTabContainer();try
{for(var i in tabs)
{var tabData=tabs[i];var name=tabData.title;var item=document.createElement("li");$(item).hover(function()
{$(this).addClass("hover");},function()
{$(this).removeClass("hover");});item.className="tab-"+i;var link=document.createElement("a");var params=tabData.params;params.mgr=this;params.link=link;params.title=name;params.id=i;this.tabs[i]=eval("new "+tabData.object+"(params);");link.tab=this.tabs[i];link.handler=this;link.onclick=function()
{this.handler.displayTab(this.tab);}
link.innerHTML="<span>"+name+"</span>";item.appendChild(link);list.appendChild(item);}}
catch(e)
{konsole.log(e);}
this.getContainer().appendChild(list);},toggleMenu:function(id)
{$(this.currentMenu).hide();$(id).show();},getLocation:function()
{return this.location;},getContainer:function()
{return this.container;},closeTab:function(tab)
{try{this.getContainer().removeChild(tab.content);}
catch(e){}},displayTab:function(tab)
{konsole.log('new tab',tab);if(this.currentTab!==tab)
{if(this.currentTab!=null)
{try{this.currentTab.close();}
catch(e){this.closeTab(tab);}}
$(tab.link.parentNode).addClass("sel");this.currentTab=tab;var node=this.currentTab.display();if(node)
this.getContainer().appendChild(node);}},currentTab:null,tabs:[]}
var PortalTab=function(param)
{if(param)
this._construct(param);}
PortalTab.prototype={_construct:function(params)
{if(params!=null)
{this.mgr=params.mgr;this.link=params.link;this.params=params;this.id=params.id;}
objects.push(this);},_destruct:function()
{for(var i in this)
this[i]=null;},showTab:function()
{},select:function()
{},isCurrent:function()
{},hasSynopsis:function()
{return(this.params.synopsis?true:false);},getSynopsis:function()
{this.synopsis=new Div({className:"synopsis",text:"<p>"+this.params.synopsis+"</p>"});return this.synopsis;},_destruct:function()
{this.resultSet=null;},close:function()
{if(this.hasSynopsis())
this.synopsis.remove();$(this.link.parentNode).removeClass("sel");if(this.content.parentNode!=null)
this.content.parentNode.removeChild(this.content);},drawContent:function()
{var portalItem=document.createElement("div");$(portalItem).addClass("portalItem");this.content=portalItem;if(this.hasSynopsis())
this.mgr.getContainer().appendChild(this.getSynopsis());this.mgr.getContainer().appendChild(this.content);$(this.content).show();return this.content;},init:function()
{return this.display();},makeRequest:function(callback,params,noLoader,adtl)
{params.widgetID=this.id;var WIDGET_PATH=Goby.conf('path.ajax')+"widget/";var request=new AjaxRequest(WIDGET_PATH+this.id,callback,params,"GET");if(!noLoader)
request.makeRequest({useLoader:true,loaderParent:adtl&&adtl.container?adtl.container:this.content,loaderClass:"loader_widget",append:true});else
request.makeRequest();return request;},display:function()
{if(this.mgr)
{var content=this.drawContent();content.innerHTML="hi. i am a portal";}}}
function ClientWidget(container)
{this.container=container;}
ClientWidget.prototype={reloadPage:function()
{window.open(window.location.href,"_self");},setClient:function(option)
{var id=option.value;var request=new AjaxRequest(AJAX_PATH+"widget_requests.php",{object:this,method:'reloadPage'},{clientID:id,action:"setClient"});request.makeRequest();},display:function()
{var request=new AjaxRequest(AJAX_PATH+"widget_requests.php",{object:this,method:'showClients'},{action:"getClients"});request.makeRequest();},showClients:function(data)
{var selector=new Selector({container:this.container,className:"selectGhost",id:"radiusGhost"},{callbackObject:this,callbackMethod:"setClient"});selector.active=false;selector.defaultOption=makeOption("-1","choose a client");for(var i in data)
{var client=data[i];selector.addOption(makeOption(client.id,client.name));}
selector.display();}}
var MapLoader={initialized:false,loaded:false,threads:[],extras:[],callback:"_activateMap",runThread:function(thread)
{if(thread.object!=null)
thread.object[thread.method]();else if(thread.method)
eval(thread.method+"()");},addExtra:function(src)
{this.extras.push(src);},_activateMap:function()
{if(typeof Marker!="undefined")
{if(!this.loaded)
{this.loaded=true;while(this.threads.length>0)
this.runThread(this.threads.pop());return true;}
else
{}}
else
{throw exception();return false;}},init:function()
{if(!this.initialized)
{Goby.get("scriptLoader").importFile(Goby.conf('google.api.url'),{remote:true,inline:false,async:true});if(Goby.conf('google.api.url.extras')!=null)
Goby.get("scriptLoader").importFile(Goby.conf('google.api.url.extras'),{remote:true,inline:false,async:true});this.initialized=true;}},loadMap:function(thread)
{if(!this.loaded)
{this.threads.push(thread);this.init();}
else
{this.runThread(thread);}},capture:function()
{if(!Goby.has("scriptLoader"))
return false;var scriptLoader=Goby.get("scriptLoader");scriptLoader.importFile(Goby.conf('path.js')+"/lib/googlemaps/",{callback:{object:this,method:this.callback},remote:true});while(this.extras.length>0)
scriptLoader.importFile(this.extras.pop(),{remote:true,inline:false});}}
if(this.objects)
this.objects.push(MapLoader);function _googleMapCallback(){Goby.get('mapLoader').capture();}
breadType={'CAT':'category','LOC':'location'}
TYPE_CATEGORY=breadType.CAT;TYPE_LOCATION=breadType.LOC;Breadcrumb=function(params,mgr)
{var node=document.createElement("li");var link=document.createElement("a");link.innerHTML=(params.label?params.label.toLowerCase():'');for(var i in this)
node[i]=this[i];node.mgr=mgr;objects.push(this);objects.push(node);if(params.type==breadType.LOC)
node.loc_type=params.loc_type;node.label=params.label;node.url=(params.link!=null?params.link:false);node.node_id=params.id;node._type=params.type;node.appendChild(link);node.link=link;if(node.url)
node.link.href=node.url;else
node.init();return node;}
Breadcrumb.prototype={remove:function()
{if(this.child!=null)
this.child.remove();if(this.mgr.isCurrent(this))
this.mgr.setCurrent(this.parent);if(this.parentNode)
this.parentNode.removeChild(this);this.parent.makeChild();this.parent.child=null;},makeChild:function()
{if(this.link2!=null)
{this.removeChild(this.link2);this.link2=null;}},addChild:function(node)
{if(this.child!=null)
this.child.remove();if(node!="dummy")
{this.child=node;this.child.setLast();this.child.parent=this;}
$(this).removeClass("last");if(this.link2==null)
{var link2=document.createElement("span");$(link2).addClass("link");link2.innerHTML="<small>&gt;</small>";this.appendChild(link2);this.link2=link2;}},setFirst:function()
{$(this).addClass("first");},setLast:function()
{$(this).addClass("last");},init:function()
{if(this.no_link)
{this.link.href="#_breadcrumb";return false;}
if(this._type==breadType.CAT)
{var location=this.mgr.getCurrent(breadType.LOC);var data={locationName:location.label,locationID:location.node_id,locationType:location.loc_type,categoryName:this.label,categoryID:this.node_id,type:"search"}
this.link.href=getFormattedUrl(data,'category');}
else if(this._type==breadType.LOC)
{this.mgr.getCurrent(breadType.CAT);var data={locationName:this.label,locationID:this.node_id,locationType:this.loc_type,type:"location"}
this.link.href=getFormattedUrl(data,'location');}
else
{}},getChild:function()
{return this.child;},getParent:function()
{return this.parent;}}
BreadcrumbMgr=function(params)
{var node=document.getElementById("breadcrumbs");node.innerHTML='';this.count=0;objects.push(this);objects.push(node);for(var i in this)
node[i]=this[i];return node;}
BreadcrumbMgr.prototype={data:[],hasCategories:true,hasLocations:true,index:{"location":{},"category":{}},currentNode:{"location":null,"category":null},getCurrent:function(type)
{return this.currentNode[type];},setCurrent:function(node)
{this.currentNode[node._type]=node;},isCurrent:function(node)
{if(this.currentNode[node._type]===node)
return true;else
return false;},add:function(data)
{this.count++;(this.count>1?$(this).show():$(this).hide());var type=data.type;var dummy="dummy";if(this.index[type]==null)
this.index[type]={};if(this.index[type][data.id]!=null)
{var mynode=this.index[type][data.id];if(mynode.child!=null)
mynode.child.remove();return mynode;}
var bc=new Breadcrumb(data,this);if((data.parent!=null)&&(this.index[type][data.parent]!=null))
this.index[type][data.parent].addChild(bc);else if(this.currentNode[type]!=null)
this.currentNode[type].addChild(bc);if(bc.parent)
$(bc).insertAfter(bc.parent);else
{if((bc._type==TYPE_CATEGORY)&&(this.hasLocations))
{}
else
{bc.setFirst();}
this.appendChild(bc);}
if((bc._type==TYPE_LOCATION)&&(this.hasCategories))
bc.addChild(dummy);this.index[type][data.id]=bc;this.setCurrent(bc);return bc;},remove:function()
{}}
var ieVALID=true;function generateFlashMovie(src,params)
{if(DetectFlashVer(8,0,0))
{var myNode=document.createElement("object");var _embed=document.createElement("embed");myNode.setAttribute("width",params.width);myNode.setAttribute("data",src);myNode.setAttribute("height",params.height);for(var p in params)
{var param=document.createElement("param");param.setAttribute("name",p);param.setAttribute("value",params[p]);_embed.setAttribute(p,params[p]);myNode.appendChild(param);}
_embed.setAttribute("type","application/x-shockwave-flash");_embed.setAttribute("src",src);_embed.setAttribute("allowscriptaccess","always");var containerNode=document.createElement("div");containerNode.appendChild(myNode);containerNode.valid=true;return containerNode;}
else
{var myNode=document.createElement("div");myNode.valid=false;myNode.innerHTML="<p>This content requires the Adobe Flash Player.<br /><a href=\"http://www.adobe.com/go/getflash/\">Get Flash</a></p>";return myNode;}}
function loadFlashMovie(id,src,params)
{var container=document.getElementById(id);var node=generateFlashMovie(src,params);if(navigator.isIE()&&(node.valid))
{container.innerHTML='<object id="ie_fix" width="'+params.width+'" height="'+params.height+'">'+'<param name="movie" value="'+src+'"></param>'+'<param name="allowFullScreen" value="true"></param>'+'<param name="allowscriptaccess" value="always"></param>'+'<param value="transparent" name="wmode"></param>'+'<embed src="'+src+'"  wmode="transparent" bgcolor="#FFFFFF" flashVars="videoGUID={12D22860-B5A9-4AF8-8FE9-B112911EFF20}&playerid=1000&plyMediaEnabled=1&configURL=http://wsj.vo.llnwd.net/o28/players/&autoStart=false" base="http://s.wsj.net/media/swf/" name="flashPlayer" width="'+params.width+'" height="'+params.height+'" seamlesstabbing="false" type="application/x-shockwave-flash" swLiveConnect="true" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>'+'</object>';}
else
{container.appendChild(node);}}
var zeropad=function(num){return((num<10)?'0':'')+num;};var iso8601=function(date){date=date||new Date();return date.getUTCFullYear()
+"-"+zeropad(date.getUTCMonth()+1)
+"-"+zeropad(date.getUTCDate())
+"T"+zeropad(date.getUTCHours())
+":"+zeropad(date.getUTCMinutes())
+":"+zeropad(date.getUTCSeconds())+"Z";};var datefmt=function(date){date=date||new Date();return zeropad(date.getMonth()+1)
+'/'+zeropad(date.getDate())
+'/'+zeropad(date.getFullYear())
+' '+zeropad(date.getHours()%12)
+':'+zeropad(date.getMinutes())
+':'+zeropad(date.getSeconds())
+' '+(Math.floor(date.getHours()/12)?'PM':'AM');}
Date.prototype.setISO8601=function(timestamp){var match=timestamp.match("^([-+]?)(\\d{4,})(?:-?(\\d{2})(?:-?(\\d{2})"+"(?:[Tt ](\\d{2})(?::?(\\d{2})(?::?(\\d{2})(?:\\.(\\d{1,3})(?:\\d+)?)?)?)?"+"(?:[Zz]|(?:([-+])(\\d{2})(?::?(\\d{2}))?)?)?)?)?)?$");if(match){for(var ints=[2,3,4,5,6,7,8,10,11],i=ints.length-1;i>=0;--i)
match[ints[i]]=(typeof match[ints[i]]!="undefined"&&match[ints[i]].length>0)?parseInt(match[ints[i]],10):0;if(match[1]=='-')
match[2]*=-1;var ms=Date.UTC(match[2],match[3]-1,match[4],match[5],match[6],match[7],match[8]);if(typeof match[9]!="undefined"&&match[9].length>0)
ms+=(match[9]=='+'?-1:1)*(match[10]*3600*1000+match[11]*60*1000);if(match[2]>=0&&match[2]<=99)
ms-=59958144000000;this.setTime(ms);return this;}
else
return null;}
function Description(container)
{this.container=container;this.morenode=$(container).children('.more').get(0);if(this.morenode!=null)
{var cntnode=$(this.morenode).text().toString();if(cntnode.length>4)
{$(this.morenode).hide();this.displayLink();}}
objects.push(this);}
Description.prototype={callback:function()
{},toggle:function()
{if($(this.morenode).is(":hidden"))
{$(this.morenode).show();this.insertLess();}
else
{$(this.morenode).hide();this.insertMore();}},displayLink:function()
{this.link=new Link({'fnc':function(){this.description.toggle();},"text":"more"});this.linkwrapper=document.createElement("span");this.linkwrapper.className="toggleLink";this.link.description=this;this.elipse=document.createTextNode("... ");this.insertMore();},insertLess:function()
{this.link.innerHTML="hide";this.linkwrapper.removeChild(this.elipse);this.linkwrapper.appendChild(this.link);this.container.appendChild(this.linkwrapper);},insertMore:function()
{this.link.innerHTML="more";this.linkwrapper.appendChild(this.elipse);this.linkwrapper.appendChild(this.link);$(this.linkwrapper).insertAfter(this.container.childNodes[1]);}}
function Location(params)
{if(params!=null)
{this.id=params.id;this.name=params.name;this.type=params.type;this.state=params.state;this.lat=params.lat;this.lng=params.lng
this.locationName=this.name;this.locationType=this.type;}}
Location.prototype={id:0,name:'',type:'',state:'',lat:45,lng:-71,getFullName:function()
{switch(this.type)
{case"STATE":return this.name;break;default:return this.name+(this.state?", "+this.state:'');}},getID:function()
{return this.id;},getName:function()
{return this.name;}}
function DateNode(params)
{this.deserialize(params);}
DateNode.prototype={deserialize:function(params)
{this.id=params.id;this.name=params.name;if(!params.start&&params.id.match(/^([0-9]{8,12})$/))
{this.start=params.id;this.end=null;}
else if(!params.start&&params.id.match(/^([0-9]{8,12})x([0-9]+)$/))
{var match=params.id.match(/^([0-9]{8,12})x([0-9]+)$/);this.start=match[1];this.end=match[2];}
else
{this.start=params.start;this.end=params.end;}},getFormatted:function()
{if(this.start)
{var start=new Date(this.start*1000);if(this.end)
var end=new Date(this.end*1000);return start.format('link')+(end?" to "+end.format('link'):'');}
else
return this.id;}}
function Category(id,name,params)
{this.id=id;this.name=name;if(params)
for(var i in params)
this[i]=params[i];}
Category.prototype={id:0,name:'',getID:function()
{return this.id;},getName:function()
{return this.name;},isKeyword:function()
{return this.id==Goby.conf('cat.keyword')?true:false;}}
function keywordCloser(wrappers,callback)
{this.wrappers={"document":document,"body":document.body};this.namespace=Math.round(Math.random()*10000);this.stack=[];this.closed=false;this.safeWrappers=[];this.callback=false;this.top=document;if(wrappers)
this.setWrappers(null,wrappers,callback);objects.push(this);}
keywordCloser.prototype.setWrappers=function(wrappers,safeWrappers,callback,top)
{if(!top)
top=document.body;if(!safeWrappers)
{var safeWrappers={"searchbox":document.getElementById("searchbox"),"browser":document.getElementById("browser")}}
for(var i in safeWrappers)
{if(safeWrappers[i]==null)
continue;if(safeWrappers[i].replace!=null)
safeWrappers[i]=document.getElementById(safeWrappers[i]);if(safeWrappers[i]!=null)
{this.wrappers[i]=safeWrappers[i];this.safeWrappers[i]=true;}}
this.callback=callback;this.top=top}
keywordCloser.prototype.initStgClick=function(tm)
{if(this.invalid)
return false;tm=(tm?tm:10);var closer=this;setTimeout(function()
{closer.initClick();},tm);}
keywordCloser.prototype.bindCloser=function(index)
{var element=this.wrappers[index];if(element!=undefined)
{if(element.closerSet==null)
element.closerSet={};$(element).unbind('click.closer');element.closerSet[this.namespace]={'index':index,'controller':this};$(element).bind('click.closer',function(e)
{var closers=this.closerSet;for(index in closers)
{if(closers[index])
{var controller=closers[index].controller;var elementIndex=closers[index].index;if((controller.closed!=true)&&(controller!=null))
{controller.addElement(elementIndex);}}}})}
else
{}}
keywordCloser.prototype.initClick=function()
{for(index in this.wrappers)
this.bindCloser(index);}
keywordCloser.prototype.addElement=function(index)
{this.stack.push(index);this.checkUp(index);}
keywordCloser.prototype.destruct=function()
{this.closed=true;for(var index in this.wrappers)
{if(this.wrappers[index]!=null)
var element=(this.wrappers[index].replace!=null?document.getElementById(index):this.wrappers[index]);if((element!=null)&&(element.closerSet!=null))
element.closerSet[this.namespace]=null;}}
keywordCloser.prototype.checkUp=function(index)
{var element=this.wrappers[index];var good=false;if(element===this.top)
{while(this.stack.length>0)
{var nodeIndex=this.stack.pop();if(this.safeWrappers[nodeIndex])
good=true;}
if(!good)
{if(this.callback)
{if(this.callback.object)
this.callback.object[this.callback.method]();else
eval(this.callback.method+"()");}
else
{this.destruct();}}}}
keywordCloser.prototype.addSafeWrapper=function(div)
{this.safeWrapper[div.id]=true;this.wrappers[div.id]=div;this.bindCloser(div.id);}
keywordCloser.prototype._destruct=function()
{var count=0;this.destruct();for(var i in this)
{if(this[i]!=null)
{if(this[i]._destruct!=null)
this[i]._destruct();else
this[i]=null;count++;}}
killself(this);}
