
//    document.debug = 1


/* Centers elements based on screen resolution, and width of 
 * element to center. Returns a number of pixels for use in:
 * document.write('<style ... #[.]element { margin-left: ' + isCentered(width) + 'px; });
 * If constrained by higher node size, give name of higher node.
 */

function isCentered(elWidth) {
    var w = (arguments.length > 1) ? arguments[1].width : screen.width;
    return parseInt(((w - elWidth)/2)-10);
}

function do_center(divName,elWidth) {
    var w = document.body.clientWidth || window.innerWidth;
    var n = parseInt((w-elWidth)/2);
    var styleStr  = '<style type="text/css">'  +   divName;
        styleStr += '{margin-left:'            +   n - 10;
        styleStr += 'px;}</style>';
    return arguments[2] == 1 ? n : styleStr;
}


	
// Prototype to Upper Case first letter of each word in string
	String.prototype.ucFirst=function() {
        if(arguments[0] == true) {
            var words=this.split(" ")
            for(var w in words) {
                words[w]=words[w].ucFirst()
			}
            return words.join(" ")
        }
        return this.charAt(0).toUpperCase()+this.substring(1,this.length)
    }

/* ====================================================================
 * Generate Page or browser specific effects and stylesheet	
 */

// Navigation Tab
    var loc  = window.location.toString();
    var page = loc.split("/");
        page.reverse();
    var styl = page[0].split(".");
        styl[0]   = (styl[0]=="index") ? "home" : styl[0];

// main_col2 percentage
    var prcnt  = 97;
    if (document.all) ++prcnt;
    if (window.opera) ++prcnt;

// start modified styles
    var stylStr = '<style TYPE="text/css">' + "\n";

// change the current page tab to white
    stylStr += '.' + styl[0] + ' { background: #ffffff URL(none); border-bottom: 1px solid #ffffff; }' + "\n";

// line up the logo
    stylStr += '.logo { margin-left: ' + (isCentered(785)+15) + 'px; }' + "\n";

// Main Nav Bar
    stylStr += '#mainnavbar  { left: ' +  isCentered(770)     + 'px; }' + "\n";

// Center content Based on Screen Resolution
    stylStr += '#content     { left: ' +  isCentered(785)     + 'px; }' + "\n";

// ieFix -- modify the classes that do not seem to line up correctly in IE
    stylStr += (document.all && !window.opera) ? '.content_border { width: 780px; }' + "\n" : "";

// main_col2
    stylStr += (prcnt != 97) ? '.main_col2 { width: ' + prcnt + '%; }' + "\n" : "";

// End Stylesheet
    stylStr += '</style>' + "\n";

    if (document.debug) { alert(stylStr) };

    document.write(stylStr);

// Page Header Image
    var headImage = '<img SRC="/images/banrs/' + styl[0] + '.jpg" HEIGHT="50" WIDTH="200" />';


	