var Hyves=Hyves||{};Hyves.type={MEMBER:6,BLOGITEM:9,TIP:11,WIDGET:27,HUB:29,HUBINTEREST:43,PRESENCE:34,MEDIA:8};Hyves.config={};Hyves.config.environment="live";Hyves.config.base_url="http://www.hyves.nl";Hyves.config.secure_url="https://secure.hyves.org";Hyves.badge={};Hyves.badge.type={OVERVIEW:"OVERVIEW",POLL:"POLL",MEDIA:"MEDIA",PREVIEW:"PREVIEW"};Hyves.badge.module={ABOUT:"About",BLOG:"Blog",MEMBER:"Member",SUBSCRIBE:"Subscribe",POLL:"Poll",PREVIEW:"Preview",THUMBNAIL:"Thumbnail"};Hyves.badge.defaults={OVERVIEW:["Subscribe"],POLL:["Poll"],MEDIA:["Thumbnail"],PREVIEW:["Preview"]};Hyves.badge.available={OVERVIEW:["About","Blog","Member","Subscribe"],POLL:["Poll"],MEDIA:["Preview","Thumbnail"],PREVIEW:["Preview"]};Hyves.badge.config={About:{height:100,item:0,row:1,count:0,itemwidth:false},Blog:{height:1,item:132,row:1,count:3,itemwidth:false},Member:{height:30,item:67,row:4,count:8,itemwidth:70},Subscribe:{height:100,item:100,row:1,count:0,itemwidth:false},Poll:{height:270,item:0,row:1,count:0,itemwidth:false},Preview:{height:270,item:0,row:1,count:0,itemwidth:false},Thumbnail:{height:72,item:63,row:4,count:8,itemwidth:74}};var Hyves=Hyves||{};Hyves.constants={empty:null,response:{status:{success:"id_res",requestLoginRequired:"setup_needed",cancelled:"cancel",unknownError:"error"},field:{userid:"ax.value.userid",language:"ax.value.language",unavailable:null},oauth:{requestToken:"oauth.request_token",accessToken:"oauth.oauth_token",accessTokenSecret:"oauth.oauth_token_secret",scope:"oauth.scope",unavailable:null},profileField:{nickname:"ax.value.nickname",profilepicture:"ax.value.profilepicture",profilepictureIcon:"ax.value.profilepicture_icon",profilepictureIconLarge:"ax.value.profilepicture_icon_large",profileurl:"ax.value.profileurl",firstname:"ax.value.firstname",lastname:"ax.value.lastname",birthdate:"ax.value.birthdate",gender:"ax.value.gender"},contactField:{address:"ax.value.address",postalcode:"ax.value.postalcode",city:"ax.value.city",email:"ax.value.email",phonenumber:"ax.value.phonenumber"}}};Hyves.connect=function(){var base_url=Hyves.config.base_url;var secure_url=Hyves.config.secure_url;var environment=Hyves.config.environment;var isLive=(environment=="development"||environment=="staging")?false:true;if(window.addEventListener){window.addEventListener("message",function(e){rpc.receiveMessage(e)},false)}else{window.attachEvent("onmessage",function(e){rpc.receiveMessage(e)})}var logging_is_enabled=true;var HYVESCONNECT_TYPE_COMBO=10001;var HYVESCONNECT_TYPE_TELLAFRIEND=10002;var HYVESCONNECT_TYPE_PAY=10003;var params=[];var aOption=[];var consumerKey="";var rpcRelay="http://"+location.host+"/statics/hcrpc_relay.html";var init=function(settings){if(settings.consumerKey){consumerKey=settings.consumerKey}if(settings.rpcRelay){rpcRelay=settings.rpcRelay}};var log={debug:function(obj){if(logging_is_enabled&&window.console){if(typeof obj=="string"&&document.domain){obj="["+document.domain+"] "+obj}console.log(obj)}}};var builder={buildPopupUrl:function(id){var par=params[id];var toAppend=[];for(var property in par){if(par.hasOwnProperty(property)){toAppend.push(escape(property)+"="+escape(par[property]))}}var url=config.getPostUrl(id)+"?"+toAppend.join("&");log.debug(url);return url},buildButton:function(id){var size=[16,24,32,48].join("|").indexOf(aOption[id].iconsize)<0?24:aOption[id].iconsize;return'<a href="javascript:;" onclick="Hyves.connect.submit('+id+');"><img style="border:none;" src="'+config.getCacheUrl()+"/images/hyvesconnect/favicon_"+size+'_round.png"></a>'},decorateDiv:function(element,id){element.style.padding="15px";element.style.backgroundColor="rgb(207, 223, 239)";element.id=id;builder.decorateGeneric(element)},decorateGeneric:function(element){element.style.position="absolute";element.style.zIndex="1000"}};var helper={getScrollOffset:function(){var element=document.body;var valueT=0,valueL=0;do{valueT+=element.scrollTop||0;valueL+=element.scrollLeft||0;element=element.parentNode}while(element);return{left:valueL,top:valueT}},getDocumentDimensions:function(){var viewportwidth;var viewportheight;if(typeof window.innerWidth!="undefined"){viewportwidth=window.innerWidth;viewportheight=window.innerHeight}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!==0){viewportwidth=document.documentElement.clientWidth;viewportheight=document.documentElement.clientHeight}else{viewportwidth=document.getElementsByTagName("body")[0].clientWidth;viewportheight=document.getElementsByTagName("body")[0].clientHeight}}return{width:viewportwidth,height:viewportheight}},getLeftAndTopOffset:function(object){var objectDimensions=helper.getElementDimensions(object);var dimensions=helper.getDocumentDimensions();var scrollOffset=helper.getScrollOffset();var left=Math.floor((dimensions.width/2)-(objectDimensions.width/2)+scrollOffset.left);var top=Math.floor((dimensions.height/2)-(objectDimensions.height/2)+scrollOffset.top);return{left:left,top:top}},getElementDimensions:function(element){return{width:element.clientWidth,height:element.clientHeight}},getElementNode:function(node){var returnValue=false;if(typeof node=="string"){returnValue=document.getElementById(node)}else{if(typeof node=="object"){returnValue=node}}return returnValue},getBadgeNode:function(node){log.debug("Looking for node: "+node);return document.getElementById(node)||document.body},encodeParams:function(params){var parts=[];for(var i in params){if(params.hasOwnProperty(i)){parts.push(encodeURIComponent(i)+"="+encodeURIComponent(params[i]))}}return parts},appendAndEncodeParams:function(url,params){var parts=helper.encodeParams(params);if(parts.length>0){var seperator="?";if(url.indexOf("?")>-1||url.indexOf("#")>-1){seperator="&"}url+=seperator+parts.join("&")}log.debug(url);return url},appendSettings:function(url){var params={consumerKey:consumerKey,rpcRelay:rpcRelay};return this.appendAndEncodeParams(url,params)},extend:function(sub,base){var copy={};for(var property in base){copy[property]=base[property]}for(var property in sub){copy[property]=sub[property]}return copy},cleanup:function(id){var element=helper.getElementNode(id);if(element){var up=element.parentNode;up.removeChild(element)}},normalizeDomain:function(uri){var uriInfo=this.parseUri(uri);return uriInfo.protocol+"://"+uriInfo.host},parseUri:function(str,strictMode){if(!strictMode){strictMode=false}var o={strictMode:strictMode,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};var m=o.parser[o.strictMode?"strict":"loose"].exec(str),uri={},i=14;while(i--){uri[o.key[i]]=m[i]||""}uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function($0,$1,$2){if($1){uri[o.q.name][$1]=$2}});return uri}};var config={getHyvesUrl:function(id){var secure=id?aOption[id].secure:false;if(secure){return secure_url}else{return(isLive?"http://www.hyves.nl":base_url.replace("cache","www"))}},getPostUrl:function(id){return this.getHyvesUrl(id)+"/hyvesconnect/smartbutton"},getBadgeUrlByType:function(type){var action="";switch(type){case Hyves.badge.type.OVERVIEW:action="module=Badge&action=showOverviewBadge";break;case Hyves.badge.type.POLL:action="module=Badge&action=showPollBadge";break;case Hyves.badge.type.MEDIA:action="module=Badge&action=showMediaBadge";break;case Hyves.badge.type.PREVIEW:action="module=Badge&action=showUpdatedPreviewModule";break}return this.getHyvesUrl()+"/?"+action},getBadgeUrl:function(){return this.getHyvesUrl()+"/hyvesconnect/badge"},getRelayUrl:function(){return this.getHyvesUrl()+"/statics/hcrpc_relay.html"},getBridgeUrl:function(){return this.getHyvesUrl()+"/hyvesconnect/bridge"},getBridgePopupUrl:function(){return this.getHyvesUrl()+"/hyvesconnect/bridgepopup"},getCacheUrl:function(){return isLive?"http://cache.hyves-static.net":base_url},getDivId:function(){return"hyvesconnect_div"},getFormId:function(){return"hyvesconnect_form"},getIframeIdPrefix:function(){return"hyvesconnect_iframe_"},defaults:{iconsize:24,secure:false},getFormMethod:function(){return"get"},getDefaultOptions:function(){return this.defaults},setDefaultOptions:function(options){for(var property in this.defaults){if(options[property]){this.defaults[property]=options[property]}}},getDefaultLoginOptions:function(){return{profileInformation:true,contactInformation:false,apiAccess:false,apiScope:""}},getDefaultLoginButtonOptions:function(){var imageUrl=config.getCacheUrl()+"/images/hyvesconnect/nl_hyvesconnect_login_button.png";return{image:imageUrl,autoAttempt:true}},getDefaultApiParams:function(){return{ha_format:"json",ha_fancylayout:"true",ha_version:"2.0"}},getIFrameHeight:function(type){var height=660;switch(type){case Hyves.type.BLOGITEM:case Hyves.type.MEDIA:case Hyves.type.TIP:case Hyves.type.HUB:case Hyves.type.HUBINTEREST:case HYVESCONNECT_TYPE_COMBO:case Hyves.type.PRESENCE:height=560;break;case Hyves.type.MEMBER:height=580;break;case Hyves.type.WIDGET:break;default:height=660}return height},getIFrameWidth:function(type){var width=530;switch(type){case HYVESCONNECT_TYPE_PAY:width=700;break;case Hyves.type.MEMBER:width=600;break}return width}};var login=function(){var bridgeInited=false;var bridgePopup=false;var bridgeRpc=null;var LoginResponse=function(response){return{status:response.status,openid:response.openid,signature:response.signature,getStatus:function(){return this.status},getIdentity:function(){return this.openid.identity},getSignature:function(){return this.signature},getField:function(key,defaultValue){if(this.openid&&this.openid[key]){return this.openid[key]}else{if(defaultValue){return defaultValue}else{return Hyves.constants.response.field.unavailable}}},getOAuthProperty:function(key){return this.getField(key,Hyves.constants.response.oauth.unavailable)},getUserid:function(){return this.getField(Hyves.constants.response.field.userid)},getLanguage:function(){return this.getField(Hyves.constants.response.field.language)},getOAuthAccessToken:function(){return this.getOAuthProperty(Hyves.constants.response.oauth.accessToken)},getOAuthAccessTokenSecret:function(){return this.getOAuthProperty(Hyves.constants.response.oauth.accessTokenSecret)},getOAuthScope:function(){return this.getOAuthProperty(Hyves.constants.response.oauth.scope)},getOAuthRequestToken:function(){return this.getOAuthProperty(Hyves.constants.response.oauth.requestToken)}}};var util={getBridgeId:function(){return config.getIframeIdPrefix()+"bridge"},createBridge:function(){if(bridgeRpc===null){bridgeRpc=Hyves.connect.rpc.create({frame:this.getBridgeId(),domain:config.getHyvesUrl(),relay:config.getRelayUrl()})}if(!bridgeInited&&!helper.getElementNode(this.getBridgeId())){var iframe=document.createElement("iframe");iframe.style.width="1px";iframe.style.height="0px";iframe.scrolling="no";iframe.frameBorder="0";iframe.id=this.getBridgeId();iframe.name=this.getBridgeId();iframe.src=helper.appendSettings(config.getBridgeUrl());log.debug("Placing hyves-bridge in document body.");setTimeout(function(){document.body.appendChild(iframe)},0);bridgeRpc.register("bridge_init",function(params){log.debug("Hyves-bridge is now inited successful.");bridgeInited=true});bridgeRpc.register("bridge_exception",function(params){log.debug("Bridge exception occured!");log.debug(params)})}},createBridgePopup:function(loginOptions){var self=this;Hyves.connect.login.require(function(){if(self.bridgePopup&&self.bridgePopup.closed){self.bridgePopup=false}if(self.bridgePopup){self.bridgePopup.close()}var bridgePopupUrl=helper.appendSettings(config.getBridgePopupUrl());bridgePopupUrl=helper.appendAndEncodeParams(bridgePopupUrl,{loginOptions:Hyves.connect.util.json.stringify(loginOptions)});self.bridgePopup=window.open(bridgePopupUrl,"hyves_bridge_popup","width=600,height=900,scrollbars=yes,location=yes")})},processResponse:function(callback,params){var loginResponse=new LoginResponse(params);if(loginResponse.getOAuthRequestToken()!==Hyves.constants.response.oauth.unavailable){api.loginResponse=loginResponse}callback(loginResponse)}};return{button:function(loginOptions,buttonOptions,callback,node){buttonOptions=helper.extend(buttonOptions,config.getDefaultLoginButtonOptions());var drawLoginButton=function(){var elem=helper.getElementNode(node);if(!elem){elem=document.body}var domLink=document.createElement("a");domLink.href="javascript:;";domLink.onclick=function(event){Hyves.connect.login.request(loginOptions,function(response){domLink.style.display="none";callback(response)})};var domImage=document.createElement("img");domImage.style.border="0px";domImage.src=buttonOptions.image;domLink.appendChild(domImage);elem.appendChild(domLink)};if(buttonOptions.autoAttempt){Hyves.connect.login.attempt(loginOptions,function(response){if(response.status==Hyves.constants.response.status.requestLoginRequired){drawLoginButton()}else{callback(response)}})}else{drawLoginButton()}},attempt:function(loginOptions,callback){var self=this;this.require(function(){bridgeRpc.register("bridge_tryLoginResponse",function(params){util.processResponse(callback,params)});bridgeRpc.call("bridge_tryLogin",helper.extend(loginOptions,config.getDefaultLoginOptions()))})},request:function(loginOptions,callback){var self=this;this.require(function(){bridgeRpc.register("bridge_doLoginResponse",function(params){util.processResponse(callback,params)});util.createBridgePopup(helper.extend(loginOptions,config.getDefaultLoginOptions()))})},require:function(func){if(bridgeInited){func();return}util.createBridge();var self=this;setTimeout(function(){self.require(func)},100)},call:function(action,params){log.debug("send call "+action);bridgeRpc.call(action,params)},register:function(action,callback){log.debug("registering call "+action);bridgeRpc.register(action,callback)}}}();var api=function(){var loginResponse=null;return{call:function(method,params,callback,options){login.require(function(){login.register("bridge_apiCallResponse",function(params){callback(params)});params.ha_method=method;login.call("bridge_apiCall",helper.extend(params,config.getDefaultApiParams()))})}}}();var main=function(){var badges=[];return{button:function(fields,options,node){params.push(fields);aOption.push(helper.extend(options,config.getDefaultOptions()));id=params.length-1;var elem=helper.getElementNode(node);var buttonHtml=builder.buildButton(id);if(elem){elem.innerHTML=buttonHtml}else{document.write(buttonHtml)}},badge:function(params,options,node){if(options.style){var n=0;for(var k in options.style){if(options.style.hasOwnProperty(k)){options["pers_item_profile."+k]=options.style[k];n++}}options.style=n>0?true:false}var iframe=document.createElement("iframe");iframe.style.border="0px";iframe.style.width="1px";iframe.scrolling="no";iframe.frameBorder="0";badges.push(iframe);var id=badges.length-1;iframe.id=config.getIframeIdPrefix()+id;iframe.src=helper.appendAndEncodeParams(config.getBadgeUrl(),helper.extend({frameId:id,badge_type:params.type},options));var badgeNode=helper.getBadgeNode(node);log.debug("Placing in node: "+badgeNode);setTimeout(function(){badgeNode.appendChild(iframe)},0);log.debug("badges array length: "+badges.length);return{call:function(key,params){Hyves.connect.rpc.call(key,params,id)}}},drawBadge:function(badgeType,owner,type,configuration,node){if(!configuration){configuration={modules:{},pimp:{}}}else{if(!configuration.modules){configuration.modules={}}if(!configuration.pimp){configuration.pimp={}}}var iframe=document.createElement("iframe");var width=configuration.width||300;width=width<175?175:width;var sumHeight=0;log.debug(badgeType);var defaults=Hyves.badge.defaults[badgeType];for(module in configuration.modules){var moduleAvailable=false;for(var i=0;i<Hyves.badge.available[badgeType].length;i++){if(Hyves.badge.available[badgeType][i]==module){moduleAvailable=true;break}}if(!moduleAvailable){log.debug("Module "+module+" not available for Badge "+badgeType);continue}sumHeight+=Hyves.badge.config[module].height;log.debug("Adding "+Hyves.badge.config[module].height+" for configured module "+module);var itemCount=configuration.modules[module].count||Hyves.badge.config[module].count;var itemHeight=Hyves.badge.config[module].item;var multiplier=false;if(Hyves.badge.config[module].itemwidth){var itemPerRow=Math.floor(width/Hyves.badge.config[module].itemwidth);log.debug("Items per row (itemWidth): "+itemPerRow);var multiplier=Math.ceil(itemCount/itemPerRow)}else{if(itemHeight&&itemCount){var itemPerRow=Hyves.badge.config[module].row;log.debug("Items per row (itemCount): "+itemPerRow);var multiplier=itemPerRow?(itemCount/itemPerRow):itemCount}}if(multiplier){var itemHeight=itemHeight*multiplier;log.debug("Item height of "+module+": "+itemHeight);sumHeight+=itemHeight}}for(i=0;i<defaults.length;i++){var module=defaults[i];if(typeof configuration.modules[module]=="undefined"){log.debug("Adding "+Hyves.badge.config[module].height+" for default module "+module);sumHeight+=Hyves.badge.config[module].height;var itemHeight=Hyves.badge.config[module].item;var itemPerRow=Math.floor(width/Hyves.badge.config[module].itemwidth);var itemCount=Hyves.badge.config[module].count;var multiplier=(itemCount/itemPerRow);var itemHeight=itemHeight*multiplier;log.debug("Adding default item height of "+module+": "+itemHeight);sumHeight+=itemHeight}}log.debug("Total "+badgeType+" badge height: "+sumHeight);var defaultBorder="1px solid ";var defaultColor="silver";if(configuration.pimp){var color=configuration.pimp.bordercolor||defaultColor;defaultColor=color.replace(/[^0-9a-z#]/gi,"")}var border=defaultBorder+defaultColor;log.debug("Border "+border);iframe.id="hyvesconnect_badge_"+badgeType.toLowerCase();iframe.style.border=border;iframe.style.width=width+"px";iframe.style.height=sumHeight+"px";iframe.scrolling="no";iframe.frameBorder="0";var url=config.getBadgeUrlByType(badgeType);var params={owner:owner,type:type,modules:Hyves.connect.util.json.stringify(configuration.modules),pimp:Hyves.connect.util.json.stringify(configuration.pimp)};iframe.src=helper.appendAndEncodeParams(url,params);setTimeout(function(){helper.getBadgeNode(node).appendChild(iframe)},0)}}}();var util=function(){return{json:function(){var m={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return{stringify:function(value){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case"string":return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c}c=a.charCodeAt();return"\\u00"+Math.floor(c/16).toString(16)+(c%16).toString(16)})+'"':'"'+value+'"';case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}a=[];if(typeof value.length==="number"&&!(value.propertyIsEnumerable("length"))){l=value.length;for(i=0;i<l;i+=1){a.push(this.stringify(value[i])||"null")}return"["+a.join(",")+"]"}for(k in value){if(value.hasOwnProperty(k)){if(typeof k==="string"){v=this.stringify(value[k]);if(v){a.push(this.stringify(k)+":"+v)}}}}return"{"+a.join(",")+"}"}},parse:function(text){if(/^[\],:{}\s]*$/.test(text.replace(/\\["\\\/b-u]/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return eval("("+text+")")}return false}}}(),client:{getHeight:function(){var display=document.body.style.display;if(display!="none"&&display!==null){return document.body.offsetHeight}var els=document.body.style;var originalVisibility=els.visibility;var originalPosition=els.position;var originalDisplay=els.display;els.visibility="hidden";els.position="absolute";els.display="block";var originalHeight=document.body.clientHeight;els.display=originalDisplay;els.position=originalPosition;els.visibility=originalVisibility;return originalHeight}}}}();var rpc=function(){var callbackPool={};var targetPool={};var frameId="..";var iframePool=[];var partBuffer={};var relay=config.getRelayUrl();var targetDomain=config.getHyvesUrl();var util={parseParams:function(params){return Hyves.connect.util.json.parse(decodeURIComponent(params))},emitIFrame:function(iframeSrc,data,partNum,numParts){if(typeof partNum=="undefined"){partNum=1}if(typeof numParts=="undefined"){numParts=0}var iframe;for(var i=iframePool.length-1;i>=0;--i){var ifr=iframePool[i];try{if(ifr&&(ifr.recyclable||ifr.readyState==="complete")){ifr.parentNode.removeChild(ifr);if(window.ActiveXObject){iframePool[i]=ifr=null;iframePool.splice(i,1)}else{ifr.recyclable=false;log.debug("reusing iframe");iframe=ifr;break}}}catch(e){}}if(!iframe){iframe=document.createElement("iframe");iframe.style.border=iframe.style.width=iframe.style.height="0px";iframe.style.visibility="hidden";iframe.style.position="absolute";iframe.onload=function(){this.recyclable=true};iframePool.push(iframe)}log.debug("iframepool size = "+iframePool.length);var maxUrlSize=50000;if(window.ActiveXObject){maxUrlSize=1500}var restData=false;if((iframeSrc.length+data.length)>maxUrlSize){var maxDataLength=maxUrlSize-iframeSrc.length;if(numParts===0){numParts=Math.ceil((data.length/maxDataLength))-1}restData=data.substring(maxUrlSize);data="part:"+partNum+":"+numParts+":"+encodeURIComponent(data.substring(0,maxUrlSize))}else{if(partNum>1){data="part:"+partNum+":"+numParts+":"+encodeURIComponent(data)}}iframe.src=iframeSrc+encodeURIComponent(data);setTimeout(function(){document.body.appendChild(iframe)},0);if(restData!==false){this.emitIFrame(iframeSrc,restData,(partNum+1),numParts)}},resize:function(frame,params){log.debug("Resizing...");var frame=document.getElementById(config.getIframeIdPrefix()+params.frame);if(frame){frame.style.width=params.width+"px";frame.style.height=params.height+"px"}else{log.debug("Frame doesn't exist..ignoring..")}},processRpcMessage:function(target,key,params){log.debug("processing "+key);try{switch(key){case"resize":this.resize(params.frame,params);break;default:if(target){callbackPool[target.domain][key](params)}else{log.debug("Got message "+key+" but was unable to find target info.")}}}catch(e){log.debug("Error executing "+key+", "+e.message)}},registerRpc:function(key,fn,target){if(!callbackPool[target.domain]){callbackPool[target.domain]={}}callbackPool[target.domain][key]=fn;log.debug("registered function "+key+" for target "+target.domain)},callRpc:function(key,params,target){var targetWindow=window.parent;if(target.frame!==Hyves.connect.rpc.targetFrameParent){targetWindow=document.getElementById(target.frame).contentWindow}var useHTML5=false;try{if(typeof targetWindow!="undefined"&&typeof targetWindow.postMessage!="undefined"){useHTML5=true}}catch(e){}if(useHTML5){var message=Hyves.connect.util.json.stringify({key:key,params:params});targetWindow.postMessage(message,target.domain);log.debug("called (using html5) "+key)}else{var data=Hyves.connect.util.json.stringify(params);var iframeSrc=target.relay+"#"+target.frame+"&"+key+"&"+encodeURIComponent(target.origin)+"&";this.emitIFrame(iframeSrc,data);log.debug("called "+key)}}};return{targetFrameParent:"..",create:function(target){target.origin=helper.normalizeDomain(location.href);target.domain=helper.normalizeDomain(target.domain);targetPool[target.domain]=target;return{target:target,register:function(key,fn){util.registerRpc(key,fn,target)},call:function(key,params){util.callRpc(key,params,target)}}},receive:function(frame,key,params){var domain=decodeURIComponent(params[0]);var params=params[1];log.debug("receiving "+key+" from domain: "+domain);paramsStr=String(params);if(paramsStr.substring(0,5)=="part:"){log.debug(key+" is split into parts, processing part.");if(!partBuffer[key]){partBuffer[key]={parts:0,data:[]}}var data=paramsStr.split(":");partBuffer[key].parts=parseInt(data[2])+1;partBuffer[key].data[parseInt(data[1])]=data[3];if(partBuffer[key].data.length!=partBuffer[key].parts){return}else{params=partBuffer[key].data.join("");log.debug(key+" all parts processed, proceeding.");delete partBuffer[key]}}params=util.parseParams(params);var target=targetPool[domain];util.processRpcMessage(target,key,params)},receiveMessage:function(messageEvent){var originDomain=helper.normalizeDomain(messageEvent.origin);var target=targetPool[originDomain];if(!target){target={domain:helper.normalizeDomain(config.getHyvesUrl())}}if(target.domain==originDomain){var message=Hyves.connect.util.json.parse(messageEvent.data);if(message&&message.key){log.debug("receiving html5 message "+message.key);util.processRpcMessage(target,message.key,message.params)}}else{log.debug("Got html5 message from unknown domain: "+originDomain+"; expected: "+target.domain)}}}}();var badge={firehose:function(options,node){return main.badge({type:"showPublicWwwMini"},options,node)},overview:function(owner,type,configuration,node){return main.drawBadge(Hyves.badge.type.OVERVIEW,owner,Hyves.type.HUB,configuration,node)},poll:function(owner,type,configuration,node){return main.drawBadge(Hyves.badge.type.POLL,owner,type,configuration,node)},media:function(owner,type,configuration,node){return main.drawBadge(Hyves.badge.type.MEDIA,owner,type,configuration,node)},preview:function(owner,type,configuration,node){return main.drawBadge(Hyves.badge.type.PREVIEW,owner,type,configuration,node)},configuration:{modules:{},width:300}};var respect={generate:function(p){var $=document.getElementById;var p=p?p:{};var w=p.width?parseInt(p.width):150;var h=21;var u=p.url?p.url:"http://www.hyves.nl";var params={url:u};var src=helper.appendAndEncodeParams(Hyves.config.base_url+"/respect/button",params);var fragments=["<iframe",'src="'+src+'"','style="border: medium none; overflow:hidden; width:'+w+"px; height:"+h+'px;"','scrolling="no"','frameborder="0"','allowTransparency="true"',">"];var ifr=fragments.join(" ")+"</iframe>";log.debug(ifr);return ifr}};return{init:init,tip:function(fields,options,node){fields.type=Hyves.type.TIP;main.button(fields,options,node)},blog:function(fields,options,node){fields.type=Hyves.type.BLOGITEM;main.button(fields,options,node)},widget:function(fields,options,node){fields.type=Hyves.type.WIDGET;main.button(fields,options,node)},interest:function(fields,options,node){fields.type=Hyves.type.HUBINTEREST;main.button(fields,options,node)},hub:function(fields,options,node){fields.type=Hyves.type.HUB;main.button(fields,options,node)},friendinvite:function(fields,options,node){fields.type=Hyves.type.MEMBER;main.button(fields,options,node)},presence:function(fields,options,node){fields.type=Hyves.type.PRESENCE;main.button(fields,options,node)},combo:function(fields,options,node){fields.type=HYVESCONNECT_TYPE_COMBO;main.button(fields,options,node)},tellafriend:function(fields,options,node){fields.type=HYVESCONNECT_TYPE_TELLAFRIEND;main.button(fields,options,node)},pay:function(fields,options,node){fields.type=HYVESCONNECT_TYPE_PAY;fields.popup=1;fields.fixed=fields&&fields.fixed===true?1:0;options=options||{};options.secure=true;main.button(fields,options,node)},media:function(fields,options,node){fields.type=Hyves.type.MEDIA;main.button(fields,options,node)},submit:function(id){var url=builder.buildPopupUrl(id);window.open(url,"popup","height="+config.getIFrameHeight(params[id].type)+",width="+config.getIFrameWidth(params[id].type)+",location=yes,scrollbars=yes")},close:function(){helper.cleanup(config.getDivId())},defaults:function(options){config.setDefaultOptions(options)},util:util,rpc:rpc,badge:badge,login:login,api:api,respect:respect}}();try{if(window.jsloaded){jsloaded("/statics/hyvesconnect_core.js")}}catch(e){}if(window.jsloaded){jsloaded("/precompiled/hyvesconnect_bundle.js")};
