// ==UserScript==
// @name           Post Separator Toggle
// @namespace      http://digitalcreations.cc
// @description    Allows the user to toggle the separators between posts
// @include        http://*tacticalgamer.com/*
// ==/UserScript==

htmlNode = document.evaluate('/html', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue
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) {
			if (postTable.rows) {
				postbitRow = postTable.rows[1]
				postbitCell = postbitRow.cells[0]
				editTable = document.getElementById('edit'+postId)
				if (editTable) {
					postTables = editTable.getElementsByTagName('table')
					separatorTable = postTables[postTables.length - 1]
					if (separatorTable) {
						separatorTable.style.display = 'none'
						separatorTable.id = 'headerBar'+postId
						postbitCell.addEventListener('click',eval("function(){toggleSeparatorDisplay('"+separatorTable.id+"')}"),false)
					}
				}
			}
		}
	}
}

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


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