var sociallyveGlobalConfig=[];sociallyveGlobalConfig.facebook={popUpWidth:470,popUpHeight:300};sociallyveGlobalConfig.twitter={popUpWidth:800,popUpHeight:830};sociallyveGlobalConfig.gmx={popUpWidth:700,popUpHeight:400};sociallyveGlobalConfig.youtube={popUpWidth:1E3,popUpHeight:400};sociallyveGlobalConfig.tonline={popUpWidth:700,popUpHeight:400};sociallyveGlobalConfig.google={popUpWidth:700,popUpHeight:400};sociallyveGlobalConfig.yahoo={popUpWidth:700,popUpHeight:400};
sociallyveGlobalConfig.linkedin={popUpWidth:700,popUpHeight:400};var soWindowHandle=null;
function Sociallyve(c){function d(a){return typeof soWindowHandle[a]=="undefined"?false:true}function e(){i=false;b.enableButtons();s({errorcode:"1401",errormessage:"User cancelled authentication"})}var b=this,t=sociallyveConfig.apiUrl,l="",u=false,i=false,j=null,m=0,n=0,g=sociallyveConfig.applicationId,o="",v=null,w=null,B=function(a){alert("missing callbackFunctionForLogin")},C=function(a){alert("missing callbackFunctionForImport")},s=function(a){},p="false",D=false,E=false,q="false",r="false",
x=false,k="",f="";if(typeof c=="string"&&c.length>15)g=c;this.setAppId=function(a){g=a};this.setUseRedirect=function(a){x=a};this.setCallbackUrl=function(a){o=a};this.setLoginFunction=function(a){v=a};this.setImportFunction=function(a){w=a};this.setCallbackFunctionForLogin=function(a){B=a};this.setCallbackFunctionForImport=function(a){C=a};this.setCallbackFunctionForError=function(a){s=a};this.setValidateImages=function(a){D=a};this.setValidateImagesForImport=function(a){E=a};this.setIgnoreDefaultScope=
function(a){q=a?"true":"false"};this.setForceImmediateUserinfo=function(a){r=a?"true":"false"};this.startLogin=function(a){this.startAuth("login",a)};this.startImport=function(a){this.startAuth("contacts",a)};this.connect=function(a){this.openAuthWindow(a,"login")};this.getcontacts=function(a){this.openAuthWindow(a,"contacts")};this.openAuthWindow=function(a,h){if(i){try{soWindowHandle.moveTo(n,m)}catch(y){}soWindowHandle.focus()}else{a=a.getAttribute("saId");this.startAuth(h,a)}};this.startAuth=
function(a,h){if(typeof sociallyveGlobalConfig[h]=="object"){i=true;this.disableButtons();this.prepareImageValidationParameter(a);this.openWindow(a,h);if(!x){window.clearTimeout(j);j=window.setTimeout(b.authWindowWatchDog,500)}}};this.openWindow=function(a,h){try{soWindowHandle!=null&&soWindowHandle.close()}catch(y){}k=a;f=h;n=window.screenX+(window.outerWidth-sociallyveGlobalConfig[f].popUpWidth)/2;m=window.screenY+(window.outerHeight-sociallyveGlobalConfig[f].popUpHeight)/2;if(x)window.location=
l+t+k+"/prepare/"+f+"?applicationid="+g+"&callback="+o+"&validate="+p+"&ignore_default_scope="+q+"&force_immediate_userinfo="+r;else{soWindowHandle=l!=""?window.open(l,"slauthwindow_"+k,"menubar=0,resizable=1,width="+sociallyveGlobalConfig[f].popUpWidth+",height="+sociallyveGlobalConfig[f].popUpHeight+",top="+m+",left="+n+""):window.open(t+k+"/prepare/"+f+"?applicationid="+g+"&callback="+o+"&validate="+p+"&ignore_default_scope="+q+"&force_immediate_userinfo="+r,"slauthwindow_"+k,"menubar=0,resizable=1,width="+
sociallyveGlobalConfig[f].popUpWidth+",height="+sociallyveGlobalConfig[f].popUpHeight+",top="+m+",left="+n+"");soWindowHandle.focus()}};this.auth=function(){return t+k+"/prepare/"+f+"?applicationid="+g+"&callback="+o+"&validate="+p+"&ignore_default_scope="+q+"&force_immediate_userinfo="+r};this.prepareImageValidationParameter=function(a){p=a=="login"&&D||a=="contacts"&&E?"true":"false"};this.authWindowWatchDog=function(){try{if(d("closed"))if(soWindowHandle.closed==false){j=window.setTimeout(b.authWindowWatchDog,
500);return}}catch(a){}e()};this.disableButtons=function(){$(".sociallyve_single_login_button").each(function(){$(this).addClass("sociallyve_single_login_button_disabled");$(this).addClass("sociallyve_single_login_button_"+this.getAttribute("said")+"_disabled")});$(".sociallyve_single_import_button").each(function(){$(this).addClass("sociallyve_single_import_button_disabled");$(this).addClass("sociallyve_single_import_button_"+this.getAttribute("said")+"_disabled")})};this.enableButtons=function(){$(".sociallyve_single_login_button").each(function(){$(this).removeClass("sociallyve_single_login_button_disabled");
$(this).removeClass("sociallyve_single_login_button_"+this.getAttribute("said")+"_disabled")});$(".sociallyve_single_import_button").each(function(){$(this).removeClass("sociallyve_single_import_button_disabled");$(this).removeClass("sociallyve_single_import_button_"+this.getAttribute("said")+"_disabled")})};this.finished=function(a){a=a.slice(a.indexOf("?")+1);if(a.indexOf("#")>0)a=a.slice(0,a.indexOf("#"));var h=a.split("&"),y=h.length;paramObj={};for(var z=0;z<y;z++){var F=h[z].split("=");paramObj[F[0]]=
Url.decode(F[1])}if(typeof paramObj.errorcode=="string"){window.clearTimeout(j);soWindowHandle.close();i=false;b.enableButtons();s({errorcode:paramObj.errorcode,errormessage:paramObj.errormessage})}else if(paramObj.sltoken)if(typeof w=="function"){w(a);soWindowHandle.close();window.clearTimeout(j);b.enableButtons();i=false}else $.ajax({type:"GET",url:sociallyveConfig.importUrl+"?"+a,data:"",dataType:"json",async:true,cache:false,contentType:"application/x-www-form-urlencoded",success:function(A){C(A.data);
window.clearTimeout(j);b.enableButtons();i=false;soWindowHandle.close()}});else if(typeof v=="function"){v(a);soWindowHandle.close();window.clearTimeout(j);b.enableButtons();i=false}else $.ajax({type:"GET",url:sociallyveConfig.loginUrl+"?"+a,data:"",dataType:"json",async:true,cache:false,contentType:"application/x-www-form-urlencoded",success:function(A){B(A);window.clearTimeout(j);b.enableButtons();i=false;soWindowHandle.close()}})};this.init=function(){if(u)return true;if(typeof g!="string"||g.length<
16){alert("applicatinId not set");return false}return b.internalInit()};this.internalInit=function(){if(u)return true;if(typeof g!="string"||g.length<16)return false;if(sociallyveConfig.pathToForwarder)l=sociallyveConfig.pathToForwarder+"#auth";this.bindButtons();u=true};this.bindButtonsClickHandler=function(){b.bindButtons()};this.rebindButtons=function(){this.unbindButtons();this.bindButtons()};this.bindButtons=function(){$(".sociallyve_single_login_button").each(function(){$(this).addClass("sociallyve_single_login_button_"+
this.getAttribute("said"));$(this).click(function(){b.connect(this);return false})});$(".sociallyve_single_import_button").each(function(){$(this).addClass("sociallyve_single_import_button_"+this.getAttribute("said"));$(this).click(function(){b.getcontacts(this);return false})})};this.unbindButtons=function(){$(".sociallyve_single_login_button").each(function(){$(this).unbind("click")});$(".sociallyve_single_import_button").each(function(){$(this).unbind("click")})};if(Sociallyve.instance!==undefined)return Sociallyve.instance;
else{this.internalInit();Sociallyve.instance=this}}
var Url={encode:function(c){return escape(this._utf8_encode(c))},decode:function(c){return this._utf8_decode(unescape(c))},_utf8_encode:function(c){c=c.replace(/\r\n/g,"\n");for(var d="",e=0;e<c.length;e++){var b=c.charCodeAt(e);if(b<128)d+=String.fromCharCode(b);else{if(b>127&&b<2048)d+=String.fromCharCode(b>>6|192);else{d+=String.fromCharCode(b>>12|224);d+=String.fromCharCode(b>>6&63|128)}d+=String.fromCharCode(b&63|128)}}return d},_utf8_decode:function(c){for(var d="",e=0,b=c1=c2=0;e<c.length;){b=
c.charCodeAt(e);if(b==43){d+=" ";e++}else if(b<128){d+=String.fromCharCode(b);e++}else if(b>191&&b<224){c2=c.charCodeAt(e+1);d+=String.fromCharCode((b&31)<<6|c2&63);e+=2}else{c2=c.charCodeAt(e+1);c3=c.charCodeAt(e+2);d+=String.fromCharCode((b&15)<<12|(c2&63)<<6|c3&63);e+=3}}return d}};function db(c){$("#debug").append(typeof c+"->");try{$("#debug").append(c.constructor+": -");$("#debug").append(c+"<br/>")}catch(d){$("#debug").append("???<br/>")}};

