
var VDNA_urls={live:"http://gateway-lite.visualdna.com/vdna_api.php",staging:"http://gateway-lite.staging.youniverse.com/vdna_api.php",deploytest:"http://gatewaylite.deploytest.dmz.youniverse.com/rest.php",vm:"http://lightgateway.vm.youniverse.com/vdna_api.php"}
var VDNA_url=VDNA_urls.live;var VDNA_enableVDNABank=true;var VDNA_cookieName="vdnaUserId";var VDNA_permCookieName="vdnaUserPermission";var VDNA_userAskedCookieName="vdnaUserAskedAboutPermission";var xmlhttp;var VDNA_userPermission;var VDNA_lastUserResponse;var VDNA_userProfile;var VDNA_userFeedback;var VDNA_userID;var VDNA_safariNewUser=false;var VDNA_safariUpdateCookie=false;var VDNA_setComplete;var VDNA_error='';var VDNA_answer='';var VDNA_functionNameCalled=new Array();function VDNA_GetUserID()
{if(VDNA_LocalCookieExists(VDNA_cookieName))
{VDNA_userID=VDNA_GetInfoFromCookie(VDNA_cookieName);return VDNA_userID;}
else
{if(VDNA_enableRemoteCookies)
{if(VDNA_RequestPeriodOver())
{VDNA_GetUserIDRemote();}
else
{return 0;}}
else
{if(!VDNA_LocalCookieExists(VDNA_permCookieName))
{VDNA_SetUpInfoCookie(VDNA_permCookieName,'true');}}}}
function VDNA_getClientPermission()
{if(VDNA_functionNameCalled.length>0&&!VDNA_LocalCookieExists(VDNA_userAskedCookieName)&&VDNA_enableVDNABank==true)
return false;if(!VDNA_LocalCookieExists(VDNA_userAskedCookieName)&&VDNA_enableVDNABank==true&&VDNA_LocalCookieExists(VDNA_cookieName))
{callback='VDNA_processGetClientPermission';var url=VDNA_url+'?method=api.soa.us.getClientPermission&param1='+VDNA_config.userID+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback='+callback+'&format=json&v=1';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);return false;}
return true;}
function VDNA_processGetClientPermission(jsonObj)
{if(jsonObj['@attributes'].stat=='ok')
{if(jsonObj.userPermission['@attributes'].permission=='0')
{VDNA_show_modal();}
else
{if(jsonObj.userPermission['@attributes'].permission=='1')
{VDNA_SetUpInfoCookie(VDNA_userAskedCookieName,'true');if(VDNA_functionNameCalled.length>0)
{for(var i=0;i<VDNA_functionNameCalled.length;i++)
eval(VDNA_functionNameCalled[i]);VDNA_functionNameCalled=new Array();}}}}
else
{if(jsonObj['@attributes'].stat=='fail')
alert(jsonObj.err['@attributes'].msg);}}
function VDNA_processUserResponse()
{if(VDNA_answer!='')
{switch(VDNA_answer)
{case'true':VDNA_SetUpInfoCookie(VDNA_userAskedCookieName,'true');VDNA_setClientPermission(1);break;case'false':VDNA_SetUpInfoCookie(VDNA_userAskedCookieName,'false');break;default:VDNA_SetUpInfoCookie(VDNA_userAskedCookieName,'24h');break;}}
if(VDNA_functionNameCalled.length>0)
{for(var i=0;i<VDNA_functionNameCalled.length;i++)
{eval(VDNA_functionNameCalled[i]);}
VDNA_functionNameCalled=new Array();}}
function VDNA_setClientPermission(val)
{callback='VDNA_processSetClientPermission';var url=VDNA_url+'?method=api.soa.us.setClientPermission&param1='+VDNA_config.userID+'&param2='+val+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&format=json&v=1'+'&callback='+callback;var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);}
function VDNA_processSetClientPermission(jsonObj)
{if(jsonObj['@attributes'].stat=='fail')
alert(jsonObj.err['@attributes'].msg);}
function VDNA_getCookieDomain()
{var thisDomain=document.domain;var domainArr=thisDomain.split(".");thisDomain='.'+domainArr[domainArr.length-2]+"."+domainArr[domainArr.length-1];return thisDomain;}
function VDNA_LocalCookieExists(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{return true;}}
return false;}
function VDNA_GetInfoFromCookie(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{c_start=c_start+c_name.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(name,infoStr)
{var availability=1000*60*60*24*356*10;if(name=='vdnaTimestamp')
{infoStr=Math.round(new Date().getTime()/1000);}
if(name==VDNA_cookieName||infoStr=='24h')
{if(infoStr==0)
return false;availability=1000*60*60*24;}
var thisDomain=VDNA_getCookieDomain();var today=new Date();today.setTime(today.getTime());var expires_date=new Date(today.getTime()+availability);document.cookie=name+"="+escape(infoStr)+";expires="+expires_date.toGMTString()+";path=/"+";domain="+thisDomain;}
function VDNA_DeleteLocalCookie(name)
{var thisDomain=VDNA_getCookieDomain();var deleteTime='Thu, 01-Jan-1970 00:00:01 GMT';document.cookie=name+"=0"+";expires="+deleteTime+";path=/"+";domain="+thisDomain;}
function VDNA_RequestPeriodOver()
{var cookieTimestamp=VDNA_GetInfoFromCookie('vdnaTimestamp');if(!cookieTimestamp)
{return true;}
var timestamp=Math.round(new Date().getTime()/1000);if(timestamp-cookieTimestamp>60*60*24)
{return true;}
return false;}
function VDNA_GetUserIDRemote()
{if((VDNA_userID===false||VDNA_userID==undefined||VDNA_userID=='false')&&VDNA_error=='')
{var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=VDNA_url+'?format=json&method=api.vdna.getRemoteCookie&v=1&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback=VDNA_GetUserIDRemoteValue';headID.appendChild(newScript);setTimeout('VDNA_GetUserIDRemote()',300);}
else
{if(VDNA_error!='')
{alert(VDNA_error);VDNA_error='';}
else
{VDNA_SetUpInfoCookie('vdnaTimestamp','');VDNA_SetUpInfoCookie(VDNA_cookieName,VDNA_userID);VDNA_SetUpInfoCookie(VDNA_permCookieName,VDNA_userPermission);}}}
function VDNA_RefreshCookieValues()
{var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=VDNA_url+'?format=json&method=api.vdna.getRemoteCookie&v=1&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback=VDNA_GetUserIDRemoteValue';headID.appendChild(newScript);}
function VDNA_GetUserIDRemoteValue(jsonObj)
{if(jsonObj['@attributes'].stat=='fail')
{VDNA_error=jsonObj.err['@attributes'].msg;alert(VDNA_error);}
else
{VDNA_userID=jsonObj.data.vdnaUserId['@value'];VDNA_config.userID=VDNA_userID;VDNA_userPermission=jsonObj.data.vdnaUserPerm['@value'];VDNA_SetUpInfoCookie('vdnaTimestamp','');VDNA_SetUpInfoCookie(VDNA_permCookieName,VDNA_userPermission);if(VDNA_userID==0)
VDNA_DeleteLocalCookie(VDNA_cookieName);else
VDNA_SetUpInfoCookie(VDNA_cookieName,VDNA_userID);}}
function VDNA_GetLastResponse(moduleID,callback)
{if(!VDNA_getClientPermission())
{var thisFunction='VDNA_GetLastResponse('+moduleID+', "'+callback+'")';VDNA_functionNameCalled[VDNA_functionNameCalled.length]=thisFunction;return false;}
if(callback==null)
callback='VDNA_processLastUserResponse';var url=VDNA_url+'?method=api.soa.us.getLastUserResponse&param1='+VDNA_config.userID+'&param2='+moduleID+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback='+callback+'&format=json&v=1';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);}
function VDNA_GetUserResponse(responseID,callback)
{if(!VDNA_getClientPermission())
{var thisFunction='VDNA_GetUserResponse('+responseID+', "'+callback+'")';VDNA_functionNameCalled[VDNA_functionNameCalled.length]=thisFunction;return false;}
if(callback==null)
callback='VDNA_processResponse';var url=VDNA_url+'?method=api.soa.us.getUserFullResponse&param1='+VDNA_config.userID+'&param2='+responseID+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback='+callback+'&format=json&v=1';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);}
function VDNA_GetSharedResponse(responseID,callback)
{if(!VDNA_getClientPermission())
{var thisFunction='VDNA_GetSharedResponse('+responseID+', "'+callback+'")';VDNA_functionNameCalled[VDNA_functionNameCalled.length]=thisFunction;return false;}
if(callback==null)
callback='VDNA_processSharedResponse';var url=VDNA_url+'?method=api.soa.us.getFullResponse&param1='+responseID+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback='+callback+'&format=json&v=1';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);}
function VDNA_GetUserProfile(callback)
{if(!VDNA_getClientPermission())
{var thisFunction='VDNA_GetUserProfile("'+callback+'")';VDNA_functionNameCalled[VDNA_functionNameCalled.length]=thisFunction;return false;}
if(callback==null)
callback='VDNA_processUserProfile';var url=VDNA_url+'?method=api.soa.us.getUserProfile&param1='+VDNA_config.userID+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback='+callback+'&format=json&v=1';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);}
function VDNA_GetUserFeedback(responseID,schema_id,callback)
{if(!VDNA_getClientPermission())
{var thisFunction='VDNA_GetUserFeedback('+responseID+', '+schema_id+', "'+callback+'")';VDNA_functionNameCalled[VDNA_functionNameCalled.length]=thisFunction;return false;}
if(callback==null)
callback='VDNA_processUserFeedback';var url=VDNA_url+'?method=api.soa.us.getUserFeedback&param1='+responseID+'&param2='+escape('<applicationData></applicationData>')+'&param3='+schema_id+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback='+callback+'&format=json&v=1';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=url;headID.appendChild(newScript);}
function VDNA_FlashGetUserID(user_id)
{VDNA_SetUpInfoCookie(VDNA_cookieName,user_id);VDNA_config.userID=user_id
VDNA_userID=user_id;if(/Safari/.test(navigator.userAgent))
VDNA_safariNewUser=true;var scriptUrl=VDNA_url+'?format=json&method=api.vdna.setRemoteCookie&v=1&param1='+user_id+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback=VDNA_SetCompleteRemoteValue';var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=scriptUrl;headID.appendChild(newScript);}
function VDNA_Redirect(resultsPage,target)
{var thisUrl=window.location.href;urlArray=thisUrl.split("/");if(urlArray[urlArray.length-1].indexOf(".")==-1)
{if(thisUrl.charAt(thisUrl.length-1)=="/"&&resultsPage.charAt(0)=="/")
resultsPage=thisUrl+resultsPage.substr(1,resultsPage.length);else
resultsPage=thisUrl+resultsPage;}
else
{urlArray.splice(urlArray.length-1,1);thisUrl=urlArray.join("/");resultsPage=thisUrl+"/"+resultsPage;}
VDNA_userPerm=VDNA_GetInfoFromCookie(VDNA_permCookieName);if((VDNA_safariNewUser==true&&VDNA_safariUpdateCookie==false))
{var scriptUrl=VDNA_url+'?format=json&method=api.vdna.setRemoteCookie&v=1&param1='+VDNA_userID+'&param2=&param3='+escape(resultsPage)+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash;window.location=scriptUrl;return false;}
if(VDNA_safariUpdateCookie==true)
{if(VDNA_userPerm=='true')
{var scriptUrl=VDNA_url+'?format=json&method=api.vdna.setRemoteCookie&v=1&param1=&param2=%22'+VDNA_userPerm+'%22&param3='+escape(resultsPage)+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash;window.location=scriptUrl;}
if(VDNA_userPerm=='false')
{var scriptUrl=VDNA_url+'?format=json&method=api.vdna.deleteRemoteCookie&v=1&param1='+escape(resultsPage)+'&api_key='+VDNA_apiKey+'&sig='+VDNA_hash;window.location=scriptUrl;}
return false;}
window.location=resultsPage;}
function VDNA_SetCompleteRemoteValue(jsonObj)
{if(jsonObj['@attributes'].stat=='fail'&&jsonObj.err['@attributes'].msg!='No vdnaUserId cookie set')
{alert(jsonObj.err['@attributes'].msg);}
else
{VDNA_setComplete=true;}}
function VDNA_FlashSetVDNA(bool)
{if(/Safari/.test(navigator.userAgent))
VDNA_safariUpdateCookie=true;if(bool=='false')
{var confText='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 conf=confirm(confText);if(conf)
{VDNA_SetUpInfoCookie(VDNA_permCookieName,'false');VDNA_DeleteCookie();return'false';}
return'true';}
else
{if(bool=='true')
{VDNA_FlashGetUserPerm('true');return'true';}}}
function VDNA_DeleteCookie()
{VDNA_DeleteLocalCookie(VDNA_cookieName);VDNA_DeleteLocalCookie('vdnaTimestamp');VDNA_DeleteLocalCookie(VDNA_userAskedCookieName);if(!/Safari/.test(navigator.userAgent))
{var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=VDNA_url+'?format=json&method=api.vdna.deleteRemoteCookie&v=1&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback=VDNA_SetCompleteRemoteValue';headID.appendChild(newScript);}}
function VDNA_FlashSendUserID()
{VDNA_userID=VDNA_GetInfoFromCookie(VDNA_cookieName);return VDNA_userID;}
function VDNA_FlashGetUserPerm(bool)
{VDNA_SetUpInfoCookie(VDNA_permCookieName,bool);var headID=document.getElementsByTagName("head")[0];var newScript=document.createElement('script');newScript.type='text/javascript';newScript.src=VDNA_url+'?format=json&method=api.vdna.setRemoteCookie&v=1&param1=&param2=%22'+bool+'%22&api_key='+VDNA_apiKey+'&sig='+VDNA_hash+'&callback=VDNA_SetCompleteRemoteValue';headID.appendChild(newScript);}
function VDNA_FlashSendUserPerm()
{VDNA_userPerm=VDNA_GetInfoFromCookie(VDNA_permCookieName);return VDNA_userPerm;}
function VDNA_modalClose(){x=document.getElementById('permModal');x.parentNode.removeChild(x);x=document.getElementById('modalDataContainer');x.parentNode.removeChild(x);document.body.style.overflow='auto';}
function VDNA_modalClose(){x=document.getElementById('permModal');x.parentNode.removeChild(x);x=document.getElementById('modalDataContainer');x.parentNode.removeChild(x);document.body.style.overflow='auto';}
function VDNA_show_modal()
{var left=(VDNA_getWindowWidth()-400)/2+"px",domain=VDNA_getCookieDomain(),timestamp=Math.round(new Date().getTime()/1000);VDNA_answer='true';var modalContainerOuter=document.createElement('div');modalContainerOuter.setAttribute('id','modalDataContainer');modalContainerOuter.style.fontFamily='font-family: Arial, "Helvetica Neue", Helvetica, sans-serif';modalContainerOuter.style.fontSize='15px';modalContainerOuter.style.lineHeight='18px';modalContainerOuter.style.textAlign='left';modalContainerOuter.style.color='#999999';modalContainerOuter.style.backgroundColor='#eeeeee';modalContainerOuter.style.position='absolute';modalContainerOuter.style.margin='0';modalContainerOuter.style.padding='0';modalContainerOuter.style.fontWeight='normal';modalContainerOuter.style.fontStyle='normal';modalContainerOuter.style.textTransform='none';modalContainerOuter.style.left=left;modalContainerOuter.style.top='90px';modalContainerOuter.style.zIndex=1001;modalContainerOuter.style.width='406px';var modalContainer=document.createElement('div');modalContainer.style.zIndex=1001;modalContainer.style.borderColor='#a9a9a9';modalContainer.style.borderWidth='6px';modalContainer.style.borderStyle='solid';var modalContainerInner=document.createElement('div');modalContainerInner.style.padding='25px 18px 13px 18px';modalContainerInner.style.zIndex=1001;modalContainerInner.innerHTML='<p style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 15px; line-height: 18px; text-align: left; color: #999; margin: 2px 0 17px 0; padding: 0 40px; font-weight: normal; font-style: normal; text-transform: none;"><a href="http://my.visualdna.com" target="_blank" title="visualdna.com" style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 15px; line-height: 18px; color: #000000; font-weight: bold; text-decoration: none;">'+domain.substr(1,domain.length)+'</a> wants permission to access your VisualDNA and give you a more personalized experience.</p>'+'<ul style="list-style: none; list-style-image: none; margin: 0; padding: 0 40px;">'+'<li style="list-style: none; list-style-image: none; margin: 0 0 6px 0; padding: 0;"><input onclick="VDNA_answer = this.value;" type="radio" name="permission" checked="checked" value="true" id="vdnaPermAllow" /> <label for="vdnaPermAllow" style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 15px; line-height: 18px; text-align: left; color: #000; margin: 0; padding: 0; font-weight: bold; font-style: normal; text-transform: none;">Allow</label></li>'+'<li style="list-style: none; list-style-image: none; margin: 0 0 6px 0; padding: 0;"><input onclick="VDNA_answer = this.value;" type="radio" name="permission" value="'+timestamp+'" id="vdnaPermDontAllow" /> <label for="vdnaPermDontAllow" style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 15px; line-height: 18px; text-align: left; color: #999; margin: 0; padding: 0; font-weight: normal; font-style: normal; text-transform: none;">Don\'t Allow</label></li>'+'<li style="list-style: none; list-style-image: none; margin: 0 0 18px 0; padding: 0;"><input onclick="VDNA_answer = this.value;" type="radio" name="permission" value="false" id="vdnaPermNeverAllow" /> <label for="vdnaPermNeverAllow" style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 15px; line-height: 18px; text-align: left; color: #999; margin: 0; padding: 0; font-weight: normal; font-style: normal; text-transform: none;">Never Allow</label></li>'+'</ul>'+'<input type="hidden" value="true" id="answer" name="answer" />'+'<input type="image" alt="Continue" title="Continue" src="http://media.youniverse.com/vdnaPermissionsI.gif" style="padding-left: 40px;" onclick="VDNA_processUserResponse(); VDNA_modalClose();" />'+'<p style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 12px; line-height: 18px; text-align: left; color: #999; margin: 20px 0 0 0; padding: 0; font-weight: normal; font-style: normal; text-transform: none;">See your VisualDNA and set preferences on <a href="http://my.visualdna.com" target="_blank" title="my.visualdna.com" style="font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif; font-size: 12px; line-height: 18px; color: #0568ff; font-weight: normal; text-decoration: none;">my.visualdna.com</a></p>'+'<div style="text-align: right; margin: 8px 0 0 0;"><a href="http://www.visualdna.com" target="_blank" title="Visit visualdna.com"><img src="http://media.youniverse.com/vdnaPermissionsII.gif" alt="VisualDNA" style="border: 0;" /></a></div>'
var permModal=document.createElement('div');permModal.id="permModal";permModal.style.filter='progid:DXImageTransform.Microsoft.Alpha(Opacity=20)';permModal.style.backgroundColor='#333';permModal.style.position='absolute';permModal.style.top='0';permModal.style.left='0';permModal.style.height='100%';permModal.style.width='100%';permModal.style.opacity='.2';permModal.style.zIndex='1000';document.body.style.overflow='hidden';document.body.appendChild(permModal);modalContainer.appendChild(modalContainerInner);modalContainerOuter.appendChild(modalContainer);document.body.appendChild(modalContainerOuter);permModal.onclick=VDNA_modalClose;}
function VDNA_getWindowWidth()
{var x=0;if(self.innerHeight)
x=self.innerWidth;else if(document.documentElement&&document.documentElement.clientHeight)
x=document.documentElement.clientWidth;else if(document.body)
x=document.body.clientWidth;return x;}
