/*-------------------*/
/*  3 Piece H2 Code  */
/*  By Choco, 2007   */
/* Do Not Re-Release */
/* No Editing Either */
/*-------------------*/

//!~: Start code. Had to fix the toggle function.
function Toggle(c){var d=$(c).attr("class");$(c).attr("class","collapse uncollapse").removeClass(d).parents("div.h2wrap").next("table").slideToggle("slow",function(){$(c).one("click",function(){Toggle($(this))})});var e=$(c).parents("div.category").attr("id");var f=(e=="stats")?[0,0]:e.split('-');if(d=="collapse"){d=1}else{d=2}$.post(main_url+"tasks/",{"task":d,"cat":f[1]},function(a){var b=true;$(c).html(a);if(typeof fixPNG=='function'){fixPNG()}})};

w=navigator.userAgent.indexOf("WebKit")>-1;
web = (w)?"margin-left:1px!important;":"";ff=(navigator.userAgent.indexOf("Firefox")!=-1)?" style='margin-left:-1px;'":"";fin=(w)?web:ff; 
if(!window.location.href.match(/\/profile\//i)) {
	//!~: Category loop.
	$("table.cat_head").each(function() {
		elz = this.parentNode;
		y=this.innerHTML;
		//!~: Weird RegExp for handling h2.special.
		y=y.split(/\<h2.*?\>/i)[1];
		if(y) y=y.split(/\<\/h2\>/i)[0];
		this.parentNode.removeChild(this);
		elz.innerHTML="<div class=\"h2wrap\"><div class=\"h2left\"><div class=\"h2right\"><div class=\"h2center\">"+y+"</div></div></div></div>"+elz.innerHTML;
	});
	
	//!~: Stats.
	$("#stats h2.special").each(function() {x=$(this);x.parent().prepend("<div class='h2wrap'"+fin+"><div class='h2left'><div class='h2right'><div class='h2center'>"+x.html()+"</div></div></div></div>");x.remove();});
	
	//!~: Forum view loop.
	$("thead th").each(function() {
		if(!window.location.href.match(/\/calendar/i)) {$(this).parent().html("<td colspan='7'><div class='h2wrap'"+fin+"><div class='h2left'><div class='h2right'><div class='h2center'>"+$(this).text().replace(/</g, "&" + "lt;").replace(/>/g, "&" + "gt;")+"</div></div></div></div></td>");
		} else {y=$(this).html();$(this).parent().html("<td colspan='7'><div class='h2wrap'"+fin+"><div class='h2left'><div class='h2right'><div class='h2center'></div></div></div></div></td>");$(".h2center").each(function() {$(y).appendTo($(this));});}
	});
} 

//!~: Calendar modifications.
if (window.location.href.match(/\/calendar/i)) {
$(".calendar div").not(".h2wrap,.h2right,.h2center,.h2left").addClass("cal_div");$(".h2wrap").parent().addClass("calh2").css("height","0px");
}

//!~: Fast Replay.
/*
if(location.href.match(/topic/i)) {
hs=$("dt:contains(Fast Reply)")
$("dt:contains(Fast Reply)").before("<div class='h2wrap'"+ff+"><div class='h2left'><div class='h2right'><div class='h2center'>"+hs.text()+"</div></div></div></div>");hs.remove();
}

//!~: Portal Box H2
if(location.href.match(/site/i)) {
$(".portal_box h2").each(function() {
$(this).before("<div class='h2wrap'"+ff+"><div class='h2left'><div class='h2right'><div class='h2center'>"+$(this).text()+"</div></div></div></div>");
$(this).remove(); });
} */
//!~: Complete!

