;(function(){if(window.loadFirebugConsole){window.loadFirebugConsole();}
var latestVersion=2;var $=null;var readySteps={document:{ready:false,callbacks:[]},publisher:{ready:false,callbacks:[]},user:{ready:false,callbacks:[]},framework:{ready:false,callbacks:[]},setup:{ready:false,callbacks:[]},complete:{ready:false,callbacks:[]}};var isDocumentReady=false;var userAgent=navigator.userAgent.toLowerCase();var browser={version:(userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,'0'])[1],msie:/msie/.test(userAgent)&&!/opera/.test(userAgent)};var preloadedData={};var viximo={version:1,build:null,publisher:null,user:null,opensocial:false,theme:'default',locale:'en-US',targetFrame:{window:window,document:document,location:location,options:{}},domain:null,url:{protocol:location.protocol.slice(0,-1),host:location.hostname,port:location.port,stylesheet:function(path){return this.build('asset','stylesheets',path+(viximo.build?'_'+viximo.build:'')+'.css');},javascript:function(path){return this.build('asset','javascripts',path+(viximo.build?'_'+viximo.build:'')+'.js');},build:function(scope,type,path){var config=viximo.urls[scope];var protocol=config.protocol;var host=config.host;var port=config[protocol];var url=protocol+'://'+host;if((protocol=='http'&&port!=80)||(protocol=='https'&&port!=443)){url+=':'+port;}
if(type){url+='/'+type;if(viximo.urls.asset.host!=viximo.urls.api.host&&(!browser.msie||browser.version>=7)){parts=path.match(/^(.*)\.([a-z]+)$/);path=parts[1]+'.gz.'+parts[2];}}
return url+'/api/v'+viximo.version+'/'+path;}},location:window.top.location,frameLocation:window.location.href,notifications:{gifting:null,purchase:null},environment:'production',hasComplete:false,init:function(options){if(options.complete)
this.hasComplete=true;if(options.opensocial)
this.opensocial=true;if(options.window){options.window.viximo=viximo;this.targetFrame={window:options.window,document:options.window.document,location:options.window.location,options:{}};}
this.domain=options.domain;var disableSkip={quibblo:true};if(!isDocumentReady&&(options.trackingOnly||options.complete)&&!disableSkip[options.publisher]){this.ready(function(){viximo.init(options);},'document');return this;}
if(options.complete){this.ready(function(){if(isDocumentReady){options.complete();}else{$(options.complete);}},'complete');}
if(this.initialized){return this;}
if(options.locale){var locale=/^([a-z]{2})-([a-z]{2})$/i.exec(options.locale);if(!locale){throw new Error(this.locale+' is not a valid locale');}
this.locale=locale[1].toLowerCase()+'-'+locale[2].toUpperCase();}
if(options.theme){this.theme=options.theme;}
if(options.version){if(options.version=='latest'){this.version=latestVersion;}else{this.version=options.version;}}
this.publisher={name:options.publisher,website:options.website,urls:this.version<3&&options.urls||{}};this.user={id:options.user,session_key:options.session,cash_currency_balance:options.cash_balance||options.balance,reward_currency_balance:options.reward_balance,display_name:options.name,friends:options.friends,gender:options.gender,location:options.location,country:options.country,locale:this.locale,avatar:options.avatar,birthday:options.birthday,profile_url:options.profile_url};if(this.version>=3&&this.user.id&&!this.user.display_name){throw new Error('Required option(s) not specified: name');}
for(var property in this.user){if(this.user[property]==null){delete this.user[property];}}
if(options.notifications){this.notifications=options.notifications;}
if(options.settings){this.settings=options.settings;}
if(options.translations){this.translations=options.translations;}
this.initialized=true;if(options.trackingOnly){getScript('tracking');this.setup();}else{if(options.version<3){var stylesheets=['default'];if(this.theme!='default'){stylesheets.push(this.theme);}
for(var i=0;i<stylesheets.length;i++){getStylesheet(stylesheets[i]);}}
if(options.reportingOnly){getScript('reportui');}else{getScript('vixui');}
getScript(viximo.url.build('api',null,'publishers/'+encodeURIComponent(this.publisher.name)+'.json?callback=viximo.publisherLoaded'));if(this.user.id){getScript(viximo.url.build('api',null,'publishers/'+encodeURIComponent(this.publisher.name)+'/users/'+encodeURIComponent(this.user.id)+'.json?callback=viximo.userLoaded&session_key='+encodeURIComponent(this.user.session_key)));}}},registerJQuery:function(jQuery){this.jQuery=$=jQuery;},publisherLoaded:function(response){this.ready(function(){if(response&&response.headers&&response.headers.Status=='404 Not Found'){viximo.ui.disable();throw new Error(viximo.publisher.name+' is not a valid account');}
$.extend(preloadedData,response.body);if(this.user.id){this.ready(this.setup,'user');}else{this.setup();}},'framework');},userLoaded:function(response){this.ready(function(){$.extend(preloadedData,response.body);this.ready(null,'user');},'framework');},setup:function(){this.ready(function(){if(viximo.data){var data=$.extend({user:{}},preloadedData);var validLocale=$.i18n.translations[this.locale]!=null;this.publisher=new viximo.data.publisher($.extend(this.publisher,data.publisher));var initializedUser=this.user;var userAttributes=$.object.except(data.user,['demographics']);this.user=viximo.publisher.users.build($.extend(data.user&&data.user.demographics,userAttributes));this.user.update(initializedUser);if(this.publisher.temporary_reward_currency&&this.user.reward_currency_balance==0){this.publisher.reward_currency_enabled=false;}
$.i18n.log=validLocale;$.i18n.add(this.locale,{});$.i18n.setLocale(this.locale);if(this.translations){$.i18n.add(this.locale,this.translations);}
$.logger.context={publisher_id:this.publisher.name,user_id:this.user.id,build:this.build||'',locale:this.locale};if(this.publisher.site_theme_enabled&&this.version>=3){getStylesheet('publishers/'+this.publisher.name+'.site');}}
this.tracker.context=$.extend({environment:this.environment,publisherId:this.publisher.name,userId:this.user.id,user_name:this.user.display_name,gender:this.user.gender,country:this.user.country,age:this.user.age},this.tracker.context);var optionalContext=['user_name','gender','country','age'];for(var i=0;i<optionalContext.length;i++){var key=optionalContext[i];if(!this.tracker.context[key]){if(viximo.data){this.tracker.context[key]='';}else{delete this.tracker.context[key];}}}
this.tracker.log('Core_Component_init');this.setupReady=true;this.ready(null,'setup');this.ready(null,'complete');},'framework');},ready:function(callback,type){if(!type){type='setup'}
var step=readySteps[type];var callbacks=step.callbacks;if(!callback){if(!step.isReady){step.isReady=true;for(var i=0;i<callbacks.length;i++){callbacks[i].call(this);}}}else{if(step.isReady){callback.call(this);}else{callbacks.push(callback);}}}};function documentReady(){isDocumentReady=true;viximo.ready(null,'document');}
if(document.addEventListener){document.addEventListener('DOMContentLoaded',function(){document.removeEventListener('DOMContentLoaded',arguments.callee,false);documentReady();},false);}else if(document.attachEvent){document.attachEvent('onreadystatechange',function(){if(document.readyState==='complete'){document.detachEvent('onreadystatechange',arguments.callee);documentReady();}});if(document.documentElement.doScroll&&window===window.top)(function(){if(isDocumentReady){return;}
try{document.documentElement.doScroll('left');}catch(error){setTimeout(arguments.callee,0);return;}
documentReady();})();}
if(window.addEventListener){window.addEventListener('load',documentReady,false);}else if(window.attachEvent){window.attachEvent('onload',documentReady);}
function getScript(url){if(!url.match(/^http/)){url=viximo.url.javascript(url);}
if(isDocumentReady){var head=document.getElementsByTagName('head')[0];var script=document.createElement('script');script.src=url;head.appendChild(script);}else{document.write('<script src="'+url+'" type="text/javascript"><\/script>');}}
function getStylesheet(url){var thirdParty=url.match(/^http/);if(!thirdParty){url=viximo.url.stylesheet(url);}
var targetDocument=viximo.targetFrame.document;if(isDocumentReady||viximo.targetFrame.window!==window){var link=targetDocument.createElement('link');link.href=url;link.rel='stylesheet';link.media='screen';link.type='text/css';var head=targetDocument.getElementsByTagName('head')[0];if(head){head.appendChild(link);}else{throw'Head element is missing. Please verify the markup validity of the page.'}}else{targetDocument.write('<link href="'+url+'" rel="stylesheet" media="screen" type="text/css" />');}}
viximo.register=function(name,script){script($);if(name=='storefront'){viximo.ready(null,'framework');}};viximo.opensocialInit=function(containerId,host,publisherId,appId,options){var legacyMode=containerId.match(/^http/i);var protocol=location.protocol.slice(0,-1);if(window.location.href.match('VIXIMO_XD_PROXY')){getScript(protocol+'://'+host+'/javascripts/api/viximo.xd.js');return;}
var userIdEncoder=function(id){return id.toString().replace(/\./g,'::');};var demographics=[opensocial.Person.Field.CURRENT_LOCATION,opensocial.Person.Field.GENDER,opensocial.Person.Field.DATE_OF_BIRTH,opensocial.Person.Field.THUMBNAIL_URL,opensocial.Person.Field.PROFILE_URL];if(options.demographics){demographics=demographics.concat(options.demographics);}
var req=opensocial.newDataRequest();var viewerParams={};viewerParams[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=demographics;req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.VIEWER,viewerParams),'viewer');var friendsIdSpec=opensocial.newIdSpec({"userId":opensocial.IdSpec.PersonId.VIEWER,"groupId":opensocial.IdSpec.GroupId.FRIENDS});var friendParams={};friendParams[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS]=demographics;friendParams[opensocial.DataRequest.PeopleRequestFields.MAX]=2000;req.add(req.newFetchPeopleRequest(friendsIdSpec,friendParams),'friends');req.send(function(response){var osErrors=[]
if(response.hasError){osErrors.push(response.getErrorMessage());}
var getData=function(response,key,errorAccumulator){var keyResponse=response.get(key);if(keyResponse.hadError()){errorAccumulator.push(keyResponse.getErrorCode()+":"+keyResponse.getErrorMessage());return null;}
return keyResponse.getData();};var viewer=getData(response,'viewer',osErrors);var friends=getData(response,'friends',osErrors);var params={};params[gadgets.io.RequestParameters.CONTENT_TYPE]=gadgets.io.ContentType.JSON;params[gadgets.io.RequestParameters.AUTHORIZATION]=gadgets.io.AuthorizationType.SIGNED;params[gadgets.io.RequestParameters.METHOD]=gadgets.io.MethodType.POST;var sessionUrl=protocol+"://"+host+"/api/v3"+"/app/"+appId+"/publishers/"+publisherId+"/users/"+userIdEncoder(viewer.getId())+"/sessions.json";var initCallback=function(response){if(response.errors&&response.errors.length>0){osErrors=osErrors.concat(response.errors);}
if(osErrors.length>0){var errorUrl=viximo.client_exceptions_url;var url=errorUrl+(errorUrl.indexOf('?')>=0?'&':'?')+"message=OpensocialInit Error:"+osErrors.join('_');var image=new Image(1,1);image.onload=function(evt){image.onload=null;};image.src=url;viximo.init({publisher:publisherId,version:3,opensocial:true,complete:function(){viximo.ui.disabledapp("#"+containerId);}});}else{var formatGender=function(genderValue){var stringValue;if(genderValue.getKey){stringValue=genderValue.getKey().toLowerCase();}else if(typeof genderValue==='string'){stringValue=genderValue.toLowerCase();}
return(stringValue=='male'||stringValue=='female')?stringValue:null;};var getLocale=function(){var prefs=new gadgets.Prefs();var lang=prefs.getLang();var country=prefs.getCountry();return lang&&country?lang.toLowerCase()+"-"+country.toUpperCase():null;}
var removeNullProperties=function(obj){for(var prop in obj){if(obj[prop]==null){delete obj[prop];}}
return obj;}
var vixFriends=[];friends.each(function(person){var vixFriend={id:userIdEncoder(person.getId()),name:person.getDisplayName(),avatar:person.getField(opensocial.Person.Field.THUMBNAIL_URL),location:person.getField(opensocial.Person.Field.CURRENT_LOCATION),gender:formatGender(person.getField(opensocial.Person.Field.GENDER)),birthday:person.getField(opensocial.Person.Field.DATE_OF_BIRTH),profile_url:person.getField(opensocial.Person.Field.PROFILE_URL)}
if(vixFriend.name&&vixFriend.id){vixFriends.push(removeNullProperties(vixFriend));}
for(var prop in vixFriend){person[prop]=vixFriend[prop];}});var initParams=removeNullProperties({user:userIdEncoder(viewer.getId()),publisher:publisherId,name:viewer.getDisplayName(),gender:formatGender(viewer.getField(opensocial.Person.Field.GENDER)),birthday:viewer.getField(opensocial.Person.Field.DATE_OF_BIRTH),avatar:viewer.getField(opensocial.Person.Field.THUMBNAIL_URL),profile_url:viewer.getField(opensocial.Person.Field.PROFILE_URL),location:viewer.getField(opensocial.Person.Field.CURRENT_LOCATION),locale:getLocale(),friends:vixFriends,session:response.data.session.session_key,version:3,opensocial:true});for(var key in options){initParams[key]=options[key];}
initParams['complete']=function(){var complete=options['complete'];if(complete!=null){complete(viewer,friends);}
if(!legacyMode){var params=gadgets.views.getParams();params['selected']=appId;params['menus']=false;params['resized']=function(event,ui){gadgets.window.adjustHeight(ui.height);};viximo.ui.application("#"+containerId,params);}};viximo.init(initParams);}};gadgets.io.makeRequest(sessionUrl,initCallback,params);});};viximo.environment='production';viximo.build=13898;var protocol=document.location.protocol.slice(0,-1);viximo.urls={api:{protocol:protocol,host:'api.viximo.com',http:80,https:443},corporate:{protocol:'https',host:'viximo.com',http:80,https:443},photo_market:{protocol:'http',host:'snapmeup.viximo.com',http:'80'},asset:{protocol:protocol,host:protocol=='http'?'cdn.viximo.com':'s3.amazonaws.com/viximo-designer-portal-production',http:80,https:443}};viximo.client_exceptions_url='http://viximo.com/client_exceptions/ping';var deferredViximo=window.viximo;window.viximo=viximo;if(deferredViximo){isDocumentReady=deferredViximo.isDocumentReady;if(deferredViximo.options){viximo.init(deferredViximo.options);}}})();