var VDNA_urls={live:"http://my.visualdna.com",staging:"http://my.staging.youniverse.com",deploytest:"http://my.deploytest.youniverse.com",vm:"http://www.my.vm.visualdna.com"};var VDNA_url=VDNA_urls.live;var VDNA_cookieName="vdnaUserId";var VDNA_permCookieName="vdnaUserPermission";var xmlhttp;var VDNA_userPermission;var VDNA_lastUserResponse;var VDNA_userProfile;var VDNA_userFeedback;var VDNA_userID;function VDNA_GetUserID(){if(VDNA_clientHasPermission()){if(VDNA_LocalCookieExists(VDNA_cookieName)){VDNA_userID=VDNA_GetInfoFromCookie(VDNA_cookieName);return VDNA_userID}else{if(VDNA_RequestPeriodOver()){VDNA_GetUserIDRemote()}else{return 0}}}}function VDNA_clientHasPermission(){return true}function VDNA_getCookieDomain(){var b=document.domain;var a=b.split(".");b="."+a[a.length-2]+"."+a[a.length-1];return b}function VDNA_LocalCookieExists(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");if(c_start!=-1){return true}}return false}function VDNA_GetInfoFromCookie(a){if(document.cookie.length>0){c_start=document.cookie.indexOf(a+"=");if(c_start!=-1){c_start=c_start+a.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_start,c_end))}}return false}function VDNA_SetUpInfoCookie(b,f){var e=1000*60*60*24*356;if(b=="vdnaTimestamp"){f=Math.round(new Date().getTime()/1000)}if(b==VDNA_cookieName){if(f==0){return false}e=1000*60*60*24}var c=VDNA_getCookieDomain();var a=new Date();a.setTime(a.getTime());var d=new Date(a.getTime()+e);document.cookie=b+"="+escape(f)+";expires="+d.toGMTString()+";path=/;domain="+c}function VDNA_DeleteLocalCookie(a){var c=VDNA_getCookieDomain();var b="Thu, 01-Jan-1970 00:00:01 GMT";document.cookie=a+"=0;expires="+b+";path=/;domain="+c}function VDNA_RequestPeriodOver(){var b=VDNA_GetInfoFromCookie("vdnaTimestamp");if(!b){return true}var a=Math.round(new Date().getTime()/1000);if(a-b>60*60*24){return true}return false}function VDNA_GetUserIDRemote(){if(VDNA_userID===false||VDNA_userID==undefined||VDNA_userID=="false"){var a=document.getElementsByTagName("head")[0];var b=document.createElement("script");b.type="text/javascript";b.src=VDNA_url+"/api/getremotecookie";a.appendChild(b);setTimeout("VDNA_GetUserIDRemote()",300)}else{if(typeof(c)=="undefined"){var c={userID:"0"}}else{c.userID=VDNA_userID}VDNA_SetUpInfoCookie("vdnaTimestamp","");VDNA_SetUpInfoCookie(VDNA_cookieName,VDNA_userID);VDNA_SetUpInfoCookie(VDNA_permCookieName,VDNA_userPermission)}}function VDNA_GetLastResponse(d,e){if(e==null){e="VDNA_processLastUserResponse"}var c=VDNA_url+"/api/getlastresponse?user_id="+VDNA_config.userID+"&module_id="+d+"&api_key="+VDNA_config.apiKey+"&key_salt="+VDNA_config.salt+"&callback="+e;var a=document.getElementsByTagName("head")[0];var b=document.createElement("script");b.type="text/javascript";b.src=c;a.appendChild(b)}function VDNA_GetUserProfile(d){if(d==null){d="VDNA_processUserProfile"}var c=VDNA_url+"/api/getuserprofile?user_id="+VDNA_config.userID+"&api_key="+VDNA_config.apiKey+"&key_salt="+VDNA_config.salt+"&callback="+d;var a=document.getElementsByTagName("head")[0];var b=document.createElement("script");b.type="text/javascript";b.src=c;a.appendChild(b)}function VDNA_GetUserFeedback(b,e,f){if(f==null){f="VDNA_processUserFeedback"}var d=VDNA_url+"/api/getuserfeedback?response_id="+b+"&api_key="+VDNA_config.apiKey+"&key_salt="+VDNA_config.salt+"&schema_id="+e+"&callback="+f;var a=document.getElementsByTagName("head")[0];var c=document.createElement("script");c.type="text/javascript";c.src=d;a.appendChild(c)}function VDNA_FlashGetUserID(b){VDNA_SetUpInfoCookie(VDNA_cookieName,b);VDNA_config.userID=b;VDNA_userID=b;var d=VDNA_url+"/api/setremotecookie?user_id="+b;var a=document.getElementsByTagName("head")[0];var c=document.createElement("script");c.type="text/javascript";c.src=d;a.appendChild(c)}function VDNA_FlashSetVDNA(a){if(a=="false"){var c="Saving your VisualDNA is recommended, as it allows you to have a more personalised experience on this site. We respect your privacy, and your VisualDNA is under your total control at all times - simply go to my.visualdna.com to manage your VisualDNA.\n\n Are you sure you want to change this setting?";var b=confirm(c);if(b){VDNA_FlashGetUserPerm("false");VDNA_DeleteCookie();return"false"}return"true"}else{if(a=="true"){VDNA_FlashGetUserPerm("true");return"true"}}}function VDNA_DeleteCookie(){VDNA_DeleteLocalCookie(VDNA_cookieName);var a=document.getElementsByTagName("head")[0];var b=document.createElement("script");b.type="text/javascript";b.src=VDNA_url+"/api/deletecookie?api_key="+VDNA_config.apiKey+"&key_salt="+VDNA_config.salt;a.appendChild(b)}function VDNA_FlashSendUserID(){VDNA_userID=VDNA_GetInfoFromCookie(VDNA_cookieName);return VDNA_userID}function VDNA_FlashGetUserPerm(b){VDNA_SetUpInfoCookie(VDNA_permCookieName,b);var a=document.getElementsByTagName("head")[0];var c=document.createElement("script");c.type="text/javascript";c.src=VDNA_url+"/api/setremotecookie?permission="+b;a.appendChild(c)}function VDNA_FlashSendUserPerm(){VDNA_userPerm=VDNA_GetInfoFromCookie(VDNA_permCookieName);return VDNA_userPerm};