window.gadgets=window.gadgets||{util:{registerOnLoadHandler:function(A){A()
}}},window.withwaves=window.withwaves||{gadgets:{}};
window.withwaves.gadgets=window.withwaves.gadgets||{};
window.gadgets.window=window.gadgets.window||{adjustHeight:function(){}};
withwaves.gadgets.load=function(D,C,A,B){if(!D){return 
}$(function(){$.ajax({type:"GET",url:D,dataType:"xml",success:function(F){var G=$(F).find("Content").text(),I,E="",J;
G=G.replace(new RegExp(C,"gi"),"");
G=G.replace(/<script[\s\S]*?<\/script>/gi,function(K){if(K){E+=K;
return""
}});
I=document.getElementById("gadgetFrame1");
J=I.contentWindow?I.contentWindow.document:I.contentDocument?I.contentDocument:I.document;
J.write("<script type='text/javascript'>window.gadgets = window.top.gadgets; window.wave = window.top.wave;<\/script>");
J.write(G);
J.write(E);
var H=wave.getState();
if(H){H.submitDelta(A||{})
}window.gadgets.window.adjustHeight()
}})
})
};var wave=wave||{};
wave.Callback=function(B,A){this.callback_=B;
this.context_=A||null
};
wave.Callback.prototype.invoke=function(){if(this.callback_){var A=Array.prototype.slice.call(wave.Callback.prototype.invoke.arguments,0);
this.callback_.apply(this.context_,A)
}};
wave.Mode={UNKNOWN:0,VIEW:1,EDIT:2,DIFF_ON_OPEN:3,PLAYBACK:4};
wave.PARAM_NAME_="wave";
wave.viewer_=null;
wave.host_=null;
wave.participants_=[];
wave.participantMap_={};
wave.state_=null;
wave.stateCallback_=new wave.Callback(null);
wave.participantCallback_=new wave.Callback(null);
wave.inWaveContainer_=false;
wave.util=wave.util||{};
wave.util.SPACES=" ";
wave.util.toSpaces_=function(A){return wave.util.SPACES.substring(0,A*2)
};
wave.util.isArray_=function(B){try{return B&&typeof B.length=="number"
}catch(A){return false
}};
wave.util.printJson=function(K,J,H){if(!K||typeof K.valueOf()!="object"){if(typeof K=="string"){return"'"+K+"'"
}else{if(K instanceof Function){return"[function]"
}}return""+K
}var I=[],G=wave.util.isArray_(K),F=G?"[]":"{}",E=J?"\n":"",B=J?" ":"",A=0;
H=H||1;
J||(H=0);
I.push(F.charAt(0));
for(var D in K){var C=K[D];
A++>0&&I.push(", ");
if(G){I.push(wave.util.printJson(C,J,H+1))
}else{I.push(E);
I.push(wave.util.toSpaces_(H));
I.push(D+": ");
I.push(B);
I.push(wave.util.printJson(C,J,H+1))
}}if(!G){I.push(E);
I.push(wave.util.toSpaces_(H))
}I.push(F.charAt(1));
return I.join("")
};
wave.Participant=function(C,A,B){this.id_=C||"";
this.displayName_=A||"";
this.thumbnailUrl_=B||""
};
wave.Participant.prototype.getId=function(){return this.id_
};
wave.Participant.prototype.getDisplayName=function(){return this.displayName_
};
wave.Participant.prototype.getThumbnailUrl=function(){return this.thumbnailUrl_
};
wave.Participant.fromJson_=function(B){var A=new wave.Participant;
A.id_=B.id;
A.displayName_=B.displayName;
A.thumbnailUrl_=B.thumbnailUrl;
return A
};
wave.State=function(){this.setState_(null)
};
wave.State.prototype.get=function(B,A){return this.state_[B]||A||null
};
wave.State.prototype.getKeys=function(){var B=[];
for(var A in this.state_){B.push(A)
}return B
};
wave.State.prototype.submitDelta=function(A){jQuery.extend(this.state_,A);
wave.stateCallback_.invoke(wave.state_)
};
wave.State.prototype.submitValue=function(A,B){var C={};
C[A]=B;
this.submitDelta(C)
};
wave.State.prototype.reset=function(){var B={};
for(var A in this.state_){B[A]=null
}this.submitDelta(B)
};
wave.State.prototype.setState_=function(A){this.state_=A||{}
};
wave.State.prototype.toString=function(){return wave.util.printJson(this.state_,true)
};
wave.checkWaveContainer_=function(){wave.inWaveContainer_=true
};
wave.isInWaveContainer=function(){return wave.inWaveContainer_
};
wave.receiveWaveParticipants_=function(D){wave.viewer_=null;
wave.host_=null;
wave.participants_=[];
wave.participantMap_={};
var C=D.myId,E=D.authorId,B=D.participants;
for(var A in B){var F=wave.Participant.fromJson_(B[A]);
if(A==C){wave.viewer_=F
}if(A==E){wave.host_=F
}wave.participants_.push(F);
wave.participantMap_[A]=F
}if(!wave.viewer_&&C){F=new wave.Participant(C,C);
wave.viewer_=F;
wave.participants_.push(F);
wave.participantMap_[C]=F
}wave.participantCallback_.invoke(wave.participants_)
};
wave.receiveState_=function(A){wave.state_=wave.state_||new wave.State;
wave.state_.setState_(A);
wave.stateCallback_.invoke(wave.state_)
};
wave.getViewer=function(){return wave.viewer_
};
wave.getHost=function(){return wave.host_
};
wave.getParticipants=function(){return wave.participants_
};
wave.getParticipantById=function(A){return wave.participantMap_[A]
};
wave.getState=function(){return wave.state_
};
wave.getMode=function(){if(wave.state_){var A=wave.state_.get("${playback}"),B=wave.state_.get("${edit}");
if(A!=null&&B!=null){return A=="1"?wave.Mode.PLAYBACK:B=="1"?wave.Mode.EDIT:wave.Mode.VIEW
}}return wave.Mode.UNKNOWN
};
wave.isPlayback=function(){return !(wave.state_&&wave.state_.get("${playback}","1")=="0")
};
wave.setStateCallback=function(B,A){wave.stateCallback_=new wave.Callback(B,A);
wave.state_&&wave.stateCallback_.invoke(wave.state_)
};
wave.setParticipantCallback=function(B,A){wave.participantCallback_=new wave.Callback(B,A);
wave.participants_&&wave.participantCallback_.invoke(wave.participants_)
};
wave.setModeCallback=function(){};
wave.getTime=function(){return(new Date).getTime()
};
wave.log=function(A){console.log(A||"")
};
wave.internalInit_=function(){wave.checkWaveContainer_();
if(wave.isInWaveContainer()){wave.receiveWaveParticipants_({myId:"testviewer@withwaves.com",authorId:"testviewer@withwaves.com",participants:{"testviewer@withwaves.com":{id:"testviewer@withwaves.com",displayName:"The Viewer",thumbnailUrl:null},"testparticipant@withwaves.com":{id:"testparticipant@withwaves.com",displayName:"One Participant",thumbnailUrl:null},"anotherparticipant@withwaves.com":{id:"anotherparticipant@withwaves.com",displayName:"Another Participant",thumbnailUrl:null}}});
wave.receiveState_({})
}};
(wave.init_=function(){window.gadgets&&gadgets.util.registerOnLoadHandler(function(){wave.internalInit_()
})
})();
