
google_ad_client = 'pub-9002107795001714';
google_ad_slot = '4396806428';
google_ad_width = 250;
google_ad_height = 250;


function encode64(inp){
    var key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var chr1, chr2, chr3, enc3, enc4, i = 0, out = "";
    while (i < inp.length) {
        chr1 = inp.charCodeAt(i++);
        if (chr1 > 127) 
            chr1 = 88;
        chr2 = inp.charCodeAt(i++);
        if (chr2 > 127) 
            chr2 = 88;
        chr3 = inp.charCodeAt(i++);
        if (chr3 > 127) 
            chr3 = 88;
        if (isNaN(chr3)) {
            enc4 = 64;
            chr3 = 0;
        }
        else 
            enc4 = chr3 & 63
        if (isNaN(chr2)) {
            enc3 = 64;
            chr2 = 0;
        }
        else 
            enc3 = ((chr2 << 2) | (chr3 >> 6)) & 63
        out += key.charAt((chr1 >> 2) & 63) + key.charAt(((chr1 << 4) | (chr2 >> 4)) & 63) + key.charAt(enc3) + key.charAt(enc4);
    }
    return encodeURIComponent(out);
}

function m2b_stats(wid){

	    var referer = encode64(document.referrer); 
	    
	    if (referer == '') {
	        referer = '%3B';
	    }
	    
	    var wid = encodeURIComponent('NTUw');        
		
		var request = 'http://advertisings.media2buy.it/m2b_track.php?wid=' + wid + '&r=' + referer;
		
		aObj = new JSONscriptRequest(request);
		aObj.buildScriptTag();
		aObj.addScriptTag();
		
		document.writeln("<script type='text/javascript' src='http://pagead2.googlesyndication.com/pagead/show_ads.js'></script>"); 
		
}

function fakeHandler(){

}


function make_update_request(){

	var tid = encode64( arguments[0] );

	var request = 'http://advertisings.media2buy.it/m2b_track.php?tid=' + tid;
	
	bObj = new JSONscriptRequest(request);
	bObj.buildScriptTag();
	bObj.addScriptTag();
	bObj.removeScriptTag();
}


function update_track(){
	    
    make_update_request( arguments[0] );

    var callback = "update_track('" + arguments[0] + "')";
	setTimeout(callback, 15000);
    
}

// --------------------------------------------------------------------------------------------------
// jsr_class.js
//
//
// Author: Jason Levitt
// Date: December 7th, 2005
//

// Constructor -- pass a REST request URL to the constructor
//
function JSONscriptRequest(fullUrl) {
    // REST request path
    this.fullUrl = fullUrl; 
    // Keep IE from caching requests
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    // Get the DOM location to put the script tag
    this.headLoc = document.getElementsByTagName('head').item(0);
    // Generate a unique script tag id
    this.scriptId = 'M2B_tracker' + JSONscriptRequest.scriptCounter++;
}

// Static script ID counter
JSONscriptRequest.scriptCounter = 1;

// buildScriptTag method
//
JSONscriptRequest.prototype.buildScriptTag = function () {

    // Create the script tag
    this.scriptObj = document.createElement('script');
    
    // Add script object attributes
    this.scriptObj.setAttribute('type', 'text/javascript');
    this.scriptObj.setAttribute('charset', 'utf-8');
    this.scriptObj.setAttribute('src', this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute('id', this.scriptId);
}
 
// removeScriptTag method
// 
JSONscriptRequest.prototype.removeScriptTag = function () {
    // Destroy the script tag
    this.headLoc.removeChild(this.scriptObj);  
}

// addScriptTag method
//
JSONscriptRequest.prototype.addScriptTag = function () {
    // Create the script tag
    this.headLoc.appendChild(this.scriptObj);
} /* // ---> WEEK NOT PRESENT //BUT GOOGLE STRING PRESENT
//google_ad_client = 'pub-9002107795001714';
google_ad_slot = '4396806428';
google_ad_width = 250;
google_ad_height = 250;
 */ 