﻿var isIE = (navigator.appName.indexOf("Microsoft")!=-1)?1:0;

function SetPostAreaWidth()
{
    if(!isIE)
    {        
        // Determine what the width of the screen is
        var windowWidth = GetWindowWidth();
        var postAreaWidth = windowWidth - 275;
        
        var elements = getElementsByClassName("postArea");
        for(i = 0; i < elements.length; i++)
            elements[i].style.width = postAreaWidth.toString() + "px"; 
    }
}

function getElementsByClassName(className, parentNode)
{
    // If a parentNode wasn't explicitly passed in ... search the
    // entire "body" element by default.
    if(!parentNode)
        parentNode = document.getElementsByTagName("body")[0];
    
    var results = [];
    var regEx = new RegExp('\\b' + className + '\\b');
    var allElements = parentNode.getElementsByTagName("*");
    
    // Go through every element, testing each against the regular expression,
    // and push matches into the results array.
    for(var i = 0; i < allElements.length; i++)
    {
        if(regEx.test(allElements[i].className))
            results.push(allElements[i]);
    }
    
    return results;
}

function GetWindowWidth()
{
    if(typeof(window.innerWidth) == 'number')
        return parseInt(window.innerWidth);
    else if(document.documentElement && document.documentElement.clientWidth)
        return parseInt(document.documentElement.clientWidth);
    else if(document.body && document.body.clientWidth)
        return parseInt(document.body.clientWidth);
}