// ==UserScript==
// @name		NGMC big 2
// @namespace	ngmcbig2
// @description	Verandert de breedte van de NGMC-layout.
// @license		Free to use, always!
// @version		1.0
// @include		http://www.game-maker.nl/*
// ==/UserScript==

// Vul hier de gewenste breedte in. Procenten zijn toegestaan.
var gewenstebreedte = "1000";

// #################### Pas hieronder niets aan tenzij je weet wat je doet. ####################

var head = document.getElementsByTagName("head")[0];
var style = document.createElement("style");
style.type = "text/css";
style.innerHTML = "\n.post { width: 780px ! important; overflow: hidden ! important; }\n"
	+".personalmessage { width: 780px ! important; overflow: hidden ! important; }\n";
/*style.innerHTML += "hr { height: 0px ! important; border: solid #999999 0px ! important; border-top-width: 1px ! important; }\n"
	+".hrcolor { height: 0px ! important; border: solid #006699 0px ! important; border-top-width: 1px ! important; }\n";*/
head.appendChild(style);

var body = document.getElementsByTagName("body")[0];
var maintable = body.childNodes[1];
maintable.width = gewenstebreedte;

var inputs = document.getElementsByTagName("input");
for(i=0;i<inputs.length;i++) {
	if(inputs[i].type=="text") {
		// bericht-editor
		if(inputs[i].name=="subject" && inputs[i].size=="80") inputs[i].size = "100";
		// pm-editor
		if(inputs[i].name=="to" && inputs[i].size=="40") inputs[i].size = "80";
		if(inputs[i].name=="bcc" && inputs[i].size=="40") inputs[i].size = "80";
		if(inputs[i].name=="subject" && inputs[i].size=="40") inputs[i].size = "80";
	}
}

var tables = document.getElementsByTagName("table");
for(i=0;i<tables.length;i++) {
	if(tables[i].className=="bordercolor") {
		/*var childs = tables[i].childNodes[1].childNodes;
		for(j=0;j<childs.length;j++) {*/
		var childs = tables[i].getElementsByTagName("tr");
		for(j=0;j<childs.length;j++) {
			
			// forum index & board index
			if(location.href.match(/^http:\/\/www\.game-maker\.nl\/forums\/(\#.*)?$/) || location.href.match(/^http:\/\/www\.game-maker\.nl\/forums\/board,/)) {
				if(childs[j].className=="titlebg") {
					var childs2 = childs[j].childNodes;
					for(k=0;k<childs2.length;k++) {
						// topics
						if(childs2[k].width=="51%") childs2[k].width = "";
						else if(childs2[k].width=="14%") childs2[k].width = "140";
						else if(childs2[k].width=="4%") childs2[k].width = "20";
						else if(childs2[k].width=="22%") childs2[k].width = "120";
						else if(childs2[k].width=="8%") childs2[k].width = "20";
						// forums
						else if(childs2[k].width=="10%" || childs2[k].width=="12%") childs2[k].width = "80";
						else if(childs2[k].width=="26%" || childs2[k].width=="24%") childs2[k].width = "180";
					}
				} else {
					var childs2 = childs[j].childNodes;
					for(k=0;k<childs2.length;k++) {
						// topics
						if(childs2[k].width=="5%") childs2[k].width = "30";
						else if(childs2[k].width=="4%") childs2[k].width = "25";
						else if(childs2[k].width=="40%") childs2[k].width = "";
						else if(childs2[k].width=="16%") childs2[k].width = "140";
						else if(childs2[k].width=="4%") childs2[k].width = "20";
						else if(childs2[k].width=="22%") childs2[k].width = "135";
						else if(childs2[k].width=="8%") childs2[k].width = "20";
						// forums
						else if(childs2[k].width=="6%") childs2[k].width = "40";
						else if(childs2[k].width=="48%" || childs2[k].width=="46%") childs2[k].width = "";
						else if(childs2[k].width=="10%") childs2[k].width = "80";
						else if(childs2[k].width=="26%" || childs2[k].width=="22%") childs2[k].width = "180";
					}
				}
			}
			
			// topic
			if(location.href.match(/^http:\/\/www\.game-maker\.nl\/forums\/topic,/)) {
				var childs2 = childs[j].childNodes;
				for(k=0;k<childs2.length;k++) {
					if(childs2[k].width=="20%") childs2[k].width = "140";
					else if(childs2[k].width=="80%") childs2[k].width = "";
				}
			}
			
			// pm's
			if(location.href.match(/^http:\/\/www\.game-maker\.nl\/forums\/action,pm/) || location.href.match(/^http:\/\/www\.game-maker\.nl\/forums\/\?action=pm/)) {
				var childs2 = childs[j].getElementsByTagName("td");
				for(k=0;k<childs2.length;k++) {
					if(childs2[k].width=="22%") childs2[k].width = "140";
					else if(childs2[k].width=="78%") childs2[k].width = "";
				}
			}
			
		}
	}
}


