// Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; GTB7.1; EasyBits GO v1.0)79.28.141.204126
var trkT = 1;
var trkUID = '380214814024779';
function Set_Cookie( name, value, expires, path, domain, secure ){
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct
	expires time, the current script below will set
	it for x number of days, to make it for hours,
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
	expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
	
}

function TGetCookieSite( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}


function linkMailTo(a){
	var prov = TGetCookieSite('Provenienza');
    var uidu = '';
    var uids = TGetCookieSite( 'uid' );
    if(uids==null || uids==''){
        //...
    }else{
        uidu = uids;
    }
    var jsel = document.createElement('SCRIPT');  jsel.type = 'text/javascript'; jsel.src = 'http://admin.abc.sm/scripts/count_click_mailto.php?a='+a+'&provenienza='+encodeURIComponent(prov)+'&uid='+uidu; window.document.body.appendChild (jsel);		
}


function StConvT(a,t){
    if(a!='' && t!=''){
        var prov = TGetCookieSite('Provenienza');
        var uidu = '';
        var uids = TGetCookieSite( 'uid' );
        if(uids==null || uids==''){
            //...
        }else{
            uidu = uids;
        }
        var jsel = document.createElement('img'); jsel.src = 'http://admin.abc.sm/scripts/set_conversion.php?a='+a+'&t='+t+'&provenienza='+encodeURIComponent(prov)+'&uid='+uidu; window.document.body.appendChild (jsel);        
    }
}


function srv_httphost(url){

	url = url.replace("http://", ""); 
	
	var urlExplode = url.split("/");
	var serverName = urlExplode[0];
	
	serverName = 'http://'+serverName;
	return serverName;
}

Set_Cookie( 'TCookiesTest', 'titanka', '', '/', '', '' );

var curr_host = srv_httphost(document.location.href)
var referer = srv_httphost(document.referrer);
if(curr_host != referer){
	
	if(!document.referrer){
		
		var old_pr = TGetCookieSite('Provenienza');
		if(old_pr==null || old_pr==''){
			Set_Cookie( 'Provenienza', 'Non rilevabile', '', '/', '', '' );
		}
	}else{
		Set_Cookie( 'Provenienza', document.referrer, '', '/', '', '' );
	}
	Set_Cookie( 'Landing', document.location.href, '', '/', '', '' ); 
}


var uidc = TGetCookieSite( 'uid' );
if(uidc==null || uidc==''){
	
    uidc = trkUID;
	Set_Cookie( 'uid', uidc, '', '/', '', '' );
    var uid = uidc;
}else{
	var uid = uidc;
    if(trkUID) uidc = trkUID;
}
if(uidc!='' && trkT==1){
    var dtrk = document.createElement("img");
    dtrk.width = 0;
    dtrk.height = 0;
    dtrk.src = 'http://admin.abc.sm/scripts/mailstatstrk/'+uidc+'.jpg?ref='+encodeURIComponent(document.referrer)+'&cur='+encodeURIComponent(document.location.href);
            
    if(window.document.body){
        
        window.document.body.appendChild(dtrk);
        
    }else{
        
        window.onload=function(){            
            window.document.body.appendChild(dtrk);
        }
        
    }
	
}

