GHQEditor

GHQ Site Editor for Chrome and Firefox

目前為 2017-02-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name           GHQEditor
// @namespace      GHQEditor
// @author         Jabroni1134
// @description    GHQ Site Editor for Chrome and Firefox
// @include        http://*.ghqnet.com/*
// @match          http://*.ghqnet.com/*
// @version        2.04
// @grant         GM_addStyle
// @grant         GM_getValue
// @grant         GM_setValue
// @grant         GM_listValues
// @grant         GM_xmlhttpRequest
// ==/UserScript==

var scriptVersion=2.04;

/*
----------------------
Disclaimer
----------------------
Certain parts of this script are taken from other similer projects, all rights
 on those sections are owned by their respective creators.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
For a full copy of the GNU General Public License, see
http://www.gnu.org/licenses/.
*/
var DEBUGNEWCODE = 0;

var scriptName='GHQEditor';
var scriptId='74664';


var path = window.location.toString();					// get the URL of the current page
var page = path.substring(0, path.indexOf('.asp'));		// extract page name from URL
var page = page.substring(page.lastIndexOf('/')+1);		// extract page name from URL

var browser = 'Firefox';

if ((typeof GM_getValue === 'undefined') || (GM_getValue('a', 'b') === undefined)) {
    browser = 'Chrome';
    this.GM_getValue=function (key,def) {
        if(localStorage[key] == 'true'){
            return true;
        }else if(localStorage[key] == 'false'){
            return false;
        }else{
            return localStorage[key] || def;
        }
    };
    this.GM_setValue=function (key,value) {
        return localStorage[key]=value;
    };
    this.GM_listValues=function () {
        var listValues = new Array();
        for (var i=0; i < localStorage.length; i++) {
            listValues.push(localStorage.key(i));
        }
        return listValues;
    };
    this.GM_xmlhttpRequest=function (obj) {
        var request=new XMLHttpRequest();
        request.onreadystatechange=function() { if(obj.onreadystatechange) { obj.onreadystatechange(request); }; if(request.readyState==4 && obj.onload) { obj.onload(request); } }
        request.onerror=function() { if(obj.onerror) { obj.onerror(request); } }
        try { request.open(obj.method,obj.url,true); } catch(e) { if(obj.onerror) { obj.onerror( {readyState:4,responseHeaders:'',responseText:'',responseXML:'',status:403,statusText:'Forbidden'} ); }; return; }
        if(obj.headers) { for(name in obj.headers) { request.setRequestHeader(name,obj.headers[name]); } }
        request.send(obj.data); 
        return request;
    }
}

if(!GM_getValue('UNIQUEKEY',false)){
    var rand = Math.floor(Math.random()*10000000000000);
    GM_setValue('UNIQUEKEY',rand.toString());
}
var UNIQUEKEY = GM_getValue('UNIQUEKEY', false);

//==========================================
//Debug Setup
//==========================================
var DEBUG_KEY = "config_debug";
var LOG_LEVEL_KEY = "config_logLevel";

var LOG_LEVEL_DEBUG = 1;
var LOG_LEVEL_INFO = 2;
var LOG_LEVEL_WARN = 3;
var LOG_LEVEL_ERROR = 4;

var location = window.location.href;
var LOG_LEVEL = getSetting(LOG_LEVEL_KEY,0);

if(!getSetting(DEBUG_KEY,false)) LOG_LEVEL = 0;

try{
    var console = {
        log: function () // Basic logging function for loading etc
        {
            if( LOG_LEVEL >= 1 ) { notify( "\nError: "+arguments[0] ,MESSAGE_CLASS_ERROR); return; }
        },
        info: function () // Show data relevent to any functions being worked on
        {
            if( LOG_LEVEL >= 2 ) { notify( "Location: "+location+" \nError: "+arguments[0] ,MESSAGE_CLASS_ERROR); return; }
        },
        warn: function () // Show any non-fatal errors
        {
            if( LOG_LEVEL >= 3 ) { notify( "Location: "+location+" \nError: "+arguments[0] ,MESSAGE_CLASS_ERROR); return; }
        },
        error: function () // If error is breaking entire script
        {
            if( LOG_LEVEL == 4 ) { notify( "Location: "+location+" \nError: "+arguments[0] ,MESSAGE_CLASS_ERROR); return; }
        }
    };

} catch (e) {notify("Console exception: "+e,MESSAGE_CLASS_ERROR);}

if(document.title.indexOf("Error")!= -1) return; // try to break out if connections down to avoid messing up error page

//==========================================
//Get/Set Functions
//Prefixes server name to settings
//==========================================
function getSetting(key,value){
    try
    {
        if (typeof value == "float") value+="";
        return GM_getValue(getClan()+"_"+key,value);
    } catch (e) { console.warn ("Line Number: "+e.lineNumber+"\n getSetting error: "+e); console.info("\nKey: "+key+"\nValue: "+value); }
}

function setSetting(key,value){
    try
    {
        if (typeof value == "float") value+="";
        return GM_setValue(getClan()+"_"+key,value);
    } catch (e) { console.log ("Line Number: "+e.lineNumber+"\n setSetting error: "+e); console.log("\nKey: "+key+"\nValue: "+value); }
}

// Simple replacement of getelementbyid with $ to save typing
function $(variable)
{
    if(!variable) return;
    if (document.getElementById(variable)) return document.getElementById(variable);
}

//==========================================
//-----------Preset Definitions-------------
//==========================================
//NOTE: These are simpy defaults. There's no need to edit these here in the script.
var MESSAGE_CLASS = "notifier";
var MESSAGE_CLASS_ERROR = "notifierError";

GM_addStyle(+
            '.notifier {background-color: Black;border: solid 1px;color: white;padding: 10px 10px 10px 10px;}}'+
            '.notifierError {background-color: Black;border: solid 2px;color: red;padding: 10px 10px 10px 10px;}}'+
            'hr.cphr {color: orange;  width: 400px;}'+
            '.cpscripttimes {text-align: center;margin:0 auto;width:200px;background-color: #191919;border: #333333 solid 1px;padding-bottom: 10px;color: white;margin-top: 10px;font-size: 8px;opacity: 0.82;  z-index: 0;}'+
            '#gm_update_alert {position: relative;top: 0px;left: 0px;margin:0 auto;width:'+getTableWidth()+'px;background-color: #191919;text-align: center;font-size: 11px;font-family: Tahoma;border: #333333 solid 1px;margin-bottom: 10px;padding-left: 0px;padding-right: 0px;padding-top: 10px;padding-bottom: 10px;opacity: 0.82;color: white;}'+
            '.gm_update_alert_buttons {'+
            '  position: relative;'+
            '  top: -5px;'+
            '  margin: 5px;'+
            '}'+
            '#gm_update_alert_button_close {'+
            '  position: absolute;'+
            '  right: 20px;'+
            '  top: 20px;'+
            '  padding: 3px 5px 3px 5px;'+
            '  border-style: outset;'+
            '  border-width: thin;'+
            '  z-index: 11;'+
            '  background-color: orange;'+
            '  color: #FFFFFF;'+
            '  cursor:pointer;'+
            '}'+
            '.gm_update_alert_buttons span, .gm_update_alert_buttons span a  {'+
            '  text-decoration:underline;'+
            '  color: #003399;'+
            '  font-weight: bold;'+
            '  cursor:pointer;'+
            '}'+
            '.gm_update_alert_buttons span a:hover  {'+
            '  text-decoration:underline;'+
            '  color: #990033;'+
            '  font-weight: bold;'+
            '  cursor:pointer;'+
            '}'+
            '#gm_update_title {'+
            '  font-weight:bold;'+
            '  color:orange;'+
            '}'+
            '.right_Menu {'+
            '	color: gold;'+
            '	font-weight: bold;'+
            '  font-size: 11px;'+
            '  cursor:pointer;'+
            '}'+
            '.right_MenuHeader {'+
            '	color: gold;'+
            '	font-weight: bold;'+
            '  font-size: 11px;'+
            '}'+
            '.left_Menu {'+
            '	color: #DDDDDD;'+
            '  font-size: 12px;'+
            '	font-weight: bold;'+
            '}');

var totalStart = new Date();
var startTime = totalStart;
var endTime;
var timerMessage = "";

//==========================================
//Returns the clan abbr
//==========================================

var _clan = null;
function getClan(){
    //console.log("retreiving clan. Clan: "+_clan);
    if(_clan == null)
    {
        //console.log("setting clan. Location: "+window.location);
        var regex = /http:\/\/([a-z]+)\.ghqnet\.com/;
        var result = regex.exec(document.referrer);
        //console.log("Result: "+result);
        if(result == null)
        {
            //console.log(document.referrer);
            var regex = /http:\/\/([a-z]+)\.ghqnet\.com/;
            result = regex.exec(document.URL);
        }
        if (result != null)
        {
            _clan = result[1];
        }
        //        else console.log ("Referrer error");
    }
    //console.log("Clan: "+_clan);
    return _clan;
}

//==========================================
//---------Display Functions----------------
//==========================================

function zeroPad(num){
    if(num <= 9)
        return "0" + num;
    return num;
}

