window.onload = function(){

	var text_top;
	var text_bot;
	var current_url;
	var another_url;
	var current_path;
	var another_path;
	var body_text;
	var preg_lookup;

	body_text = document.body.innerHTML;
	current_url = window.location.href;
	current_path = window.location.pathname;


	if (/blog/.test(current_url)) {
		// location for<div> Blog</div>uri
		another_url = current_url.replace('blog/', '');
		another_path = current_path.replace('blog/', '');
		text_top = "<center><table class='jucatori' cellspacing='0' cellpadding='0' style='margin-bottom: -20px;'><tr><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_inactive.png) top left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: top; color: black; cursor: pointer;' onclick='document.location.href=\""+another_url+"\";'><div style='margin-top: 6px;'><img src='/fileadmin/mw-opr/images/icons/i.gif'/> Profil</div></td><td style='width: 10px;'></td><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_active_top.png) top left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: top;'><div style='margin-top: 6px;'><img src='/fileadmin/mw-opr/images/icons/b.gif'/> Blog</div></td></tr></table></center>";
		text_bot = "<center><table class='jucatori' cellspacing='0' cellpadding='0'><tr><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_inactive.png) bottom left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: bottom; color: black; cursor: pointer;' onclick='document.location.href=\""+another_url+"\";'><div style='margin-bottom: 12px;'><img src='/fileadmin/mw-opr/images/icons/i.gif'/> Profil</div></td><td style='width: 10px;'></td><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_active_bot.png) bottom left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: bottom;'><div style='margin-bottom: 12px;'><img src='/fileadmin/mw-opr/images/icons/b.gif'/> Blog</div></td></tr></table></center>";
	} else {
		// location for other
		if (/profil/.test(current_url)) {
			another_url = current_url.replace('profil', 'blog');
			another_path = current_path.replace('profil', 'blog');
		} else {
			another_url = current_url+'blog/';
			another_path = current_path+'blog/';
		}
		text_top = "<center><table class='jucatori' cellspacing='0' cellpadding='0' style='margin-bottom: -20px;'><tr><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_active_top.png) top left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: top;'><div style='margin-top: 6px;'><img src='/fileadmin/mw-opr/images/icons/i.gif'/> Profil</div></td><td style='width: 10px;'></td><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_inactive.png) top left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: top; color: black; cursor: pointer;' onclick='document.location.href=\""+another_url+"\";'><div style='margin-top: 6px;'><img src='/fileadmin/mw-opr/images/icons/b.gif'/> Blog</div></td></tr></table></center>";
		text_bot = "<center><table class='jucatori' cellspacing='0' cellpadding='0'><tr><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_active_bot.png) bottom left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: bottom;'><div style='margin-bottom: 12px;'><img src='/fileadmin/mw-opr/images/icons/i.gif'/> Profil</div></td><td style='width: 10px;'></td><td style='background: url(/fileadmin/mw-opr/images/buttons/flip_inactive.png) bottom left no-repeat; width: 128px; height:50px; text-align: left; padding-left: 35px; vertical-align: bottom; color: black; cursor: pointer;' onclick='document.location.href=\""+another_url+"\";'><div style='margin-bottom: 12px;'><img src='/fileadmin/mw-opr/images/icons/b.gif'/> Blog</div></td></tr></table></center>";
	}

	another_path = another_path.replace(/\//,'');
	//alert(another_path);
	preg_lookup = new RegExp(another_path, 'mi');
	if(preg_lookup.test(body_text) && current_path != '/jucatori/') {
		$('articleheader').update(text_top);
		$('articlefooter').update(text_bot);
	}

};
