// ==UserScript==
// @name           Post Sig Toggle
// @namespace      http://digitalcreations.cc
// @description    Allows the user to toggle the display of each post's signature
// @include        http://*tacticalgamer.com/*
// ==/UserScript==

signatureSeparator = '				__________________<br>'

htmlNode = document.evaluate('/html', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue
if (htmlNode.innerHTML.indexOf('templates/wow') == -1) {
postAnchors = document.evaluate("//a[@name]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < postAnchors.snapshotLength; i++) {
	postAnchor = postAnchors.snapshotItem(i);
	if (postAnchor.name.indexOf('post') == 0) {
		postId = postAnchor.name.replace('post','')
		postTable = document.getElementById(postAnchor.name)

		if (postTable) {
					postSigCell = document.getElementById('td_post_'+postId)
					if (postSigCell) {
						postSigCellDivs = postSigCell.getElementsByTagName('div')
						if (postSigCellDivs) {
							for (var j = 0; j < postSigCellDivs.length; j++) {
								postSigDiv = postSigCellDivs[j]
								if (postSigDiv.innerHTML.indexOf(signatureSeparator) != -1 && postSigDiv.id.length == 0) {
									postSigDiv.style.display = 'none'
									postSigDiv.id = 'postsigdiv' + postId
									postSigCell.addEventListener('click',eval("function(){togglePostSigDisplay('"+postSigDiv.id+"')}"),false)
									break
								}
							}
						}

			}
		}

	}
}

if (location.href.indexOf('#') != -1) {
	location.href = location.href
}
}

function togglePostSigDisplay(id) {
	obj = document.getElementById(id)
	if (obj) {
		if (obj.style.display == 'none') {
			obj.style.display = ''
		}
	else {
		obj.style.display = 'none'
	}
}
}