function getTableWidth(){
    var tables = document.evaluate(
        "//table[@class='top']",
        document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
    //console.log('Found '+ tables.snapshotLength + ' tables.');
    if(tables.snapshotLength==0) return 900;
    var topTable = tables.snapshotItem(0);
    return topTable.getAttribute("width");
}

function URLDecode (encodedString) {
    var output = encodedString;
    var binVal, thisString;
    var myregexp = /(%[^%]{2})/;
    while ((match = myregexp.exec(output)) != null
           && match.length > 1
           && match[1] != '') {
        binVal = parseInt(match[1].substr(1),16);
        thisString = String.fromCharCode(binVal);
        output = output.replace(match[1], thisString);
    }
    return output;
}

//Notifier Utility Code
//http://javascript.nwbox.com/asyncAlert/
//-----------------------------------
var notifycount = 1;
function notify(m,c){
    if($('Message'))
    {
        document.body.removeChild($('Message'));
    }
    //  create a block element
    var b=document.createElement('div');
    b.id='Message';
    b.className=c||'';
    b.style.cssText='position:absolute;white-space:nowrap;z-index:10;';
    //  classname not passed, set default classname
    if(b.className.length==0){
        b.className = "notifier";
    }
    //  insert block in to body
    b=document.body.insertBefore(b,document.body.firstChild);
    //  write HTML fragment to it
    b.innerHTML=m;
    //  save width/height before hiding
    var bw=b.offsetWidth;
    var bh=b.offsetHeight;
    //  hide, move and then show
    b.style.display='none';
    b.style.top = (document.body.clientHeight/2 + window.pageYOffset - bh/2)+"px";
    b.style.left = (document.body.clientWidth/2 + window.pageXOffset - bw/2)+"px";

    //console.log( b.style.top);
    //console.log("window height: "+document.body.clientHeight);
    //console.log("window width: "+document.body.clientWidth);
    //console.log("window scroll x: "+window.pageXOffset);
    //console.log("window scroll y: "+window.pageYOffset);

    b.style.display='block';
    var duration = 2000;
    var endOpacity = 0;
    if(c==MESSAGE_CLASS_ERROR)
    {
        b.className = "notifierError";
        b.id='errorMessage';
        var pos = notifycount * 40;
        b.style.top = (document.body.clientHeight/2 + window.pageYOffset - bh/2) - (400 - pos);
        duration = 4000;
        if(DEBUGNEWCODE) duration = 8000;
        endOpacity = 50;
    }

    notifycount++;
    // fadeout block if supported
    setFading(b,100,endOpacity,duration,function(){document.body.removeChild(b);});
}

// apply a fading effect to an object
// by applying changes to its style
// @o = object style
// @b = begin opacity
// @e = end opacity
// @d = duration (millisec)
// @f = function (optional)
function setFading(o,b,e,d,f){
    var t=setInterval(
        function(){
            b=stepFX(b,e,2);
            setOpacity(o,b/100);
            if(b==e){
                if(t){clearInterval(t);t=null;}
                if(typeof f=='function'){f();}
            }
        },d/20
    );
}
// set opacity for element
// @e element
// @o opacity
function setOpacity(e,o){
    // for IE
    e.style.filter='alpha(opacity='+o*100+')';
    // for others
    e.style.opacity=o;
}

// increment/decrement value in steps
// checking for begin and end limits
//@b begin
//@e end
//@s step
function stepFX(b,e,s){
    return b>e?b-s>e?b-s:e:b<e?b+s<e?b+s:e:b;
}

function insertNotification(message){
    if (message != null)
    {
        var notification = document.createElement("div");
        notification.setAttribute('id', 'gm_update_alert');
        var close = document.createElement("div");
        close.setAttribute('id', 'gm_update_alert_button_close');
        close.innerHTML = "Click to hide";
        close.addEventListener('click', function(event) {
            document.body.removeChild($('gm_update_alert'));
            document.body.removeChild($('gm_update_alert_button_close'));
        }, true);
        notification.innerHTML = ''
            +'  <div id="gm_update_title">GHQEditor Notification</div>'
            +'  <hr class="cphr" /><p>' + message
            +'</p>';
        notification.appendChild(close);
        document.body.insertBefore(notification, document.body.firstChild);
    }
}

function cleanBoards(){
    var thisTime = new Date().getTime();
    var clean = thisTime - 60*60*24;
    if(getSetting( 'LastCleaned', '0' ) < clean){
        var keys = GM_listValues();
        //var curTime = new Date().getTime();
        var youngestTime = curTime - 60*60*24*8*1000;
        for(var i=0; i<keys.length; ++i){
            if(keys[i].substr(0,6) == 'Posts_'){
                var Posts = getSetting( keys[i], ':' );
                var postarr = Posts.split(':');
                for(var x=0; x<postarr.length; ++x){
                    if(postarr[x] == ''){ continue; }
                    var lastReadTime = postarr[x].split('-')[1];
                    if(youngestTime >= lastReadTime){
                        postarr.splice(x, 1);
                        x--;
                    }
                }
                Posts = postarr.join(':');
                setSetting( keys[i], Posts );
            }
        }
        setSetting( 'LastCleaned', thisTime.toString() );
    }
}




//-----------------------------------
//Auto Launch count down script
//-----------------------------------

function timeToCounter(milliseconds)
{
    milliseconds = milliseconds/1000;
    var h = Math.floor(milliseconds/3600);
    var m = Math.floor((milliseconds % 3600)/60);
    var s = Math.floor((milliseconds % 3600) % 60);
    var counterString = "";
    if(h > 0)
        counterString += h+"h ";
    if(m > 0)
        counterString += m+"m ";
    if(s > 0)
        counterString += s+"s";
    return counterString;
}

//-----------------------------------
//End Auto Launch count down script
//-----------------------------------
//==========================================
// Check if new install
//==========================================
function installCheck(){
    try{
        var OldVersion = parseFloat(GM_getValue("scriptVersion",0+""));
        var NewVersion = parseFloat(scriptVersion);
        var LastMessage = GM_getValue("scriptLastMessage",'');
        var LatestVersion = 0.0;
        var lastCheck = parseInt(GM_getValue("updateCheckTime",0+""));
        var currTime = (new Date).getTime();
        //console.log("LastChecked: " + lastCheck);
        //console.log("Current Time: " + currTime);
        //console.log("Difference: " + (currTime - lastCheck));
        //console.log(scriptVersion);
        var Clan_Clan = getClan();
        if (OldVersion==null || OldVersion==""){	   
            GM_setValue("scriptVersion",NewVersion+"");		   
            insertNotification("You have sucessfully installed "+scriptName+" Version: "+NewVersion+" to your web browser.<br />");
            return;
        } else if (NewVersion>OldVersion){
            GM_setValue("scriptVersion",NewVersion+"");
            insertNotification("You have sucessfully upgraded "+scriptName+" From ("+OldVersion+") To ("+NewVersion+").<br/>");
        }
        delete OldVersion;
        delete NewVersion;
        delete LatestVersion;
        delete lastCheck;
        delete currTime;
    } catch (e) { console.log ("Line Number: "+e.lineNumber+"\ninstallCheck(): "+e); }
}

//==========================================
//Config Page
//==========================================

var ANIMATE_SERVER_TIME_KEY = "config_animateServerTime";
var GAME_TIME_SHOW_KEY = "config_gameTime";
var LOCAL_TIME_SHOW_KEY = "config_localTime";
var HOUR24_KEY = "config_24Hour";
var POST_AREA_KEY = "config_postArea";
var LEFT_MENU_KEY = "config_leftMenu";
var NEW_POSTS_KEY = "config_newPosts";
var TARGET_SELECTOR_KEY = "config_targetSelector";
var EDIT_USER_KEY = "config_editUser";
var SITE_MANAGER_KEY = "config_siteManager";
var GHQEDITOR_HEADER = "config_ghqeditorHeader";

function configBody()
{
    var url = location;
    GM_addStyle('.configHeading {'
                +'	color: gold;'
                +'	font-weight: bold;'
                +'}'
                +'.featureName {'
                +'	color: #EEDC82;'
                +'}'
                +'.subFeatureName {'
                +'	color: #8B814C;'
                +'	padding-left:20'
                +'}'
                +'.footnote {'
                +'	color: gold;'
                +'	font-weight: bold;'
                +'}');
    var width = getTableWidth();
    if (width<900) width = 900;
    var newbody = "<div align='center'>"+
        "<h2>GHQEditor - Settings</h2>"+
        "<small>Script Version: "+scriptVersion+"<span id='pageDate'></span></small> <br/>"+
        "<table width='"+width+"'>"+
        "<tr bgcolor='#222222'><th width='230' colspan='2'>Feature</th><th>Description</th></tr>";

    newbody = newbody +"<tr bgcolor='#222222'><td colspan='3' class='configHeading'>General</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_ghqeditorHeader' /> Move GHQEditor Header</td>"+
        "<td style='padding-left:20'>Displays the \"GHQEditor Settings\" and \"GHQEditor Website\" at the bottom of every page instead of in the Header.</td></tr>";

    newbody = newbody +"<tr bgcolor='#222222'><td colspan='3' class='configHeading'>Times</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_24Hour' /> 24 Hour Format</td>"+
        "<td style='padding-left:20'>Displays clocks in a 24 Hour format instead of AM/PM.</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_animateServerTime' /> Animate Times</td>"+
        "<td style='padding-left:20'>Display constantly updated server time.</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_gameTime' /> Game Time</td>"+
        "<td style='padding-left:20'>Shows additional timer to show EarthEmpires GameTime.</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_localTime' /> Local Time</td>"+
        "<td style='padding-left:20'>Shows additional timer to show your current local time.</td></tr>";

    newbody = newbody +"<tr bgcolor='#222222'><td colspan='3' class='configHeading'>Page Changes</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_newPosts' /> Show New Posts</td>"+
        "<td style='padding-left:20'>Tracks all New Posts on boards and posts a \"New Post\" Image next to topics with new posts.<br>*All posts older then a week will not be shown as \"New\"</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_leftMenu' /> Left Menu</td>"+
        "<td style='padding-left:20'>Allows user you decide what links to show and what not to.</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_postArea' /> PostArea</td>"+
        "<td style='padding-left:20'>Augments the PostArea of Boards to include extra information like HTML quicklinks.</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_editUser' /> Edit Users - Broken</td>"+
        "<td style='padding-left:20'>Adds groups and other usefull information to the page.</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_siteManager' /> Site Manager - Broken</td>"+
        "<td style='padding-left:20'>Adds an easier way to edit the header of a site.</td></tr>";


    newbody = newbody +"<tr bgcolor='#222222'><td colspan='5' class='configHeading'>Earth Empire GHQ Sites (Only for EarthEmpire Sites)</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_targetSelector' /> Target Selector</td>"+
        "<td style='padding-left:20'>Adds extra options and coloring to the Target Selector page.</td></tr>";

/*
    newbody = newbody +"<tr bgcolor='#222222'><td colspan='3' class='configHeading'>Debug</td></tr>"+

        "<tr bgcolor='#222222'><td class='featureName' colspan='2'><input type='checkbox' id='config_debug' /> Console log</td>"+
        "<td style='padding-left:20'>Logs to FireBug console. Must have Firebug extension installed.</td>"+
        "</tr>"+

        "<tr bgcolor='#222222'><td colspan='3' class='subfeatureName'>"+
        "<Input type = radio Name ='logLevel' Value = '1'>Log</input><br />"+
        "<Input type = radio Name ='logLevel' Value = '2'>Info</input><br />"+
        "<Input type = radio Name ='logLevel' Value = '3'>Warn</input><br />"+
        "<Input type = radio Name ='logLevel' Value = '4'>Error</input><br />"+
        "</tr></td>";
*/
    newbody = newbody +"<tr  bgcolor='#222222'><td colspan='3' align='center'><input id='saveButton' type=submit name='Save' value='Save' /> - <input id='resetButton' type=submit name='Reset to defaults' value='Reset to defaults' /></td></tr></table>"+
        "<a id='backLink' href='"+url+"'>Return to GHQ</a><br><br>"+


        "<table width='"+width+"'>";

    newbody = newbody +"<tr bgcolor='#222222'><td colspan='2' class='configHeading'>Board Monitoring<br>GHQEditor will not check for new posts on these boards<br>NOTE: This change will not take affect until GHQ is competely reloaded.</td></tr>"+
        "<tr bgcolor='#222222'><th>Do NOT Monitor Board</th><th>Description</th></tr>";

    var links = getSetting( 'menuBoards', '' );
    var linksarr = links.split('::::::');
    var boardsignore = getSetting( 'boards_ignore', ' ' );

    if(linksarr.length != 0){
        for(var i=0; i<linksarr.length; ++i){
            if(boardsignore.indexOf('::::::'+linksarr[i]+'::::::') != -1){
                checked = 'checked';
            }else{
                checked = '';
            }
            newbody = newbody +"<tr bgcolor='#222222'><td class='featureName'><input type='checkbox' Name='config_ignoreBoard' value='"+linksarr[i]+"' "+checked+"/> "+linksarr[i]+"</td>"+
                "<td style='padding-left:20'>Ignore Board when searching for new Posts?</td></tr>";
        }
    }

    newbody = newbody +"<tr bgcolor='#222222'><td colspan='2' align='center'><input id='saveButton2' type=submit name='Save' value='Save' /> - <input id='resetButton' type=submit name='Reset to defaults' value='Reset to defaults' /></td></tr>";
    newbody = newbody +"</table>"+
        "<small>GHQEditor created by Jabroni1134. Portions of the script are from Vigs AE Script (Config Page, Popups, Alerts)</small><br /><br />"+

        "<br /><br /><a id='backLink' href='"+url+"'>Return to GHQ</a>"+
        "</div>";
    return newbody;
}
function showConfig()
{
    document.body.innerHTML = "<html><body background='' bgcolor='black' link='#00C0FF' text='#DDDDDD' vlink='#d3d3d3'>";
    document.body.appendChild(firstTable);
    document.body.innerHTML = document.body.innerHTML+configBody()+"</body></html>";
    loadConfig();
    $('saveButton').addEventListener('click', function(event) {
        saveConfig();
    }
                                     , true);
    $('saveButton2').addEventListener('click', function(event) {
        saveConfig();
    }
                                      , true);
    $('resetButton').addEventListener('click', function(event) {
        resetConfig();
    }
                                      , true);
}

//==========================================
//Save/Load Config
//==========================================

function saveConfig()
{
    //console.log("Saving config");
    try{
        setSetting(ANIMATE_SERVER_TIME_KEY,$(ANIMATE_SERVER_TIME_KEY).checked);
        setSetting(LOCAL_TIME_SHOW_KEY,$(LOCAL_TIME_SHOW_KEY).checked);
        setSetting(GAME_TIME_SHOW_KEY,$(GAME_TIME_SHOW_KEY).checked);
        setSetting(HOUR24_KEY,$(HOUR24_KEY).checked);
        setSetting(POST_AREA_KEY,$(POST_AREA_KEY).checked);
        setSetting(LEFT_MENU_KEY,$(LEFT_MENU_KEY).checked);
        setSetting(NEW_POSTS_KEY,$(NEW_POSTS_KEY).checked);
        setSetting(TARGET_SELECTOR_KEY,$(TARGET_SELECTOR_KEY).checked);
        setSetting(EDIT_USER_KEY,$(EDIT_USER_KEY).checked);
        setSetting(SITE_MANAGER_KEY,$(SITE_MANAGER_KEY).checked);
        setSetting(GHQEDITOR_HEADER,$(GHQEDITOR_HEADER).checked);
        setSetting(DEBUG_KEY,$(DEBUG_KEY).checked);

        var logLevel = LOG_LEVEL_WARN;
        var radioButtons = document.evaluate(
            "//input[@type='radio']",
            document,
            null,
            XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
            null);
        //console.log(redCells.snapshotLength);
        for(var i=0;i<radioButtons.snapshotLength;i++)
        {
            //console.log(radioButtons.snapshotItem(i));
            if (radioButtons.snapshotItem(i).checked==true) {
                logLevel = radioButtons.snapshotItem(i).value;
            }

        }
        setSetting(LOG_LEVEL_KEY,logLevel);


        var boxes = document.getElementsByName('config_ignoreBoard');
        var txt = "::::::";
        for (i = 0; i < boxes.length; i++) {
            if (boxes[i].checked) {
                txt = txt + boxes[i].value+"::::::";
            }
        }
        setSetting('boards_ignore',txt);

    } catch (e) {console.log("Save settings on "+getClan()+": "+e);}
    notify("Settings successfully saved.");
}
function loadConfig()
{
    try{

        //console.log("Loading config");
        if ($(ANIMATE_SERVER_TIME_KEY)) $(ANIMATE_SERVER_TIME_KEY).checked = getSetting(ANIMATE_SERVER_TIME_KEY,true);
        if ($(LOCAL_TIME_SHOW_KEY)) $(LOCAL_TIME_SHOW_KEY).checked = getSetting(LOCAL_TIME_SHOW_KEY,true);
        if ($(GAME_TIME_SHOW_KEY)) $(GAME_TIME_SHOW_KEY).checked = getSetting(GAME_TIME_SHOW_KEY,true);
        if ($(HOUR24_KEY)) $(HOUR24_KEY).checked = getSetting(HOUR24_KEY,false);
        if ($(POST_AREA_KEY)) $(POST_AREA_KEY).checked = getSetting(POST_AREA_KEY,true);
        if ($(LEFT_MENU_KEY)) $(LEFT_MENU_KEY).checked = getSetting(LEFT_MENU_KEY,true);
        if ($(NEW_POSTS_KEY)) $(NEW_POSTS_KEY).checked = getSetting(NEW_POSTS_KEY,true);
        if ($(TARGET_SELECTOR_KEY)) $(TARGET_SELECTOR_KEY).checked = getSetting(TARGET_SELECTOR_KEY,true);
        if ($(EDIT_USER_KEY)) $(EDIT_USER_KEY).checked = getSetting(EDIT_USER_KEY,true);
        if ($(SITE_MANAGER_KEY)) $(SITE_MANAGER_KEY).checked = getSetting(SITE_MANAGER_KEY,true);
        if ($(DEBUG_KEY)) $(DEBUG_KEY).checked = getSetting(DEBUG_KEY,false);
        if ($(GHQEDITOR_HEADER)) $(GHQEDITOR_HEADER).checked = getSetting(GHQEDITOR_HEADER,false);

        var logLevel = getSetting(LOG_LEVEL_KEY,LOG_LEVEL_WARN);
        //console.log("Log level: "+logLevel);
        var radioButtons = document.evaluate(
            "//input[@type='radio']",
            document,
            null,
            XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
            null);
        //console.log(redCells.snapshotLength);
        for(var i=0;i<radioButtons.snapshotLength;i++)
        {
            //console.log(radioButtons.snapshotItem(i));
            if (radioButtons.snapshotItem(i).value==logLevel) {
                radioButtons.snapshotItem(i).checked = true;
            }

        }

    } catch (e) { console.log("Config loaded: "+e); return; }
}
function resetConfig(install)
{
    try{

        setSetting(ANIMATE_SERVER_TIME_KEY,true);
        setSetting(GAME_TIME_SHOW_KEY,true);
        setSetting(LOCAL_TIME_SHOW_KEY,true);
        setSetting(HOUR24_KEY,false);
        setSetting(POST_AREA_KEY,true);
        setSetting(LEFT_MENU_KEY,true);
        setSetting(NEW_POSTS_KEY,true);
        setSetting(TARGET_SELECTOR_KEY,true);
        setSetting(EDIT_USER_KEY,true);
        setSetting(SITE_MANAGER_KEY,true);
        setSetting(DEBUG_KEY,false);
        setSetting(GHQEDITOR_HEADER,false);

        if(install == "newInstall") { notify ("Settings set to default for new install."); return; }
    } catch (e) { console.log("Config reset: "+e); return; }
    notify("Settings successfully reset reloading page to update.");

    window.location.reload();
}
//==========================================
//AUGMENT FUNCTIONS
//==========================================

/*
*  POSTAREA AUGMENTATION
*/
function postAreaAugment() {
    function postAreaAugment_TextEditor(span) {
        id = span.id;
        if(subjectfocus){
            var box = Subject;
        }else{
            var box = Message;
        }

        var start = box.selectionStart; 
        var end = box.selectionEnd; 
        switch (id){
            case 'BoldStart':
                text = '<b>';
                break;
            case 'Bold':
                if(start != end){
                    box.value = box.value.substr(0, end) + '</b>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<b>' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<b> </b>';
                }
                break;
            case 'BoldEnd':
                text = '</b>';
                break;
            case 'UnderlineStart':
                text = '<u>';
                break;
            case 'Underline':
                if(start != end){
                    box.value = box.value.substr(0, end) + '</u>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<u>' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<u> </u>';
                }
                break;
            case 'UnderlineEnd':
                text = '</u>';
                break;
            case 'ItalicsStart':
                text = '<i>';
                break;
            case 'Italics':
                if(start != end){
                    box.value = box.value.substr(0, end) + '</i>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<i>' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<i> </i>';
                }
                break;
            case 'ItalicsEnd':
                text = '</i>';
                break;
            case 'ColorIA':
                if(start != end){
                    box.value = box.value.substr(0, end) + '</font>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<font color="orange">' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<font color="orange">';
                }
                break;
            case 'ColorWar':
                if(start != end){
                    box.value = box.value.substr(0, end) + '</font>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<font color="dodgerblue">' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<font color="dodgerblue">';
                }
                break;
            case 'ColorFR':
                if(start != end){
                    box.value = box.value.substr(0, end) + '</font>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<font color="mediumseagreen">' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<font color="mediumseagreen">';
                }
                break;
            case 'ColorEnd':
                text = '</font>';
                break;
            case 'Fontx-Small':
            case 'FontSmall':
            case 'FontLarge':
            case 'Fontx-Large':
                var size = id.substr(4);
                if(start != end){
                    box.value = box.value.substr(0, end) + '</span>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<span style="font-size: '+size+'">' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<span style="font-size: '+size+'"> ';
                }
                break;
            case 'FontEnd':
                text = '</span>';
                break;
            case 'AddURL':
                var url = prompt('What URL would you like to Add? (Paste URL)');
                var text = prompt('What Text would you like shown to the user for the link? (Text Header shown to user for link)');
                text = '<a href="'+url+'">'+text+'</a>';
                break;
            case 'AddImage':
                var image = prompt('What is the URL to the Image? (Paste URL)');
                text = '<img border="0" src="'+image+'">';
                break;
            case 'Emotessmile': 
                text = ' :) ';
                break;
            case 'Emoteswink':
                text = ' ;) ';
                break;
            case 'Emotesfrown':
                text = ' :( ';
                break;
            case 'Emotescool':
                text = ' 8) ';
                break;
            case 'Emotesmad':
                text = ' >:{ ';
                break;
            case 'Emotestongue':
                text = ' :P ';
                break;
            case 'Emotescrazy':
                text = ' ~:~ ';
                break;
            case 'Emotesshocked':
                text = ' :O ';
                break;
            case 'Emotesdetermined':
                text = ' >:) ';
                break;
            case 'Emotesundecided':
                text = ' :/ ';
                break;
            case 'Emotesyelling':
                text = ' >:O ';
                break;
            case 'Emotessealed':
                text = ' :X ';
                break;
            case 'Emoteslaugh':
                text = ' :D ';
                break;
            case 'Emotescrying':
                text = ' :*( ';
                break;
            case 'Emotesblush':
                text = ' *blush* ';
                break;
            default:
                if(id.substr(0, 5) != 'Color'){ return; }
                var color = id.substr(5);
                if(start != end){
                    box.value = box.value.substr(0, end) + '</font>' + box.value.substr(end, box.value.length); 
                    box.value = box.value.substr(0, start) + '<font color="'+color+'">' + box.value.substr(start, box.value.length); 
                }else{
                    text = '<font color="'+color+'">';
                }


                break;
        }
        if(text !== undefined){
            box.value = box.value.substr(0, start) + text + box.value.substr(end, box.value.length); 
        }
        box.focus(); 
    }
    var subjectfocus = false;
    var Message = document.getElementsByTagName("textarea")[0];
    Message.cols = '75';
    Message.rows = '20';
    Message.addEventListener("focus", function(){ subjectfocus = false; }, false);
    var table = Message.parentNode.parentNode.parentNode;
    var rowindex = Message.parentNode.parentNode.sectionRowIndex;
    var editor = table.rows[rowindex].cells[0];
    editor.align = 'center';
    editor.vAlign = 'middle';
    var colorstext = '';
    var colors = new Array('Aqua', 'Blue', 'Crimson', 'DarkBlue', 'DarkCyan', 'DarkGreen', 'DarkViolet', 'DodgerBlue', 'Gray', 'Green', 'Lime', 'Maroon', 'Navy', 'Orange', 'Purple', 'Red', 'RoyalBlue', 'SeaGreen', 'Teal', 'Yellow');
    for(var i=0; i<colors.length; ++i){
        if(i == 5 || i == 10 || i == 15 || i == 20){
            colorstext += '<br>';
        }
        colorstext += '<span id="Color'+colors[i]+'" style="color: '+colors[i]+'" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">'+colors[i]+',</span> ';
    }
    editor.innerHTML = '<font style="color: DarkOrange; font-size: small"><span id="BoldStart" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">[B]</span> - <span id="Bold" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'"><b>Bold</b></span> - <span id="BoldEnd" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">[/B]</span><br><span id="UnderlineStart" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">[U]</span> - <span id="Underline" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'"><u>Underline</u></span> - <span id="UnderlineEnd" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">[/U]</span><br><span id="ItalicsStart" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">[I]</span> - <span id="Italics" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'"><i>Italics</i></span> - <span id="ItalicsEnd" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">[/I]</span><br><br>Colors: <span id="ColorIA" style="color: orange" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">IA,</span> <span id="ColorWar" style="color: dodgerblue" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">War,</span> <span id="ColorFR" style="color: mediumseagreen" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">FR</span><br>'+colorstext+'<br><span id="ColorEnd" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">End Color</span><br><br><span style="font-size: medium; text-decoration: underline"><strong>Size</strong></span><br><span id="Fontx-Small" style="font-size: x-Small" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">x-Small</span>, <span id="FontSmall" style="font-size: Small" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">Small</span>, <span id="FontLarge" style="font-size: Large" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">Large</span>, <span id="Fontx-Large" style="font-size: x-Large" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">x-Large</span><br><span id="FontEnd" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">End Size</span><br><br><span id="AddURL" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">Add URL</span><br><span id="AddImage" onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">Add Image</span><br><br><span id="Emotessmile" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/smile.gif"></span> <span id="Emoteswink" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/wink.gif"></span> <span id="Emotesfrown" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/frown.gif"></span> <span id="Emotescool" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/cool.gif"></span> <span id="Emotesmad" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/mad.gif"></span><br><span id="Emotestongue" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/tongue.gif"></span> <span id="Emotescrazy" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/crazy.gif"></span> <span id="Emotesshocked" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/shocked.gif"></span> <span id="Emotesdetermined" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/determined.gif"></span> <span id="Emotesundecided" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/undecided.gif"></span><br><span id="Emotesyelling" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/yelling.gif"></span> <span id="Emotessealed" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/sealed.gif"></span> <span id="Emoteslaugh" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/laugh.gif"></span> <span id="Emotescrying" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/crying.gif"></span> <span id="Emotesblush" onmouseover="this.style.cursor=\'pointer\'"><img border="0" src="http://sol.ghqnet.com/images/Emotes/blush.gif"></span>';

    document.getElementById("BoldStart").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Bold").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("BoldEnd").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("UnderlineStart").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Underline").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("UnderlineEnd").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("ItalicsStart").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Italics").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("ItalicsEnd").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("ColorIA").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("ColorWar").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("ColorFR").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("ColorEnd").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Fontx-Small").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("FontSmall").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("FontLarge").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Fontx-Large").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("FontEnd").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("AddURL").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("AddImage").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotessmile").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emoteswink").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotesfrown").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotescool").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotesmad").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotestongue").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotescrazy").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotesshocked").addEventListener("click", function(){TextEditor(this);}, false);
    document.getElementById("Emotesdetermined").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotesundecided").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotesyelling").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotessealed").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emoteslaugh").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotescrying").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    document.getElementById("Emotesblush").addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);

    for(var i=0; i<colors.length; ++i){
        var name = "Color"+colors[i];
        document.getElementById(name).addEventListener("click", function(){postAreaAugment_TextEditor(this);}, false);
    }
    var allInputs = document.getElementsByTagName("input");
    for(var i=0; i<allInputs.length; ++i){
        if(allInputs[i].name == 'Subject'){
            var Subject = allInputs[i];
            allInputs[i].addEventListener("focus", function(){ subjectfocus = true; }, false);
            allInputs[i].size = '70';
        }
    }
}


