var COOKIE_NAME = 'CharleyEnabled'; var _CVID = -1;

function ConversionCookie(hours){
    this.name = COOKIE_NAME;
    if(hours) this.expiration = new Date((new Date()).getTime() + hours * 3600000);
    else this.expiration = null;
    this.VID=null;
    this.PVID=null;
}
ConversionCookie.prototype.load = function(){
    var cookieVal='';
    var allCookies=document.cookie;
    if(allCookies=='')return false;
    if(allCookies.indexOf(this.name+'=')==-1)return false;
    var cookies=allCookies.split('; ');
    for(var x=0;x<cookies.length;x++)if(cookies[x].indexOf(this.name)==0){cookieVal=cookies[x].substring(cookies[x].indexOf('=')+1,cookies[x].length);break;}
    if(cookieVal=='')return false;            
    var a=cookieVal.split('&');
    for(var i=0;i<a.length;i++){
        var b = a[i].split(':');
        this[b[0]]=b[1];
    }
    return true;
}

var ConvCookie = new ConversionCookie();
if(ConvCookie.load()){
    if(ConvCookie.VID!=null) _CVID = ConvCookie.VID;
    if(isNaN(_CVID))_CVID = -1;
}
if(_CVID > 0){
	var script = document.getElementById('charleyConv');
	if(script != null){
		var img = new Image(1,1);
		img.src = script.src.replace('js', 'aspx?vid=' + _CVID);
		img.onload = function(){return;}
    }
}
