/*
 * AdPerf Network - Weborama.com
 * Last update : 2010-01-28
 */

function _ap_i_can_has_cookies() {
    document.cookie = 'wbocc=true; path=/';
    return ( document.cookie.indexOf('wbocc', 0) < 0 ) ? false : true;
}
function _ap_has_session_cookie(name, value) {
    if ( document.cookies == '' ) return false;
    var cookies = document.cookie.split(';');
    for ( var i = 0; i < cookies.length; i++ ) {
        var c = cookies[i];
        while ( c.charAt(0) == ' ' ) c = c.substring(1, c.length);
        if ( c.indexOf(name+'=') == 0 ) {
            if ( value == null ) { return c.split(name+'=')[1]; }
            if ( value == c.split(name+'=')[1] ) {
                return value;
            }
        }
    }
    return false;
}
function _check_and_update_cookie_net(name, value) {
   	var ar_nets_ck = _ap_has_session_cookie(name);
    var ar_nets = [];

    /* lock network */
    if ( ar_nets_ck != false ) {
        ar_nets = ar_nets_ck.split(',');
        for ( var i = 0; i <= ar_nets.length; i++ ) {
            if ( ar_nets[i] == value ) return true;
        }
    }
	ar_nets.push(wr_site);
	document.cookie = name+'='+ar_nets+'; path=/';	
	return false;
}
function _ap_defined(name) {
    return ( typeof(window[name]) == "undefined" ) ? false : true;
}
function _ap_array_to_str(arr) {
  var r="";
  if (arr instanceof Array) {
    for(var i=0; i < arr.length; i++) {
      var data = arr[i];
      if (data instanceof Array && data.length == 2) {
        if (data[0].match(/^[a-zA-Z0-9]+$/) && data[1].match(/^[a-zA-Z0-9]+$/)) {
          r += data[0]+":"+data[1]+",";
        }
      }
    }
  }
  return r.length > 0 ? r.substr(0,r.length-1) : null
}
var _ap_ad         = new Object;
var wr_secure      = '';
var wr_solutions   = 'solution.weborama.fr/fcgi-bin/diff.fcgi?';
_ap_ad.count  	   = function(p) {
  this.img = new Image(1,1); this.img.src = 'http://pro.weborama.fr/fcgi-bin/comptage.fcgi?ID=260816&ZONE='+wr_site+'&PAGE='+p+'&MEDIA=MAIL'; return false; 
};
_ap_ad.write_js    = function(data) { document.write('<scr'+'ipt type="text/'+'jav'+'ascri'+'pt" src="'+data+'"></scr'+'ipt>'); };
_ap_ad.skip  	   = function(data) { if (this.check) this.count(400); return false; };
if (_ap_defined('wr_backup') && wr_backup.length > 7) {
	_ap_ad.backup = 'bak='+escape(wr_backup);
	_ap_ad.skip  = function(data) { this.write_js(wr_backup); if (this.check) this.count(410); return false; };
} else { _ap_ad.backup = null;}
_ap_ad.host        = ( _ap_defined('wr_host') )        ? wr_host : 'aimfar';
_ap_ad.board       = ( _ap_defined('wr_board') )       ? 'ide='+wr_board : null;
_ap_ad.boardsize   = ( _ap_defined('wr_boardsize') )   ? 'emp='+wr_boardsize : 'emp=1x1';
_ap_ad.autopage    = ( _ap_defined('wr_detail') )      ? 'kp='+wr_detail : null;
_ap_ad.floating    = ( _ap_defined('wr_floating') )    ? 'floating='+wr_floating : 'floating=0';
_ap_ad.site        = ( _ap_defined('wr_site') )        ? 'ids='+wr_site : null;
_ap_ad.page        = ( _ap_defined('wr_page') )        ? 'pageid='+wr_page : null;
_ap_ad.extparams   = ( _ap_defined('wr_extparams') )   ? 'ext_params='+escape(wr_extparams) : null;
_ap_ad.crealist    = ( _ap_defined('wr_crealist') )    ? 'cl='+wr_crealist : null;
_ap_ad.annolist    = ( _ap_defined('wr_advlist') )     ? 'al='+wr_advlist : null;
_ap_ad.camplist    = ( _ap_defined('wr_camplist') )    ? 'cal='+wr_camplist : null;
_ap_ad.model       = ( _ap_defined('wr_model') )       ? 'model='+wr_model : null;
_ap_ad.thema       = ( _ap_defined('wr_thema') )       ? 'wthema='+wr_thema : null;
_ap_ad.click       = ( _ap_defined('wr_click') )       ? 'ext_click='+escape(wr_click) : null;
_ap_ad.display     = ( _ap_defined('wr_display') )     ? 'ext_display='+escape(wr_display) : null;
_ap_ad.ex_secteurs = ( _ap_defined('wr_ex_secteurs' )) ? 'nsa='+escape(wr_ex_secteurs) : null;
_ap_ad.check       = ( _ap_defined('wr_check') )       ? wr_check : 0;
_ap_ad.dynkeys     = ( _ap_defined('wr_dynamic_keys')) ? 'dynkeys='+_ap_array_to_str(wr_dynamic_keys) : null;
wr_check = 0;
_ap_ad.ref		 = null;
_ap_ad.url		 = null;
try {
	_ap_ad.url='url='+escape(document.location);
	var ref = (top!=null && top.location!=null && typeof(top.location.href)=="string")?top.document.referrer:document.referrer;
	_ap_ad.ref='ref='+escape(ref);	
} catch (e) {}

_ap_adlist       = [ 'site', 'page', 'boardsize', 'autopage', 'board', 'crealist',
                     'annolist', 'camplist', 'model', 'thema', 'floating', 'extparams', 'ref', 'url', 'click', 'display',
                     'ex_secteurs', 'backup', 'dynkeys'
                   ];
var _ap_script   = 'http' + wr_secure + '://' + _ap_ad.host + '.' + wr_solutions;
var _ap_first    = true;

/* adperf publisher script src */
for ( var k in _ap_adlist ) {
    var key = _ap_adlist[k];
    if ( 'undefined' != typeof(_ap_ad[key]) && _ap_ad[key] != null && _ap_ad[key] != '' ) {
        _ap_script += (_ap_first ? '' : '&') + _ap_ad[key];
        _ap_first = false;
    }
}

/* one ad-net at a time */
_ap_ad.write = _ap_ad.skip;
if ( _ap_i_can_has_cookies() && (!_ap_defined('wr_locked') || window['wr_locked'] != true)) {
	_ap_ad.write       = function(data) { this.write_js(data); if (this.check) this.count(100); };

    /* lock page */
    window['wr_locked'] = true;

    /* lock network */
	if (_check_and_update_cookie_net('wbonet', wr_site)) {
		  _ap_ad.write = _ap_ad.skip;
          window['wr_locked'] = false;
	}
}
_ap_ad.write(_ap_script);