/*
*  NEW POSTS
*/
function newPosts() {
    function newPosts_MarkAllRead() {
        var allNew = document.getElementsByName("NEW");
        for(var i=0; i<allNew.length; ++i){
            allNew[i].parentNode.removeChild( allNew[i] ); 
            i--;
        }
        setSetting( 'Posts_'+BoardID, ':AllRead-'+curTime+':' );
        notify('All topics marked as Read.');
    }
    var allTR = document.getElementsByTagName('tr');			// get all TD elements
    var allInputs = document.getElementsByTagName("input");
    for(var i=0; i<allInputs.length; ++i){
        if(allInputs[i].name == 'BoardID'){
            BoardID = allInputs[i].value;
            break;
        }
    }
    var Posts = getSetting( 'Posts_'+BoardID, ':' );
    var t = Posts.indexOf(':AllRead-');
    if(t!=-1){
        var tEnd = Posts.indexOf(':', t+1);
        var val = Posts.slice(t, tEnd);
        val = val.replace(':', '');
        var allReadTime = val.split('-')[1];
    }else{
        var allReadTime = 0;
    }
    if(document.forms[0].name == 'EditBoard'){
        colnum = 3;
    }else{
        colnum = 0;
    }
    var youngestTime = curTime - 60*60*24*7*1000;
    for(var i=0; i < allTR.length; ++i){
        if(allTR[i].firstChild.colSpan == 4 || allTR[i].firstChild.colSpan == 4+colnum){
            if(allTR[i].firstChild.firstChild != 'undefined' && allTR[i].lastChild.firstChild != 'undefined'){
                if(allTR[i].lastChild.firstChild.innerHTML == 'View Emotes' ){
                    var row = allTR[i].parentNode.insertRow(0);
                    var cell = row.insertCell(0);
                    cell.bgColor = 'black';
                    cell.colSpan = 4+colnum;
                    cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';" id="MarkRead"><font style="color: Orange; font-size: small"><strong>Mark all as "Read"</strong></font></span>';
                    $('MarkRead').addEventListener("click", function(){newPosts_MarkAllRead();}, false);
                    i++;
                }
            }
            continue;
        }
    
        if(allTR[i].cells.length != 5+colnum){            
            continue;
        }
   
        if(allTR[i].cells[4+colnum].innerHTML == 'Last Post'){           
            continue;            
        }
        var PostDate = allTR[i].lastChild.innerHTML;
        PostDate = Date.parse(PostDate); 
        if(youngestTime >= PostDate || allReadTime >= PostDate){
            continue;
        }

        var ThreadID = allTR[i].childNodes[0+colnum].firstChild.href.split('&')[1];
        ThreadID = ThreadID.split('=')[1];
        var t = Posts.indexOf(':'+ThreadID+'-');
       
        if(t!=-1){
           
            var tEnd = Posts.indexOf(':', t+1);
            var val = Posts.slice(t, tEnd);
            val = val.replace(':', '');
            var lastReadTime = val.split('-')[1];
            if(PostDate <= lastReadTime){
                continue;
            }
            //allTR[i].childNodes[0+colnum].innerHTML = '<span id="t_'+ThreadID+'" name="NEW"> <font style="color: Red; font-size: x-small">*NEW* </font></span>'+allTR[i].childNodes[0+colnum].innerHTML;
            allTR[i].childNodes[0+colnum].innerHTML = '<span id="t_'+ThreadID+'" name="NEW"><img src="http://www.ghqnet.com/sites/SOL/Files/newpost.png"> </span>'+allTR[i].childNodes[0+colnum].innerHTML;
        }else{
            //allTR[i].childNodes[0+colnum].innerHTML = '<span id="t_'+ThreadID+'" name="NEW"><font style="color: Red; font-size: x-small">*NEW* </font></span>'+allTR[i].childNodes[0+colnum].innerHTML;
            allTR[i].childNodes[0+colnum].innerHTML = '<span id="t_'+ThreadID+'" name="NEW"><img src="http://www.ghqnet.com/sites/SOL/Files/newpost.png"> </span>'+allTR[i].childNodes[0+colnum].innerHTML;
        }
    }
}
function newPostMarkRead() {
    var BoardID = path.split('&')[0].split('=')[1];
    var Posts = getSetting( 'Posts_'+BoardID, ':' );
    var t = Posts.indexOf(':AllRead-');
    if(t!=-1){
        var tEnd = Posts.indexOf(':', t+1);
        var val = Posts.slice(t, tEnd);
        val = val.replace(':', '');
        var allReadTime = val.split('-')[1];
    }else{
        var allReadTime = 0;
    }
    var PostDate = path.split('&')[3].split('=')[1];
    PostDate = Date.parse(URLDecode(PostDate));
    //var curTime = new Date().getTime();
    var youngestTime = curTime - 60*60*24*7*1000;
    if(youngestTime < PostDate && allReadTime < PostDate){
        var ThreadID = path.split('&')[1].split('=')[1];
        t = Posts.indexOf(':'+ThreadID+'-');
        if(t!=-1){
            tEnd = Posts.indexOf(':', t+1);
            var val = Posts.slice(t, tEnd);
            Posts = Posts.replace(val, ':'+ThreadID+'-'+PostDate+':');
        }else{
            Posts = Posts+ThreadID+'-'+PostDate+':';
        }
        setSetting( 'Posts_'+BoardID, Posts );
    }
}
/*
*  END: NEW POSTS
*/	

/*
*  CLEAN BOARD
*/
function cleanBoard() {
    function cleanBoard_onChange(t) {
        var Value = t.value; 
        switch (Value){
            case 'Choose One':
                $("CleanBoard_SpanOlderThen").style.display = 'none';
                $("CleanBoard_SpanSortOrder").style.display = 'none';
                $("CleanBoard_SortOrder").selectedIndex = $("CleanBoard_SortOrder").options[0].index;
                $("CleanBoard_SpanStartingWithA").style.display = 'none';
                $("CleanBoard_SpanCustom").style.display = 'none';
                $("CleanBoard_SpanExplain").style.display = 'none';
                $("CleanBoard_SpanCleanBoard").style.display = 'none';
                break;
            case 'Check Boxes':
                $("CleanBoard_SpanOlderThen").style.display = '';
                $("CleanBoard_SpanSortOrder").style.display = 'none';
                $("CleanBoard_SortOrder").selectedIndex = $("CleanBoard_SortOrder").options[0].index;
                $("CleanBoard_SpanStartingWithA").style.display = 'none';
                $("CleanBoard_SpanCustom").style.display = 'none';
                $("CleanBoard_SpanExplain").style.display = '';
                $("CleanBoard_SpanCleanBoard").style.display = '';
                break;
            default:
                $("CleanBoard_SpanOlderThen").style.display = '';
                $("CleanBoard_SpanSortOrder").style.display = '';
                $("CleanBoard_SortOrder").selectedIndex = $("CleanBoard_SortOrder").options[0].index;
                $("CleanBoard_SpanStartingWithA").style.display = 'none';
                $("CleanBoard_SpanCustom").style.display = 'none';
                $("CleanBoard_SpanExplain").style.display = 'none';
                $("CleanBoard_SpanCleanBoard").style.display = 'none';
                break;
        }
    }
    function cleanBoard_onChangeSortOrder(t) {
        var Value = t.value; 
        switch (Value){
            case 'Keep Current Sort Order':
                $("CleanBoard_SpanStartingWithA").style.display = 'none';
                $("CleanBoard_SpanCustom").style.display = 'none';
                $("CleanBoard_SpanExplain").style.display = '';
                $("CleanBoard_SpanCleanBoard").style.display = '';
                break;
            case 'Alphabetically':
                $("CleanBoard_SpanStartingWithA").style.display = '';
                $("CleanBoard_SpanCustom").style.display = 'none';
                $("CleanBoard_SpanExplain").style.display = '';
                $("CleanBoard_SpanCleanBoard").style.display = '';
                break;
            case 'Custom':
                $("CleanBoard_SpanStartingWithA").style.display = 'none';
                $("CleanBoard_SpanCustom").style.display = '';
                $("CleanBoard_SpanExplain").style.display = '';
                $("CleanBoard_SpanCleanBoard").style.display = '';
                break;
            default:
                $("CleanBoard_SpanStartingWithA").style.display = 'none';
                $("CleanBoard_SpanCustom").style.display = 'none';
                $("CleanBoard_SpanExplain").style.display = 'none';
                $("CleanBoard_SpanCleanBoard").style.display = 'none';
                break;
        }
    }
    function cleanBoard_Explain() {
        var CleanBoard = $("CleanBoard");
        var Value = CleanBoard.value; 
        switch (Value){
            case 'Choose One':
                return;
                break;
            case 'Check Boxes':
                var days = $('CleanBoard_Days');
                alert('"Check Boxes" on any posts older then "'+days.value+'" Days.');
                break;
            default:
                var SortOrder = $("CleanBoard_SortOrder");
                var Value2 = SortOrder.value; 
                var days = $('CleanBoard_Days');
                switch (Value2){
                    case 'Keep Current Sort Order':
                        alert('"Move to selected board" any posts older then "'+days.value+'" Days while "Keeping the Current Sort Order".');
                        break;
                    case 'Alphabetically':
                        var StartingWithA = $('CleanBoard_StartingWithA');
                        var InStepsOfSign = $('CleanBoard_InStepsOfSign');
                        var InStepsOf = $('CleanBoard_InStepsOf');
                        if(InStepsOfSign.value == '+'){
                            var b = Number(StartingWithA.value) + Number(InStepsOf.value);
                            var c = b + Number(InStepsOf.value);
                            var d = c + Number(InStepsOf.value);
                        }else{
                            var b = Number(StartingWithA.value) - Number(InStepsOf.value);
                            var c = b - Number(InStepsOf.value);
                            var d = c - Number(InStepsOf.value);
                        }
                        alert('"Move to selected board" any posts older then "'+days.value+'" Days while sorting "Alphabetically" starting with "A" at "'+StartingWithA.value+'" and in steps of "'+InStepsOfSign.value+InStepsOf.value+'". So A="'+StartingWithA.value+'", B="'+b+'", C="'+c+'", D="'+d+'", etc.');
                        break;
                    case 'Custom':
                        var Custom = $('CleanBoard_Custom');
                        alert('"Move to selected board" any posts older then "'+days.value+'" Days while placing all moved topics at position "'+Custom.value+'".');
                        break;
                    default:
                        return;
                        break;
                }
                break;
        }
    }
    function cleanBoard_CleanBoard() {
        var CleanBoard = $("CleanBoard");
        var Value = CleanBoard.value; 
        switch (Value){
            case 'Choose One':
                return;
                break;
            case 'Check Boxes':
                var days = $('CleanBoard_Days');
                var allChecks = table.getElementsByTagName('input');			// get all TD elements
                var dif = parseInt(days.value) * 24 * 60 * 60 * 1000;
                currentTime = curTime - dif;
                var count = 0;
                for(var i=0; i<allChecks.length; ++i){
                    if(allChecks[i].parentNode.parentNode.childNodes[6] == undefined){
                        continue;
                    }else if(allChecks[i].parentNode.parentNode.childNodes[6].innerHTML == undefined){
                        continue;
                    }
                    if(allChecks[i].parentNode.parentNode.childNodes[6].innerHTML == ''){
                        continue;
                    }
                    var date = allChecks[i].parentNode.parentNode.childNodes[6].innerHTML;
                    date = Date.parse(date);
                    if(isNaN(date)){ continue; }
                    if(currentTime > date){
                        allChecks[i].checked = true;
                        count++;
                    }
                }
                alert('"'+count+'" Topics have been selected. You may now use the GHQ functions to Move the topics or Delete them.');
                break;
            default:
                var SortOrder = $("CleanBoard_SortOrder");
                var Value2 = SortOrder.value; 
                var days = $('CleanBoard_Days');
                switch (Value2){
                    case 'Keep Current Sort Order':
                        var days = $('CleanBoard_Days');
                        var allChecks = table.getElementsByTagName('input');			// get all TD elements
                        var dif = parseInt(days.value) * 24 * 60 * 60 * 1000;
                        currentTime = curTime - dif;
                        var count = 0;
                        for(var i=0; i<allChecks.length; ++i){
                            if(allChecks[i].parentNode.parentNode.childNodes[6] == undefined){
                                continue;
                            }else if(allChecks[i].parentNode.parentNode.childNodes[6].innerHTML == undefined){
                                continue;
                            }
                            if(allChecks[i].parentNode.parentNode.childNodes[6].innerHTML == ''){
                                continue;
                            }
                            var date = allChecks[i].parentNode.parentNode.childNodes[6].innerHTML;
                            date = Date.parse(date);
                            if(isNaN(date)){ continue; }
                            if(currentTime > date){
                                allChecks[i].checked = true;
                                count++;
                            }
                        }
                        if(confirm('Are you sure you want to move these "'+count+'" Topics to the selected board while keeping the current Sort Order?')){
                            $('NewBoardID').value = Value;
                            document.forms[0].submit();
                        }

                        break;
                    case 'Alphabetically':
                        var StartingWithA = $('CleanBoard_StartingWithA');
                        var InStepsOfSign = $('CleanBoard_InStepsOfSign');
                        var InStepsOf = $('CleanBoard_InStepsOf');




                        break;
                    case 'Custom':
                        var Custom = $('CleanBoard_Custom');





                        break;
                    default:
                        return;
                        break;
                }
                break;
        }
    }
    var allInputs = document.getElementsByTagName('input');			// get all TD elements
    for(var i=0; i<allInputs.length; ++i){
        if(allInputs[i].name == 'Delete'){
            var deleteElem = allInputs[i];
        }
        if(allInputs[i].name == 'Move'){
            allInputs[i].id = 'Move';
        }
    }
    if(deleteElem === undefined){ return; }
    if(document.forms[0].name == 'EditBoard'){
    }else{
        return;
    }
    var table = deleteElem.parentNode.parentNode.parentNode;
    var row = table.insertRow(-1);
    var cell = row.insertCell(0);
    row.bgColor = deleteElem.parentNode.parentNode.bgColor;
    cell.colSpan = '7';
    var options = "<option>Choose One</option><option>Check Boxes</option>";
    var allSelects = document.getElementsByTagName('select');			// get all TD elements
    for(var i=0; i<allSelects.length; ++i){
        if(allSelects[i].name == 'NewBoardID'){
            var moveElem = allSelects[i];
            allSelects[i].id = 'NewBoardID';
            break;
        }
    }
    if(moveElem === undefined){ 
    }else{
        for(var i=0; i<moveElem.options.length; ++i){
            options += '<option value="'+moveElem.options[i].value+'">MoveTo: '+moveElem.options[i].text+'</option>';
        }
    }
    cell.innerHTML = '</form>CleanBoard: <select id="CleanBoard">'+options+'</select>'+
        '<span id="CleanBoard_SpanOlderThen" style="display: none;"> any Posts Older Then <select id="CleanBoard_Days"><option value="0">0 Days</option><option value="7">7 Days</option><option value="14">14 Days</option><option selected value="30">1 Month</option><option value="60">2 Months</option><option value="90">3 Months</option><option value="120">4 Months</option><option value="150">5 Months</option><option value="180">6 Months</option><option value="365">1 Year</option></select></span>'+
        '<span id="CleanBoard_SpanSortOrder" style="display: none;"> and set at Sort Order <select id="CleanBoard_SortOrder"><option>Choose One</option><option>Keep Current Sort Order</option><option>Alphabetically</option><option>Custom</option></select></span>'+
        '<span id="CleanBoard_SpanStartingWithA" style="display: none;"> starting with A at <input value="0" size="5" id="CleanBoard_StartingWithA" /> and in steps of <select id="CleanBoard_InStepsOfSign"><option selected>-</option><option>+</option></select><input value="2" size="3" id="CleanBoard_InStepsOf"/></span>'+
        '<span id="CleanBoard_SpanCustom" style="display: none;"> at SortOrder <input value="0" size="5" id="CleanBoard_Custom" /></span>'+
        '<span id="CleanBoard_SpanExplain" style="display: none;"><button id="CleanBoard_Explain" onclick="return false">  Explain</button></span>'+
        '<span id="CleanBoard_SpanCleanBoard" style="display: none;"><button id="CleanBoard_CleanBoard" onclick="return false">  CleanBoard</button></span>';
    $("CleanBoard").addEventListener("change", function(){cleanBoard_onChange(this);}, false);
    $("CleanBoard_SortOrder").addEventListener("change", function(){cleanBoard_onChangeSortOrder(this);}, false);
    $("CleanBoard_Explain").addEventListener("click", function(){cleanBoard_Explain(this);}, false);
    $("CleanBoard_CleanBoard").addEventListener("click", function(){cleanBoard_CleanBoard();}, false);

}
/*
*  END: CLEAN BOARD
*/	


