﻿function toggleElementsForContactForm(yesElementName, elementArray)
{
    var yesElement = document.getElementById(yesElementName);
    if(typeof(yesElement) != 'undefined')
    {
        for(i = 0; i < elementArray.length; i++)
        {
            var element = document.getElementById(elementArray[i]);
            if(typeof(element) != 'undefined')
            {
                element.disabled = !yesElement.checked;
            }
        }
    }
}

function checkLength(textElement)
{
    if(typeof(textElement) != 'undefined')
    {
        textElement.style.backgroundColor = '';
        
        if(textElement.value.length > 7000)
            textElement.style.backgroundColor = 'yellow';
    }
}

function verifyForm(searchTextBox)
{
    var searchInputElement = document.getElementById(searchTextBox);
    var strQuery = searchInputElement.value;
    var reNonSpace = /\S/g;
    if (reNonSpace.test(strQuery))
    {
        return true;
    }
    else
    {
        alert('Please enter a question.');
        searchInputElement.focus();
        return false;
    }
}

// IE 6 hack to allow copy/paste
// thanks to Tom Gilder http://blog.tom.me.uk/2003/07/23/boie6selecta.php
if (window.createPopup && document.compatMode && document.compatMode=="CSS1Compat"){
  document.onreadystatechange = onresize = function fixIE6AbsPos(){
    if (!document.body) return;
    //if (document.body.style.margin != "0px") document.body.style.margin = 0;
    onresize = null;
    document.body.style.height = 0;
    setTimeout(function(){ document.body.style.height = document.documentElement.scrollHeight+"px"; }, 1);
    setTimeout(function(){ onresize = fixIE6AbsPos; }, 100); 
  }
}

