// avenseo.js v2.3.0/chronodrive
// Copyright 2010 Avenseo. All rights reserved.
// http://www.avenseo.com

avenseo_url = 'st.avenseo.com/f2/s?cid=Chronodriv';

function avenseo_getCookie(c) {
   var i = document.cookie.indexOf(c+'=');
   if (i >= 0) {
       i += c.length + 1;
       var j = document.cookie.indexOf(';', i);
       if (j < 0) { j = document.cookie.length; }
       return document.cookie.substring(i, j);
   }
   return '';
}
function avenseo_cookieDomain() {
   var v = document.domain.split('.');
   if (v.length>2) { return '; domain=.' + v[v.length-2] + '.' + v[v.length-1]; }
   return '';
}
function avenseo_disabled() {
   return avenseo_getCookie('avenseo') == '0';
}
function avenseo_disable() {
   document.cookie = 'avenseo=0; expires=' + new Date(new Date().getTime() + 1800000).toGMTString() + '; path=/' + avenseo_cookieDomain();
   if (avenseo_disabled()) { window.location.reload(); }
}
function avenseo_timout() {
   if (avenseo_status == 'call') { avenseo_disable(); }
}
function avenseo_remoted(t) {
   var c = avenseo_getCookie('avenseo_'+t).split(':');
   return c.length >= 2 && c[1] == '1';
}
function avenseo_remote(t, r) {
   var c = avenseo_getCookie('avenseo_'+t).split(':');
   if (c.length < 3 || c[0] != r) {
       c = [r, (((Math.random()*100) < r) ? '1':'0'), ((c.length >= 3) ? c[2]:'')];
       document.cookie = 'avenseo_'+t + '=' + c.join(':') + '; expires=' + new Date(new Date().getTime() + 2592000000).toGMTString() + '; path=/' + avenseo_cookieDomain();
   }
   return avenseo_remoted(t);
}
function avenseo_call(t, p, a) {
   var x = avenseo_getCookie('avenseo_'+t).split(':')[2];
   eval('avenseo_X_' + t + '=\'' + x + '\';');
   if (!avenseo_disabled()) {
       avenseo_status = 'call';
       var u = (window.location.protocol == 'https:' ? 'https:' : 'http:') + '//' + avenseo_url + p + '&X=' + x;
       if (a) {
           $.ajax({type:'GET', dataType:'script', scriptCharset:'utf-8', global:false, url:u, complete:function(){avenseo_end(t);}});
       } else {
	        window.setTimeout('avenseo_timout()', 10000);
	        document.write('<'+'scr'+'ipt type="text/javascript" charset="utf-8" src="' + u + '"><'+'/scr'+'ipt>');
		 }
   }
}
function avenseo_show(t) {
   avenseo_status = 'show';
   var d = document.getElementById('avenseo_'+t);
   if (d) { d.parentNode.removeChild(d); }
   document.write(eval('avenseo_'+t));
}
function avenseo_fetch(t, r, ts, ps) {
   if (avenseo_remote(t, r)) { avenseo_call(t, '&T=' + ts + ps, false); }
}
function avenseo_transform(t, c, ps) {
   if (avenseo_remoted(t)) { avenseo_call(t, '&C=' + c + ps, true); }
}
function avenseo_end(t) {
   avenseo_status = 'end';
   if (avenseo_remoted(t)) { avenseo_save_ctx(t, eval('avenseo_X_'+t)); }
}
function avenseo_save_ctx(t, x) {
   var c = avenseo_getCookie('avenseo_'+t).split(':');
   if (c.length >= 3) {
       c[2] = x;
       document.cookie = 'avenseo_'+t + '=' + c.join(':') + '; expires=' + new Date(new Date().getTime() + 2592000000).toGMTString() + '; path=/' + avenseo_cookieDomain();
   }
}