/*
*  LINKS
*/
function links() {
    function links_ShowEdits() {
        var links = getSetting( 'Links', '' );
        var linksarr = links.split('::::::');
        if(!editing){
            alert('This function will allow you to select Menu Items you dont use and move them to the bottom of the Menu to get them out of the way. - Simply click the X next to the Menu Item.');
            for(var i=0; i<allTR.length; ++i){
                if(i<=2 || allTR[i].id.slice(0, 14) == 'EditMenuTitle_'){
                    allTR[i].firstChild.colSpan = 2;
                    if(allTR[i].style.display == 'none'){
                        allTR[i].style.display = '';
                        EditMenuIndex = i;
                    }
                }else{
                    var cell = allTR[i].insertCell(0);
                    cell.align = 'center';
                    if(allTR[i].id.slice(0, 6) == 'Moved_'){
                        allTR[i].style.display = '';
                        cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: x-small">+</font></span>';
                        cell.addEventListener("click", function(){links_UnMoveMenuItem(this);}, false);
                    }else{
                        cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: x-small">X</font></span>';
                        cell.addEventListener("click", function(){links_MoveMenuItem(this);}, false);
                    }
                }
            }
            editing = true;
        }else{
            for(var i=0; i<allTR.length; ++i){
                if(allTR[i].firstChild.colSpan == 2){
                    allTR[i].firstChild.colSpan = 1;
                }else{
                    var cell = allTR[i].deleteCell(0);
                    if(allTR[i].id.slice(0, 6) == 'Moved_'){
                        allTR[i].style.display = 'none';
                    }
                }
            }
            allTR[EditMenuIndex].style.display = 'none';
            x = EditMenuIndex-1;
            allTR[x].style.display = 'none';
            editing = false;
        }
    }
    function links_MoveMenuItem(t) {
        var row = t.parentNode;
        var obj = row.cloneNode(true);
        var id = obj.id.substr(9);
        obj.id = 'Moved_'+id;
        var s = row.parentNode.appendChild(obj);
        s.firstChild.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: x-small">+</font></span>';
        s.firstChild.addEventListener("click", function(){links_UnMoveMenuItem(this);}, false);
        row.style.display = 'none';
        val = row.lastChild.firstChild.innerHTML;
        var links = getSetting( 'Links', '' );
        if(links == ''){
            setSetting( 'Links', ':::'+val+':::' );
            return;
        }
        if(links.indexOf(':::'+val+':::')!=-1){
            return;
        }
        setSetting( 'Links', links+':::'+val+':::' );
    }
    function links_UnMoveMenuItem(t) {
        var row = t.parentNode;
        var id = row.id.substr(6);
        var s = document.getElementById('EditMenu_'+id);
        s.style.display = '';
        row.parentNode.deleteRow(row.rowIndex);
        var links = getSetting( 'Links', '' );
        links = links.replace(':::'+row.lastChild.firstChild.innerHTML+':::', '');
        setSetting( 'Links', links );
    }
    function links_ResetMenuVerify(t) {
        var answer = confirm("Are you sure you want to clear your Menu Filter Links?");
        if(answer){ links_ResetMenu(t); }else{ return; }
    }
    function links_ResetMenu(t) {
        setSetting( 'Links', '' );
        for(var i=0; i<allTR.length; ++i){
            if(allTR[i] === undefined){
                break;
            }
            if(allTR[i].firstChild.colSpan == 2){
                allTR[i].firstChild.colSpan = 1;
            }else{
                if(editing){
                    var cell = allTR[i].deleteCell(0);
                }
                allTR[i].style.display = '';

                if(allTR[i].id.slice(0, 6) == 'Moved_'){
                    allTR[i].parentNode.deleteRow(allTR[i].rowIndex);
                    i--;
                }
            }
        }
        editing = false;
        allTR[allTR.length-1].style.display = 'none';
        allTR[allTR.length].style.display = 'none';
    }
    function links_MarkBoardRead(t) {
        var boardIDVal = t.id.substr(9);
        var s = myRef.document.getElementById('table_'+boardIDVal);
        s.style.display = 'none';
        var boardNameVal = myRef.document.getElementById('boardIDName_'+boardIDVal).innerHTML;
        setSetting( 'Posts_'+boardIDVal, ':AllRead-'+curTime+':' );
        //notify('All topics marked as Read in '+boardNameVal+'.');//GOES TO WRONG WINDOW
    }
    function links_IgnoreBoard(t) {
        var boardIDVal = t.id.substr(12);
        var boardNameVal = myRef.document.getElementById('boardIDName_'+boardIDVal).innerHTML;
        var s = myRef.document.getElementById('table_'+boardIDVal);
        s.style.display = 'none';
        setSetting( 'Posts_'+boardIDVal, ':AllRead-'+curTime+':' );
        var ignoredBoards = getSetting( 'boards_ignore', '::::::' );
        setSetting('boards_ignore', ignoredBoards+boardNameVal+'::::::');
        //notify('All topics marked as Read in '+boardNameVal+'.');//GOES TO WRONG WINDOW
    }
    function links_RefreshBoard(t) {
        var boardIDVal = t.id.substr(8);
        var boardNameVal = myRef.document.getElementById('boardIDName_'+boardIDVal).innerHTML;
        var s = myRef.document.getElementById('Refresh_'+boardIDVal);
        s.innerHTML = 'Refreshing...   ';
        var id = myRef.document.getElementById('ID_'+boardIDVal).innerHTML;
        links_CheckforNewPostsOnBoard(id, 1);
    }

    function links_CheckforNewPostsVerify(t) {
        var answer = confirm("This process loads all Boards and checks them for new posts. This may take awhile on slower internets as it runs in the background. You must have Popup blocker disabled for GHQ in order to get the full experience. Are you sure you want to continue?");
        if(answer){ links_CheckforNewPosts(t); }else{ return; }
    }
    function links_CheckforNewPostsOnBoard(i, update) {
        if(boardLinks[i] === undefined || boardLinks[i] === null){ myRef.document.close(); return; }
        var patt4=/ShowPost\.asp\?BoardID=[0-9]{1,}&ThreadID=[0-9]{1,}&site=[A-z]{1,8}&lastpost=.{14,20}(AM|PM)\b/i; //SHowPost URLS
        var patt1=/ShowPost\.asp\?BoardID=[0-9]{1,}/; //BoardID
        var patt2=/=.{14,20}(AM|PM)/gi; //PostTime
        var patt3=/ThreadID=[0-9]{1,}/i; //ThreadID
        var patt5=/[0-9]{1,2}.[0-9]{1,2}.[0-9]{4}.[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}.(AM|PM)/i; //PostTime

        var OldBoardID = 0;
        var count = 0;
        var newPostsText = '';
        GM_xmlhttpRequest({
            method: 'GET',
            url: menuLinksArr[boardLinks[i]].href,
            headers: {
                'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
                'main': 'application/scriptVersion+xml,application/xml,text/xml',
            },
            onload: function(responseDetails) {
                if(curTime == "" || curTime === undefined){
                    curTime = responseDetails.responseText.match(patt5);
                    curTime = Date.parse(curTime[0]);
                }
                var youngestTime = curTime - 60*60*24*7*1000;

                var rows = responseDetails.responseText.split(/<\/TR>/i); //Gets every ShowPost Link
                if(rows === null){ i++; links_CheckforNewPostsOnBoard(i, 0); }
                for(var x=0; x<rows.length; ++x){
                    var response = rows[x].match(patt4); //Gets every ShowPost Link
                    if(response === null){ continue; }
                    BoardID = response[0].match(patt1);
                    BoardID = BoardID[0].slice(21);
                    if(BoardID == 0){
                        continue;
                    }
                    if(BoardID != OldBoardID){
                        OldBoardID = BoardID;
                        var Posts = getSetting( 'Posts_'+BoardID, ':' );
                        var t = Posts.indexOf(':AllRead-');
                        if(t!=-1){
                            var tEnd = Posts.indexOf(':', t+1);
                            var val = Posts.slice(t, tEnd);
                            val = val.replace(':', '');
                            var allReadTime = val.split('-')[1];
                        }else{
                            var allReadTime = 0;
                        }
                    }
                    var PostDate = response[0].match(patt2);
                    var PostDate = PostDate[0].slice(1);
                    PostDate = Date.parse(PostDate);
                    if(youngestTime >= PostDate || allReadTime >= PostDate){
                        continue;
                    }
                    var ThreadID = response[0].match(patt3);
                    var ThreadID = ThreadID[0].slice(9);
                    var t = Posts.indexOf(':'+ThreadID+'-');
                    if(t!=-1){
                        var tEnd = Posts.indexOf(':', t+1);
                        var val = Posts.slice(t, tEnd);
                        val = val.replace(':', '');
                        var lastReadTime = val.split('-')[1];
                        if(PostDate <= lastReadTime){
                            continue;
                        }
                    }
                    count++;
                    if(newPostsArr[BoardID] === undefined){
                        newPostsArr[BoardID] = new Array;
                    }
                    if(newPostsArr[BoardID][ThreadID] === undefined){
                        var cols = rows[x].split(/<\/td>/i); //Gets every TD of a row
                        if(cols === null){ continue; }
                        if(cols[6] === undefined){ //NO EDIT BOARDS
                            var t = cols[0].indexOf('>');
                            var Topic = cols[0].slice(t+1);                         
                            //var Topic = cols[0].slice(t+10);
                            //var Topic = '<a target="main" href=\'Boards/'+Topic;
                            var t = cols[1].indexOf('>');
                            var Originator = cols[1].slice(t+1);
                            var t = cols[2].indexOf('>');
                            var Posts = cols[2].slice(t+1);
                            var t = cols[3].indexOf('>');
                            var Last_Post = cols[3].slice(t+1);                  
                        }else{
                            var t = cols[3].indexOf('>');
                            var Topic = cols[3].slice(t+1);
                            //var Topic = cols[3].slice(t+10);
                            //var Topic = '<a target="main" href=\'Boards/'+Topic;
                            var t = cols[4].indexOf('>');
                            var Originator = cols[4].slice(t+1);
                            var t = cols[5].indexOf('>');
                            var Posts = cols[5].slice(t+1);
                            var t = cols[6].indexOf('>');
                            var Last_Post = cols[6].slice(t+1);
                        }
                        newPostsText = newPostsText+'<tr bgcolor="#222222">'+Topic+'</td><td width="15%" nowrap>'+Originator+'</td><td align="center" width="5%" nowrap>'+Posts+'</td><td width="25%" nowrap>'+Last_Post+'</td></tr>';
                    }
                }
                if(count >= 1){
                    if(update === 1){
                        if(count >= 2){ pleral = 's'; }else{ pleral = ''; }
                        var t = '<br><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr bgcolor="#222222"><td colspan=4><table width="100%"><tr><td><span onmouseover="this.style.cursor=\'pointer\';" id="Refresh_'+BoardID+'"><img src="http://www.ghqnet.com/sites/SOL/Files/refresh-icon.png"></span> '+menuLinksArr[boardLinks[i]].parentNode.innerHTML+' - '+count+' New Post'+pleral+' - <span onmouseover="this.style.cursor=\'pointer\';" id="MarkRead_'+BoardID+'"><font style="color: Orange; font-size: small"><strong>Mark Board as "Read"</strong></font></span></td><td align="right"><span onmouseover="this.style.cursor=\'pointer\';" id="IgnoreBoard_'+BoardID+'"><font style="color: Orange; font-size: small"><strong>Permanently Ignore Board</strong></font></span></td></tr></table></td></tr><tr bgcolor="#222222"><td width="47.5%"><b>Topic</b></td><td><b>Originator</b></td><td align="center"><b>Posts</b></td><td><b>Last Post</b></td></tr>';
                        t = t + newPostsText;
                        var s = myRef.document.getElementById('table_'+BoardID);
                        s.innerHTML = t;
                        myRef.document.getElementById('MarkRead_'+BoardID).addEventListener("click", function(){links_MarkBoardRead(this);}, false);
                        myRef.document.getElementById('IgnoreBoard_'+BoardID).addEventListener("click", function(){links_IgnoreBoard(this);}, false);
                        myRef.document.getElementById('Refresh_'+BoardID).addEventListener("click", function(){links_RefreshBoard(this);}, false);
                        return;
                    }else{
                        menuLinksArr[boardLinks[i]].parentNode.innerHTML = '<span name="NEW"><img src="http://www.ghqnet.com/sites/SOL/Files/newpost.png"> </span>'+menuLinksArr[boardLinks[i]].parentNode.innerHTML;
                        if(count >= 2){ pleral = 's'; }else{ pleral = ''; }
                        myRef.document.write('<span id="ID_'+BoardID+'" style="display:none">'+i+'</span><span id="boardIDName_'+BoardID+'" style="display:none">'+menuLinksArr[boardLinks[i]].innerHTML+'</span><span id="table_'+BoardID+'"><br><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr bgcolor="#222222"><td colspan=4><table width="100%"><tr><td><span onmouseover="this.style.cursor=\'pointer\';" id="Refresh_'+BoardID+'"><img src="http://www.ghqnet.com/sites/SOL/Files/refresh-icon.png"></span> '+menuLinksArr[boardLinks[i]].parentNode.innerHTML+' - '+count+' New Post'+pleral+' - <span onmouseover="this.style.cursor=\'pointer\';" id="MarkRead_'+BoardID+'"><font style="color: Orange; font-size: small"><strong>Mark Board as "Read"</strong></font></span></td><td align="right"><span onmouseover="this.style.cursor=\'pointer\';" id="IgnoreBoard_'+BoardID+'"><font style="color: Orange; font-size: small"><strong>Permanently Ignore Board</strong></font></span></td></tr></table></td></tr><tr bgcolor="#222222"><td width="47.5%"><b>Topic</b></td><td><b>Originator</b></td><td align="center"><b>Posts</b></td><td><b>Last Post</b></td></tr>');
                        myRef.document.write(newPostsText);
                        myRef.document.write('</table></span>');
                        myRef.document.getElementById('MarkRead_'+BoardID).addEventListener("click", function(){links_MarkBoardRead(this);}, false);
                        myRef.document.getElementById('IgnoreBoard_'+BoardID).addEventListener("click", function(){links_IgnoreBoard(this);}, false);
                        myRef.document.getElementById('Refresh_'+BoardID).addEventListener("click", function(){links_RefreshBoard(this);}, false);
                    }
                }else{
                    if(update === 1){
                        var t = '<br><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr bgcolor="#222222"><td colspan=4><table width="100%"><tr><td><span onmouseover="this.style.cursor=\'pointer\';" id="Refresh_'+BoardID+'"><img src="http://www.ghqnet.com/sites/SOL/Files/refresh-icon.png"></span> '+menuLinksArr[boardLinks[i]].parentNode.innerHTML+' - 0 New Posts</td><td align="right"><span onmouseover="this.style.cursor=\'pointer\';" id="IgnoreBoard_'+BoardID+'"><font style="color: Orange; font-size: small"><strong>Permanently Ignore Board</strong></font></span></td></tr></table></td></tr><tr bgcolor="#222222"><td width="47.5%"><b>Topic</b></td><td><b>Originator</b></td><td align="center"><b>Posts</b></td><td><b>Last Post</b></td></tr><tr bgcolor="#222222"><td colspan="4" align="center">No New Posts</td></tr>';
                        var s = myRef.document.getElementById('table_'+BoardID);
                        s.innerHTML = t;
                        myRef.document.getElementById('IgnoreBoard_'+BoardID).addEventListener("click", function(){links_IgnoreBoard(this);}, false);
                        myRef.document.getElementById('Refresh_'+BoardID).addEventListener("click", function(){links_RefreshBoard(this);}, false);
                        return;
                    }
                }
                notify('<center>'+menuLinksArr[boardLinks[i]].innerHTML+'<br>'+count+' New Posts</center>');
                i++;
                percentage = i / totalboards;
                percentage = Math.round(percentage * 100);
                myRef.document.getElementById('progress').innerHTML = i;
                myRef.document.getElementById('percent').innerHTML = percentage;
                var a = myRef.document.getElementsByTagName('a');
                for (var z = 0; z <a.length; z++){ 
                    a[z].target = "main"; 
                    if(a[z].href.indexOf('ShowPost.asp') != -1 && a[z].href.indexOf('Boards/') == -1){
                        //if(a[z].innerHTML == 'Newest'){
                        t = a[z].href.indexOf('ghqnet.com/') //SPLIT THE HTTP:SOL SHIT OUT AND PUT IN BOARDS/


                        if(t!=-1){
                            var val = a[z].href.slice(t+11);
                            a[z].href = 'Boards/'+val;
                        }
                    }

                }
                links_CheckforNewPostsOnBoard(i, 0);
            }
        });
    }
    function links_CheckforNewPosts(t) {
        var allNew = document.getElementsByName("NEW");
        for(var i=0; i<allNew.length; ++i){
            allNew[i].parentNode.removeChild( allNew[i] ); 
            i--;
        }
        myRef = window.open('about:blank','newPostsPage','left=20,top=20,width=1000,height=500,scrollbars=1');
        if(ignorecount >= 2){ pleral = 's'; }else{ pleral = ''; }
        myRef.document.body.innerHTML = ''; //FIREFOX OLD
        myRef.document.write('<meta content="Earth, Military, Army, Navy, Marines, Air Force, Jets, Troops, Spies, Games" name="keywords"><html><head><meta content="en-us" http-equiv="Content-Language"></head><body background="" bgcolor="black" link="#00C0FF" text="#DDDDDD" vlink="#d3d3d3"><style type="text/css"> a:hover {	text-decoration: underline; } td { font-family: verdana, ariel, Helvetica, sans-serif; font-size: 14px; } .style1 { text-align: center;	font-size: small; } .style2 { font-size: x-small; } </style><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr bgcolor="#222222"><td class="style1"><strong>Boards with New Posts<br><span id="progress">0</span> of '+count+' Processed - <span id="percent">0</span>% Completed - Ignoring '+ignorecount+' Board'+pleral+'<br></strong><span class="style2">Click on a Board Name or a Post to go to that page.<br>Click on &quot;Mark Board Read&quot; to mark all posts as read.<br>Click &quot;Ignore Board&quot; to no longer parse this board for new Posts. (Less Boards Monitored = Quicker Processing)</span></td></tr></table>');
        links_CheckforNewPostsOnBoard(0, 0);
    }
    var curTime = "";
    var myRef = '';
    var patt5=/ShowBoard\.asp\?board=.+/i; //Is it a board link?
    var menuLinksArr = document.getElementsByTagName("a");
    var boardLinks = new Array();
    var newPostsArr = new Array();
    var temp = '';
    var count = 0;
    var ignorecount = 0;
    var boardsignore = getSetting( 'boards_ignore', ' ' );
    for(var i = 0; i<menuLinksArr.length; i++) {
        var isBoard = menuLinksArr[i].href.match(patt5);
        if(isBoard === null){ continue; }
        if(count == 0 && ignorecount == 0){
            temp = menuLinksArr[i].innerHTML;
        }else{
            temp = temp+'::::::'+menuLinksArr[i].innerHTML;
        }
        if(boardsignore.indexOf('::::::'+menuLinksArr[i].innerHTML+'::::::') != -1){
            ignorecount++;
            continue;
        }
        boardLinks[count] = i;
        count++;
    }
    var totalboards = count;
    setSetting( 'menuBoards', temp );
    var allTR = document.getElementsByTagName('tr');			// get all TD elements
    var editing = false;
    var row = allTR[0].parentNode.insertRow(0);
    var cell = row.insertCell(0);
    cell.bgColor = allTR[1].bgColor;
    row.bgColor = allTR[1].bgColor;
    cell.align = 'center';
    cell.innerHTML = '<font color="orange"><strong>GHQEditor</strong></font>';
    cell.addEventListener("click", function(){links_ShowEdits();}, false);

    var row = allTR[0].parentNode.insertRow(1);
    var cell = row.insertCell(0);
    cell.bgColor = allTR[3].bgColor;
    row.bgColor = allTR[3].bgColor;
    cell.align = 'center';
    cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: 12px;">Edit Menu Items</font></span>';
    cell.addEventListener("click", function(){links_ShowEdits();}, false);

    var row = allTR[0].parentNode.insertRow(2);
    var cell = row.insertCell(0);
    cell.bgColor = allTR[1].bgColor;
    row.bgColor = allTR[1].bgColor;
    cell.align = 'center';
    cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: 12px;">Reset Menu Items</font></span>';
    cell.addEventListener("click", function(){links_ResetMenuVerify();}, false);

    var row = allTR[0].parentNode.insertRow(3);
    var cell = row.insertCell(0);
    cell.bgColor = allTR[1].bgColor;
    row.bgColor = allTR[1].bgColor;
    cell.align = 'center';
   
    if(browser == 'Firefox'){
        cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: 12px; text-decoration: line-through;">Check 4 New Posts</font></span>';
    }else{
        cell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: 12px;">Check 4 New Posts</font></span>';
        cell.addEventListener("click", function(){links_CheckforNewPostsVerify();}, false);
    }

    var row = allTR[0].parentNode.insertRow(-1);
    var cell = row.insertCell(0);
    cell.align = 'center';
    cell.innerHTML = '<font style="color: Orange; font-size: 14px;"><b>____________</b></font>';
    row.style.display = 'none';
    row.id = 'EditMenuTitle_'+row.rowIndex;
    var row = allTR[0].parentNode.insertRow(-1);
    var cell = row.insertCell(0);
    cell.bgColor = allTR[0].bgColor;
    row.bgColor = allTR[0].bgColor;
    row.id = 'EditMenuTitle_'+row.rowIndex;
    cell.align = 'center';
    cell.innerHTML = '<font style="color: Orange; font-size: 14px;"><b>HIDDEN ITEMS</b></font>';
    row.style.display = 'none';
    row.id = 'EditMenuTitle_'+row.rowIndex;
    var links = getSetting( 'Links', '' );
    var linksarr = links.split('::::::');
    if(linksarr.length != 0){
        for(var i=0; i<allTR.length; ++i){
            var val = allTR[i].firstChild.firstChild.innerHTML;
            if(allTR[i].id.slice(0, 14) == 'EditMenuTitle_' || allTR[i].id.slice(0, 6) == 'Moved_'){
                break;
            }
            if(allTR[i].id == ''){
                allTR[i].id = 'EditMenu_'+allTR[i].rowIndex;
            }
            if(links.indexOf(':::'+val+':::')!=-1){
                var obj = allTR[i].cloneNode(true);
                var id = obj.id.substr(9);
                obj.id = 'Moved_'+id;
                var s = allTR[i].parentNode.appendChild(obj);
                s.firstChild.addEventListener("click", function(){links_UnMoveMenuItem(this);}, false);
                allTR[i].style.display = 'none';
                s.style.display = 'none';
            }
        }
    }
}
/*
*  END: LINKS
*/	

