var DemandConnect={campaign:{value:null,key:null,field:null,keyword:null,referrer:null,referrerDomain:null},campaigns:{},specialCampaigns:{direct:null,referral:null},keywordParams:new Array('q','p','query'),timestampFormat:'Y-m-d H:i:s O',campaignHistory:null,referringUrl:null,referringDomain:null,isReturnFromSubmit:false,__construct:function(){this.referringUrl=document.referrer;if(this.getQueryParam('referrer')){this.referringUrl=window.location.href.split('referrer=')[1];}
this.referringDomain=this.referringUrl.split('/')[2];if(this.getQueryParam('dcFormReturn')==1){this.isReturnFromSubmit=true;this.clearCampaigns();}},__emailOnChange:function(){var elqDt=new Date();var elqMs=elqDt.getMilliseconds();var elqPPS='50';var elqDLKey=escape('e368af281bb545578050f5da31362189');var elqDLLookup='<C_EmailAddress>'+DemandConnect.email.value+'</C_EmailAddress>';if((typeof elqCurE!='undefined')&&(typeof elqPPS!='undefined')){document.write('<SCR'+'IPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="'+elqCurE+'?pps='+elqPPS+'&siteid='+elqSiteID+'&DLKey='+elqDLKey+'&DLLookup='+elqDLLookup+'&ms='+elqMs+'"><\/SCR'+'IPT>');}},setEloquaDataLookup:function(id){},getCookie:function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}
return null;},setCookie:function(name,value,days){var expires;if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString();}else{expires="";}
document.cookie=name+"="+value+expires+"; path=/";},getDomain:function(url,isRegistered){if(!url){return'';}
var domain=url.split('\/')[2].split('?')[0];if(isRegistered){domain=domain.split('.').reverse();domain=domain[1]+'.'+domain[0];}else{domain=domain.replace(/^www\./,'');}
return domain;},getHost:function(url){return this.getDomain(url,true).split('.')[0].toLowerCase();},getQueryParam:function(key,url){if(!url){url=window.location.href;}
key=key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+key+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(url);return(!results?'':decodeURIComponent((results[1]).replace(/\+/g,'%20')));},getKeyword:function(){var keyword;var params=this.keywordParams;for(var i=0;i<params.length;i++){if(keyword=this.getQueryParam(params[i],this.referringUrl)){return keyword;}}
return'';},getTimestamp:function(format){return(new Date()).format(format);},hasCampaign:function(campaignId){var ch=this.campaignHistory;for(var i=0;i<ch.length;i++){if(ch[i].value==campaignId){return true;}}
return false;},clearCampaigns:function(){this.setCookie('CampaignHistory','');this.campaignHistory=new Array();},getCampaignHistory:function(){if(!this.campaignHistory){var ch=this.getCookie('CampaignHistory');try{this.campaignHistory=(ch?DCJSON.parse(ch):new Array());}catch(e){this.campaignHistory=new Array();}}
return this.campaignHistory;},addCampaign:function(campaign){if(!campaign||!campaign.value){return false;}
this.campaign=campaign;campaign.timestamp=this.getTimestamp(this.timestampFormat);campaign.referrer=this.referringUrl.replace(';','');campaign.referrerDomain=this.getDomain(this.referringUrl,true);if(this.campaignHistory.length>=4){this.campaignHistory[3]=campaign;}else{this.campaignHistory.push(campaign);}
this.setCookie('CampaignHistory',DCJSON.stringify(this.campaignHistory));},addCampaignsToForm:function(formId,emailId){var form=(typeof formId=='object'?formId:document.getElementById(formId));var c=this.campaignHistory;var obj;for(var i=0;i<c.length;i++){obj=document.createElement('INPUT');obj.name='demandconnect'+i+'_value';obj.type='hidden';obj.value=c[i].value;form.appendChild(obj);obj=document.createElement('INPUT');obj.name='demandconnect'+i+'_field';obj.type='hidden';obj.value=c[i].field;form.appendChild(obj);obj=document.createElement('INPUT');obj.name='demandconnect'+i+'_time';obj.type='hidden';obj.value=c[i].timestamp;form.appendChild(obj);obj=document.createElement('INPUT');obj.name='demandconnect'+i+'_keyword';obj.type='hidden';obj.value=(c[i].keyword?c[i].keyword:'');form.appendChild(obj);obj=document.createElement('INPUT');obj.name='demandconnect'+i+'_referrer';obj.type='hidden';obj.value=c[i].referrer;form.appendChild(obj);obj=document.createElement('INPUT');obj.name='demandconnect'+i+'_referrerdomain';obj.type='hidden';obj.value=c[i].referrerDomain;form.appendChild(obj);}
var email=document.getElementById(emailId);if(email&&(typeof window.GetElqContentPersonalizationValue=='function')){this.email=email;if(email.addEventListener){email.addEventListener('change',this.__emailOnChange,false);}else{email.attachEvent('onchange',this.__emailOnChange);}}},logCampaign:function(){if(this.isReturnFromSubmit){return;}
this.campaignHistory=this.getCampaignHistory();var c={value:null,key:null,field:null,keyword:null,referrer:null,referrerDomain:null};for(var key in this.campaigns){if(this.getQueryParam(key)){c.value=this.getQueryParam(key);c.key=key;c.field=this.campaigns[key];break;}}
if(!c.value){if(this.getDomain(window.location.href)!=this.getDomain(this.referringUrl)&&this.referringUrl!=undefined&&this.referringUrl.length>0){c.value=this.specialCampaigns.referral;c.field='referral';c.keyword=this.getKeyword();}}
if(!c.value){if(this.referringUrl==undefined||this.referringUrl.length<=0){c.value=this.specialCampaigns.direct;c.field='direct';}}
if(c.value&&!this.hasCampaign(c.value)&&this.referringDomain!='now.eloqua.com'&&this.referringDomain!='secure.eloqua.com'){this.addCampaign(c);}
var dcForm=document.getElementsByName('DemandConnect.Form');if(dcForm.length>0){for(var i=0;i<dcForm.length;i++){this.addCampaignsToForm(dcForm[i].parentNode);}}}};Date.prototype.format=function(format){var returnStr='';var replace=Date.replaceChars;for(var i=0;i<format.length;i++){var curChar=format.charAt(i);if(replace[curChar]){returnStr+=replace[curChar].call(this);}else{returnStr+=curChar;}}return returnStr;};Date.replaceChars={shortMonths:['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],longMonths:['January','February','March','April','May','June','July','August','September','October','November','December'],shortDays:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],longDays:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],d:function(){return(this.getDate()<10?'0':'')+this.getDate();},D:function(){return Date.replaceChars.shortDays[this.getDay()];},j:function(){return this.getDate();},l:function(){return Date.replaceChars.longDays[this.getDay()];},N:function(){return this.getDay()+1;},S:function(){return(this.getDate()%10==1&&this.getDate()!=11?'st':(this.getDate()%10==2&&this.getDate()!=12?'nd':(this.getDate()%10==3&&this.getDate()!=13?'rd':'th')));},w:function(){return this.getDay();},z:function(){return"Not Yet Supported";},W:function(){return"Not Yet Supported";},F:function(){return Date.replaceChars.longMonths[this.getMonth()];},m:function(){return(this.getMonth()<11?'0':'')+(this.getMonth()+1);},M:function(){return Date.replaceChars.shortMonths[this.getMonth()];},n:function(){return this.getMonth()+1;},t:function(){return"Not Yet Supported";},L:function(){return"Not Yet Supported";},o:function(){return"Not Supported";},Y:function(){return this.getFullYear();},y:function(){return(''+this.getFullYear()).substr(2);},a:function(){return this.getHours()<12?'am':'pm';},A:function(){return this.getHours()<12?'AM':'PM';},B:function(){return"Not Yet Supported";},g:function(){return this.getHours()%12||12;},G:function(){return this.getHours();},h:function(){return((this.getHours()%12||12)<10?'0':'')+(this.getHours()%12||12);},H:function(){return(this.getHours()<10?'0':'')+this.getHours();},i:function(){return(this.getMinutes()<10?'0':'')+this.getMinutes();},s:function(){return(this.getSeconds()<10?'0':'')+this.getSeconds();},e:function(){return"Not Yet Supported";},I:function(){return"Not Supported";},O:function(){return(this.getTimezoneOffset()<0?'-':'+')+(this.getTimezoneOffset()/60<10?'0':'')+(this.getTimezoneOffset()/60)+'00';},T:function(){return"Not Yet Supported";},Z:function(){return this.getTimezoneOffset()*60;},c:function(){return"Not Yet Supported";},r:function(){return this.toString();},U:function(){return this.getTime()/1000;}};if(!this.DCJSON){this.DCJSON={};}
(function(){function f(n){return n<10?'0'+n:n;}
if(typeof Date.prototype.toDCJSON!=='function'){Date.prototype.toDCJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toDCJSON=Number.prototype.toDCJSON=Boolean.prototype.toDCJSON=function(key){return this.valueOf();};}
var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toDCJSON==='function'){value=value.toDCJSON(key);}
if(typeof rep==='function'){value=rep.call(holder,key,value);}
switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
if(typeof DCJSON.stringify!=='function'){DCJSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('DCJSON.stringify');}
return str('',{'':value});};}
if(typeof DCJSON.parse!=='function'){DCJSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
return reviver.call(holder,key,value);}
text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
throw new SyntaxError('DCJSON.parse');};}}());DemandConnect.__construct();DemandConnect.specialCampaigns={direct:'701A00000002PmSIAU',referral:'701A00000002PmXIAU'};DemandConnect.campaigns={hcmacid:'ExternalId__c'};DemandConnect.logCampaign();
