var _bright=new Object({C_NAME:"BE_CLA",BE_URL:"cdn.brightedge.com/brightedge.php",MAX_URL_LENGTH:2000,TIMEOUT:6*31*24*60*60*1000,S_TIMEOUT:30*60*1000,_initialize:function(a){_bright.id=a;_bright.domain="";_bright.path="";_bright.goal="";_bright.goalvalue="";_bright.pagetype="";_bright.linkerEnabled=false;return _bright},_setDomain:function(a){_bright.domain=a},_setDomainPath:function(a){_bright.path=a},_copyDomainPath:function(b){var a=this.getCookie(_bright.C_NAME);if(a.length>0){this.setCookie(_bright.C_NAME,a,_bright.TIMEOUT,_bright.domain,b)}},_setGoal:function(b,a){_bright.goal=b;_bright.goalvalue=a},_setPageType:function(a){_bright.pagetype=a},_enableCrossDomainTracking:function(a){_bright.linkerEnabled=a},_trackCrossDomain:function(a){if(!a||a==""){return}if(_bright.linkerEnabled){document.location.href=this.linkerUrl(a)}else{document.location.href=a}},_trackCrossDomain_ByPost:function(a){if(!a||!a.action||a.action==""){return}if(_bright.linkerEnabled){a.action=this.linkerUrl(a.action)}else{a.action=a.action}return},_trackBright:function(){var e=(("https:"==document.location.protocol)?"https://":"http://");var l=e+_bright.BE_URL;var m=location.href;if(window.location&&window.location.href){m=window.location.href}var g=document.referrer;if(window.document&&window.document.referrer){g=window.document.referrer}var B=document.title;var k=this.getmetaContents("description");var c=this.getmetaContents("keywords");var o={};o.id=_bright.id;o.url=m;o.ref=g;o.cg=_bright.goal;o.cgv=_bright.goalvalue;o.cptv=_bright.pagetype;o.title=B;o.metadesc=k;o.metakeywords=c;var q=true;var n=this.getCookie(_bright.C_NAME);if(_bright.path!=""){var d=m.substring(m.indexOf(document.domain)+document.domain.length);if(this.getBrowserName()=="Firefox"){d+="/"}var z=d.indexOf(_bright.path);if(z==-1&&n.length<=0){q=false}}if(_bright.domain!=""&&document.domain.indexOf(_bright.domain)==-1){q=false}if(q){var p=false;if(_bright.linkerEnabled){if(m&&m!=""&&m.indexOf("p_id=")>-1){n=m;p=true}}var w=this.parseCookie(n,"p_id=","&");var u=this.parseCookie(n,"p_last_ref=","&");var b=this.parseCookie(n,"p_first_ref=","&");var t=this.parseCookie(n,"p_first_entry=","&");var h=this.parseCookie(n,"s_id=","&");var s=this.parseCookie(n,"s_entry=","&");var r=this.parseCookie(n,"s_expire=","&");var a=new Date();if(!p){if(n.length>0){if(r<=a.getTime()){h=this.generateUniqID(_bright.id);s=m;u=g}}else{w=this.generateUniqID(_bright.id);b=g;t=m;u=g;h=this.generateUniqID(_bright.id);s=m}}var v=new Date(a.getTime()+_bright.S_TIMEOUT);r=v.getTime();var j="p_id="+escape(w)+"&p_last_ref="+escape(u)+"&s_entry="+escape(s)+"&p_first_ref="+escape(b)+"&p_first_entry="+escape(t)+"&s_expire="+escape(r)+"&s_id="+escape(h);this.setCookie(_bright.C_NAME,j,_bright.TIMEOUT,_bright.domain,_bright.path)}var x=false;n=this.getCookie(_bright.C_NAME);if(n.length>0){x=true}if(x){o.p_id=this.parseCookie(n,"p_id=","&");o.s_id=this.parseCookie(n,"s_id=","&");o.p_last_ref=this.parseCookie(n,"p_last_ref=","&");o.s_entry=this.parseCookie(n,"s_entry=","&");o.p_first_ref=this.parseCookie(n,"p_first_ref=","&");o.p_first_entry=this.parseCookie(n,"p_first_entry=","&")}if(x){var y=new Array("id","p_id","url","ref","cg","cgv","cptv","p_last_ref","s_entry","p_first_ref","p_first_entry","title","metadesc","metakeywords","s_id")}else{var y=new Array("id","url","ref","cg","cgv","cptv","title","metadesc","metakeywords")}var f=this.createURL(l,o,y);if(f.length>_bright.MAX_URL_LENGTH){f=this.truncURL(l,o,y)}var A=new Image(1,1);A.src=f;A.onload=function(){}},parseCookie:function(g,a,e){if(!g||g==""||!a||a==""||!e||e==""){return""}var d,f,b,h="";d=g.indexOf(a);b=a.indexOf("=")+1;if(d>-1){f=g.indexOf(e,d);if(f<0){f=g.length}h=g.substring((d+b),f)}return unescape(h)},linkerUrl:function(e){var c=this.getCookie(_bright.C_NAME);var f=e.indexOf("?");var a=e.length+c.length+1;if(c.length>0){if(f>-1){url=e+"&"+c}else{url=e+"?"+c}}else{url=e}if(a>_bright.MAX_URL_LENGTH){var d={};d.p_id=this.parseCookie(c,"p_id=","&");d.p_last_ref=this.parseCookie(c,"p_last_ref=","&");d.p_first_ref=this.parseCookie(c,"p_first_ref=","&");d.p_first_entry=this.parseCookie(c,"p_first_entry=","&");d.s_id=this.parseCookie(c,"s_id=","&");d.s_entry=this.parseCookie(c,"s_entry=","&");d.s_expire=this.parseCookie(c,"s_expire=","&");var b=new Array("p_id","p_last_ref","s_entry","p_first_ref","p_first_entry","s_expire","s_id");url=this.truncURL(e,d,b)}return url},truncURL:function(c,e,a){for(var d in e){if(e[d]){e[d]=e[d]+"";e[d]=e[d].substring(0,450)}}result_url=this.createURL(c,e,a);var b=a.length-1;while(result_url.length>_bright.MAX_URL_LENGTH){a.splice(a.length-1,1);result_url=this.createURL(c,e,a);if(a.length<=1){break}}return result_url},createURL:function(b,c,a){for(i=0;i<a.length;i++){var d=b.indexOf("?");if((a[i]=="cg"||a[i]=="cgv"||a[i]=="cptv")&&c[a[i]]==""){continue}if(d>-1){b=b+"&"}else{b=b+"?"}b=b+a[i]+"="+escape(c[a[i]])}return b},getmetaContents:function(c){var a=document.getElementsByTagName("meta");for(i=0;i<a.length;i++){if(a[i].name==null){continue}if((a[i].name).toLowerCase()==c.toLowerCase()){var b=a[i].content;if(b.length>255){b=b.substring(0,255)}return b}}return""},setCookie:function(a,d,c,b,f){var e=new Date();e.setTime(e.getTime()+c);document.cookie=a+"="+escape(d)+"; expires="+e.toGMTString()+"; "+this.getPath(f)+"; "+this.getDomain(b)},getPath:function(b){var a="";if(b!=""){a=b}else{a="/"}a="path="+a;return a},getDomain:function(a){var b="";if(a!=""){b=a}else{if(window.document.domain){b=window.document.domain}else{if(document.domain){b=document.domain}}}if(b!=""){b="domain="+b}return b},getCookie:function(a){if(document.cookie.length>0){c_begin=document.cookie.indexOf(a+"=");if(c_begin!=-1){c_begin=c_begin+a.length+1;c_end=document.cookie.indexOf(";",c_begin);if(c_end==-1){c_end=document.cookie.length}return unescape(document.cookie.substring(c_begin,c_end))}}return""},get36base:function(b){var a=b.charCodeAt(0);a=(a<=57)?a-22:a-65;return a},get36char:function(a){a=(a<10)?a+48:a+55;return String.fromCharCode(a)},EncodeString:function(e){var c,a="";for(var d=e.length-1;d>=0;d--){c=(this.get36base(e.charAt(d))*17)%36;c=this.get36char(c);a=a+c}return a},hashString:function(d){var b=0,c=1;for(var a=d.length-1;a>=0;a--){b=d.charCodeAt(a);b=(b*b*b)&268435455;c=c<<6+c*b}return c},generateUniqID:function(a){var d=this.hashString(navigator.userAgent);var c=Math.floor(Math.random(d)*524288)+Math.floor(Math.random()*524288);var b=(new Date()).getTime();var e=a+c+b;e=this.EncodeString(e);return e},getBrowserName:function(){var c=navigator.userAgent;var a,b;var d="";if((b=c.indexOf("MSIE"))!=-1){d="IE"}else{if((b=c.indexOf("Opera"))!=-1){d="Opera"}else{if((b=c.indexOf("Chrome"))!=-1){d="Chrome"}else{if((b=c.indexOf("Safari"))!=-1){d="Safari"}else{if((b=c.indexOf("Firefox"))!=-1){d="Firefox"}else{if((a=c.lastIndexOf(" ")+1)<(b=c.lastIndexOf("/"))){d=c.substring(a,b);if(d.toLowerCase()==d.toUpperCase()){d=navigator.appName}}}}}}}return d}});