/*
*  EDIT SITE MANAGER HOMEPAGE
*/
function siteManager() {
    var allTA = document.getElementsByTagName('textarea');			// get all TD elements
    for(var i=0; i<allTA.length; ++i){
        if(allTA[i].name == 'HeadlineTitle'){
            allTA[i].cols = 75;
            allTA[i].rows = 6;
        }
    }
}
/*
*  END: EDIT SITE MANAGER
*/	

/*
*  TARGET SELECTOR
*/	
function targetInfo() {
    function targetInfo_hideRow(t, type) {
        if(Hide[t.id] === undefined){
            Hide[t.id] = new Array();
        }
        if(Hide[t.id][type] === undefined){
            Hide[t.id][type] = true;
        }
        t.style.display = 'none';
    }
    function targetInfo_unHideRow(t, type) {
        if(Hide[t.id] === undefined){
            return;
        }
        if(Hide[t.id][type] === undefined){
            return;
        }
        delete Hide[t.id][type];
        for (var i = 0; i < Hide[t.id].length; ++i){ //CHROME FIX - WAS a for each
            if(Hide[t.id][i]){
                return;
            }
        }
        delete Hide[t.id];
        t.style.display = '';
    }
    function targetInfo_filter(t) {
        var Name = t.id.substr(7);
        var Value = t.value; 
        var CellIndex = t.parentNode.cellIndex; 
        switch (Name){
            case 'GDI':
                for(var i=0; i<allTR.length; ++i){
                    if(allTR[i].id === undefined){ continue; }
                    if(allTR[i].id == ''){ continue; }
                    if(Value == ''){
                        targetInfo_unHideRow(allTR[i], Name);
                        continue;
                    }
                    if(Value == allTR[i].cells[CellIndex].firstChild.innerHTML){
                        targetInfo_unHideRow(allTR[i], Name);
                    }else{
                        targetInfo_hideRow(allTR[i], Name);
                    }
                }
                break;
            case 'Age':
            case 'NW':
            case 'Land':
            case 'Spal':
            case 'SDI':
                var Operator = Value.substr(0, 1); 
                var Value = Value.substr(1); 
                for(var i=0; i<allTR.length; ++i){
                    if(allTR[i].id === undefined){ continue; }
                    if(allTR[i].id == ''){ continue; }
                    if(Value == ''){
                        targetInfo_unHideRow(allTR[i], Name);
                        continue;
                    }
                    if(Name == 'Age'){
                        var TRValue = allTR[i].cells[CellIndex].firstChild.firstChild.innerHTML;
                    }else if( Name == 'Spal'){
                        var TRValue = allTR[i].cells[CellIndex].firstChild.innerHTML;
                    }else if( Name == 'SDI'){
                        var TRValue = allTR[i].cells[CellIndex].firstChild.firstChild.innerHTML.slice(0, -1);
                    }else if( Name == 'Land'){
                        var TRValue = allTR[i].cells[CellIndex].firstChild.innerHTML.replace(/\,/g,'');
                    }else{
                        var TRValue = allTR[i].cells[CellIndex].firstChild.innerHTML;
                    }

                    if(Operator == '>'){
                        if(parseFloat(TRValue) >= parseFloat(Value)){
                            targetInfo_unHideRow(allTR[i], Name);
                        }else{
                            targetInfo_hideRow(allTR[i], Name);
                        }
                    }else{
                        if(parseFloat(TRValue) < parseFloat(Value)){
                            targetInfo_unHideRow(allTR[i], Name);
                        }else{
                            targetInfo_hideRow(allTR[i], Name);
                        }
                    }
                }
                break;
            case 'NWDiff':
            case 'LandDiff':
                for(var i=0; i<allTR.length; ++i){
                    if(allTR[i].id === undefined){ continue; }
                    if(allTR[i].id == ''){ continue; }
                    if(Value == ''){
                        targetInfo_unHideRow(allTR[i], Name);
                        continue;
                    }
                    if(allTR[i].cells[CellIndex].firstChild.innerHTML != '' && allTR[i].cells[CellIndex].firstChild.innerHTML != '0'){
                        targetInfo_unHideRow(allTR[i], Name);
                    }else{
                        targetInfo_hideRow(allTR[i], Name);
                    }
                }
                break;
            default:
                break;
        }
    }
    function targetInfo_quickSets(t) {
        if(t == 'UnHide'){
            for(var i=0; i<allTR.length; ++i){
                targetInfo_unHideRow(allTR[i], 'Hide');
            }
        }else if(t == 'Filters'){
            var allSelects = document.getElementsByTagName('select');
            for(var i=0; i<allSelects.length; ++i){
                for(var x=0; x<allSelects[i].length; ++x){
                    if(allSelects[i].options[x].value == ''){ 
                        allSelects[i].selectedIndex = allSelects[i].options[x].index;
                        break;
                    }
                }
            }
            for(var x=0; x<allTR.length; ++x){
                var Name = allTR[x].id.substr(7);
                allTR[x].style.display = '';
                delete Hide;
                var Hide = new Array;
            }
        }else{
            var NW = $('Filter_NWDiff');
            var Land = $('Filter_LandDiff');
            var NW_Name = NW.id.substr(7);
            var NW_Value = NW.value; 
            var NW_CellIndex = NW.parentNode.cellIndex; 
            var Land_Name = Land.id.substr(7);
            var Land_Value = Land.value; 
            var Land_CellIndex = Land.parentNode.cellIndex; 
            for(var x=0; x<allTR.length; ++x){
                var Name = allTR[x].id.substr(7);
                allTR[x].style.display = '';
                delete Hide;
                var Hide = new Array;
                if(allTR[x].id === undefined){ continue; }         
                if(allTR[x].id === ''){ continue; }           
                if(allTR[x].cells[NW_CellIndex].firstChild.innerHTML == '0' && allTR[x].cells[Land_CellIndex].firstChild.innerHTML == '0'){
                    targetInfo_hideRow(allTR[x], Name);
                    window.alert("sometext3");
                }else{
                    targetInfo_unHideRow(allTR[x], Name);
                }
            }
        }
    }
    var allTR = document.getElementsByTagName('tr');			// get all TD elements	
    Hide = new Array();
    Data = new Array();
    var allTH = document.getElementsByTagName('th');			// get all TD elements
    for(var i=0; i<allTH.length; ++i){
        if(allTH[i].innerHTML.slice(-11, -4) == 'Country' ){
            var table = allTH[i].parentNode.parentNode;
            table.id = 'CountryTable';
            var header = 'Number';
            num = 10000;
            for (var x=0; x<table.rows.length; x++) {
                var newCell = table.rows[x].insertCell(i+1);
                newCell.bgColor = '#222222';
                newCell.align = 'center';
                if(x == 0){
                    newCell.innerHTML = '<text color=#DDDDDD><b>'+header+'</b></font>';
                }else{
                    newCell.innerHTML = '';
                    newCell.id = num+'_CountryNumber';
                    num++;
                }
                var newCell = table.rows[x].insertCell(i);
                newCell.bgColor = '#222222';
                newCell.align = 'center';
                if(x == 0){
                    newCell.innerHTML = '<text color=#DDDDDD><b>Hide Country</b></font>';
                }else{
                    newCell.innerHTML = '<span onmouseover="this.style.cursor=\'pointer\'; this.style.textDecoration=\'underline\'" onmouseout="this.style.textDecoration=\'none\'">Hide</span>';
                    newCell.id = 'Hide_'+x;
                    newCell.addEventListener("click", function(){targetInfo_hideRow(this.parentNode, 'Hide');}, false);
                }
            }
        } 
    }
    var sp1 = document.createElement("span");
    sp1.innerHTML = '<table width="100%"><tr><td align="right">QUICKSETS: <button style="color: orange; font-family: Verdana, Helvetica, Arial; font-size: 10 pt; font-weight: bold; background-color: #191919; border: 2px #444444 solid" id="QuickSet_NWLandChange" onClick="return false;">Show only NW OR Land Changes</button> - <button style="color: red; font-family: Verdana, Helvetica, Arial; font-size: 10 pt; font-weight: bold; background-color: #191919; border: 2px #444444 solid" id="QuickSet_UnHide" onClick="return false;">UnHide All Rows</button><button style="color: red; font-family: Verdana, Helvetica, Arial; font-size: 10 pt; font-weight: bold; background-color: #191919; border: 2px #444444 solid" id="QuickSet_Filters" onClick="return false;"><strong>Reset Filters</strong></button></td></td></table>';
    table.parentNode.parentNode.insertBefore(sp1, table.parentNode);
    document.getElementById("QuickSet_NWLandChange").addEventListener("click", function(){targetInfo_quickSets("NWLandChange");}, false);
    document.getElementById("QuickSet_UnHide").addEventListener("click", function(){targetInfo_quickSets("UnHide");}, false);
    document.getElementById("QuickSet_Filters").addEventListener("click", function(){targetInfo_quickSets("Filters");}, false);

    var row = table.insertRow(0);
    var cell = row.insertCell(0);
    cell.colSpan = table.rows[1].cells.length;
    cell.innerHTML = '';
    var allTH = table.getElementsByTagName('th');			// get all TD elements
    var row = table.insertRow(1);
    for(var i=0; i<allTH.length; ++i){
        var column = allTH[i].firstChild.innerHTML;
        Data[allTH[i].cellIndex] = column;
    }
    for(var i=0; i<table.rows[2].cells.length; ++i){
        var cell = row.insertCell(i);
        cell.bgColor = 'black';
        if(i == 0){
            cell.align = 'center';
            cell.innerHTML = '<a href="javascript:location.reload()">Refresh this page</a>';
            continue;
        }
        if(i == 2){
            cell.align = 'right';
            cell.innerHTML = 'FILTERS: ';
            continue;
        }
        cell.align = 'center';
        if(Data[i] === undefined){
            cell.innerHTML = ' ';
            continue;
        }

        switch (Data[i])
        {
            case 'GDI':
                cell.innerHTML = '<select name="Filter_GDI" id="Filter_GDI" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option> </option><option>Y</option></select>';
                document.getElementById("Filter_GDI").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'Age(h)':
                cell.innerHTML = '<select name="Filter_Age" id="Filter_Age" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value="<24"><24</option><option value="<6"><6</option><option value="<2"><2</option><option selected value=""> </option><option value=">2">>2</option><option value=">6">>6</option><option value=">12">>12</option><option value=">24">>24</option></select>';
                document.getElementById("Filter_Age").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'NW(M)':
                cell.innerHTML = '<select name="Filter_NW" id="Filter_NW" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value="<5"><5m</option><option value="<1"><1m</option><option value="<0.5"><500k</option><option selected value=""> </option><option value=">0.5">>500k</option><option value=">1">>1m</option><option value=">2">>2m</option><option value=">5">>5m</option></select>';
                document.getElementById("Filter_NW").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'NW Diff':
                cell.innerHTML = '<select name="Filter_NWDiff" id="Filter_NWDiff" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value=""> </option><option value="Changed">Changed</option></select>';
                document.getElementById("Filter_NWDiff").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'Land':
                cell.innerHTML = '<select name="Filter_Land" id="Filter_Land" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value="<10000"><10000</option><option value="<5000"><5000</option><option selected value=""> </option><option value=">1000">>1000</option><option value=">5000">>5000</option><option value=">10000">>10000</option><option value=">20000">>20000</option></select>';
                document.getElementById("Filter_Land").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'Land Diff':
                cell.innerHTML = '<select name="Filter_LandDiff" id="Filter_LandDiff" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value=""> </option><option value="Changed">Changed</option></select>';
                document.getElementById("Filter_LandDiff").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'Spal':
                cell.innerHTML = '<select name="Filter_Spal" id="Filter_Spal" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value="<75"><75</option><option value="<50"><50</option><option value="<25"><25</option><option value="<15"><15</option><option selected value=""> </option></select>';
                document.getElementById("Filter_Spal").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            case 'SDI':
                cell.innerHTML = '<select name="Filter_SDI" id="Filter_SDI" style="color: white; font-family: Verdana, Helvetica, Arial; font-size: 8 pt; background-color: #191919; border: 1px #444444 solid"><option value="<50"><50%</option><option value="<25"><25%</option><option value="<10"><10%</option><option selected value=""> </option></select>';
                document.getElementById("Filter_SDI").addEventListener("change", function(){targetInfo_filter(this);}, false);
                break;
            default:
                continue;
                break;
        }
    }
    var allTD = table.getElementsByTagName('td');			// get all TD elements
    var number = 10000;
    for(var i=0; i<allTD.length; ++i){
        if(allTD[i].parentNode.rowIndex <= 2){
            continue;
        }
        var Name = Data[allTD[i].cellIndex];
        if(Name != undefined){
            allTD[i].id = number+'_'+Name;
            number++;
        }
        if(allTD[i].id == ''){
            continue;
        }
        if(allTD[i].id.substr(6) == 'CountryNumber'){
            var last = i-1;
            //				var num = allTD[last].innerHTML.split('#'); // OLD FIREFOX
            //				allTD[i].innerHTML = num[1].slice(0, -5); // OLD FIREFOX
            var num = allTD[last].firstChild.innerHTML.split('#'); //CHROME FIX
            allTD[i].innerHTML = num[1].slice(0, -1); //CHROME FIX
            allTD[last].noWrap = true;
            allTD[i].parentNode.id = 'TR_'+num[1].slice(0, -1);
        } 
        if(Name == undefined){
            continue;
        } 
        switch (Name)
        {
            case 'GDI':
                var val = allTD[i].innerHTML;
                if(val!=''){
                    allTD[i].bgColor = 'DarkRed';
                }
                break;
            case 'Age(h)':
                var val = allTD[i].firstChild.firstChild.innerHTML;
                if(val <= 2 && val!=''){
                    allTD[i].bgColor = 'DarkGreen';
                }else if(val >= 12){
                    allTD[i].bgColor = 'DarkRed';
                }else if(val >= 3){
                    allTD[i].bgColor = '#800080';
                }else{
                    allTD[i].bgColor = '#222222';
                }
                break;
            case 'NW Diff':
                var val = allTD[i].firstChild.innerHTML;
                if(val!='' && val != 0){
                    allTD[i].bgColor = 'DarkRed';
                }
                break;
            case 'Land Diff':
                var val = allTD[i].firstChild.innerHTML;
                if(val!='' && val!='0'){
                    allTD[i].bgColor = 'DarkRed';
                }
                break;
            case 'Spal':
                var val = allTD[i].firstChild.innerHTML;
                if(val == ''){ continue; }
                if(val <= 25){
                    allTD[i].bgColor = 'DarkGreen';
                }else if(val >= 50){
                    allTD[i].bgColor = 'DarkRed';
                }else{
                    allTD[i].bgColor = '#800080';
                }
                break;
            case 'SDI':
                var val = allTD[i].firstChild.innerHTML.slice(0, -1);
                if(val <= 24 && val!=''){
                    allTD[i].bgColor = 'DarkGreen';
                }else if(val >= 50){
                    allTD[i].bgColor = 'DarkRed';
                }else if(val >= 25){
                    allTD[i].bgColor = '#800080';
                }else{
                    allTD[i].bgColor = '#222222';
                }
                break;

            default:
                continue;
                break;
        }
    }
    var NW = $('Filter_NWDiff');
    var Land = $('Filter_LandDiff');
    if(NW === undefined || Land === undefined){ 
        var b = $('QuickSet_NWLandChange');
        b.parentNode.removeChild(b);
    }

}
/*
*  END: TARGET SELECTOR 
*/	

/*
*  TARGET SELECTOR HOMEPAGE
*/
function targetSelector() {
    function targetSelector_quickSets(t) {
        for(var i=0; i<allInputs.length; ++i){
            if(allInputs[i].type == 'checkbox'){
                allInputs[i].checked = false; 
            }
        }
        for(var i=0; i<Data[t].length; ++i){
            var temp = Data[t][i];
            document.getElementById(temp).checked = true;
        }
    }
    var Data = new Array();
    Data['SiG'] = new Array('Tag', 'Age', 'Networth', 'NWDiff', 'Land', 'LandDiff', 'Spies', 'Spal', 'Missiles');
    Data['Warmod'] = new Array();
    var allTD;												// holds collection of all TD elements
    allTD = document.getElementsByTagName('td');			// get all TD elements
    var allInputs = document.getElementsByTagName("input");
    var number = 0;
    for(var i=0; i<allInputs.length; ++i){
        allInputs[i].id = allInputs[i].name;
        if(allInputs[i].type == 'checkbox'){
            if(allInputs[i].checked == true){
                Data['Warmod'][number] = allInputs[i].id;
                number++;
            }
        }
    }
    for(var i=0; i<allTD.length; ++i){
        if(allTD[i].innerHTML  == "Select your desired fields"){
            allTD[i].innerHTML = allTD[i].innerHTML + '<BR>QUICKSETS: <button style="color: darkturquoise; font-family: Verdana, Helvetica, Arial; font-size: 10 pt; font-weight: bold; background-color: #191919; border: 2px #444444 solid" id="QuickSet_Warmod" onClick="return false;"><strong>Warmod</strong></button>  |  <button style="color: DarkViolet; font-family: Verdana, Helvetica, Arial; font-size: 10 pt; font-weight: bold; background-color: #191919; border: 2px #444444 solid" id="QuickSet_SiG" onClick="return false;"><strong>SiG</strong></button>';
            document.getElementById("QuickSet_Warmod").addEventListener("click", function(){targetSelector_quickSets("Warmod");}, false);
            document.getElementById("QuickSet_SiG").addEventListener("click", function(){targetSelector_quickSets("SiG");}, false);
        } 
    }
}
/*
*  END: TARGET SELECTOR 
*/	

