_spub = 0;
// 0 pub alternative
// 1 pub oas
// 9 no pub

// Saisir ici les pseudos des skyblogs "officiels" ou ceux qui doivent avoir un tag de pub OAS spécifique.
var _pub_oas_blog = new Array(
// Array( pseudo , page oas qui sera préfixé de officiel_ )
Array('recettesmiam', 'nopub'), // pas d'appel à OAS
Array('apolloj', 'apolloj'),
Array('jamaischezmoi', 'sncf1225'),
Array('ipodstory', 'apple'),
Array('nattendspas50ans', 'sprite'),
Array('adidas-clima', 'adidas'),
Array('diamsofficiel', 'diams'),
Array('letransporteur2', 'transporteur2'),
Array('amineofficiel', 'amineofficiel'),
Array('dansloued','dansloued'),
Array('eskacrew','eskacrew'),
Array('myiaa','myiaa'), // skyblog officiel d'ines pour ses tests...
Array('revolver01','revolver01'),
Array('lady-laistee','lady-laistee'),
Array('nathyboss','nathyboss'),
Array('pes5konami','pes5konami'),
/*
Array('difool','difool'),
Array('planeterap','planeterap'),
*/
Array('ivmypeoplecrew','ivmypeoplecrew'),
Array('lanocturnesky','lanocturnesky'),
Array('fortxminor','fortxminor')
);

/* Délestage OAS - Config */

var pub_is_megaban = 0;
var _spub_list_img  = new Array();
var _spub_list_link = new Array();

_spub_list_img[0]  = "http://www.skyblog.com/banners/autopromos/SRdifool_50cent.gif";
_spub_list_link[0] = "http://www.skyrock.com/planetesky/evenements.phtml?id=55";

_spub_list_img[1]  = "http://www.skyblog.com/banners/autopromos/TSsexesousinfluence.gif";
_spub_list_link[1] = "http://www.tasante.com/sous_rubrique/bien_etre/psychologie/Pages/sexeSousInfluence.php";

_spub_list_img[2]  = "http://www.skyblog.com/banners/autopromos/TSforums_2.gif";
_spub_list_link[2] = "http://www.tasante.com/phorumv2/";

_spub_list_img[3]  = "http://www.skyblog.com/banners/autopromos/Ynew10.gif";
_spub_list_link[3] = "http://www.yazata.com/";

_spub_list_img[4]  = "http://www.skyblog.com/banners/autopromos/TMgenerique.gif";
_spub_list_link[4] = "http://www.tropmalin.com";

// % age d'autopromos 
_spub_pcts = -1; // 0%, min -1, max 100.

/* Fin Délestage OAS - Config */

/* Délestage OAS - Détermination */

_spub_ban = Math.round(Math.random() * (_spub_list_img.length - 1));
_spub_link = _spub_list_link[_spub_ban];
_spub_img = _spub_list_img[_spub_ban];

_spub_rn = Math.round(Math.random() * 100);
if (_spub == 0 && _spub_rn >= _spub_pcts) 
	_spub = 1;

/* Fin Délestage OAS */

if (typeof blog_spath != 'undefined')
{
	if (blog_spath.indexOf('/iledefrance') > 0)
	{
		_spub = 2;
		_spub_link = 'http://www.tns-sofres.com/etudes/pol/180405_jeunes_r.htm';
		_spub_img  = 'http://www.skyrock.com/pub/200504/banidf.gif';
	}
	else if (blog_spath.indexOf('/jglavany.') > 0)
	{
		_spub = 3;
		_spub_link = 'http://www.legrandtarbes.fr/';
		_spub_img  = 'http://www.skyrock.com/pub/200504/bandeau_blog.gif';
	}
	else if (blog_spath.indexOf('/voeuxskyregie.') > 0)
	{
		pub_sky_page = 'voeuxskyregie';
	}
	else if (_pub_oas_blog.length > 0)
	{
		for (var _pubcpt = 0; _pubcpt < _pub_oas_blog.length; _pubcpt++)
		{
			if (blog_spath.indexOf('/' + _pub_oas_blog[_pubcpt][0] + '.') > 0)
			{
				if (_pub_oas_blog[_pubcpt][1] == 'nopub')
				{
					_spub = 9;
					break;
				}
				var old_pub_sky_page = pub_sky_page;
				pub_sky_page = 'officiel';
				if (_pub_oas_blog[_pubcpt][1].length)
				{
					_spub = 1;
					pub_sky_page += '_' + _pub_oas_blog[_pubcpt][1];
				}
				if(old_pub_sky_page == 'bloguserphoto' || old_pub_sky_page == 'blogusercomment')
				{
					pub_sky_page = 'popup_' + pub_sky_page; // page avec pub en 468x60.
				}
				break;
			}
		}
	}
}

// blogs sans pub !
if (typeof blog_no_pub != 'undefined' && blog_no_pub == 1)
	_spub = 9;

OAS_url = 'http://oas.skyregie.com/RealMedia/ads/';

OAS_listpos = 'Top';
if (pub_sky_page == 'bloguser' || pub_sky_page == 'adminuser' || pub_sky_page == 'officiel' || pub_sky_page.indexOf('officiel_') >= 0)
	OAS_listpos += ',Bottom';

OAS_query = '';
OAS_sitepage = 'www.skyblog.com/' + pub_sky_page;

OAS_rn  = new String(Math.random()); 
OAS_rns = OAS_rn.substring (2, 11);

