/**
 * If you would like to add new codes in the future, simply create
 * a new element in this array and make the value the new code.
 **/
var availableCodes = new Array();
availableCodes[0] = "Seminar";
// availableCodes[1] = "NewCodeGoesHere";

/**
 * displayCodeBox
 * This toggles the code box. This should be called by the onClick
 * event of the object that you want to toggle the visibility of the
 * coupon code box.
 **/
function displayCodeBox()
{
    var codeRow = document.getElementById( "CodeRow" );
    var browserString = navigator.appName;
   
    if( codeRow.style.display == "none" )
    {
        if( browserString == "Microsoft Internet Explorer" )
        {
            codeRow.style.display = "block";
        } // end of if
        else
        {
            codeRow.style.display = "table-row";
        } // end of else
    } // end of if
    else
    {
        codeRow.style.display = "none";
    } // end of if
} // end of function

/**
 * checkCode( inCode )
 * This only checks the code that was passed in as a parameter
 * against an array of valid codes. This is normally called by
 * updatePrices().
 * @param (string) A code
 * @return true if the code is valid, false if it is not  **/ function checkCode( inCode ) {
    var retVal = false;
    for( var i = 0; i < availableCodes.length; i++ )
    {
        if( inCode == availableCodes[i] )
        {
            retVal = true;
            break;
        } // end of if
    } // end of for
    return retVal;
} // end of function

/**
 * updatePrices()
 * This updates the form and text to reflect a discount if the coupon
 * code that has been entered is valid. It should be called by the
 * onClick event of the element that you want to apply any codes.
 **/
function updatePrices()
{
    var code = "";
    var result;

    code = document.getElementById( "CodeInput" ).value;
    result = checkCode( code );
    if( result == true )
    {
        document.getElementById("PowerWebRadio").value = "33467032";
        document.getElementById("PowerDeskRadio").value = "33836391";
        document.getElementById("PowerDeskPrice").style.color= "red";
        document.getElementById("PowerWebPrice").style.color= "red";
        document.getElementById("PowerWebPrice").innerHTML = "$9.95/mo";
        document.getElementById("PowerDeskPrice").innerHTML = "$29.95/mo";
    } // end of if
} // end of function
