function confirm_hide(pid){
    document.getElementById("confirm-"+pid).innerHTML='<div class="button" style="width: 100px; font-size: 9px; height: 12px; padding: 1px 0px 3px 0px; text-align: center; float: right; cursor: pointer;" onclick="confirm_show('+pid+');">Remove signature</div>';
}

function confirm_show(pid){
    document.getElementById("confirm-"+pid).innerHTML+='<div style="position: absolute; margin-left: -167px; margin-top: -54px; border: 1px solid; width: 268px; height: 50px; background-color: #e2e2e2; color: #000000; text-align: center;"><div style="margin: 4px;">Are you sure you want to remove this signature?</div><input type="button" class="button" style="margin-top: 2px; margin-right: 2px; font-size: 9px; height: 18px" value="Yes" onclick="remove_signature('+pid+');" /><input type="button" class="button" style="margin-top: 2px; margin-left: 2px; font-size: 9px; height: 18px" value="No" onclick="confirm_hide('+pid+');" /></div>';
}

function remove_signature(pid){
	var randf = Math.round(new Date().getTime()/1000.0);
	var url = ipb_var_base_url+"act=xmlout&do=remove-signature&pid="+pid+"&md5check="+ipb_md5_check+"r="+randf;
	var ajaxRequest;
	try{
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP")
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				alert("Your browser broke!");
				return false;
			}
		}
	}	
	
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			if(ajaxRequest.responseText == "OK"){
				confirm_hide(pid);
				url = String(document.location).split("#");
				window.location=url[0]+"&view=findpost&p="+pid;
			}
		}
	}
	
	ajaxRequest.open("GET", url, true);
	ajaxRequest.send(null);
}

if(document.getElementById("legend")){
	document.getElementById("legend").innerHTML='</div><strong>Leaders:</strong> '+
	'<a href="http://mm-rs.org/forums/co-leader.html"><span style="font-weight:bold;color:#ff0000">Co-Leader</span></a> '+
	'<a href="http://mm-rs.org/forums/high-council-plus.html"><span style="font-weight:bold;color:#ff0000">[*] High Council</span></a>  '+
	'<a href="http://mm-rs.org/forums/high-council.html"><span style="font-weight:bold;color:#ff6600">[+] High Council</span></a> '+
	'<a href="http://mm-rs.org/forums/warlord.html"><b><span style="color:#ffcc00">[+] Warlord</span></b></a> '+
	'<a href="http://mm-rs.org/forums/events-co-ordinator.html"><b><span style="color:#ffcc66">[-] Events Co-Ordinator</span></b></a> '+
	'<a href="http://mm-rs.org/forums/elder-p.html"><b><span style="color:#FF99CC">[*] Elder</span></b></a> '+
	'<a href="http://mm-rs.org/forums/elder.html"><b><span style="color:pink">[A] Elder</span></b></a> '+
	'<a href="http://mm-rs.org/forums/honored-ex-mm.html"><b><span style="color:#cc66cc">[-] Honoured Ex-MM</span></b></a>'+
	'</div>'+
	'<div>'+
	'<strong>Members:</strong> '+
	'<a href="http://mm-rs.org/forums/legend.html"><b><span style="color:#996600">[MM] Legend</span></b></a> '+
	'<a href="http://mm-rs.org/forums/old-school-mm.html"><b><span style="color:#8888FF">[MM] Oldschool Member</span></b></a> '+
	'<a href="http://mm-rs.org/forums/elite-mm.html"><b><span style="color:#0000ff">[MM] Elite Member</span></b></a> '+
	'<a href="http://mm-rs.org/forums/mayhem-maker.html"><b><span style="color:#0099ff">[MM] Member</span></b></a> '+
	'<a href="http://mm-rs.org/forums/new-mm.html"><b><b><span style="color:#66ffff">[MM] New Member</span></b></a>'+
	'</div>'+
	'<strong>Community:</strong> '+
	'<a href="http://mm-rs.org/forums/forum-mod.html"><b><span style="color:black">[+] Forum Mods</span></b></a> '+
	'<a href="http://mm-rs.org/forums/ex-oldschool.html"><b><span style="color:#99CCCC">[A] Ex-Oldschool</span></b></a> '+
	'<a href="http://mm-rs.org/forums/ex-mm.html"><b><span style="color:Green">[A] Ex-MM</span></b></a> '+
	'<a href="http://mm-rs.org/forums/special-guest.html"><b><span style="color:#0EA67D">[A] Special Guest</span></b></a> '+
	'<a href="http://mm-rs.org/forums/pure-clan-general.html"><b><span style="color:yellow">[H]Pure Clan General</span></b></a> '+
	'<a href="http://mm-rs.org/forums/forum-guest.html"><span style="color:purple">Forum Guest</span></a></div>';
}

