/*** SET BUTTON'S FOLDER HERE ***/
var buttonFolder = "Images/Buttons/";

/*** SET BUTTONS' FILENAMES HERE ***/
upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png","button8up.png");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png");


//*** NO MORE SETTINGS BEYOND THIS POINT ***//
totalButtons = upSources.length;



//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
	for ( x=0; x<totalButtons; x++ ) {
		buttonUp = new Image();
		buttonUp.src = buttonFolder + upSources[x];
		buttonOver = new Image();
		buttonOver.src = buttonFolder + overSources[x];
	}
}

// SET MOUSEOVER BUTTON
function setOverImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + overSources[But-1];
}

// SET MOUSEOUT BUTTON
function setOutImg(But, ID) {
	document.getElementById('button' + But + ID).src = buttonFolder + upSources[But-1];
}


//preload();



function openBrWindow(theURL, winName, features) {
    window.open(theURL, winName, features);
}



function switchid(id, height) {
            hideallids();
            showdiv(id);
            window.scrollTo(0, height) 
        }

        function hideallids() {
            //loop through the array and hide each element by id
            for (var i = 0; i < ids.length; i++) {
                hidediv(ids[i]);
            }
        }

        function hidediv(id) {
            //safe function to hide an element with a specified id
            if (document.getElementById) { // DOM3 = IE5, NS6
                document.getElementById(id).style.display = 'none';
            }
            else {
                if (document.layers) { // Netscape 4
                    document.id.display = 'none';
                }
                else { // IE 4
                    document.all.id.style.display = 'none';
                }
            }
        }

        function showdiv(id) {
            //safe function to show an element with a specified id

            if (document.getElementById) { // DOM3 = IE5, NS6
                document.getElementById(id).style.display = 'block';
            }
            else {
                if (document.layers) { // Netscape 4
                    document.id.display = 'block';
                }
                else { // IE 4
                    document.all.id.style.display = 'block';
                }
            }
        }


        function counter(field, countfield, maxlimit) {
            if (field.value.length > maxlimit) {
                field.value = field.value.substring(0, maxlimit);
            }
            else {
                countfield.value = maxlimit - field.value.length;
            }
        }





        function ScrollableTable(tableEl, tableHeight, tableWidth) {

            this.initIEengine = function() {

                this.containerEl.style.overflowY = 'auto';
                if (this.tableEl.parentElement.clientHeight - this.tableEl.offsetHeight < 0) {
                    this.tableEl.style.width = this.newWidth - this.scrollWidth + 'px';
                } else {
                    this.containerEl.style.overflowY = 'hidden';
                    this.tableEl.style.width = this.newWidth + 'px';
                }

                if (this.thead) {
                    var trs = this.thead.getElementsByTagName('tr');
                    for (x = 0; x < trs.length; x++) {
                        trs[x].style.position = 'relative';
                        trs[x].style.setExpression("top", "this.parentElement.parentElement.parentElement.scrollTop + 'px'");
                    }
                }

                if (this.tfoot) {
                    var trs = this.tfoot.getElementsByTagName('tr');
                    for (x = 0; x < trs.length; x++) {
                        trs[x].style.position = 'relative';
                        trs[x].style.setExpression("bottom", "(this.parentElement.parentElement.offsetHeight - this.parentElement.parentElement.parentElement.clientHeight - this.parentElement.parentElement.parentElement.scrollTop) + 'px'");
                    }
                }

                eval("window.attachEvent('onresize', function () { document.getElementById('" + this.tableEl.id + "').style.visibility = 'hidden'; document.getElementById('" + this.tableEl.id + "').style.visibility = 'visible'; } )");
            };


            this.initFFengine = function() {
                this.containerEl.style.overflow = 'hidden';
                this.tableEl.style.width = this.newWidth + 'px';

                var headHeight = (this.thead) ? this.thead.clientHeight : 0;
                var footHeight = (this.tfoot) ? this.tfoot.clientHeight : 0;
                var bodyHeight = this.tbody.clientHeight;
                var trs = this.tbody.getElementsByTagName('tr');
                if (bodyHeight >= (this.newHeight - (headHeight + footHeight))) {
                    this.tbody.style.overflow = '-moz-scrollbars-vertical';
                    for (x = 0; x < trs.length; x++) {
                        var tds = trs[x].getElementsByTagName('td');
                        tds[tds.length - 1].style.paddingRight += this.scrollWidth + 'px';
                    }
                } else {
                    this.tbody.style.overflow = '-moz-scrollbars-none';
                }

                var cellSpacing = (this.tableEl.offsetHeight - (this.tbody.clientHeight + headHeight + footHeight)) / 4;
                this.tbody.style.height = (this.newHeight - (headHeight + cellSpacing * 2) - (footHeight + cellSpacing * 2)) + 'px';

            };

            this.tableEl = tableEl;
            this.scrollWidth = 16;

            this.originalHeight = this.tableEl.clientHeight;
            this.originalWidth = this.tableEl.clientWidth;

            this.newHeight = parseInt(tableHeight);
            this.newWidth = tableWidth ? parseInt(tableWidth) : this.originalWidth;

            this.tableEl.style.height = 'auto';
            this.tableEl.removeAttribute('height');

            this.containerEl = this.tableEl.parentNode.insertBefore(document.createElement('div'), this.tableEl);
            this.containerEl.appendChild(this.tableEl);
            this.containerEl.style.height = this.newHeight + 'px';
            this.containerEl.style.width = this.newWidth + 'px';


            var thead = this.tableEl.getElementsByTagName('thead');
            this.thead = (thead[0]) ? thead[0] : null;

            var tfoot = this.tableEl.getElementsByTagName('tfoot');
            this.tfoot = (tfoot[0]) ? tfoot[0] : null;

            var tbody = this.tableEl.getElementsByTagName('tbody');
            this.tbody = (tbody[0]) ? tbody[0] : null;

            if (!this.tbody) return;

            if (document.all && document.getElementById && !window.opera) this.initIEengine();
            if (!document.all && document.getElementById && !window.opera) this.initFFengine();


        }