if (_spub == 1)
{
	document.write('<script type="text/javascript" src="'+OAS_url+'adstream_mjx.ads/'+OAS_sitepage+'/1'+OAS_rns+'@'+OAS_listpos+OAS_query+'"></script>');
}

function OAS_NORMAL(pos)
{ 
	document.write('<a href="'+OAS_url+'click_nx.ads/'+OAS_sitepage+'/1'+OAS_rns+'@'+pos+OAS_query+'" onclick="window.open(this.href); return false;"><img src="'+OAS_url+'adstream_nx.ads/'+OAS_sitepage+'/1'+OAS_rns+'@'+pos+OAS_query+'" alt="Pub" /></a>');
}

function OAS_AD(pos)
{
	if (_spub == 1)
	{
		if (typeof(OAS_RICH) != "undefined")
			return OAS_RICH(pos);
		return OAS_NORMAL(pos);
	}

	if(pos == 'Top' && _spub != 9)
		document.write('<a href="' + _spub_link + '" onclick="window.open(this.href); return false;"><img src="' + _spub_img + '" alt="Pub" /></a>');
}

// MegaBanners !
function publog_changelogo()
{
	var curlogo = publog_get_cur_logo();

	if (document.body.clientWidth > (728 + 201 + 12))
	{
		var diff = (document.body.clientWidth - 728 - 201 - 10 - 12) / 2;

		if (diff < 0)
			diff = 0;
		if (curlogo != _publog_logo_large)
		{
			document.getElementById('pub').style.left = (201 + 10 + diff) + 'px';
			if (typeof tpl_ver != "undefined" && tpl_ver >= 2)
			{
				if (document.getElementById('toplogo'))
				{
					document.getElementById('toplogo').className = 'grologo';
					document.getElementById('toplogo').src = _publog_logo_large;
				}
			}
			else
			{
				document.getElementById('top').style.backgroundImage = _publog_logo_large;
			}
		}
	}
	else
	{
		var diff = -1;

		if (curlogo != _publog_logo_small)
		{
			document.getElementById('pub').style.left = (80 + diff) + 'px';
			if (typeof tpl_ver != "undefined" && tpl_ver >= 2)
			{
				if (document.getElementById('toplogo'))
				{
					document.getElementById('toplogo').className = 'pitilogo';
					document.getElementById('toplogo').src = _publog_logo_small;
				}
			}
			else
			{
				document.getElementById('top').style.backgroundImage = _publog_logo_small;
			}
		}
	}
  var publog_timer = setTimeout('publog_changelogo();',1000);
}

function publog_get_cur_logo()
{
	if (typeof tpl_ver != "undefined" && tpl_ver >= 2)
		return (document.getElementById('toplogo') ? document.getElementById('toplogo').src : "");
	if (document.all)
		return document.getElementById('top').currentStyle.backgroundImage;
	return document.defaultView.getComputedStyle(document.getElementById('top'), '').getPropertyValue("background-image");
}

function publog_geturlminilogo(id_tpl)
{
	return 'http://www.skyblog.com/pics/minilogo/logotemplate'+id_tpl+'.gif';
}

function publog_megaban()
{
	document.getElementById('pub').style.top    = '3px';
	document.getElementById('pub').style.left   = '211px';
	document.getElementById('pub').style.width  = '738px'; // 728 + 10 pour les creas cheloues
	document.getElementById('top').style.height = (_publog_height + 6) + 'px';
}

function ban_getcookie(name, defaultvalue)
{
	name += "=";
	if (document.cookie.length > 0)
	{
		var offset = document.cookie.indexOf(name);
		if (offset != -1)
		{
			offset += name.length;
			var end = document.cookie.indexOf(";", offset)
			return unescape(document.cookie.substring(offset, (end != -1) ? end : document.cookie.length));
		}
	}
	return (defaultvalue);
}

function ban_setcookie(name, value)
{
	var cookie = name + "=" + escape(value);
	var today = new Date();
	var expire = new Date();
	
	expire.setTime(today.getTime() + 1000 * 60 * 60 * 1); // 1 heure
	cookie += "; expires=" + expire.toGMTString();
	cookie += "; path=/";
	document.cookie = cookie;
}

function publog_is_megabanpage()
{
	if (typeof GetComments!='undefined' 
	 && typeof pub_sky_page != 'undefined' 
	 && (pub_sky_page == 'bloguser' || pub_sky_page == 'officiel' || pub_sky_page.indexOf('officiel_') >= 0) 
	 && typeof publog_get_cur_logo != 'undefined')
		return true;
	return false;
}

function publog_get_idtpl()
{
	if (typeof idtpl != "undefined" && idtpl >= 0)
		return idtpl;
	var tmp = publog_get_cur_logo();
	return tmp.match(/[0-9]{1,3}/)[0];
}

function publog_get_mini_logo()
{
	if (typeof tpl_ver != "undefined" && tpl_ver >= 2)
		return 'http://www.skyblog.com/pics/logoSkyblogcarre.png';
	return 'url("' + publog_geturlminilogo(publog_get_idtpl()) + '")';
}

function publog_get_gros_logo(id_tpl)
{
	return 'http://www.skyblog.com/pics/logoSkybloglong.png';
}

function publog_megaban_v2()
{
	_publog_logo_large = publog_get_cur_logo();
	_publog_logo_small = publog_get_mini_logo();
	pub_is_megaban = 1;

	publog_megaban();
	publog_changelogo();
}
