/*
 * easyXDM 
 * http://easyxdm.net/
 * Copyright(c) 2009, Øyvind Sean Kinsey, oyvind@kinsey.no.
 * 
 * MIT Licensed - http://easyxdm.net/license/mit.txt
 * 
 */
 (function(i,s,b,c,o,a){var w=this;var r=0;var t=Function.prototype;var y=/^(http.?:\/\/([^\/\s]+))/,z=/[\-\w]+\/\.\.\//,l=/([^:])\/\//g;var f=/msie [67]/.test(navigator.userAgent.toLowerCase());function k(E,G){var F=typeof E[G];return F=="function"||(!!(F=="object"&&E[G]))||F=="unknown"}function h(E,F){return !!(typeof(E[F])=="object"&&E[F])}var m=(function(){if(k(i,"addEventListener")){return function(G,E,F){G.addEventListener(E,F,false)}}else{return function(E,G,F){E.attachEvent("on"+G,F)}}}());var p=(function(){if(k(i,"removeEventListener")){return function(H,F,G,E){H.removeEventListener(F,G,E)}}else{return function(E,G,F){E.detachEvent("on"+G,F)}}}());function v(E){return E.match(y)[2]}function D(E){return E.match(y)[1]}function d(E){E=E.replace(l,"$1/");if(!E.match(/^(http||https):\/\//)){var F=(E.substring(0,1)==="/")?"":b.pathname;if(F.substring(F.length-1)!=="/"){F=F.substring(0,F.lastIndexOf("/")+1)}E=b.protocol+"//"+b.host+F+E}while(z.test(E)){E=E.replace(z,"")}return E}function j(E,H){var J="",G=E.indexOf("#");if(G!==-1){J=E.substring(G);E=E.substring(0,G)}var I=[];for(var F in H){if(H.hasOwnProperty(F)){I.push(F+"="+H[F])}}return E+((E.indexOf("?")===-1)?"?":"&")+I.join("&")+J}var A=(function(){var G={},H,F=b.search.substring(1).split("&"),E=F.length;while(E--){H=F[E].split("=");G[H[0]]=H[1]}return G}());function e(E){return typeof E==="undefined"}function n(){var F={};var G={a:[1,2,3]},E='{"a":[1,2,3]}';if(JSON&&typeof JSON.stringify==="function"&&JSON.stringify(G).replace((/\s/g),"")===E){return JSON}if(Object.toJSON){if(Object.toJSON(G).replace((/\s/g),"")===E){F.stringify=Object.toJSON}}if(typeof String.prototype.evalJSON==="function"){G=E.evalJSON();if(G.a&&G.a.length===3&&G.a[2]===3){F.parse=function(H){return H.evalJSON()}}}if(F.stringify&&F.parse){n=function(){return F};return F}return null}function u(E,F,G){var I;for(var H in F){if(F.hasOwnProperty(H)){if(H in E){I=F[H];if(typeof I==="object"){u(E[H],I,G)}else{if(!G){E[H]=F[H]}}}else{E[H]=F[H]}}}return E}function C(E){var F;if(E.props.name&&f){F=s.createElement('<iframe name="'+E.props.name+'"/>')}else{F=s.createElement("IFRAME")}u(F,E.props);F.id=F.name;if(E.onLoad){F.loadFn=function(){E.onLoad(F.contentWindow)};m(F,"load",F.loadFn)}if(E.container){F.border=F.frameBorder=0;E.container.appendChild(F)}else{F.style.position="absolute";F.style.left="-2000px";F.style.top="0px";s.body.appendChild(F)}return F}var B=(function(){if(k(i,"XMLHttpRequest")){return function(){return new XMLHttpRequest()}}else{var E=(function(){var G=["Microsoft","Msxml2","Msxml3"],F=G.length;while(F--){try{E=G[F]+".XMLHTTP";var I=new ActiveXObject(E);return E}catch(H){}}}());return function(){return new ActiveXObject(E)}}}());function q(E){u(E,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Requested-With":"XMLHttpRequest"},success:t,error:function(J){throw new Error(J)},data:{},type:"plain"},true);var G=B(),H=[];G.open(E.method,E.url,true);for(var I in E.headers){if(E.headers.hasOwnProperty(I)){G.setRequestHeader(I,E.headers[I])}}G.onreadystatechange=function(){if(G.readyState==4){if(G.status>=200&&G.status<300){var J=G.responseText;if(E.type==="json"){J=n().parse(J)}E.success(J)}else{E.error("An error occured. Status code: "+G.status)}G.onreadystatechange=null;delete G.onreadystatechange}};for(var F in E.data){if(E.data.hasOwnProperty(F)){H.push(a(F)+"="+a(E.data[F]))}}G.send(H.join("&"))}function g(G){var L=G.protocol,F;G.isHost=G.isHost||e(A.xdm_p);if(!G.props){G.props={}}if(!G.isHost){G.channel=A.xdm_c;G.secret=A.xdm_s;G.remote=o(A.xdm_e);L=A.xdm_p}else{G.remote=d(G.remote);G.channel=G.channel||"default"+r++;G.secret=Math.random().toString(16).substring(2);if(e(L)){if(k(i,"postMessage")){L="1"}else{if(k(i,"ActiveXObject")&&k(i,"execScript")){L="3"}else{if(G.remoteHelper){G.remoteHelper=d(G.remoteHelper);L="2"}else{L="0"}}}}}switch(L){case"0":u(G,{interval:300,delay:2000,useResize:true,useParent:false,usePolling:false},true);if(G.isHost){if(!G.local){var J=b.protocol+"//"+b.host,E=s.body.getElementsByTagName("img"),H=E.length,K;while(H--){K=E[H];if(K.src.substring(0,J.length)===J){G.local=K.src;break}}if(!G.local){G.local=i}}var I={xdm_c:G.channel,xdm_p:0};if(G.local===i){G.usePolling=true;G.useParent=true;G.local=b.protocol+"//"+b.host+b.pathname+b.search;I.xdm_e=a(G.local);I.xdm_pa=1}else{I.xdm_e=d(G.local)}if(G.container){G.useResize=false;I.xdm_po=1}G.remote=j(G.remote,I)}else{u(G,{channel:A.xdm_c,remote:o(A.xdm_e),useParent:!e(A.xdm_pa),usePolling:!e(A.xdm_po),useResize:G.useParent?false:G.useResize})}F=[new easyXDM.stack.HashTransport(G),new easyXDM.stack.ReliableBehavior({timeout:((G.useResize?50:G.interval*1.5)+(G.usePolling?G.interval*1.5:50))}),new easyXDM.stack.QueueBehavior({encode:true,maxLength:4000-G.remote.length}),new easyXDM.stack.VerifyBehavior({initiate:G.isHost})];break;case"1":F=[new easyXDM.stack.PostMessageTransport(G),new easyXDM.stack.QueueBehavior()];break;case"2":F=[new easyXDM.stack.NameTransport(G),new easyXDM.stack.QueueBehavior(),new easyXDM.stack.VerifyBehavior({initiate:G.isHost})];break;case"3":F=[new easyXDM.stack.NixTransport(G),new easyXDM.stack.QueueBehavior()];break}return F}function x(H){var I,G={incoming:function(K,J){this.up.incoming(K,J)},outgoing:function(J,K){this.down.outgoing(J,K)},callback:function(J){this.up.callback(J)},init:function(){this.down.init()},destroy:function(){this.down.destroy()}};for(var F=0,E=H.length;F<E;F++){I=H[F];u(I,G,true);if(F!==0){I.down=H[F-1]}if(F!==E-1){I.up=H[F+1]}}return I}w.easyXDM={version:"2.4.0.90",apply:u,query:A,ajax:q,getJSONObject:n,stack:{}};easyXDM.DomHelper={on:m,un:p,requiresJSON:function(E){if(!h(i,"JSON")){s.write('<script type="text/javascript" src="'+E+'"><\/script>')}}};(function(){var E={};easyXDM.Fn={set:function(F,G){E[F]=G},get:function(G,F){var H=E[G];if(F){delete E[G]}return H}}}());easyXDM.Socket=function(F){var E=x(g(F).concat([{incoming:function(I,H){F.onMessage(I,H)},callback:function(H){if(F.onReady){F.onReady(H)}}}])),G=D(F.remote);this.destroy=function(){E.destroy()};this.postMessage=function(H){E.outgoing(H,G)};E.init()};easyXDM.Rpc=function(G,F){if(F.local){for(var I in F.local){if(F.local.hasOwnProperty(I)){var H=F.local[I];if(typeof H==="function"){F.local[I]={method:H}}}}}var E=x(g(G).concat([new easyXDM.stack.RpcBehavior(this,F),{callback:function(J){if(G.onReady){G.onReady(J)}}}]));this.destroy=function(){E.destroy()};E.init()};easyXDM.stack.PostMessageTransport=function(H){var J,K,F,G;function E(L){if(L.origin){return L.origin}if(L.uri){return D(L.uri)}if(L.domain){return b.protocol+"//"+L.domain}throw"Unable to retrieve the origin of the event"}function I(M){var L=E(M);if(L==G&&M.data.substring(0,H.channel.length+1)==H.channel+" "){J.up.incoming(M.data.substring(H.channel.length+1),L)}}return(J={outgoing:function(M,N,L){F.postMessage(H.channel+" "+M,N||G);L()},destroy:function(){p(i,"message",I);if(K){F=null;K.parentNode.removeChild(K);K=null}},init:function(){G=D(H.remote);if(H.isHost){m(i,"message",function L(M){if(M.data==H.channel+"-ready"){F=K.contentWindow;p(i,"message",L);m(i,"message",I);c(function(){J.up.callback(true)},0)}});u(H.props,{src:j(H.remote,{xdm_e:b.protocol+"//"+b.host,xdm_c:H.channel,xdm_p:1})});K=C(H)}else{m(i,"message",I);F=i.parent;F.postMessage(H.channel+"-ready",G);c(function(){J.up.callback(true)},0)}}})};easyXDM.stack.NixTransport=function(F){var H,J,I,E,G;return(H={outgoing:function(L,M,K){I(L);K()},destroy:function(){G=null;if(J){J.parentNode.removeChild(J);J=null}},init:function(){E=D(F.remote);if(F.isHost){try{if(!k(i,"GetNixProxy")){i.execScript("Class NixProxy\n    Private m_parent, m_child, m_Auth\n\n    Public Sub SetParent(obj, auth)\n        If isEmpty(m_Auth) Then m_Auth = auth\n        SET m_parent = obj\n    End Sub\n    Public Sub SetChild(obj)\n        SET m_child = obj\n        m_parent.ready()\n    End Sub\n\n    Public Sub SendToParent(data, auth)\n        If m_Auth = auth Then m_parent.send(CStr(data))\n    End Sub\n    Public Sub SendToChild(data, auth)\n        If m_Auth = auth Then m_child.send(CStr(data))\n    End Sub\nEnd Class\nFunction GetNixProxy()\n    Set GetNixProxy = New NixProxy\nEnd Function\n","vbscript")}G=GetNixProxy();G.SetParent({send:function(L){H.up.incoming(L,E)},ready:function(){c(function(){H.up.callback(true)},0)}},F.secret);I=function(L){G.SendToChild(L,F.secret)}}catch(K){throw new Error("Could not set up VBScript NixProxy:"+K.message)}u(F.props,{src:j(F.remote,{xdm_e:b.protocol+"//"+b.host,xdm_c:F.channel,xdm_s:F.secret,xdm_p:3})});J=C(F);J.contentWindow.opener=G}else{try{G=i.opener}catch(K){throw new Error("Cannot access window.opener")}G.SetChild({send:function(L){w.setTimeout(function(){H.up.incoming(L,E)},0)}});I=function(L){G.SendToParent(L,F.secret)};c(function(){H.up.callback(true)},0)}}})};easyXDM.stack.NameTransport=function(I){var J;var L,P,H,N,O,F,E;function M(S){var R=I.remoteHelper+(L?("#_3"+a(E+"#"+I.channel)):("#_2"+I.channel));P.contentWindow.sendMessage(S,R)}function K(){if(L){if(++N===2||!L){J.up.callback(true)}}else{M("ready");J.up.callback(true)}}function Q(R){J.up.incoming(R,F)}function G(){if(O){c(function(){O(true)},0)}}return(J={outgoing:function(S,T,R){O=R;M(S)},destroy:function(){P.parentNode.removeChild(P);P=null;if(L){H.parentNode.removeChild(H);H=null}},init:function(){L=I.isHost;N=0;F=D(I.remote);I.local=d(I.local);if(L){easyXDM.Fn.set(I.channel,function(R){if(L&&R==="ready"){easyXDM.Fn.set(I.channel,Q);K()}});E=j(I.remote,{xdm_e:I.local,xdm_c:I.channel,xdm_p:2});u(I.props,{src:E+"#"+I.channel,name:I.channel});H=C(I)}else{I.remoteHelper=I.remote;easyXDM.Fn.set(I.channel,Q)}P=C({props:{src:I.local+"#_4"+I.channel},onLoad:function(){p(P,"load",P.loadFn);easyXDM.Fn.set(I.channel+"_load",G);K()}})}})};easyXDM.stack.HashTransport=function(V){var T;var W=this,Q,F,E,P,H,M,S;var J,O,G,K;function I(Y){if(!S){return}var X=V.remote+"#"+(H++)+"_"+Y;if(Q||!O){S.contentWindow.location=X;if(G){S.width=S.width>75?50:100}}else{S.location=X}}function U(X){P=X;T.up.incoming(P.substring(P.indexOf("_")+1),K)}function L(){U(M.location.hash)}function R(){if(M.location.hash&&M.location.hash!=P){U(M.location.hash)}}function N(){if(J){F=setInterval(R,E)}else{m(M,"resize",L)}}return(T={outgoing:function(X,Y){I(X)},destroy:function(){if(J){i.clearInterval(F)}else{if(M){p(M,"resize",R)}}if(Q||!O){S.parentNode.removeChild(S)}S=null},init:function(){Q=V.isHost;E=V.interval;P="#"+V.channel;H=0;J=V.usePolling;O=V.useParent;G=V.useResize;K=D(V.remote);if(!Q&&O){M=i;S=parent;N();T.up.callback(true)}else{u(V,{props:{src:(Q?V.remote:V.remote+"#"+V.channel),name:(Q?"local_":"remote_")+V.channel},onLoad:(Q&&O||!Q)?(function(){M=i;N();T.up.callback(true)}):null});S=C(V);if(Q&&!O){var Z=0,X=V.delay/50;(function Y(){if(++Z>X){throw new Error("Unable to reference listenerwindow")}if(M){return}try{M=S.contentWindow.frames["remote_"+V.channel];i.clearTimeout(F);N();T.up.callback(true);return}catch(aa){c(Y,50)}}())}}}})};easyXDM.stack.ReliableBehavior=function(G){var H,E,L,J,N=0,I=0,K=G.tries||5,M=G.timeout,F=0,O;return(H={incoming:function(R,P){var Q=R.indexOf("_"),T=parseInt(R.substring(0,Q),10),S;R=R.substring(Q+1);Q=R.indexOf("_");S=parseInt(R.substring(0,Q),10);Q=R.indexOf("_");R=R.substring(Q+1);if(E&&T===N){i.clearTimeout(E);E=null;if(O){c(function(){O(true)},0)}}if(S!==0){if(S!==F){F=S;R=R.substring(S.length+1);H.down.outgoing(S+"_0_ack",P);c(function(){H.up.incoming(R,P)},G.timeout/2)}else{H.down.outgoing(S+"_0_ack",P)}}},outgoing:function(R,P,Q){O=Q;I=0;L={data:F+"_"+(++N)+"_"+R,origin:P};(function S(){E=null;if(++I>K){if(O){c(function(){O(false)},0)}}else{H.down.outgoing(L.data,L.origin);E=c(S,G.timeout)}}())},destroy:function(){if(E){i.clearInterval(E)}H.down.destroy()}})};easyXDM.stack.QueueBehavior=function(I){var J,E=[],L=true,G="",K,F=0;function H(){if(L||E.length===0||K){return}L=true;var M=E.shift();J.down.outgoing(M.data,M.origin,function(N){L=false;if(M.callback){c(function(){M.callback(N)},0)}H()})}return(J={init:function(){if(e(I)){I={}}F=I.maxLength?I.maxLength:0;J.down.init()},callback:function(M){L=false;H();J.up.callback(M)},incoming:function(P,N){var O=P.indexOf("_"),M=parseInt(P.substring(0,O),10);G+=P.substring(O+1);if(M===0){if(I.encode){G=o(G)}J.up.incoming(G,N);G=""}},outgoing:function(Q,N,P){if(I.encode){Q=a(Q)}var M=[],O;if(F){while(Q.length!==0){O=Q.substring(0,F);Q=Q.substring(O.length);M.push(O)}}else{M.push(Q)}while((O=M.shift())){E.push({data:M.length+"_"+O,origin:N,callback:M.length===0?P:null})}H()},destroy:function(){K=true;J.down.destroy()}})};easyXDM.stack.VerifyBehavior=function(I){var J,H,F,G=false;function E(){H=Math.random().toString(16).substring(2);J.down.outgoing(H)}return(J={incoming:function(M,K){var L=M.indexOf("_");if(L===-1){if(M===H){J.up.callback(true)}else{if(!F){F=M;if(!I.initiate){E()}J.down.outgoing(M)}}}else{if(M.substring(0,L)===F){J.up.incoming(M.substring(L+1),K)}}},outgoing:function(M,K,L){J.down.outgoing(H+"_"+M,K,L)},callback:function(K){if(I.initiate){E()}}})};easyXDM.stack.RpcBehavior=function(K,F){var H,M=F.serializer||n();var L=0,J={};function E(N){N.jsonrpc="2.0";H.down.outgoing(M.stringify(N))}function I(N,P){var O=Array.prototype.slice;return function(){var Q=arguments.length,S,R={method:P};if(Q>0&&typeof arguments[Q-1]==="function"){if(Q>1&&typeof arguments[Q-2]==="function"){S={success:arguments[Q-2],error:arguments[Q-1]};R.params=O.call(arguments,0,Q-2)}else{S={success:arguments[Q-1]};R.params=O.call(arguments,0,Q-1)}J[""+(++L)]=S;R.id=L}else{R.params=O.call(arguments,0)}E(R)}}function G(N,P,S,Q){if(!S){if(P){E({id:P,error:{code:-32601,message:"Procedure not found."}})}return}var U=false,T,R;if(P){T=function(W){if(U){return}U=true;E({id:P,result:W})};R=function(W){if(U){return}U=true;E({id:P,error:{code:-32099,message:"Application error: "+W}})}}else{T=R=t}try{var V=S.method.apply(S.scope,Q.concat([T,R]));if(!e(V)){T(V)}}catch(O){R(O.message)}}return(H={incoming:function(O,N){var P=M.parse(O);if(P.method){if(F.handle){F.handle(P,E)}else{G(P.method,P.id,F.local[P.method],P.params)}}else{var Q=J[P.id];if(P.error){if(Q.error){Q.error(P.error)}}else{if(Q.success){Q.success(P.result)}}delete J[P.id]}},init:function(){if(F.remote){for(var N in F.remote){if(F.remote.hasOwnProperty(N)){K[N]=I(F.remote[N],N)}}}H.down.init()},destroy:function(){for(var N in F.remote){if(F.remote.hasOwnProperty(N)&&K.hasOwnProperty(N)){delete K[N]}}H.down.destroy()}})}})(window,document,location,window.setTimeout,decodeURIComponent,encodeURIComponent);

function gup(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function loadFrame(remoteURL) {
if (gup('wsuid') != "") {
	loadWSFrame('verifyEmail.aspx?uid=' + gup('wsuid') + '&code=' + gup('wscode') + '&cobrand=' + gup('wscb') + '&resize=' + gup('wsr') + '&intent=C');
} else if (gup('wsurl') != "") {
  loadWSFrame(gup('wsurl'));
} else {
	loadWSFrame(remoteURL);
}
}

function loadWSFrame(remoteURL) {
WSsocket = new easyXDM.Socket({
    remote: "https://www.webservius.com/cbFrame.aspx?cbUrl=" + escape(remoteURL),
    container: document.getElementById("wsFrame"),
    onMessage: function(message, origin){
        this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
}
});
}

function setFrame(contentURL) {
WSsocket.destroy();
loadWSFrame(contentURL);
}

function loadExtFrame(remoteURL) {
WSsocket = new easyXDM.Socket({
    remote: remoteURL,
    container: document.getElementById("wsFrame"),
    onMessage: function(message, origin){
        this.container.getElementsByTagName("iframe")[0].style.height = message + "px";
}
});
}

function setExtFrame(remoteURL) {
WSsocket.destroy();
loadExtFrame(remoteURL);
}