/*
*  EDIT USER HOMEPAGE
*/
function userManager(){
    function userManager_SwitchProcess() {
        var t = myRef2.document.getElementById('StopProcess');
        var t2 = myRef2.document.getElementById('ResumeProcess');
        if(t.style.display == ''){
            t.style.display = 'none';
            t2.style.display = '';
            stopProcess = 'true';
        }else{
            t.style.display = '';
            t2.style.display = 'none';
            var i = stopProcess;
            stopProcess = 'false';
            userManager_CheckUserPermsCheckUser(i);
        }
    }
    function userManager_CheckUserPerms() {
        var answer = confirm('This function may take awhile as it loads each user individually. Are you sure you want to continue?');
        if(answer){ userManager_CheckUserPermsConfirmed(); }else{ return; }
    }
    function userManager_RefreshUser(t) {
        var userIDVal = t.id.substr(8);
        var id = myRef2.document.getElementById('ID_'+userIDVal).innerHTML;
        userManager_CheckUserPermsCheckUser(id, 1);
    }
    function userManager_CheckUserPermsConfirmed() {
        var allInputs = document.getElementsByTagName("input");
        var number = 0;
        for(var i=0; i<allInputs.length; ++i){
            if(allInputs[i].type != 'checkbox'){ continue; }
            var UserID = allInputs[i].value;
            var URL = allInputs[i].parentNode.parentNode.firstChild.firstChild.href;
            var Name = allInputs[i].parentNode.parentNode.childNodes[2].innerHTML;
            var Title = allInputs[i].parentNode.parentNode.childNodes[4].innerHTML;
            Names[number] = new Array();
            Names[number]['UserID'] = UserID;
            Names[number]['URL'] = URL;
            Names[number]['Name'] = Name;
            Names[number]['Title'] = Title;
            number++;
        }
        myRef2 = window.open('','userPermsListing','left=20,top=20,width=1000,height=500,scrollbars=1');
        myRef2.document.body.innerHTML = '';
        myRef2.document.write('<meta content="Earth, Military, Army, Navy, Marines, Air Force, Jets, Troops, Spies, Games" name="keywords"><html><head><meta content="en-us" http-equiv="Content-Language"></head><body background="" bgcolor="black" link="#00C0FF" text="#DDDDDD" vlink="#d3d3d3"><style type="text/css"> a:hover {	text-decoration: underline; } td { font-family: verdana, ariel, Helvetica, sans-serif; font-size: 14px; } .style1 { text-align: center;	font-size: small; } .style2 { font-size: x-small; } </style><table border="0" cellpadding="3" cellspacing="1" width="100%"><tr bgcolor="#222222"><td class="style1"><span id="StopProcess"><button style="color: #FF0000"><strong>Pause Process</strong></button></span><span id="ResumeProcess" style="display:none"><button style="color: #FF0000"><strong>Resume Process</strong></button></span></td><td class="style1"><strong>User Perms Listing<br><span id="progress">0</span> of '+number+' Processed - <span id="percent">0</span>% Complete<br></strong><span class="style2">Click a users name to open their edit window in your main GHQ window.<br>Click the Refresh icon to refresh the current users perms.<br>Click the "I" icon next to a users name to display additonal information.<br>Blueish Text = User has the perm associated with a group.<br>Limegreen Text = User has a perm not associated with a group.</span></td><td> </td></tr></table>');
        myRef2.document.getElementById('StopProcess').addEventListener("click", function(){userManager_SwitchProcess();}, false);
        myRef2.document.getElementById('ResumeProcess').addEventListener("click", function(){userManager_SwitchProcess();}, false);
        totalUsers = number;
        userManager_CheckUserPermsCheckUser(0);
    }
    function userManager_ShowText(id) {
        var t = myRef2.document.getElementById('spanhave'+id);
        var t2 = myRef2.document.getElementById('spandonthave'+id);
        if(t.style.display == 'block'){
            t.style.display = 'none';
            t2.style.display = 'none';
        }else{
            t.style.display = 'block';
            t2.style.display = 'block';
        }
    }
    function userManager_ShowInfo(id) {
        var t = myRef2.document.getElementById('row2_'+id);
        if(t.style.display == ''){
            t.style.display = 'none';
        }else{
            t.style.display = '';
        }
    }
    function userManager_CheckUserPermsCheckUser(cUser, update) {
        if(Names[cUser] === undefined || Names[cUser] === null){ myRef2.document.close(); return; }
        var text = '';
        if(stopProcess !== 'false' && update != 1){
            stopProcess = cUser;
            return;
        }
        GM_xmlhttpRequest({
            method: 'GET',
            url: Names[cUser].URL,
            headers: {
                'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
                'main': 'application/scriptVersion+xml,application/xml,text/xml',
            },
            onload: function(responseDetails) {
                var response = responseDetails.responseText;
                var div = document.createElement('div');
                div.innerHTML = response;
                var allInputs = div.getElementsByTagName('input');			// get all Input elements
                allTD = div.getElementsByTagName('td');			// get all TD elements
                if(runNumber === 0){
                    myRef2.document.write('<table border="0" cellpadding="1" cellspacing="1" width="100%"><tr id="PermRow" bgcolor="#222222"><td nowrap> </td><td nowrap> </td>');
                    var c = 0;
                    for(var x=0; x<allInputs.length; ++x){
                        if(allInputs[x].name != 'Permissions'){ continue; }
                        var permname = allInputs[x].parentNode.parentNode.childNodes[1].innerHTML;
                        PermList[allInputs[x].value] = permname;
                        myRef2.document.write('<td nowrap width="50px" align="center"><p style="font-size: xx-small">'+permname+'</p></td>');
                        if(c === 25 || c === 50 || c === 75 || c === 100 || c === 125 || c === 150 || c === 175 || c === 200){
                            myRef2.document.write('<td> </td><td> </td>');
                            totalCols++;
                            totalCols++;
                        }
                        permname = permname.replace('&amp;', '&');
                        Perms[permname] = new Array();
                        Perms[permname]['InGroup'] = 0;
                        Perms[permname]['Name'] = permname;
                        PermNames[c] = permname;
                        c++;
                        totalCols++;
                    }
                    myRef2.document.write('</tr>');
                    if(Clan_Clan == 'sol'){
                        Data = solUserGroups(allTD);
                    }
                }
                for(var x=0; x<allInputs.length; ++x){
                    if(allInputs[x].name != 'Permissions'){ continue; }
                    var permname = PermList[allInputs[x].value];
                    permname = permname.replace('&amp;', '&');
                    if(allInputs[x].checked === true){ 
                        Perms[permname]['UserHas'] = 1;
                    }else{
                        Perms[permname]['UserHas'] = 0;
                    }
                    Perms[permname]['UserCount'] = 0;
                    Perms[permname]['InUsersGroup'] = 0;
                }
                var moves = '';
                if(Clan_Clan == 'sol'){
                    //PARSE GROUPS
                    for (var i=0;i<Data.length;i++){
                        var userhave = 1;
                        for (var x=0;x<Data[i]['Perms'].length;x++){
                            var temp = Data[i]['Perms'][x];
                            if(Perms[temp] === undefined){
                            }else{
                                if(Perms[temp]['UserHas'] == 0){
                                    userhave = 0;
                                }
                            }
                        }
                        if(userhave == 1){
                            for (var x=0;x<Data[i]['Perms'].length;x++){
                                var temp = Data[i]['Perms'][x];
                                if(Perms[temp] === undefined){
                                }else{
                                    Perms[temp]['UserCount']++;
                                    Perms[temp]['InUsersGroup'] = 1;
                                }
                            }
                        }
                    }
                    var moves = '<tr><td bgcolor="'+bgcolor+'" colspan="3" align="center"><span style="font-size: xx-small"><strong>Group View</strong></span></td></tr><tr><td bgcolor="'+bgcolor+'" align="center"><span style="font-size: xx-small"><strong>Dont Have</strong></td> <td bgcolor="'+bgcolor+'"></td><td bgcolor="'+bgcolor+'" align="center"><span style="font-size: xx-small"><strong>Have</strong></td></tr>';
                    for (var i=0;i<Data.length;i++){
                        if(bgcolor == bgcolor1){ bgcolor = bgcolor2; }else{ bgcolor = bgcolor1; }
                        var groupName = Data[i]['Title'];
                        var userhave = 1;
                        var showpermslisthave = '';
                        var showpermslistdonthave = '';
                        for (var x=0;x<Data[i]['Perms'].length;x++){
                            var temp = Data[i]['Perms'][x];
                            if(Perms[temp] === undefined){
                            }else{
                                if(Perms[temp]['UserCount'] > 1){
                                    var color = 'grey';
                                }else{
                                    var color = 'green';
                                }
                                if(Perms[temp]['UserHas'] == 1){
                                    showpermslisthave = showpermslisthave + '<font color="'+ color +'">' + temp + '</font><BR>';
                                }else{
                                    showpermslistdonthave = showpermslistdonthave + '<font color="'+ color +'">' + temp + '</font><BR>';
                                    userhave = 0;
                                }					
                            }
                        }
                        var spanhave = '<span id="spanhave_'+Names[cUser]['UserID']+'_'+ groupName +'" class="box" return false;" style="display:none; font-size: xx-small"><br><br>'+showpermslisthave+'</span>';
                        var spandonthave = '<span id="spandonthave_'+Names[cUser]['UserID']+'_'+ groupName +'" class="box" return false;" style="display:none; font-size: xx-small"><br><br>'+showpermslistdonthave+'</span>';
                        var color = Data[i]['Color'];
                        if(userhave == 1){
                            moves = moves + '<tr><td align="right" bgcolor="'+bgcolor+'" valign="top" width="200px"><br>'+spandonthave+'</td><td bgcolor="'+bgcolor+'"> </td><td width="200px" valign="top" bgcolor="'+bgcolor+'" id="_'+Names[cUser]['UserID']+'_'+groupName +'"><p style="color: '+ color +'; font-size: xx-small">' + groupName + '</font>' + spanhave + '</td></tr>';
                        }else{
                            moves = moves + '<tr><td align="right" bgcolor="'+bgcolor+'" valign="top" width="200px" id="_'+Names[cUser]['UserID']+'_'+groupName +'"><p style="color: '+ color +'; font-size: xx-small">' + groupName + '</font>' + spandonthave +'</td><td bgcolor="'+bgcolor+'"> </td><td width="200px" valign="top" bgcolor="'+bgcolor+'"><br>' + spanhave + '</td></tr>';
                        }
                    }	
                }
                var c = 0;
                var nig = 0;
                var text = '';
                for(var x=0; x<allInputs.length; ++x){
                    if(allInputs[x].name != 'Permissions'){ continue; }
                    if(allInputs[x].checked === true){ 
                        var permname = PermList[allInputs[x].value];
                        permname = permname.replace('&amp;', '&');
                        if(Perms[permname]['UserCount'] >= 1){
                            text = text+'<td nowrap bgcolor="#006666"> </td>';
                        }else{
                            text = text+'<td nowrap bgcolor="limegreen"> </td>';
                            nig++;
                        }
                    }else{
                        text = text+'<td nowrap bgcolor="#5B0000"> </td>';
                    }
                    if(c === 25 || c === 50 || c === 75 || c === 100 || c === 125 || c === 150 || c === 175 || c === 200){
                        text = text+'<td nowrap bgcolor="#222222"><p style="font-size: xx-small"><a target="main" href="http://sol.ghqnet.com/Admin/EditUser.asp?UserID='+Names[cUser]['UserID']+'">'+Names[cUser]['Name']+'</a></p></td><td nowrap bgcolor="#222222"><p style="font-size: xx-small">'+Names[cUser]['Title']+'</p></td>';
                    }
                    c++;
                }
                if(Clan_Clan == 'sol'){
                    text = '<td nowrap bgcolor="#222222"><span id="ID_'+Names[cUser]['UserID']+'" style="display:none">'+cUser+'</span><span style="font-size: xx-small">'+nig+'</span><span onmouseover="this.style.cursor=\'pointer\';" id="Refresh_'+Names[cUser]['UserID']+'"><img height="11px" src="http://www.ghqnet.com/sites/SOL/Files/refresh-icon.png"></span> <span onmouseover="this.style.cursor=\'pointer\';" id="Info_'+Names[cUser]['UserID']+'"><img height="11px" src="http://www.ghqnet.com/sites/SOL/Files/InfoIcon.gif"></span> <span style="font-size: xx-small"><a target="main" href="http://sol.ghqnet.com/Admin/EditUser.asp?UserID='+Names[cUser]['UserID']+'">'+Names[cUser]['Name']+'</a></span></td><td nowrap bgcolor="#222222"><p style="font-size: xx-small">'+Names[cUser]['Title']+'</p></td>'+text;
                }else{
                    text = '<td nowrap bgcolor="#222222"><span id="ID_'+Names[cUser]['UserID']+'" style="display:none">'+cUser+'</span><span onmouseover="this.style.cursor=\'pointer\';" id="Refresh_'+Names[cUser]['UserID']+'"><img height="11px" src="http://www.ghqnet.com/sites/SOL/Files/refresh-icon.png"></span> <span style="font-size: xx-small"><a target="main" href="http://sol.ghqnet.com/Admin/EditUser.asp?UserID='+Names[cUser]['UserID']+'">'+Names[cUser]['Name']+'</a></span></td><td nowrap bgcolor="#222222"><p style="font-size: xx-small">'+Names[cUser]['Title']+'</p></td>'+text;
                }
                if(update === 1){
                    var s = myRef2.document.getElementById('row_'+Names[cUser]['UserID']);
                    s.innerHTML = text;
                    if(Clan_Clan == 'sol'){
                        var s = myRef2.document.getElementById('row2_Info_'+Names[cUser]['UserID']);
                        moves = '<td colspan="'+totalCols+'"><table border="0" cellpadding="1" cellspacing="0">'+moves+'</table></td></span>';
                        s.innerHTML = moves;
                    }
                    notify('Perms for '+Names[cUser]['Name']+' have been refreshed.'); 
                }else{
                    myRef2.document.write('<tr id="row_'+Names[cUser]['UserID']+'">');
                    myRef2.document.write(text);
                    if(Clan_Clan == 'sol'){
                        myRef2.document.write('<tr id="row2_Info_'+Names[cUser]['UserID']+'" style="display:none"><td colspan="'+totalCols+'"><table border="0" cellpadding="1" cellspacing="0">');
                        myRef2.document.write(moves);
                        myRef2.document.write('</table></td></span></tr>');
                    }else{
                        myRef2.document.write('</span></tr>');
                    }
                }
                if(Clan_Clan == 'sol'){
                    var te = myRef2.document.getElementById('Info_'+Names[cUser]['UserID']);
                    te.addEventListener("click", function(){userManager_ShowInfo(this.id);}, false);
                    for (var i=0;i<Data.length;i++){
                        var groupName = Data[i]['Title'];
                        var te = myRef2.document.getElementById('_'+Names[cUser]['UserID']+'_'+groupName);
                        te.addEventListener("click", function(){userManager_ShowText(this.id);}, false);
                    }
                }
                myRef2.document.getElementById('Refresh_'+Names[cUser]['UserID']).addEventListener("click", function(){userManager_RefreshUser(this);}, false);
                if(update === 1){
                    return;
                }
                if(runNumber === 30 || runNumber === 60 || runNumber === 90 || runNumber === 120 || runNumber === 150  || runNumber === 180  || runNumber === 210  || runNumber === 240 || runNumber === 270 ){
                    var obj = myRef2.document.getElementById('PermRow').cloneNode(true); 
                    myRef2.document.getElementById('PermRow').parentNode.appendChild(obj);
                }
                runNumber++;
                cUser++; 
                percentage = cUser / totalUsers;
                percentage = Math.round(percentage * 100);
                myRef2.document.getElementById('progress').innerHTML = cUser;
                myRef2.document.getElementById('percent').innerHTML = percentage;
                userManager_CheckUserPermsCheckUser(cUser);
            }
        });


    }
    function userManager_DeleteConfirm(t) {
        //	var allInputs = document.getElementsByTagName("input");
        //	var Names = new Array();
        //	for(var i=0; i<allInputs.length; ++i){
        //		if(allInputs[i].name != 'UserID'){ continue; }
        //		if(allInputs[i].checked != true){ continue; }
        //		Names.push(allInputs[i].parentNode.parentNode.cells[DisplayNameID].innerHTML);
        //	}
        //	var answer = confirm('Are you sure you want to delete these users? \n'+Names);
        //	if(answer == true){
        //		document.forms[0].submit();
        //	}
    }
    var Names = new Array();
    var allTR = document.getElementsByTagName('tr');			// get all TD elements
    var table = document.forms[0].parentNode;
    var allTR = table.getElementsByTagName('tr');			// get all TD elements
    var CountryID = false;
    var LastLoginID = false;
    var DisplayNameID = false;
    var day = (1000*60*60*24);
    var hour = (1000*60*60);
    var min = (1000*60);
    var nUser = 0;
    var runNumber = 0;
    var PermList = new Array();
    var totalUsers = 0;
    var stopProcess = 'false';
    var Clan_Clan = getClan();
    var bgcolor = '#454545';
    var bgcolor1 = '#454545';
    var bgcolor2 = '#333333';
    var Perms = new Array();
    var PermNames = new Array();
    var Data = new Array();
    var totalCols = 0;
    for(var i=0; i<allTR[1].cells.length; ++i){
        if(allTR[1].cells[i].innerHTML.indexOf("Country")!=-1){
            CountryID = i;
        } else if(allTR[1].cells[i].innerHTML.indexOf("Login")!=-1){
            LastLoginID = i;
        } else if(allTR[1].cells[i].innerHTML.indexOf("Display")!=-1){
            DisplayNameID = i;
        } 
    }
    if(browser === 'Chrome'){
        allTR[0].firstChild.innerHTML = allTR[0].firstChild.innerHTML+'  -  <span id="userManager_Link_CheckPerms" onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: 12px; text-decoration: line-through;">Check User Perms</font></span>';
    }else{
        allTR[0].firstChild.innerHTML = allTR[0].firstChild.innerHTML+'  -  <span id="userManager_Link_CheckPerms" onmouseover="this.style.cursor=\'pointer\';"><font style="color: Orange; font-size: 12px;">Check User Perms</font></span>';
        $('userManager_Link_CheckPerms').addEventListener("click", function(){userManager_CheckUserPerms();}, false);
    }		
    for(var i=1; i<allTR.length; ++i){
        if(allTR[i].firstChild.colSpan >= 2){
            //if(i == allTR.length-1){
            //	allTR[i].firstChild.innerHTML = '<button name="Delete2" value="Delete Selected">Delete Selected</button>';
            //	allTR[i].firstChild.firstChild.addEventListener("click", function(){DeleteConfirm(this);}, false);
            //}
            continue;
        }
        var cell = allTR[i].insertCell(-1);
        cell.bgColor = allTR[i].bgColor;
        cell.noWrap = true;
        if(i == 1){
            allTR[i].cells[LastLoginID+1].innerHTML = '<font color="Orange">How Long Ago</font><input name="Delete" type="hidden" value"Delete Selected">';
            allTR[i].cells[LastLoginID+1].align = 'center';
            continue;
        }
        if(LastLoginID != false){
            var LastLogin = allTR[i].cells[LastLoginID].innerHTML;
            allTR[i].cells[LastLoginID].noWrap = true;
            if(LastLogin == ''){
                allTR[i].cells[LastLoginID+1].bgColor = 'DarkRed';
                continue;
            }
            LastLogin = Date.parse(LastLogin);
            var dif = curTime - LastLogin;
            if(dif >= day){
                var d = Math.floor(dif/day);
                t = dif - d * day;
                var h = Math.floor(t/hour);
                var timestring = d+" Day(s) "+h+" Hours Ago";
                if(d >= 30){
                    allTR[i].cells[LastLoginID+1].bgColor = 'DarkRed';
                }else if(d >= 7){
                    allTR[i].cells[LastLoginID+1].bgColor = '#0080C0';
                }
            }else if(dif >= hour){
                var h = Math.floor(dif/hour);
                t = dif - h * hour;
                var m = Math.floor(t/min);
                var timestring = h+" Hours "+m+" Mins Ago";
            }else{
                var m = Math.floor(dif/min);
                var timestring = m+" Mins Ago";

            }
            allTR[i].cells[LastLoginID+1].innerHTML = timestring;
        }
        if(CountryID != false){
            var Country = allTR[i].cells[CountryID].innerHTML;
            if(Country == ''){
                allTR[i].cells[CountryID].bgColor = 'DarkRed';
            }
        }
    }
}
/*
*  END: EDIT USER HOMEPAGE
*/	