function close_uploader(){
	document.getElementById("uploader_frame").src="";
    document.getElementById("uploader").style.display="none";
}

function open_uploader(){
	document.getElementById("uploader_frame").src="http://www.mm-rs.org/uploader/forums.html";
    document.getElementById("uploader").style.display="block";
}

function add_images(){
	if(document.getElementById("ed-0_textarea")){
		document.getElementById("ed-0_textarea").value+=document.getElementById("uploader_frame").contentWindow.document.getElementById("image-links").value;
	}else if(document.getElementById("fast-reply_textarea")){
		document.getElementById("fast-reply_textarea").value+=document.getElementById("uploader_frame").contentWindow.document.getElementById("image-links").value;
	}
}

function new_msg_bling(){
	var msg_color = document.getElementById("msg_box_link").style.color;
	if(msg_color == "rgb(34, 34, 34)" || msg_color == "#222222"){	document.getElementById("msg_box_link").style.color="#FF0000";	document.getElementById("msg_box_link").style.fontWeight="bold";	}
	else{	document.getElementById("msg_box_link").style.color="#222222";	}
	setTimeout("new_msg_bling()", 500);
}
if(ipb_new_msgs > 0){	new_msg_bling();	}

function countdown(eventday,eventhour,eventmin,eventsec,objectid,msgstring,msgstrend){
	var msgs = "";
	var ctime = new Date();
	var day = eventday-ctime.getDay();
	var hour = ctime.getHours()+1;
	var minute = eventmin-ctime.getMinutes()-1;
	var second = eventsec-ctime.getSeconds()-1;
	var eventhouroffset = ((()+eventhour)-hour);
	if(day != 0 && eventhouroffset < 0){eventhouroffset = eventhouroffset+24;}
	if(minute < 0 && eventhouroffset != 0){minute = minute+60;}
	if(day < 0){day = day+7;}
	
	if(day == 0 && eventhouroffset < 0)
	{
		if(document.getElementById(objectid))
		{
			document.getElementById(objectid).innerHTML = "<font color='red'>"+msgstrend+"</font>";
		}
	}
	else
	{
		msgs = msgstring.replace(/%d%/, day);
		msgs = msgs.replace(/%h%/, eventhouroffset);
		msgs = msgs.replace(/%m%/, minute);
		msgs = msgs.replace(/%s%/, second);
		
		if(document.getElementById(objectid))
		{
			document.getElementById(objectid).innerHTML = msgs;
		}
		setTimeout("countdown("+eventday+","+eventhour+","+eventmin+","+eventsec+",'"+objectid+"','"+msgstring+"','"+msgstrend+"')", 1000);
	}	
}
countdown(12,21,60,60,"mmvsfoe","Time till MM vs FOE F2p full out war: <b>%d% Days %h% Hours %m% Minutes %s% Seconds.</b>","Time to kick some FOE ass!");
countdown(5,23,60,60,"fri","Time till Friday F2p PK trip: <b>%d% Days %h% Hours %m% Minutes %s% Seconds.</b>","Event started!");
countdown(6,21,60,60,"sat","Time till Saturday F2p Pk trip: <b>%d% Days %h% Hours %m% Minutes %s% Seconds.</b>","Event started!");
countdown(0,20,60,60,"sun","Time till Sunday P2p PK trip: <b>%d% Days %h% Hours %m% Minutes %s% Seconds.</b>","Event started!");