/*
*  SOL USER Groups Perms
*/
function solUserGroups(allTD){

    var number = 0;
    var Data = new Array();

    Data[number] = new Array();
    Data[number]['Department'] = '';
    Data[number]['Level'] = '';
    Data[number]['Title'] = 'Vacationer';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = '#9999CC';
    Data[number]['Perms'] = new Array('Compose Messages', 'Status Upload Exempt', 'ACCESS: Vacationers', 'BOARD: SOL History Project');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = '';
    Data[number]['Level'] = '';
    Data[number]['Title'] = 'Merc';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = '#999999';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor User', 'Regular User', 'Show Headline', 'Strategy User', 'View Enemy Reports', 'View User List', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'BOARD: SOL History Project');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = '';
    Data[number]['Level'] = '';
    Data[number]['Title'] = 'Member';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'white';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor User', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'View Enemy Reports', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'BOARD: SOL History Project');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = '';
    Data[number]['Level'] = '';
    Data[number]['Title'] = 'Veteran';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'white';
    Data[number]['Perms'] = new Array('Compose Messages', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor Admin', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'BOARD: SOL History Project', 'BOARD: Veterans Board', 'IA DEPT: Main', 'IA DEPT: Strategy Team', 'IA DEPT: Strategy Team - MSG ONLY');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = '';
    Data[number]['Level'] = '';
    Data[number]['Title'] = 'Historian Editor';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'white';
    Data[number]['Perms'] = new Array('Compose Messages', 'Group Messaging', 'Mass Mailing', 'Permission Messaging', 'Regular User', 'ACCESS: Vacationers', 'BOARD: SOL History Project', 'BOARDMOD: SOL History Project');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'Recruiter';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = '#FFCC99';
    Data[number]['Perms'] = new Array('Compose Messages', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'View Applications', 'View Enemy Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers',  'IA DEPT: Main', 'IA DEPT: Recruiting Team', 'IA DEPT: Recruiting Team - MSG ONLY');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'R&D Scientist';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = '#FFCC99';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor Admin', 'Mentor User', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'View Enemy Reports', 'View Reports', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: R&D Scientist', 'IA DEPT: R&D Scientist - MSG ONLY');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'Strategy Team Member';
    Data[number]['Abbr'] = 'STM';
    Data[number]['Color'] = '#FFCC99';
    Data[number]['Perms'] = new Array('Compose Messages', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor Admin', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: Strategy Team', 'IA DEPT: Strategy Team - MSG ONLY');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'Times Team Member';
    Data[number]['Abbr'] = 'TTM';
    Data[number]['Color'] = '#FFCC99';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'View Enemy Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: Times Team Member', 'IA DEPT: Times Team - MSG ONLY');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '3';
    Data[number]['Title'] = 'Recruiter Team Leader';
    Data[number]['Abbr'] = 'RTL';
    Data[number]['Color'] = '#FF9966';
    Data[number]['Perms'] = new Array('Compose Messages', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'View Applications', 'View Enemy Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: Recruiting Team', 'IA DEPT: Recruiting Team - MSG ONLY', 'IA DEPT: Recruiting Team Leader');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '3';
    Data[number]['Title'] = 'R&D Scientist Team Leader';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = '#FF9966';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor Admin', 'Mentor User', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'View Enemy Reports', 'View Reports', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: R&D Scientist', 'IA DEPT: R&D Scientist - MSG ONLY', 'IA DEPT: R&D Scientist Team Leader');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '3';
    Data[number]['Title'] = 'Strategy Team Leader';
    Data[number]['Abbr'] = 'STL';
    Data[number]['Color'] = '#FF9966';
    Data[number]['Perms'] = new Array('Compose Messages', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor Admin', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: Strategy Team', 'IA DEPT: Strategy Team - MSG ONLY', 'IA DEPT: Strategy Team Leader');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '3';
    Data[number]['Title'] = 'Times Team Leader';
    Data[number]['Abbr'] = 'TTL';
    Data[number]['Color'] = '#FF9966';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'View Enemy Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'IA DEPT: Main', 'IA DEPT: Times Team Member', 'IA DEPT: Times Team - MSG ONLY', 'IA DEPT: Times Team Leader');
    number++;

    ForceLeader = new Array();
    ForceLeader['Department'] = 'IA';
    ForceLeader['Level'] = '3';
    ForceLeader['Abbr'] = 'FL';
    ForceLeader['Color'] = '#FF9966';
    ForceLeader['Perms'] = 'EDITABLE BELOW';

    var FLPerms = new Array();
    for(var i=0; i<allTD.length; ++i){
        if (allTD[i].innerHTML.indexOf("checkbox")!=-1 && allTD[i].innerHTML.indexOf("Permissions")!=-1 && allTD[i].innerHTML.indexOf("Edit User Permissions")==-1){
            var temp = allTD[i].innerHTML.split("\"");
            var next = i+1;
            var permname = allTD[next].innerHTML;

            if(permname.indexOf("FL: ")!=-1){
                Data[number] = new Array();
                Data[number]['Department'] = ForceLeader['Department'];
                Data[number]['Level'] = ForceLeader['Level'];
                Data[number]['Title'] = permname;
                Data[number]['Abbr'] = ForceLeader['Abbr'];
                Data[number]['Color'] = ForceLeader['Color'];
                Data[number]['Perms'] = new Array('Compose Messages', 'Force Leader', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor Admin', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy User', 'View Enemy Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'FL - MSG ONLY', permname, 'IA DEPT: Main');
                FLPerms[number] = permname;
                number++;
            }
        }
    }


    Data[number] = new Array();
    Data[number]['Department'] = 'IA';
    Data[number]['Level'] = '2';
    Data[number]['Title'] = 'IA/Merc Coordinator';
    Data[number]['Abbr'] = 'Coord';
    Data[number]['Color'] = '#FF6633';
    var arraystart = new Array('Administrator', 'Compose Messages', 'Edit Users', 'Force Administrator', 'Force Leader', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Medal Administrator', 'Mentor Admin', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'View Applications','View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'View User Notes', 'Voting Booth Administrator', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'FL - MSG ONLY');
    var arrayend = new Array('IA DEPT: Coordinator', 'IA DEPT: Main', 'IA DEPT: R&D Scientist', 'IA DEPT: R&D Scientist - MSG ONLY', 'IA DEPT: R&D Scientist Team Leader', 'IA DEPT: Recruiting Team', 'IA DEPT: Recruiting Team - MSG ONLY', 'IA DEPT: Recruiting Team Leader', 'IA DEPT: Strategy Team', 'IA DEPT: Strategy Team - MSG ONLY', 'IA DEPT: Strategy Team Leader', 'IA DEPT: Times Team', 'IA DEPT: Times Team - MSG ONLY', 'IA DEPT: Times Team Leader', 'PAGEMOD: Training Page');
    for(var i=0; i<FLPerms.length; ++i){
        if(FLPerms[i] === undefined){
            continue;
        }
        arraystart.push(FLPerms[i]);
    }
    Data[number]['Perms'] = arraystart.concat(arrayend);
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'War';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'Executioners';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'DarkCyan';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor User', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Reports', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'WAR DEPT: Main', 'WAR DEPT: Executioners', 'WAR DEPT: Executioners Message Only');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'War';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'SIG';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'DarkViolet';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor User', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Reports', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'WAR DEPT: Main', 'WAR DEPT: Spy Team Member', 'WAR DEPT: Spy Team Message Only');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'War';
    Data[number]['Level'] = '3';
    Data[number]['Title'] = 'Warmod';
    Data[number]['Abbr'] = 'WMD';
    Data[number]['Color'] = 'darkturquoise';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mentor User', 'Regular User', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'WAR DEPT: Main', 'WAR DEPT: War Mod');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'War';
    Data[number]['Level'] = '2';
    Data[number]['Title'] = 'War Coord';
    Data[number]['Abbr'] = 'WMC';
    Data[number]['Color'] = 'deepskyblue';
    Data[number]['Perms'] = new Array('Compose Messages', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'WAR DEPT: Main', 'WAR DEPT: Spy Team Member', 'WAR DEPT: Spy Team Message Only', 'WAR DEPT: War Mod', 'WAR DEPT: War Officer');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'War';
    Data[number]['Level'] = '2';
    Data[number]['Title'] = 'SIG Coord';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'deepskyblue';
    Data[number]['Perms'] = new Array('Compose Messages', 'Force Messaging', 'Group Messaging', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retals', 'Show Headline', 'Strategy Admin', 'Strategy Reports', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'WAR DEPT: Main', 'WAR DEPT: Spy Team Member', 'WAR DEPT: Spy Team Message Only', 'WAR DEPT: War Mod', 'WAR DEPT: War Officer');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'FR';
    Data[number]['Level'] = '5';
    Data[number]['Title'] = 'Retal Mod';
    Data[number]['Abbr'] = '';
    Data[number]['Color'] = 'LawnGreen';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retal Moderator', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'FR DEPT: Retal Mod Training', 'FR DEPT: Main', 'FR DEPT: Training Module');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'FR';
    Data[number]['Level'] = '4';
    Data[number]['Title'] = 'Jnr FR';
    Data[number]['Abbr'] = 'jFR';
    Data[number]['Color'] = 'lime';
    Data[number]['Perms'] = new Array('Compose Messages', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retal Moderator', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'FR DEPT: PR Main', 'FR DEPT: Retal Mod Training', 'FR DEPT: Allies Pacts', 'FR DEPT: Main', 'FR DEPT: Training Module');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'FR';
    Data[number]['Level'] = '3';
    Data[number]['Title'] = 'Foreign Relations Officer';
    Data[number]['Abbr'] = 'FRO';
    Data[number]['Color'] = 'limegreen';
    Data[number]['Perms'] = new Array('Clan Manager', 'Compose Messages', 'Country Moderator', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retal Moderator', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'FR DEPT: PR Main', 'FR DEPT: Retal Mod Training', 'FR DEPT: Allies Pacts', 'FR DEPT: Ally Request BoardMod', 'FR DEPT: Boardmod', 'FR DEPT: Discussion', 'FR DEPT: Main', 'FR DEPT: Training Module');
    number++;

    Data[number] = new Array();
    Data[number]['Department'] = 'FR';
    Data[number]['Level'] = '2';
    Data[number]['Title'] = 'Senior Foreign Relations Officer';
    Data[number]['Abbr'] = 'SFRO';
    Data[number]['Color'] = '#009900';
    Data[number]['Perms'] = new Array('Clan Manager', 'Compose Messages', 'Country Moderator', 'Intel User', 'Mass Mailing', 'Mentor User', 'Permission Messaging', 'Regular User', 'Retal Moderator', 'Retals', 'Show Headline', 'Strategy User', 'Target Selector', 'View Enemy Reports', 'View Online Users', 'View Reports', 'View User Countries', 'View User List', 'ACCESS: SOL Member', 'ACCESS: SOL Mercenary', 'ACCESS: Vacationers', 'FR DEPT: PR Main', 'FR DEPT: Retal Mod Training', 'FR DEPT: Allies Pacts', 'FR DEPT: Ally Request BoardMod', 'FR DEPT: Boardmod', 'FR DEPT: Discussion', 'FR DEPT: FR Coord Board', 'FR DEPT: Main', 'FR DEPT: Training Module');
    number++;

    return Data;
}
/*
*  Edit User
*/
function editUser() {
    function editUser_ParseGroups(){
        var bgcolor = '#454545';
        var moves = '';
        for (var x=0;x<PermNames.length;x++){
            var temp = PermNames[x];
            Perms[temp]['UserCount'] = 0;	
            Perms[temp]['InUsersGroup'] = 0;
        }
        for (var i=0;i<Data.length;i++){
            var userhave = 1;
            for (var x=0;x<Data[i]['Perms'].length;x++){
                var temp = Data[i]['Perms'][x];
                if(Perms[temp] === undefined){
                }else{
                    if(Perms[temp]['UserHas'] == 0){
                        userhave = 0;
                    }
                }
            }
            if(userhave == 1){
                for (var x=0;x<Data[i]['Perms'].length;x++){
                    var temp = Data[i]['Perms'][x];
                    if(Perms[temp] === undefined){
                    }else{
                        Perms[temp]['UserCount']++;
                        Perms[temp]['InUsersGroup'] = 1;
                    }
                }
            }
        }
        for (var i=0;i<Data.length;i++){
            if(bgcolor == bgcolor1){ bgcolor = bgcolor2; }else{ bgcolor = bgcolor1; }
            var groupName = Data[i]['Title'];
            var userhave = 1;
            var showpermslisthave = '';
            var showpermslistdonthave = '';
            for (var x=0;x<Data[i]['Perms'].length;x++){
                var temp = Data[i]['Perms'][x];
                if(Perms[temp] === undefined){
                }else{
                    if(Perms[temp]['UserCount'] > 1){
                        var color = 'grey';
                    }else{
                        var color = 'green';
                    }
                    if(Perms[temp]['UserHas'] == 1){
                        showpermslisthave = showpermslisthave + '<font color="'+ color +'">' + temp + '</font><BR>';
                    }else{
                        showpermslistdonthave = showpermslistdonthave + '<font color="'+ color +'">' + temp + '</font><BR>';
                        userhave = 0;
                    }					
                }
            }

            var spanhave = '<span id="spanhave_'+ groupName +'" class="box" return false;" style="display:none">'+showpermslisthave+'</span>';
            var spandonthave = '<span id="spandonthave_'+ groupName +'" class="box" return false;" style="display:none">'+showpermslistdonthave+'</span>';
            var color = Data[i]['Color'];
            if(userhave == 1){
                moves = moves + '<tr><td align="right" bgcolor="'+bgcolor+'"><br>'+spandonthave+'</td><td bgcolor="'+bgcolor+'"><button style="color: #FF0000" id="Move_'+ groupName +'" name="'+ i +'"><strong><<<</strong></button></td><td bgcolor="'+bgcolor+'" id="_'+ groupName +'"><font color="'+ color +'">' + groupName + '</font>' + spanhave + '</td></tr>';
            }else{
                moves = moves + '<tr><td align="right" bgcolor="'+bgcolor+'" id="_'+ groupName +'"><font color="'+ color +'">' + groupName + '</font>' + spandonthave +'</td><td bgcolor="'+bgcolor+'"><button id="Move_' + groupName + '" name="'+ i +'"><strong>>>></strong></button></td><td bgcolor="'+bgcolor+'"><br>' + spanhave + '</td></tr>';
            }

        }	

        var moves2 = '';
        var showpermslisthave = '';
        var showpermslistdonthave = '';
        for (var i=0;i<PermNames.length;i++){
            if(bgcolor == bgcolor1){ bgcolor = bgcolor2; }else{ bgcolor = bgcolor1; }
            var temp = PermNames[i];
            var color = 'white';
            var cellcolor = bgcolor;
            if (temp.indexOf("IA")!=-1 || temp.indexOf("FL -")!=-1){
                color = '#FF6633';
            }else if (temp.indexOf("WAR DEPT:")!=-1){
                color = 'deepskyblue';
            }else if (temp.indexOf("FR")!=-1){
                color = 'limegreen';
            }else if (temp.indexOf("FL:")!=-1){
                color = '#FF9966';
            }
            if (Perms[temp]['InUsersGroup'] == 0){
                cellcolor = 'darkred';
            }
            if(Perms[temp]['UserHas'] == 1){
                showpermslisthave = showpermslisthave + '<font color="'+ color +'">' + temp + '</font><BR>';
                moves2 = moves2 + '<tr><td align="right" bgcolor="'+bgcolor+'"><br></td><td bgcolor="'+bgcolor+'"><button style="color: #FF0000" id="MovePerm_' + temp + '" name="'+ i +'"><strong><<<</strong></button></td><td bgcolor="'+cellcolor+'" id="_'+ temp +'"><font color="'+color+'">' + temp + '</font></td></tr>';
            }else{
                showpermslistdonthave = showpermslistdonthave + '<font color="'+ color +'">' + temp + '</font><BR>';
                moves2 = moves2 + '<tr><td align="right" bgcolor="'+bgcolor+'" id="_'+ temp +'"><font color="'+color+'">' + temp +'</font></td><td bgcolor="'+bgcolor+'"><button id="MovePerm_' + temp + '" name="'+ i +'"><strong>>>></strong></button></td><td bgcolor="'+bgcolor+'"><br></td></tr>';
            }
        }
        allTD[tableIndex].innerHTML = tableHeader + moves + tableMiddle + moves2 + tableFooter;
        for (var i=0;i<Data.length;i++){
            var groupName = Data[i]['Title'];
            var t = document.getElementById('Move_'+groupName);
            var te = document.getElementById('_'+groupName);
            te.addEventListener("click", function(){editUser_ShowText(this.id);}, false);
            if(t.innerHTML == '<strong>&lt;&lt;&lt;</strong>'){
                t.addEventListener("click", function(){editUser_setPerms(this.name, "have");}, false);
            }else{
                t.addEventListener("click", function(){editUser_setPerms(this.name, "donthave");}, false);
            }
        }
        for (var i=0;i<PermNames.length;i++){
            var temp = PermNames[i];
            var t = document.getElementById('MovePerm_'+temp);
            t.addEventListener("click", function(){editUser_setPerm(this.id);}, false);					
        }
    }
    function editUser_setAllPerms(groupName){
        if(groupName == 'Member' || groupName == 'Veteran'){
            alert('Please Choose a Force from the Force Dropdown menu then hit Edit User!');
            var force = $('Force');
            force.size = force.options.length;
            force.focus(); 
        }else{
            var forceID = document.getElementById("Force");
            for (var i = 0; i < forceID.length; ++i){
                if (forceID[i].text.indexOf(groupName)!=-1){
                    forceID.selectedIndex = i;
                    break;
                }
            }
        }
        document.getElementById("Position").value = groupName;
        var groupID = document.getElementById("Group");
        for (var i = 0; i < groupID.length; ++i){
            if (groupName == 'Vacationer'){
                if(groupID[i].text.indexOf('Vacation')!=-1){
                    groupID.selectedIndex = i;
                    break;
                }
            }else if (groupID[i].text.indexOf(groupName)!=-1){
                groupID.selectedIndex = i;
                break;
            }
        }
        var publicBoardAccessID = document.getElementById("BoardAccess");
        for (var i = 0; i < publicBoardAccessID.length; ++i){
            if (groupName == 'Veteran'){
                if(publicBoardAccessID[i].text.indexOf('Veteran')!=-1){
                    publicBoardAccessID.selectedIndex = i;
                    break;
                }
            }else if (publicBoardAccessID[i].text.indexOf('Member')!=-1){
                publicBoardAccessID.selectedIndex = i;
                break;
            }
        }
        for (var x=0;x<PermNames.length;x++){
            var pName = PermNames[x];
            Perms[pName]['UserHas'] = 0;
            Perms[pName]['UserCount'] = 0;
            document.getElementById("checkbox_"+pName).checked = false;
        }
        //var permName = 'Status Upload Exempt';
        //if(groupName == 'Vacationer'){
        //	Perms[permName]['UserHas'] = 1;
        //	Perms[permName]['UserCount']++;
        //	document.getElementById("checkbox_"+permName).checked = true;
        //}
        for (var i=0;i<Data.length;i++){
            if(groupName == Data[i]['Title']){
                break;
            }
        }	
        editUser_setPerms(i, 'donthave');
        notify('User placed into: "'+groupName+'"'); 
    }
    function editUser_setPerms(DataID, current){
        if(Data[DataID]['Title'] == 'Vacationer' && current == 'donthave'){
            alert('The "Vacationer" group automatically adds "Status Upload Exempt" to users so they dont need to upload a status report to view common forums.  This should not be given out to members.');
        }
        for (var x=0;x<Data[DataID]['Perms'].length;x++){
            var temp = Data[DataID]['Perms'][x];
            if(Perms[temp] === undefined){
            }else{
                if(current == 'donthave'){
                    Perms[temp]['UserHas'] = 1;
                    Perms[temp]['UserCount']++;
                    document.getElementById("checkbox_"+temp).checked = true;
                }else{
                    if(Perms[temp]['UserCount'] <= 1){
                        Perms[temp]['UserHas'] = 0;
                        Perms[temp]['UserCount'] = 0;
                        document.getElementById("checkbox_"+temp).checked = false;
                    }else{
                        Perms[temp]['UserCount']--;
                    }
                }					
            }
        }
        editUser_ParseGroups();
    }
    function editUser_setPerm(permName){
        permName = permName.substr(9);
        if(Perms[permName]['UserHas'] == 1){
            Perms[permName]['UserHas'] = 0;
            Perms[permName]['UserCount'] = 0;
            document.getElementById("checkbox_"+permName).checked = false;
        }else{
            Perms[permName]['UserHas'] = 1;
            Perms[permName]['UserCount']++;
            document.getElementById("checkbox_"+permName).checked = true;
        }

        editUser_ParseGroups();
    }
    function editUser_ShowText(id) {
        var t = document.getElementById('spanhave'+id);
        var t2 = document.getElementById('spandonthave'+id);
        if(t.style.display == 'block'){
            t.style.display = 'none';
            t2.style.display = 'none';
        }else{
            t.style.display = 'block';
            t2.style.display = 'block';
        }
    }
    function editUser_checkedBox(t) {
        temp = t.id.substr(9);
        if(t.checked == true){
            Perms[temp]['UserHas'] = 1;
            Perms[temp]['UserCount']++;
        }else{
            Perms[temp]['UserHas'] = 0;
            Perms[temp]['UserCount']--;
        }
        editUser_ParseGroups();
    }
    var allTH;
    var allTD;												// holds collection of all TD elements
    var td_index;											// var used to index
    allTD = document.getElementsByTagName('td');			// get all TD elements
    allTH = document.getElementsByTagName('th');			// get all TH elements

    var Data = solUserGroups(allTD);		

    var allTextAreas = document.getElementsByTagName("textarea");
    for(var i=0; i<allTextAreas.length; ++i){
        if(allTextAreas[i].name == 'Comments'){
            allTextAreas[i].cols = 50;
            allTextAreas[i].rows = 8;
        }
    }
    var allInputs = document.getElementsByTagName("input");
    for(var i=0; i<allInputs.length; ++i){
        if(allInputs[i].name == 'Permissions'){ continue; }
        allInputs[i].id = allInputs[i].name;
    }
    var allSelects = document.getElementsByTagName("select");
    for(var i=0; i<allSelects.length; ++i){
        allSelects[i].id = allSelects[i].name;
    }
    var allTextAreas = document.getElementsByTagName("textarea");
    for(var i=0; i<allTextAreas.length; ++i){
        if(allTextAreas[i].name == 'Comments'){
            allTextAreas[i].cols = 50;
            allTextAreas[i].rows = 8;
        }
    }

    var bgcolor = '#454545';
    var bgcolor1 = '#454545';
    var bgcolor2 = '#333333';
    var style = '<style type="text/css"><!--  .box { background-color: #504D6F; border: 1px solid #FFF; width: 250; padding: 5px; } --> </style>';
    var Perms = new Array();
    var PermNames = new Array();
    var done = 0;
    var number2 = 0;
    for(var i=0; i<allTD.length; ++i){
        if(allTD[i].innerHTML == '<b><font size="+1">Edit User</font></b>' && allTD[i].innerHTML.indexOf("QUICKSETS")==-1 && done==0){	// find td object with keyword in it
            allTD[i].innerHTML = style+'<table width=100%><tr><td>'+allTD[i].innerHTML + '</td><td align=right id="quicksets">QUICKSETS: (Replaces Perms)<button style="color: #FF0000" id="Vacationer"><strong>Vacation</strong></button>  |  <button style="color: #FF0000" id="Merc"><strong>Merc</strong></button>  |  <button style="color: #FF0000" id="Member"><strong>Member</strong></button>  |  <button style="color: #FF0000" id="Veteran"><strong>Veteran</strong></button></td></tr></table>';
            document.getElementById("Vacationer").addEventListener("click", function(){editUser_setAllPerms("Vacationer");}, false);
            document.getElementById("Merc").addEventListener("click", function(){editUser_setAllPerms("Merc");}, false);
            document.getElementById("Member").addEventListener("click", function(){editUser_setAllPerms("Member");}, false);
            document.getElementById("Veteran").addEventListener("click", function(){editUser_setAllPerms("Veteran");}, false);
            done = 1;
        }

        if(allTD[i].innerHTML == '<b><font size="+1">Edit User Permissions</font></b>'){	// find td object with keyword in it
            var perms = new Array();			
            var tableIndex = i;

            allTD[i].bgColor = 'black';
            allTD[i].parentNode.bgColor = 'black';

            var tableHeader = '<table align=center border="0" cellspacing="1" cellpadding="2"><tr><td valign="top"> <table align=center border="0" cellspacing="1" cellpadding="2"><tr><th bgcolor="'+bgcolor+'" colspan=3>Quick Groups Editing<br><font color=gray size=small>*Click a group to see associated perms.<br>*Gray Perms are duplicate perms and are being used by other groups as well.<br>*Green Perms will be transfered when the group is transfered.</font></th></tr><tr><th width=300px bgcolor="'+bgcolor+'">Dont Have</th> <th bgcolor="'+bgcolor+'">M</th><th width=300px bgcolor="'+bgcolor+'">Have</th></tr>';
            save = '<tr><td align="right"></td><td></td><td align=left></td></tr>';
            var tableMiddle = '</table></td><td valign="top"><table align=center border="0" cellspacing="1" cellpadding="2"><tr><th bgcolor="'+bgcolor+'" colspan=3>Quick Permission Editing<br><font color=gray size=small>*Cells in <font color=red>RED</font> are perms not associated with a Group.</font></th></tr><tr><th width=300px bgcolor="'+bgcolor+'">Dont Have</th><th bgcolor="'+bgcolor+'">M</th><th width=300px bgcolor="'+bgcolor+'">Have</th></tr>';
            save2 = '<tr><td align="right"></td><td></td><td align=left></td></tr>';
            var tableFooter = '</td></tr></table></td></tr></table></td></tr><tr bgcolor="#22222"><td colspan=3 bgcolor="#222222"><b>Edit User Permissions</b>';

            allTD[i].innerHTML = tableHeader + save + tableMiddle + save2 + tableFooter;

        }

        if (allTD[i].innerHTML.indexOf("checkbox")!=-1 && allTD[i].innerHTML.indexOf("Permissions")!=-1 && allTD[i].innerHTML.indexOf("Edit User Permissions")==-1){
            var temp = allTD[i].innerHTML.split("\"");
            var next = i+1;
            var permname = allTD[next].innerHTML;

            permname = permname.replace('&amp;', '&');

            Perms[permname] = new Array();
            Perms[permname]['TDIndex'] = temp;
            Perms[permname]['InGroup'] = 0;

            PermNames[number2] = permname;
            number2++;

            if (allTD[i].innerHTML.indexOf("checked")!=-1){
                Perms[permname]['UserHas'] = 1;
            }else{
                Perms[permname]['UserHas'] = 0;
            }
            Perms[permname]['UserCount'] = 0;
            var t = allTD[i].getElementsByTagName('input');
            t[0].id = 'checkbox_'+permname;
            t[0].addEventListener("click", function(){editUser_checkedBox(this);}, false);
        }
    }

    for (var i=0;i<Data.length;i++){
        for (var x=0;x<Data[i]['Perms'].length;x++){
            var temp = Data[i]['Perms'][x];
            if(Perms[temp] === undefined){
            }else{
                Perms[temp]['InGroup'] = 1;
            }
        }
    }
    editUser_ParseGroups();
}
/*
*  END: EDIT PAGE
*/	

function clocks() {

    var temp = new Date();
    temp = temp - locTimeFirst;

    ghqTime = ghqTimeFirst.getTime() + temp;

    var ghqTime = new Date(ghqTime);
    var month = ghqTime.getMonth()+1;
    var day = ghqTime.getDate();
    var year = ghqTime.getFullYear();
    var hour = ghqTime.getHours();
    var minute = ghqTime.getMinutes();
    var second = ghqTime.getSeconds();
    second = zeroPad(second);
    minute = zeroPad(minute);

    if(getSetting(HOUR24_KEY,false)){
        hour = zeroPad(hour);
        ghqTimeString = month+'/'+day+'/'+year+' '+hour+':'+minute+':'+second;
    }else{
        if (hour>=12){
            AorP="P.M.";
        }else{
            AorP="A.M.";
        }
        if (hour>=13){
            hour -=12;
        }
        if (hour==0){
            hour=12;
        }
        ghqTimeString = month+'/'+day+'/'+year+' '+hour+':'+minute+':'+second+' '+AorP;
    }
    headerLeftMenu.innerHTML = 'GHQ: '+ghqTimeString;
    if(getSetting(GAME_TIME_SHOW_KEY,true)){
        var gameTime = new Date();
        var month = gameTime.getUTCMonth()+1;
        var day = gameTime.getUTCDate();
        var year = gameTime.getUTCFullYear();
        var hour = gameTime.getUTCHours();
        var minute = gameTime.getUTCMinutes();
        var second = gameTime.getUTCSeconds();
        second = zeroPad(second);
        minute = zeroPad(minute);
        if(getSetting(HOUR24_KEY,false)){
            hour = zeroPad(hour);
            gameTime = month+'/'+day+'/'+year+' '+hour+':'+minute+':'+second;
        }else{
            if (hour>=12){
                AorP="P.M.";
            }else{
                AorP="A.M.";
            }
            if (hour>=13){
                hour -=12;
            }
            if (hour==0){
                hour=12;
            }
            gameTime = month+'/'+day+'/'+year+' '+hour+':'+minute+':'+second+' '+AorP;
        }
        headerLeftMenu.innerHTML = headerLeftMenu.innerHTML+'<br>Game: '+gameTime;
    }
    if(getSetting(LOCAL_TIME_SHOW_KEY,true)){
        var locTime = new Date();
        var month = locTime.getMonth()+1;
        var day = locTime.getDate();
        var year = locTime.getFullYear();
        var hour = locTime.getHours();
        var minute = locTime.getMinutes();
        var second = locTime.getSeconds();
        second = zeroPad(second);
        minute = zeroPad(minute);
        if(getSetting(HOUR24_KEY,false)){
            hour = zeroPad(hour);
            locTime = month+'/'+day+'/'+year+' '+hour+':'+minute+':'+second;
        }else{
            if (hour>=12){
                AorP="P.M.";
            }else{
                AorP="A.M.";
            }
            if (hour>=13){
                hour -=12;
            }
            if (hour==0){
                hour=12;
            }
            locTime = month+'/'+day+'/'+year+' '+hour+':'+minute+':'+second+' '+AorP;
        }
        var locTimeOffset = new Date().getTimezoneOffset() / 60 * -1;
        headerLeftMenu.innerHTML = headerLeftMenu.innerHTML+'<br>Local: '+locTime+'<br>Your Time Zone: GT '+locTimeOffset;
    }
    if(getSetting(ANIMATE_SERVER_TIME_KEY,true)){
        setTimeout(clocks,1000);
    }
}

//==========================================
//MAIN LOAD
//==========================================
try{
    var Clan_Clan = getClan();
    //ADD TIME FORMAT AND RIGHT MENU LINKS
    //var tables = document.evaluate("//table",document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
    var tables = document.evaluate("//table", document, null, XPathResult.ANY_TYPE, null); 
    var endTable = tables.iterateNext();
    var firstTable = endTable;
    var end = 0;
    var runs = 0;
    while (endTable) {
        if(end == 0){
            if(endTable.innerHTML === ''){
                end = 1;
            }else if(runs >= 1){
                end = 1;
                break;
            }
            endTable = tables.iterateNext();
            if(endTable === null){
                endTable = 0;
                end = 1;
                break;
            }
        }else{
            if(endTable.cellSpacing == 1 && endTable.cellPadding == 0 && endTable.border == 0 && endTable.width == '100%'){
            }else{
                endTable = 0;
            }
            break;
        }
        runs++;
    }

    var center = firstTable.firstChild.firstChild.childNodes[1];
    if(center !== undefined){
        var Clan_Username = firstTable.firstChild.firstChild.childNodes[1].childNodes[2].innerHTML;
        var Clan_Username = Clan_Username.substring(0, Clan_Username.indexOf(','));
        setSetting('Clan_Username', Clan_Username);
        firstTable.firstChild.firstChild.childNodes[0].width = '15%';
        firstTable.firstChild.firstChild.childNodes[2].width = '15%';
        bgcolor = firstTable.firstChild.firstChild.bgColor;
        var html = '<table width="100%" cellspacing="1" cellpadding="0"><tr bgcolor="'+bgcolor+'"><td align="center">'+center.innerHTML+'</td></tr></table>';
        center.innerHTML = html; 
        if(endTable != 0){
            center.appendChild(endTable);
        }
        center.bgColor = 'black';
        if(!getSetting(GHQEDITOR_HEADER,false)){ //Had to change to non-booleon for chrome
            //HEADER RIGHT MENU
            headerRightMenu = firstTable.firstChild.firstChild.childNodes[2];
            var span = document.createElement("span");
            span.id = 'SettingsLink';
            span.innerHTML = 'GHQEditor Settings';
            span.setAttribute('align','center');
            span.setAttribute('class','right_Menu');
            var lineBreak = document.createElement('br');
            headerRightMenu.appendChild(lineBreak);
            headerRightMenu.appendChild(span);
            var span = document.createElement("span");
            span.id = 'SettingsHomepage';
            span.innerHTML = "GHQEditor Homepage";
            span.setAttribute('align','center');
            span.setAttribute('class','right_Menu');
            var lineBreak = document.createElement('br');
            headerRightMenu.appendChild(lineBreak);
            headerRightMenu.appendChild(span);
        }else{
            var newdiv = document.createElement('div');
            newdiv.innerHTML = '<center><span id="GHQSet">GHQEditor: <span id="SettingsLink">Settings</span> | <span id="SettingsHomepage">Homepage</span></span></center>';
            document.body.appendChild(newdiv);
            $('GHQSet').setAttribute('class','right_MenuHeader');
            $('SettingsLink').setAttribute('class','right_Menu');
            $('SettingsHomepage').setAttribute('class','right_Menu');
        }
        $('SettingsLink').addEventListener("click", function(){ showConfig(null); }, true);
        $('SettingsHomepage').addEventListener("click", function(){ window.open('http://www.damnlazy.co.uk/UserScripts/'); }, true);
        //HEADER LEFT MENU
        headerLeftMenu = firstTable.firstChild.firstChild.childNodes[0];
        headerLeftMenu.noWrap = true;
        var ghqTimeFirst = headerLeftMenu.firstChild.firstChild.innerHTML;
        curTime = headerLeftMenu.firstChild.firstChild.innerHTML;
        curTime = Date.parse(curTime);
        headerLeftMenu.setAttribute('class','left_Menu');
        ghqTimeFirst = Date.parse(ghqTimeFirst);
        ghqTimeFirst = new Date(ghqTimeFirst);
        var locTimeFirst = new Date();
        clocks();
        //CLEAN BOARD NEW POSTS
        cleanBoards();
        installCheck();
    }
    switch (page){
        case "ShowBoard":
            if(getSetting(NEW_POSTS_KEY,true)){
                newPosts();
            }
            //cleanBoard();
        case "ShowPost":
            if(getSetting(POST_AREA_KEY,true)){
                postAreaAugment();
            }
            if(getSetting(NEW_POSTS_KEY,true) && page === "ShowPost"){
                newPostMarkRead();
            }		
            break;
        case "SiteManager":
            if(getSetting(SITE_MANAGER_KEY,true)){
                //siteManager();
            }
            break;
        case "TargetInfo":
            if(getSetting(TARGET_SELECTOR_KEY,true)){
                targetInfo();
            }
            break;
        case "TargetSelector":
            if(getSetting(TARGET_SELECTOR_KEY,true)){
                targetSelector();
            }
            break;
        case "UserManager":
            if(getSetting(EDIT_USER_KEY,true)){
                //userManager();
            }
            break;
        case "EditUser":
            var Clan_Clan = getClan();
            if(Clan_Clan == 'sol'){
                if(getSetting(EDIT_USER_KEY,true)){
                    //editUser();
                }
            }
            break;
        default:
            if(getSetting(LEFT_MENU_KEY,true)){
                var page2 = path.substring(0, path.indexOf('.ASP'));		// extract page name from URL
                var page2 = page2.substring(page2.lastIndexOf('/')+1);		// extract page name from URL
                if(page2 == "LINKS"){
                    if(window.name != 'newPostsPage'){
                        links();
                    }
                }
            }
            break;
    }

} catch (e) { console.log("Main Load: "+e); return; }