/*
 * Copyright (c) 2005-2008 by Cisco Systems, Inc.,
 * 170 West Tasman Drive, San Jose, California, 95134, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of Cisco
 * Systems, Inc. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with the
 * terms of the license agreement you entered into with Cisco.
 *
 */


var HOSTNAME_MIN_LEN = 2;
var MAX_LABEL_LENGHT = 63;

var timeZone;
var timeZoneSec;
var timeZoneID;
var otherRegion = "Others";
var PRIMARY_TZ_REGION_ID = "timeZonePrimaryRegion";
var PRIMARY_TZ_ID = "timeZonePrimary";
var SECONDARY_TZ_REGION_ID = "timeZoneSecondaryRegion";
var SECONDARY_TZ_ID = "timeZoneSecondary";

var defCountryIndex;

var popUpHelp;
var downloadWindow;
var popUpXmlFile;

var formObj;
var productName="";
var productVersion="";
var autoNeg="";
var nicSpeed="";
var nicDuplex="";
var changeMtuSize="";
var nicMtuSize="";
var enableDHCP="";
var hostName="";
var hostIP="";
var hostMask="";
var hostGateway="";
var enableDNS="";
var primaryDNS="";
var secondaryDNS="";
var domainName="";
var adminName="";
var adminPasswd="";
var certOrg="";
var certUnit="";
var certLoc="";
var certState="";
var certCon="";
var primaryRoutePoint="";
var endUserLanguage="";
var cerCcmVersion="";
var firstNode="yes";
var hostNamePrimary="";
var hostIPPrimary ="";
var securityPW="";
var externalNTP="";
var ntpServer1="";
var ntpServer2="";
var ntpServer3="";
var ntpServer4="";
var ntpServer5="";
var smtpEnabled="";
var smtpLocation="";
var appUserUsername="";
var appUserPW="";
var w1Upgrade="";
var downloadOption="";
var downloadServerIP="";
var downloadServerUserName="";
var downloadServerUserPW="";
var dmaTarballLocation="";
var dmaTarballName="";
var endUserPIN="";
var endUserPW="";

var hostNameLst="";

var strSubscribers="";
var mmcaSecondaryNodeType="";

// list of existing admins
var adminList = ['root',
                                'bin',
                                'daemon',
                                'adm',
                                'lp',
                                'sync',
                                'shutdown',
                                'halt',
                                'mail',
                                'news',
                                'uucp',
                                'operator',
                                'games',
                                'gopher',
                                'ftp',
                                'nobody',
                                'vcsa',
                                'rpm',
                                'nscd',
                                'sshd',
                                'rpc',
                                'pcap',
                                'ntp',
                                'named',
                                'netdump',
                                'quagga',
                                'radvd',
                                'postgres',
                                'sftpuser',
                                'platform',
                                'tomcat',
                                'pwrecovery',
                                'servmgr',
                                'drf',
                                'licmgr',
                                'enotify',
                                'certmgr',
                                'ipsecmgr',
                                'drfuser',
                                'drfkeys',
                                'informix',
                                'ccmbase',
                                'cdp',
                                'ccmservice',
                                'database',
                                'certbase',
                                'ctftp',
                                'lpm',
                                'certuser',
                                'tomcatmgr',
                                'ccmsyslog',
                                'dbuser',
                                'hpsmh'];

// list of country codes
var countryCodeList=   ["AX" ,
                                                "AF" ,
                                                "AL" ,
                                                "DZ" ,
                                                "AD" ,
                                                "AO" ,
                                                "AI" ,
                                                "AQ" ,
                                                "AG" ,
                                                "AR" ,
                                                "AM" ,
                                                "AW" ,
                                                "AT" ,
                                                "AU" ,
                                                "AZ" ,
                                                "BS" ,
                                                "BH" ,
                                                "BD" ,
                                                "BB" ,
                                                "BY" ,
                                                "BE" ,
                                                "BZ" ,
                                                "BJ" ,
                                                "BM" ,
                                                "BT" ,
                                                "BO" ,
                                                "BA" ,
                                                "BW" ,
                                                "BV" ,
                                                "BR" ,
                                                "IO" ,
                                                "BN" ,
                                                "BG" ,
                                                "BF" ,
                                                "BI" ,
                                                "KH" ,
                                                "CM" ,
                                                "CA" ,
                                                "CV" ,
                                                "KY" ,
                                                "CF" ,
                                                "TD" ,
                                                "CL" ,
                                                "CN" ,
                                                "CX" ,
                                                "CC" ,
                                                "CO" ,
                                                "KM" ,
                                                "CD" ,
                                                "CG" ,
                                                "CK" ,
                                                "CI" ,
                                                "CR" ,
                                                "HR" ,
                                                "CU" ,
                                                "CY" ,
                                                "CZ" ,
                                                "DK" ,
                                                "DJ" ,
                                                "DM" ,
                                                "DO" ,
                                                "TL" ,
                                                "EC" ,
                                                "EG" ,
                                                "SV" ,
                                                "ER" ,
                                                "EE" ,
                                                "ET" ,
                                                "GQ" ,
                                                "FO" ,
                                                "FK" ,
                                                "FI" ,
                                                "FJ" ,
                                                "FR" ,
                                                "GF" ,
                                                "PF" ,
                                                "TF" ,
                                                "GA" ,
                                                "GM" ,
                                                "GE" ,
                                                "DE" ,
                                                "GH" ,
                                                "GI" ,
                                                "GR" ,
                                                "GL" ,
                                                "GD" ,
                                                "GN" ,
                                                "GP" ,
                                                "GT" ,
                                                "GU" ,
                                                "GW" ,
                                                "GY" ,
                                                "HT" ,
                                                "HM" ,
                                                "HN" ,
                                                "HK" ,
                                                "HU" ,
                                                "IS" ,
                                                "IN" ,
                                                "ID" ,
                                                "IR" ,
                                                "IQ" ,
                                                "IE" ,
                                                "IL" ,
                                                "IT" ,
                                                "JM" ,
                                                "JP" ,
                                                "JO" ,
                                                "KZ" ,
                                                "KE" ,
                                                "KI" ,
                                                "KP" ,
                                                "KR" ,
                                                "KW" ,
                                                "KG" ,
                                                "LA" ,
                                                "LV" ,
                                                "LB" ,
                                                "LS" ,
                                                "LR" ,
                                                "LY" ,
                                                "LI" ,
                                                "LT" ,
                                                "LU" ,
                                                "MO" ,
                                                "MK" ,
                                                "MG" ,
                                                "MW" ,
                                                "MY" ,
                                                "MV" ,
                                                "ML" ,
                                                "MT" ,
                                                "MH" ,
                                                "MQ" ,
                                                "MR" ,
                                                "MU" ,
                                                "YT" ,
                                                "MX" ,
                                                "FM" ,
                                                "MD" ,
                                                "MC" ,
                                                "MN" ,
                                                "MS" ,
                                                "MA" ,
                                                "MZ" ,
                                                "MM" ,
                                                "NA" ,
                                                "NR" ,
                                                "NP" ,
                                                "NL" ,
                                                "AN" ,
                                                "NC" ,
                                                "NZ" ,
                                                "NI" ,
                                                "NE" ,
                                                "NG" ,
                                                "NU" ,
                                                "NF" ,
                                                "MP" ,
                                                "NO" ,
                                                "OM" ,
                                                "PK" ,
                                                "PW" ,
                                                "PS" ,
                                                "PA" ,
                                                "PG" ,
                                                "PY" ,
                                                "PE" ,
                                                "PH" ,
                                                "PN" ,
                                                "PL" ,
                                                "PT" ,
                                                "PR" ,
                                                "QA" ,
                                                "RE" ,
                                                "RO" ,
                                                "RU" ,
                                                "RW" ,
                                                "AS" ,
                                                "WS" ,
                                                "SM" ,
                                                "ST" ,
                                                "SA" ,
                                                "SN" ,
                                                "CS" ,
                                                "SC" ,
                                                "SL" ,
                                                "SG" ,
                                                "SK" ,
                                                "SI" ,
                                                "SB" ,
                                                "SO" ,
                                                "ZA" ,
                                                "GS" ,
                                                "ES" ,
                                                "LK" ,
                                                "KN" ,
                                                "SH" ,
                                                "LC" ,
                                                "PM" ,
                                                "VC" ,
                                                "SD" ,
                                                "SR" ,
                                                "SJ" ,
                                                "SZ" ,
                                                "SE" ,
                                                "CH" ,
                                                "SY" ,
                                                "TW" ,
                                                "TJ" ,
                                                "TZ" ,
                                                "TH" ,
                                                "TG" ,
                                                "TK" ,
                                                "TO" ,
                                                "TN" ,
                                                "TR" ,
                                                "TM" ,
                                                "TC" ,
                                                "TT" ,
                                                "TV" ,
                                                "UG" ,
                                                "UA" ,
                                                "AE" ,
                                                "GB" ,
                                                "US" ,
                                                "UY" ,
                                                "UM" ,
                                                "UZ" ,
                                                "VU" ,
                                                "VA" ,
                                                "VE" ,
                                                "VN" ,
                                                "VG" ,
                                                "VI" ,
                                                "WF" ,
                                                "EH" ,
                                                "YE" ,
                                                "ZM" ,
                                                "ZW"
                                                ];

// list of countries
var countryList = 	["Aaland Islands" ,
                                        "Afghanistan" ,
                                        "Albania" ,
                                        "Algeria" ,
                                        "Andorra" ,
                                        "Angola" ,
                                        "Anguilla" ,
                                        "Antarctica" ,
                                        "Antigua & Barbuda" ,
                                        "Argentina" ,
                                        "Armenia" ,
                                        "Aruba" ,
                                        "Austria" ,
                                        "Australia" ,
                                        "Azerbaijan" ,
                                        "Bahamas" ,
                                        "Bahrain" ,
                                        "Bangladesh" ,
                                        "Barbados" ,
                                        "Belarus" ,
                                        "Belgium" ,
                                        "Belize" ,
                                        "Benin" ,
                                        "Bermuda" ,
                                        "Bhutan" ,
                                        "Bolivia" ,
                                        "Bosnia & Herzegovina" ,
                                        "Botswana" ,
                                        "Bouvet Island" ,
                                        "Brazil" ,
                                        "British Indian Ocean Territory" ,
                                        "Brunei" ,
                                        "Bulgaria" ,
                                        "Burkina Faso" ,
                                        "Burundi" ,
                                        "Cambodia" ,
                                        "Cameroon" ,
                                        "Canada" ,
                                        "Cape Verde" ,
                                        "Cayman Islands" ,
                                        "Central African Rep." ,
                                        "Chad" ,
                                        "Chile" ,
                                        "China" ,
                                        "Christmas Island" ,
                                        "Cocos (Keeling) Islands" ,
                                        "Colombia" ,
                                        "Comoros" ,
                                        "Congo (Dem. Rep.)" ,
                                        "Congo (Rep.)" ,
                                        "Cook Islands" ,
                                        "Cote d'Ivoire" ,
                                        "Costa Rica" ,
                                        "Croatia" ,
                                        "Cuba" ,
                                        "Cyprus" ,
                                        "Czech Republic" ,
                                        "Denmark" ,
                                        "Djibouti" ,
                                        "Dominica" ,
                                        "Dominican Republic" ,
                                        "East Timor" ,
                                        "Ecuador" ,
                                        "Egypt" ,
                                        "El Salvador" ,
                                        "Eritrea" ,
                                        "Estonia" ,
                                        "Ethiopia" ,
                                        "Equatorial Guinea" ,
                                        "Faeroe Islands" ,
                                        "Falkland Islands" ,
                                        "Finland" ,
                                        "Fiji" ,
                                        "France" ,
                                        "French Guiana" ,
                                        "French Polynesia" ,
                                        "French Southern & Antarctic Lands" ,
                                        "Gabon" ,
                                        "Gambia" ,
                                        "Georgia" ,
                                        "Germany" ,
                                        "Ghana" ,
                                        "Gibraltar" ,
                                        "Greece" ,
                                        "Greenland" ,
                                        "Grenada" ,
                                        "Guineav",
                                        "Guadeloupe" ,
                                        "Guatemala" ,
                                        "Guam" ,
                                        "Guinea-Bissau" ,
                                        "Guyana" ,
                                        "Haiti" ,
                                        "Heard Island & McDonald Islands" ,
                                        "Honduras" ,
                                        "Hong Kong" ,
                                        "Hungary" ,
                                        "Iceland" ,
                                        "India" ,
                                        "Indonesia" ,
                                        "Iran" ,
                                        "Iraq" ,
                                        "Ireland" ,
                                        "Israel" ,
                                        "Italy" ,
                                        "Jamaica" ,
                                        "Japan" ,
                                        "Jordan" ,
                                        "Kazakhstan" ,
                                        "Kenya" ,
                                        "Kiribati" ,
                                        "Korea (North)" ,
                                        "Korea (South)" ,
                                        "Kuwait" ,
                                        "Kyrgyzstan" ,
                                        "Laos" ,
                                        "Latvia" ,
                                        "Lebanon" ,
                                        "Lesotho" ,
                                        "Liberia" ,
                                        "Libya" ,
                                        "Liechtenstein" ,
                                        "Lithuania" ,
                                        "Luxembourg" ,
                                        "Macau" ,
                                        "Macedonia" ,
                                        "Madagasca" ,
                                        "Malawi" ,
                                        "Malaysia" ,
                                        "Maldives" ,
                                        "Mali" ,
                                        "Malta" ,
                                        "Marshall Islands" ,
                                        "Martinique" ,
                                        "Mauritania" ,
                                        "Mauritius" ,
                                        "Mayotte" ,
                                        "Mexico" ,
                                        "Micronesia" ,
                                        "Moldova" ,
                                        "Monaco" ,
                                        "Mongolia" ,
                                        "Montserrat" ,
                                        "Morocco" ,
                                        "Mozambique" ,
                                        "Myanmar (Burma)" ,
                                        "Namibia" ,
                                        "Nauru" ,
                                        "Nepal" ,
                                        "Netherlands" ,
                                        "Netherlands Antilles" ,
                                        "New Caledonia" ,
                                        "New Zealand" ,
                                        "Nicaragua" ,
                                        "Niger" ,
                                        "Nigeria" ,
                                        "Niue" ,
                                        "Norfolk Island" ,
                                        "Northern Mariana Islands" ,
                                        "Norway" ,
                                        "Oman" ,
                                        "Pakistan" ,
                                        "Palau" ,
                                        "Palestine" ,
                                        "Panama" ,
                                        "Papua New Guinea" ,
                                        "Paraguay" ,
                                        "Peru" ,
                                        "Philippines" ,
                                        "Pitcairn" ,
                                        "Poland" ,
                                        "Portugalv",
                                        "Puerto Rico" ,
                                        "Qatar" ,
                                        "Reunion" ,
                                        "Romania" ,
                                        "Russia" ,
                                        "Rwanda" ,
                                        "Samoa (American)" ,
                                        "Samoa (Western)" ,
                                        "San Marino" ,
                                        "Sao Tome & Principe" ,
                                        "Saudi Arabia" ,
                                        "Senegal" ,
                                        "Serbia and Montenegro" ,
                                        "Seychelles" ,
                                        "Sierra Leone" ,
                                        "Singapore" ,
                                        "Slovakia" ,
                                        "Slovenia" ,
                                        "Solomon Islands" ,
                                        "Somalia" ,
                                        "South Africa" ,
                                        "South Georgia & the South Sandwich Islands" ,
                                        "Spain" ,
                                        "Sri Lanka" ,
                                        "St Kitts & Nevis" ,
                                        "St Helena" ,
                                        "St Lucia" ,
                                        "St Pierre & Miquelon" ,
                                        "St Vincent" ,
                                        "Sudan" ,
                                        "Suriname" ,
                                        "Svalbard & Jan Mayen" ,
                                        "Swaziland" ,
                                        "Sweden" ,
                                        "Switzerland" ,
                                        "Syria" ,
                                        "Taiwan" ,
                                        "Tajikistan" ,
                                        "Tanzania" ,
                                        "Thailand" ,
                                        "Togo" ,
                                        "Tokelau" ,
                                        "Tonga" ,
                                        "Tunisia" ,
                                        "Turkey" ,
                                        "Turkmenistan" ,
                                        "Turks & Caicos Is" ,
                                        "Trinidad & Tobago" ,
                                        "Tuvalu" ,
                                        "Uganda" ,
                                        "Ukraine" ,
                                        "United Arab Emirates" ,
                                        "United Kingdom" ,
                                        "United States of America" ,
                                        "Uruguay" ,
                                        "US minor outlying islands" ,
                                        "Uzbekistan" ,
                                        "Vanuatu" ,
                                        "Vatican City" ,
                                        "Venezuela" ,
                                        "Vietnam" ,
                                        "Virgin Islands (UK)" ,
                                        "Virgin Islands (US)" ,
                                        "Wallis & Futuna" ,
                                        "Western Sahara" ,
                                        "Yemen" ,
                                        "Zambia" ,
                                        "Zimbabwe"
                                        ];

var languageList = ["Canadian French", "English"];

// checks if string is a number
function isNum(strNum)
{
 for (var i=0; i<strNum.length; i++)
   {
         var ch = strNum.charAt(i);
         if (ch >= "0" && ch <= "9")
           continue;
         else
           return false;
   }
   return true;
}

// checks if string contains only alphabets
function isAlpha(strTxt)
{
        var strTemp = fnTrim(strTxt);
        var blnFlag = true;
        if(strTemp=="")
        {
                return false;
        }
        for (var i=0; i<strTemp.length; i++)
        {
                var ch = strTemp.charAt(i);

                if (ch >= "A" && ch <= "Z")
                        continue;
                else if (ch >= "a" && ch <= "z")
                        continue;
                else
                        return false;
        }
        return true;
}

// checks if string contains only alphabets or numbers
function isAlphaNum(strTxt)
{
        var strTemp = fnTrim(strTxt);
        var blnFlag = true;
        if(strTemp=="")
        {
                return false;
        }
        for (var i=0; i<strTemp.length; i++)
        {
                var ch = strTemp.charAt(i);

                if (ch >= "0" && ch <= "9")
                        continue;
                else if (ch >= "A" && ch <= "Z")
                        continue;
                else if (ch >= "a" && ch <= "z")
                        continue;
                else
                        return false;
        }
        return true;
}

// checks if string is a valid host name
function fnValidHostName(strText)
{
        var strTemp = fnTrim(strText);
        var blnFlag = true;
        if(strTemp=="")
        {
                return false;
        }
        for (var i=0; i<strTemp.length; i++)
        {
                var ch = strTemp.charAt(i);

                if (ch >= "0" && ch <= "9")
                        continue;
                else if (ch >= "A" && ch <= "Z")
                        continue;
                else if (ch >= "a" && ch <= "z")
                        continue;
                else if (ch == "-")
                        continue;
                else
                        return false;
        }
        return true;
}

// checks if string is valid ip address
function fnValidateIP(ipAddress)
{

        var reIPAddress = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;

        if (reIPAddress.test(ipAddress))
        {
                var ipOctects = ipAddress.split('.');
                for (var i=0; i<ipOctects.length; i++)
                {
                        if (parseInt(parseFloat(ipOctects[i])) > 255)
                        {
                                //alert("Invalid IP Address");
                                return false;
                        }
                }
        }
        else
        {
                //alert("Incorrect IP Address");
                return false;
        }


        if (fnTrim(ipAddress) == "0.0.0.0")
        {
                //alert("Invalid IP Address");
                return false;
        }

        return true;
}

// checks if string is a valid mask
function fnValidateMask(ipMask)
{

        var reIPMask = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;

        if (reIPMask.test(ipMask))
        {
                var ipOctects = ipMask.split('.');
                for (var i=0; i<ipOctects.length; i++)
                {
                        if (parseInt(parseFloat(ipOctects[i])) > 255)
                        {
                                //alert("Invalid Mask");
                                return false;
                        }
                }
        }
        else
        {
                //alert("Invalid Mask format");
                return false;
        }
        //alert("initial passed");
        var ipOctects = ipMask.split('.');
        var octect = 0;
        var foundOne = 0;
        var foundZero = 0;
        for (var i=0; i<ipOctects.length; i++)
        {
                octect = parseInt(parseFloat(ipOctects[i]));
                for ( var j=0; j<8; j++)
                {
                        //alert(octect << j);
                        //alert((( octect << j ) & 0x80));
                        if ((( octect << j ) & 0x80) == 0x0)
                        {
                                if (foundOne == 1)
                                {
                                        foundZero = 1;
                                        //alert("Invalid Mask");
                                        //return false;
                                }
                                // if first bit is zero then return false
                                if (i==0 && j==0)
                                {
                                        return false;
                                }
                        }
                        else
                        {
                                if (foundOne == 1 && foundZero == 1)
                                {
                                        return false;
                                }
                                foundOne = 1;
                                //alert("1 found");
                        }
                }

        }

        return true;
}

// checks if string is a valid domain label
function validateDomainLabel(strLabel)
{

        if (strLabel == '' || !isAlpha(strLabel.charAt(0)) ||
                strLabel.length == 0 || !isAlphaNum(strLabel.charAt(strLabel.length-1)))
        {
                return false;
        }
        else
        {
                for (var i=0 ; i< strLabel.length; i++)
                {
                        if (strLabel.charAt(i) != '.' && strLabel.charAt(i) != '-'
                                && !isAlphaNum(strLabel.charAt(i)))
                        {
                                return false;
                                break;
                        }
                }
        }
        return true;
}

// checks if string is a valid domain name
function fnValidateDomain(domainName)
{
        var tempDomName = fnTrim(domainName);

        if (tempDomName != "" && isAlphaNum(tempDomName.charAt(0)) &&
                isAlphaNum(tempDomName.charAt(tempDomName.length-1)) &&
                tempDomName.length > 0 && tempDomName.charAt(tempDomName.length-1) != '.')
        {
                var len = tempDomName.length;
                var i=0;
                var labelName = "";
                var tempName = tempDomName;
                while (i < len)
                {
                        matchIndex = tempName.indexOf('.');
                        if (matchIndex == -1 )
                                labelName = tempName;
                        else
                                labelName = tempName.substr(0,matchIndex);

                        if (labelName.length == 0 || labelName.length > 63)
                        {
                                //alert("Invalid Domain Name");
                                return false;
                                break;
                        }
                        else
                        {
                                if (!validateDomainLabel(labelName))
                                {
                                        //alert("Invalid Domain Name");
                                        return false;
                                        break
                                }
                                else
                                {
                                        i = ( matchIndex == -1 ? len : matchIndex+1);
                                        tempName = tempName.substr(matchIndex+1);
                                }
                        }
                }

                var allDigitsFlag = 1;
                for (var j=0; j<len;j++)
                {
                        if ( !isNum(tempDomName.charAt(j)) && tempDomName.charAt(j) != '.')
                        {
                                allDigitsFlag = 0;
                                break;
                        }

                }

                if (allDigitsFlag == 0)
                        return true;
                else
                {
                        //alert("Invalid Domain Name");
                        return false;
                }
        }
        else
        {
                //alert("Invalid Domain Name");
                return false;
        }
        return true;
}

//check for valid nicMtusize
function fnValidateNicMtuSize(nicMtuSize)
{
	var tempNicMtuSize = fnTrim(nicMtuSize);
	
	if(tempNicMtuSize>=552 && tempNicMtuSize<=1500)
	{
		return true;
	}
	else
	{
		return false;
	}
}
	
// checks if string is a valid host name
function fnValidateHostName(hostName)
{
        var tempHostName = fnTrim(hostName);

        if (tempHostName != "" && isAlpha(tempHostName.charAt(0)) &&
                isAlphaNum(tempHostName.charAt(tempHostName.length-1)) &&
                tempHostName.length >=2 && tempHostName.length <=63 &&
                fnValidHostName(tempHostName))
        {
                return true;
        }
        else
        {
                //alert("Invalid Host Name");
                return false;
        }
        return true;
}

// checks is string contains valid characters for user name
function validUser(strUserName)
{
        var strTempUserName = fnTrim(strUserName);
        for (var i=0 ; i <strTempUserName.length; i++)
        {
                if (!isAlphaNum(strTempUserName.charAt(i)) && strTempUserName.charAt(i)
                        != '_' && strTempUserName.charAt(i) != '-')
                {
                        return false;
                }
        }
        return true;
}

// checks if string is valid user name
function fnValidateUserName(strUserName)
{
        var strTempUserName = fnTrim(strUserName);
        if (strTempUserName == '' || strTempUserName.length == 0)
        {
                //alert("Invalid User Name");
                return false;
        }
        else if (!isAlpha(strTempUserName.charAt(0)))
        {
                //alert("Invalid User Name");
                return false;
        }
        else
        {
                if (!validUser(strTempUserName))
                {
                        //alert("Invalid User Name");
                        return false;
                }
        }
        return true;
}

// checks if string is a valid password
function fnValidatePW(strPW)
{
	if(strPW.search(' ') != -1)
	{
		alert("Please enter a valid password.  Spaces are not accepted.");
		return false;
	}
	
        var strTempPW = fnTrim(strPW);
        if (strTempPW == '')
		{
				alert("Please enter a valid password.");
                return false;
		}
		else if (strTempPW.length > 31)
        {
                alert("Please enter a password that is less than 32 characters.");
                return false;
        }
        else
        {
                /*if (!validUser(strTempPW))
                {
                        //alert("Invalid Password");
                        return false;
                }*/
        }
        return true;
}

// checks if string is a valid admin name
function fnValidateAdmin(strName)
{
        var strTempName = fnTrim(strName);
        if (strTempName == '' || strTempName.length == 0)
        {
                        //alert("Invalid User Name");
                        return false;
        }
        for (var i=0;i<adminList.length; i++)
        {
                if (adminList[i] == strTempName)
                {
                        //alert("Invalid User Name");
                        return false;
                }
        }

        return fnValidateUserName(strTempName);
}

// checks if string contains only valid characters for CSR data
function allowedCSRChar(charCSR)
{
        if (charCSR == ' ' || charCSR == '\t' || charCSR == '{' || charCSR == '}' ||
                                charCSR == '(' || charCSR == ')' || charCSR == '[' || charCSR == ']' ||
                                charCSR == '.' || charCSR == ',' ||
                                charCSR == '-' || charCSR == '_' ||	charCSR == ':' || charCSR == ';')
                return true;

        return false;
}

// checks if string is valid CSR string
function fnValidateCSR(strCSR)
{
        var strTempCSR = fnTrim(strCSR);
        if (strTempCSR == '' || strTempCSR.length ==0)
        {
                return false;
        }
        for (var i=0;i<strTempCSR.length; i++)
        {
                if (!isAlphaNum(strTempCSR.charAt(i)) &&
                        ! allowedCSRChar(strTempCSR.charAt(i)))
                {
                        return false;
                }
        }
        return true;
}



// checks if string contains only valid file name characters
function validFileName(strFileName)
{
        var strTemp = strFileName;
        if(strTemp=="")
        {
                return false;
        }
        for (var i=0; i<strTemp.length; i++)
        {
                var ch = strTemp.charAt(i);

                if (ch >= "0" && ch <= "9")
                        continue;
                else if (ch >= "A" && ch <= "Z")
                        continue;
                else if (ch >= "a" && ch <= "z")
                        continue;
                else if (ch == "/" || ch == "-" || ch == "_" || ch == "#" || ch == ".")
                        continue;
                else
                        return false;
        }
        return true;


}
// checks if string is valid file name
function fnValidateFileName(strFileName)
{
        var strTempFileName = fnTrim(strFileName);
        if (strTempFileName == "" || strTempFileName.length == 0)
        {
                //alert("Invalid File Name");
                return false;
        }
        else
        {
                for (var i=0; i< strTempFileName.length; i++)
                {
                        if (!validFileName(strTempFileName.charAt(i)))
                        {
                                //alert("Invalid File Name");
                                return false;
                        }
                }
        }
        return true;

}

// checks if string is valid directory name
function fnValidateDirectory(strDirName)
{
        var strTempDirName = fnTrim(strDirName);
        for (var i=0; i< strTempDirName.length; i++)
        {
                if (!validFileName(strTempDirName.charAt(i)))
                {
                        //alert("Invalid Directory Name");
                        return false;
                }
        }
        return true;
}

//checks if valid Primary Route Point
function fnValidatePRP(strPRP)
{
	var strTempPRP = fnTrim(strPRP);
	for(var i=0; i< strTempPRP.length; i++)
	{
		if(!isNum(strTempPRP.charAt(i)) && strTempPRP.charAt(i)!='*' && strTempPRP.charAt(i)!='#')
		{
			return false;
		}
	}
	return true;
}
	
// trims the strings of leading and trailing white spaces
function fnTrim(strText)
{
        // this will get rid of leading spaces
        while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);
        // this will get rid of TRailing spaces
        while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
        return strText;
}

// this function populates the combo boxes for timezones and countries when page loads
function populateOptions()
{
        // Add product names
        updateProducts();
        
        if (countryList.length != countryCodeList.length)
        {
                return false;
        }

        var country;
        var countryCode;
        for (var count=0; count<countryList.length; count++)
        {
                var optCountry = new Option (countryList[count],countryCodeList[count]);
                formObj.certCon.options[count] = optCountry;

                if (countryCodeList[count] == "US")
                {
                        formObj.certCon.options.selectedIndex=count;
                        defCountryIndex = count;
                }
        }

		if(formObj.productName.value=="cer")
		{
			var language;
			for (var count=0; count<languageList.length; count++)
			{
					var optLanguage = new Option (languageList[count],languageList[count]);
					formObj.endUserLanguage.options[count] = optLanguage;

					if (languageList[count] == "English")
					{
							formObj.endUserLanguage.options.selectedIndex=count;
							defLanguageIndex = count;
					}
			}
		}

}

// this function is used to initialize the page depending upon
// the values of various parameters selected by default on the page.
function initializePage()
{
        fnProduct();
        fnNIC('1');
        fnNIC('2');
        fnStatic('1');
        fnStatic('2');
        fnDNSOption('1');
        fnDNSOption('2');
        fnNTP();
        fnSMTP();
        fnSecondaryList();
}

// added during muster development
// this function sets the background of the secondary hostlist
// based on the number of element in it
// if 0 element then lightgrey, if more than 0 then white
function fnSecondaryList()
{
        var optLen = formObj.hostNameList.options.length;
        if (optLen > 0)
        {
                formObj.hostNameList.disabled=false;
                formObj.hostNameList.style.backgroundColor='white';
        }
        else
        {
                formObj.hostNameList.disabled=true;
                formObj.hostNameList.style.backgroundColor='lightgrey';
        }
}

// Added for muster
// this function is called when the drop down containing
// products to be installed is changed to a different value.
function fnProduct()
{
        var obj = formObj.productName;

        if (obj.value == "coresident")
        {
                // co-res was selected
                formObj.autoNegConfSecondary.disabled=true;
                formObj.nicSpeedSecondary.disabled=true;
                formObj.nicDuplexSecondary.disabled=true;
                formObj.changeMtuSizeSecondary.disabled=true;
                formObj.nicMtuSizeSecondary.disabled=true;

                formObj.enableDHCPSecondary.disabled=true;
                formObj.hostNameSecondary.disabled=true;
                formObj.hostIPSecondary.disabled=true;
                formObj.hostMaskSecondary.disabled=true;
                formObj.hostGatewaySecondary.disabled=true;

                formObj.enableDNSSecondary.disabled = true;
                formObj.usePrimaryDNSSetting.disabled = true;
                formObj.primaryDNSSecondary.disabled=true;
                formObj.secondaryDNSSecondary.disabled=true;
                formObj.domainNameSecondary.disabled=true;

                formObj.sameTimeZone.disabled = true;
                formObj.timeZoneSecondaryRegion.disabled = true;
                formObj.timeZoneSecondary.disabled = true;
                formObj.addSecondary.disabled = true;
                formObj.deleteSecondary.disabled = true;
                formObj.hostNameList.disabled = true;

                formObj.nicSpeedSecondary.style.backgroundColor='lightgrey';
                formObj.nicDuplexSecondary.style.backgroundColor='lightgrey';
                formObj.nicMtuSizeSecondary.style.backgroundColor='lightgrey';

                formObj.hostNameSecondary.style.backgroundColor='lightgrey';
                formObj.hostIPSecondary.style.backgroundColor='lightgrey';
                formObj.hostMaskSecondary.style.backgroundColor='lightgrey';
                formObj.hostGatewaySecondary.style.backgroundColor='lightgrey';

                formObj.primaryDNSSecondary.style.backgroundColor='lightgrey';
                formObj.secondaryDNSSecondary.style.backgroundColor='lightgrey';
                formObj.domainNameSecondary.style.backgroundColor='lightgrey';

                formObj.timeZoneSecondaryRegion.style.backgroundColor='lightgrey';
                formObj.timeZoneSecondary.style.backgroundColor='lightgrey';
                formObj.hostNameList.style.backgroundColor='lightgrey';

        }
        else
        {
                formObj.autoNegConfSecondary.disabled=false;
                fnNIC('2');
                formObj.enableDHCPSecondary.disabled=false;
                formObj.hostNameSecondary.disabled=false;
                fnStatic('2');
                fnDNSOption('2');
                var select = formObj.usePrimaryDNSSetting.checked;
                if (select == true)
                {
                        formObj.usePrimaryDNSSetting.disabled=false;
                }
                formObj.sameTimeZone.disabled=false;
                formObj.timeZoneSecondaryRegion.disabled=false;
                formObj.timeZoneSecondary.disabled=false;

                formObj.addSecondary.disabled=false;
                formObj.deleteSecondary.disabled=false;

                fnSecondaryList();

                formObj.hostNameSecondary.style.backgroundColor='white';
                formObj.timeZoneSecondaryRegion.style.backgroundColor='white';
                formObj.timeZoneSecondary.style.backgroundColor='white';

                if(formObj.productName.value=="cer")
                {
                    formObj.primaryRoutePoint.disabled=false;
                    formObj.endUserLanguage.disabled=false;
                    formObj.cerCcmVersion.disabled=false;

                    formObj.primaryRoutePoint.style.backgroundColor='white';
                    formObj.endUserLanguage.style.backgroundColor='white';
                    formObj.cerCcmVersion.style.backgroundColor='white';
                }
        }
        if (obj.value == "expertadvisor")
        {
                formObj.mmcanodeselectionfield.style.display = "";
        }
        else
        {
                formObj.mmcanodeselectionfield.style.display = "none";
        }

        // Update the version options based on current product name
        updateVersions();

        // Since the version options have changed call fnVersions()
        fnVersion();
}

// this function is called when the drop down containing
// product versions is changed to a different value.
function fnVersion()
{
    // Update the primary and secondary time zone regions
    var productName = formObj.productName.value;
    var productVersion = formObj.productVersion.value;
    updateTimeZoneRegions(PRIMARY_TZ_REGION_ID, productName, productVersion);
    updateTimeZoneRegions(SECONDARY_TZ_REGION_ID, productName, productVersion);

    // Since the region options have changed call fnTimeZoneRegion()
    fnTimeZoneRegion(PRIMARY_TZ_REGION_ID, PRIMARY_TZ_ID);
    fnTimeZoneRegion(SECONDARY_TZ_REGION_ID, SECONDARY_TZ_ID);
}

// this function is called when the drop down containing
// time zone regions is changed to a different value.
function fnTimeZoneRegion(timeZoneRegionElement, timeZoneElement)
{
    var timeZoneRegion;
    if (timeZoneRegionElement == PRIMARY_TZ_REGION_ID) {
        timeZoneRegion = formObj.timeZonePrimaryRegion.value;
    } else {
        timeZoneRegion = formObj.timeZoneSecondaryRegion.value;
    }

    updateTimeZone(timeZoneElement, timeZoneRegion)
}

// this function is called when the Change MTU Size check box
// checked or unchecked . it enables the NIC Size
// depending on the state of the Change MTU Size check box
function fnMTU(nodeType)
{

	if(nodeType == '1')
	{
		var obj= formObj.changeMtuSizePrimary;
		var select = obj.checked;
		if(select == true)
		{
			formObj.nicMtuSizePrimary.disabled=false;
			formObj.nicMtuSizePrimary.style.backgroundColor='white';
		}
		else
		{

			formObj.nicMtuSizePrimary.value="";
			formObj.nicMtuSizePrimary.disabled=true;
			formObj.nicMtuSizePrimary.style.backgroundColor='lightgrey';
		}
	}
	else
	{
		var obj= formObj.changeMtuSizeSecondary;
		var select = obj.checked;
		if(select == true)
		{
			formObj.nicMtuSizeSecondary.disabled=false;
			formObj.nicMtuSizeSecondary.style.backgroundColor='white';
		}
		else
		{
			formObj.nicMtuSizeSecondary.value="";
			formObj.nicMtuSizeSecondary.disabled=true;
			formObj.nicMtuSizeSecondary.style.backgroundColor='lightgrey';
		}
	}
}

// this function is called when the Auto Negotiation check box
// checked or unchecked . it enabled the NIC Speed and NIC Duplex
// depending on the state of the Auto Negotitiation check box
function fnNIC(nodeType)
{
        //alert("here only");
        if (nodeType == '1')
        {
                var obj= formObj.autoNegConfPrimary;
                var select = obj.checked;
                if (select == true)
                {
                        formObj.nicSpeedPrimary.disabled=true;
                        formObj.nicDuplexPrimary.disabled=true;
						formObj.changeMtuSizePrimary.checked=false;
						formObj.changeMtuSizePrimary.disabled=true;
						formObj.nicMtuSizePrimary.value="";
						formObj.nicMtuSizePrimary.disabled=true;

                        formObj.nicSpeedPrimary.style.backgroundColor='lightgrey';
                        formObj.nicDuplexPrimary.style.backgroundColor='lightgrey';
						formObj.nicMtuSizePrimary.style.backgroundColor='lightgrey';
                }
                else if (select == false)
                {
                        formObj.nicSpeedPrimary.disabled=false;
                        formObj.nicDuplexPrimary.disabled=false;
						formObj.changeMtuSizePrimary.disabled=false;

                        formObj.nicSpeedPrimary.style.backgroundColor='white';
                        formObj.nicDuplexPrimary.style.backgroundColor='white';
						
                }
        }
        else
        {
                var obj= formObj.autoNegConfSecondary;
                var select = obj.checked;
                if (select == true)
                {
                        formObj.nicSpeedSecondary.disabled=true;
                        formObj.nicDuplexSecondary.disabled=true;
						formObj.changeMtuSizeSecondary.checked=false;
						formObj.changeMtuSizeSecondary.disabled=true;
						formObj.nicMtuSizeSecondary.value="";
						formObj.nicMtuSizeSecondary.disabled=true;

                        formObj.nicSpeedSecondary.style.backgroundColor='lightgrey';
                        formObj.nicDuplexSecondary.style.backgroundColor='lightgrey';
						formObj.nicMtuSizeSecondary.style.backgroundColor='lightgrey';
                }
                else if (select == false)
                {
                        formObj.nicSpeedSecondary.disabled=false;
                        formObj.nicDuplexSecondary.disabled=false;
						formObj.changeMtuSizeSecondary.disabled=false;

                        formObj.nicSpeedSecondary.style.backgroundColor='white';
                        formObj.nicDuplexSecondary.style.backgroundColor='white';
						
                }
        }
}

// this function is called when checkbox for DHCP is checked or unchecked.
// this enables or disables the DHCP parameters depending ofn the state of the checkbox.
function fnStatic(nodeType)
{

        if (nodeType == '1')
        {
                var obj = document.paramForm.enableDHCPPrimary;
                var select = obj.checked;
                if (select == true)
                {
                        // warn user that secondary nodes using Primary Node setting will be deleted

                        //adding check to ensure that no secondary nodes with
                        //primary dns settings exist in the secondary list
                        //when DHCP is set to yes

                        if (formObj.hostNameList.options.length > 0)
                        {
                                var lenOpt = formObj.hostNameList.options.length;
                                var isPrimaryUsed = false;

                                // check if atleast one secondary node uses primary settings
                                for (var count=0; count<lenOpt; count++)
                                {
                                        var optValue = formObj.hostNameList.options[count].value;
                                        if (optValue.indexOf('Primary DNS Settings') != -1)
                                        {
                                                isPrimaryUsed = true;
                                                break;
                                        }
                                }

                                // if atleast one secondary node uses primary settings
                                if (isPrimaryUsed == true)
                                {
                                        var strWarning = "All Secondary Nodes using Primary DNS Settings will be deleted.Are you sure you want to proceed?";
                                        if (!confirm(strWarning))
                                        {
                                                // if user does not want to continue revert checkbox to original state
                                                document.paramForm.enableDHCPPrimary.checked=false;
                                                return;
                                        }
                                        else
                                        {
                                                // delete all secondary nodes using Primary DNS Settings

                                                var lenOptDel = formObj.hostNameList.options.length;

                                                // set all nodes with primary DNS settings to null
                                                for (var count=lenOptDel-1; count>=0; count--)
                                                {
                                                        var optValueDel = formObj.hostNameList.options[count].value;
                                                        if (optValueDel.indexOf('Primary DNS Settings') != -1)
                                                        {
                                                                formObj.hostNameList.options[count]=null;
                                                        }
                                                }
                                        }
                                }
                        }

                        // Disable host IP address only if no secondary nodes added
                        var noOfSecondaryNodes = formObj.hostNameList.options.length;
                        if (noOfSecondaryNodes == null || noOfSecondaryNodes == 0) {
                            formObj.hostIPPrimary.disabled=true;
                            formObj.hostIPPrimary.style.backgroundColor='lightgrey';
                        }

                        //formObj.hostNamePrimary.disabled=true;
                        formObj.hostMaskPrimary.disabled=true;
                        formObj.hostGatewayPrimary.disabled=true;

                        //formObj.hostNamePrimary.style.backgroundColor='lightgrey';
                        formObj.hostMaskPrimary.style.backgroundColor='lightgrey';
                        formObj.hostGatewayPrimary.style.backgroundColor='lightgrey';

                        //now disable DNS settings and parameters
                        document.paramForm.enableDNSPrimary.checked = false;
                        document.paramForm.enableDNSPrimary.disabled=true;

                        formObj.primaryDNSPrimary.value="";
                        formObj.secondaryDNSPrimary.value="";
                        formObj.domainNamePrimary.value="";

                        formObj.primaryDNSPrimary.disabled=true;
                        formObj.secondaryDNSPrimary.disabled=true;
                        formObj.domainNamePrimary.disabled=true;

                        formObj.primaryDNSPrimary.style.backgroundColor='lightgrey';
                        formObj.secondaryDNSPrimary.style.backgroundColor='lightgrey';
                        formObj.domainNamePrimary.style.backgroundColor='lightgrey';

                        // unset the use primary DNS settings check box also
                        formObj.usePrimaryDNSSetting.checked=false;
                        formObj.usePrimaryDNSSetting.disabled = true;

                }
                else if (select == false)
                {
                        //formObj.hostNamePrimary.disabled=false;
                        formObj.hostIPPrimary.disabled=false;
                        formObj.hostMaskPrimary.disabled=false;
                        formObj.hostGatewayPrimary.disabled=false;

                        //formObj.hostNamePrimary.style.backgroundColor='white';
                        formObj.hostIPPrimary.style.backgroundColor='white';
                        formObj.hostMaskPrimary.style.backgroundColor='white';
                        formObj.hostGatewayPrimary.style.backgroundColor='white';

                        // enable DNS checkbox alone

                        document.paramForm.enableDNSPrimary.disabled=false;

                        /*formObj.primaryDNSPrimary.disabled=false;
                        formObj.secondaryDNSPrimary.disabled=false;
                        formObj.domainNamePrimary.disabled=false;

                        formObj.primaryDNSPrimary.style.backgroundColor='white';
                        formObj.secondaryDNSPrimary.style.backgroundColor='white';
                        formObj.domainNamePrimary.style.backgroundColor='white';*/

                }
        }
        else
        {
                var obj = document.paramForm.enableDHCPSecondary;
                var select = obj.checked;
                if (select == true)
                {
                        //formObj.hostNameSecondary.disabled=true;
                        formObj.hostIPSecondary.disabled=true;
                        formObj.hostMaskSecondary.disabled=true;
                        formObj.hostGatewaySecondary.disabled=true;

                        //formObj.hostNameSecondary.style.backgroundColor='lightgrey';
                        formObj.hostIPSecondary.style.backgroundColor='lightgrey';
                        formObj.hostMaskSecondary.style.backgroundColor='lightgrey';
                        formObj.hostGatewaySecondary.style.backgroundColor='lightgrey';

                        // disable the DNS parameters
                        formObj.enableDNSSecondary.checked=false;
                        formObj.enableDNSSecondary.disabled=true;

                        formObj.primaryDNSSecondary.value="";
                        formObj.secondaryDNSSecondary.value="";
                        formObj.domainNameSecondary.value="";

                        formObj.primaryDNSSecondary.disabled=true;
                        formObj.secondaryDNSSecondary.disabled=true;
                        formObj.domainNameSecondary.disabled=true;

                        formObj.primaryDNSSecondary.style.backgroundColor='lightgrey';
                        formObj.secondaryDNSSecondary.style.backgroundColor='lightgrey';
                        formObj.domainNameSecondary.style.backgroundColor='lightgrey';

                        // disable the Use Primary DNS setting also
                        formObj.usePrimaryDNSSetting.checked=false;
                        formObj.usePrimaryDNSSetting.disabled = true;

                }
                else if (select == false)
                {
                        //formObj.hostNameSecondary.disabled=false;
                        formObj.hostIPSecondary.disabled=false;
                        formObj.hostMaskSecondary.disabled=false;
                        formObj.hostGatewaySecondary.disabled=false;

                        //formObj.hostNameSecondary.style.backgroundColor='white';
                        formObj.hostIPSecondary.style.backgroundColor='white';
                        formObj.hostMaskSecondary.style.backgroundColor='white';
                        formObj.hostGatewaySecondary.style.backgroundColor='white';

                        // enable the DNS checkbox alone
                        formObj.enableDNSSecondary.disabled=false;

                        /*formObj.primaryDNSSecondary.disabled=false;
                        formObj.secondaryDNSSecondary.disabled=false;
                        formObj.domainNameSecondary.disabled=false;

                        formObj.primaryDNSSecondary.style.backgroundColor='white';
                        formObj.secondaryDNSSecondary.style.backgroundColor='white';
                        formObj.domainNameSecondary.style.backgroundColor='white';*/
                }
        }
}

// this function is called when DNS checkbox is checked or unchecked.
// it enables or disables DNS parameters depending upon the state of the checkbox.
// it also checks for any secondary nodes that might be left unusable when checkbox is
// disabled and deletes them.
function fnDNSOption(nodeType)
{

        if (nodeType == '1')
        {
                var obj = document.paramForm.enableDNSPrimary;
                var select = obj.checked;
                if (select == true)
                {
                        formObj.primaryDNSPrimary.disabled=false;
                        formObj.secondaryDNSPrimary.disabled=false;
                        formObj.domainNamePrimary.disabled=false;

                        formObj.primaryDNSPrimary.style.backgroundColor='white';
                        formObj.secondaryDNSPrimary.style.backgroundColor='white';
                        formObj.domainNamePrimary.style.backgroundColor='white';

                        if (formObj.enableDNSSecondary.checked == true)
                                formObj.usePrimaryDNSSetting.disabled = false;
                        else if (formObj.enableDNSSecondary.checked == false)
                        {
                                formObj.usePrimaryDNSSetting.checked=false;
                                formObj.usePrimaryDNSSetting.disabled = true;
                        }
                }
                else if (select == false)
                {

                        //adding check to ensure that no secondary nodes with
                        //primary dns settings exist in the secondary list if
                        //the primary dns settings is removed

                        if (formObj.hostNameList.options.length > 0)
                        {
                                var lenOpt = formObj.hostNameList.options.length;
                                var isPrimaryUsed = false;

                                // check if atleast one secondary node uses primary settings
                                for (var count=0; count<lenOpt; count++)
                                {
                                        var optValue = formObj.hostNameList.options[count].value;
                                        if (optValue.indexOf('Primary DNS Settings') != -1)
                                        {
                                                isPrimaryUsed = true;
                                                break;
                                        }
                                }

                                // if atleast one secondary node uses primary settings
                                if (isPrimaryUsed == true)
                                {
                                        var strWarning = "All Secondary Nodes using Primary DNS Settings will be deleted.Are you sure you want to proceed?";
                                        if (!confirm(strWarning))
                                        {
                                                // if user does not want to continue revert checkbox to original state
                                                document.paramForm.enableDNSPrimary.checked=true;
                                                return;
                                        }
                                        else
                                        {
                                                // delete all secondary nodes using Primary DNS Settings

                                                var lenOptDel = formObj.hostNameList.options.length;

                                                // set all nodes with primary DNS settings to null
                                                for (var count=lenOptDel-1; count>=0; count--)
                                                {
                                                        var optValueDel = formObj.hostNameList.options[count].value;
                                                        if (optValueDel.indexOf('Primary DNS Settings') != -1)
                                                        {
                                                                formObj.hostNameList.options[count]=null;
                                                        }
                                                }
                                        }
                                }
                        }

                        formObj.primaryDNSPrimary.disabled=true;
                        formObj.secondaryDNSPrimary.disabled=true;
                        formObj.domainNamePrimary.disabled=true;

                        formObj.primaryDNSPrimary.style.backgroundColor='lightgrey';
                        formObj.secondaryDNSPrimary.style.backgroundColor='lightgrey';
                        formObj.domainNamePrimary.style.backgroundColor='lightgrey';

                        formObj.usePrimaryDNSSetting.checked=false;
                        formObj.usePrimaryDNSSetting.disabled = true;
                }
        }
        else
        {
                var obj = document.paramForm.enableDNSSecondary;
                var select = obj.checked;
                if (select == true)
                {
                        formObj.primaryDNSSecondary.disabled=false;
                        formObj.secondaryDNSSecondary.disabled=false;
                        formObj.domainNameSecondary.disabled=false;

                        formObj.primaryDNSSecondary.style.backgroundColor='white';
                        formObj.secondaryDNSSecondary.style.backgroundColor='white';
                        formObj.domainNameSecondary.style.backgroundColor='white';

                        if (formObj.enableDNSPrimary.checked == true)
                                formObj.usePrimaryDNSSetting.disabled = false;
                        else if (formObj.enableDNSPrimary.checked == false)
                        {
                                formObj.usePrimaryDNSSetting.checked=false;
                                formObj.usePrimaryDNSSetting.disabled = true;
                        }
                }
                else if (select == false)
                {
                        formObj.primaryDNSSecondary.disabled=true;
                        formObj.secondaryDNSSecondary.disabled=true;
                        formObj.domainNameSecondary.disabled=true;

                        formObj.primaryDNSSecondary.style.backgroundColor='lightgrey';
                        formObj.secondaryDNSSecondary.style.backgroundColor='lightgrey';
                        formObj.domainNameSecondary.style.backgroundColor='lightgrey';

                        formObj.usePrimaryDNSSetting.checked=false;
                        formObj.usePrimaryDNSSetting.disabled = true;
                }
        }
}

// this function is called when NTP checkbox is checked or unchecked.
// it enables or disables the NTP fields depending on the state of the checkbox.
function fnNTP()
{
        var obj = document.paramForm.externalNTP;
        var select = obj.checked;
        if (select == true)
        {
                formObj.ntpServer1.disabled=false;
                formObj.ntpServer2.disabled=false;
                formObj.ntpServer3.disabled=false;
                formObj.ntpServer4.disabled=false;
                formObj.ntpServer5.disabled=false;

                formObj.ntpServer1.style.backgroundColor='white';
                formObj.ntpServer2.style.backgroundColor='white';
                formObj.ntpServer3.style.backgroundColor='white';
                formObj.ntpServer4.style.backgroundColor='white';
                formObj.ntpServer5.style.backgroundColor='white';
        }
        else if (select == false)
        {
                formObj.ntpServer1.disabled=true;
                formObj.ntpServer2.disabled=true;
                formObj.ntpServer3.disabled=true;
                formObj.ntpServer4.disabled=true;
                formObj.ntpServer5.disabled=true;

                formObj.ntpServer1.style.backgroundColor='lightgrey';
                formObj.ntpServer2.style.backgroundColor='lightgrey';
                formObj.ntpServer3.style.backgroundColor='lightgrey';
                formObj.ntpServer4.style.backgroundColor='lightgrey';
                formObj.ntpServer5.style.backgroundColor='lightgrey';
        }
}


// this function is called when W1 checkbox is checked or unchecked.
// it enables or disables the W1 parameters depending on state of checkbox.
function fnW1()
{
        var obj = document.paramForm.w1Upgrade;
        var select = obj.checked;
        if (select == true)
        {
                formObj.downloadOption.disabled = false;
                formObj.downloadServerIP.disabled = false;
                formObj.downloadServerUserName.disabled = false;
                formObj.downloadServerUserPW.disabled = false;
                formObj.downloadServerUserPWConfirm.disabled = false;
                formObj.dmaTarballLocation.disabled = false;
                formObj.dmaTarballName.disabled = false;        				
				
                formObj.downloadOption.style.backgroundColor='white';
                formObj.downloadServerIP.style.backgroundColor='white';
                formObj.downloadServerUserName.style.backgroundColor='white';
                formObj.downloadServerUserPW.style.backgroundColor='white';
                formObj.downloadServerUserPWConfirm.style.backgroundColor='white';
                formObj.dmaTarballLocation.style.backgroundColor='white';
                formObj.dmaTarballName.style.backgroundColor='white';
			
				if(formObj.productName.value=="callmanager")
				{
					formObj.endUserPIN.disabled = false;
					formObj.endUserPW.disabled = false;
					formObj.endUserPINConfirm.disabled = false;
					formObj.endUserPWConfirm.disabled = false;
					
					formObj.endUserPIN.style.backgroundColor='white';
					formObj.endUserPW.style.backgroundColor='white';
					formObj.endUserPINConfirm.style.backgroundColor='white';
					formObj.endUserPWConfirm.style.backgroundColor='white';
				}
        }
        else if (select == false)
        {
                formObj.downloadOption.disabled = true;
                formObj.downloadServerIP.disabled = true;
                formObj.downloadServerUserName.disabled = true;
                formObj.downloadServerUserPW.disabled = true;
                formObj.downloadServerUserPWConfirm.disabled = true;
                formObj.dmaTarballLocation.disabled = true;
                formObj.dmaTarballName.disabled = true;              
                formObj.downloadOption.style.backgroundColor='lightgrey';
                formObj.downloadServerIP.style.backgroundColor='lightgrey';
                formObj.downloadServerUserName.style.backgroundColor='lightgrey';
                formObj.downloadServerUserPW.style.backgroundColor='lightgrey';
                formObj.downloadServerUserPWConfirm.style.backgroundColor='lightgrey';
                formObj.dmaTarballLocation.style.backgroundColor='lightgrey';
                formObj.dmaTarballName.style.backgroundColor='lightgrey';              
				
				if(formObj.productName.value=="callmanager")
				{
					formObj.endUserPIN.disabled = true;
	                formObj.endUserPW.disabled = true;
	                formObj.endUserPINConfirm.disabled = true;
	                formObj.endUserPWConfirm.disabled = true;
					
					formObj.endUserPIN.style.backgroundColor='lightgrey';
	                formObj.endUserPW.style.backgroundColor='lightgrey';
	                formObj.endUserPINConfirm.style.backgroundColor='lightgrey';
	                formObj.endUserPWConfirm.style.backgroundColor='lightgrey';
				}
        }
}

// this function is called when SMPT checkbox is enabled or disabled.
// the SMTP fields are enabled or disabled depending on the state of this checkbox
function fnSMTP()
{
        var obj = document.paramForm.smtpEnabled;
        var select = obj.checked;
        if (select == true)
        {
                formObj.smtpLocation.disabled=false;
                formObj.smtpLocation.style.backgroundColor='white';
        }
        else if (select == false)
        {
                formObj.smtpLocation.disabled=true;
                formObj.smtpLocation.style.backgroundColor='lightgrey';
        }
}

// this function is called when Download Option is set to TAPE
// the Download Option fields (IP Address, etc) are enabled/disabled based on this
function fnDownloadOption()
{
        var obj = document.paramForm.downloadOption;
        var option = obj.value;
        if (option == "TAPE")
        {
                formObj.downloadServerIP.disabled=true;
                formObj.downloadServerIP.style.backgroundColor='lightgrey';
				formObj.downloadServerUserName.disabled=true;
                formObj.downloadServerUserName.style.backgroundColor='lightgrey';
				formObj.downloadServerUserPW.disabled=true;
                formObj.downloadServerUserPW.style.backgroundColor='lightgrey';
				formObj.downloadServerUserPWConfirm.disabled=true;
                formObj.downloadServerUserPWConfirm.style.backgroundColor='lightgrey';
				formObj.dmaTarballLocation.disabled=true;
                formObj.dmaTarballLocation.style.backgroundColor='lightgrey';
				formObj.dmaTarballName.disabled=true;
                formObj.dmaTarballName.style.backgroundColor='lightgrey';
        }
        else
        {
                formObj.downloadServerIP.disabled=false;
                formObj.downloadServerIP.style.backgroundColor='white';
				formObj.downloadServerUserName.disabled=false;
                formObj.downloadServerUserName.style.backgroundColor='white';
				formObj.downloadServerUserPW.disabled=false;
                formObj.downloadServerUserPW.style.backgroundColor='white';
				formObj.downloadServerUserPWConfirm.disabled=false;
                formObj.downloadServerUserPWConfirm.style.backgroundColor='white';
				formObj.dmaTarballLocation.disabled=false;
                formObj.dmaTarballLocation.style.backgroundColor='white';
				formObj.dmaTarballName.disabled=false;
                formObj.dmaTarballName.style.backgroundColor='white';
        }
}

// this is a tab index created on page elements for modify
// tab navigation. it is not used currently
function fnCreateTabIndex()
{
        // Clusterwide
        formObj.productName.tabIndex=1;
        formObj.adminName.tabIndex=2;
        formObj.adminPasswd.tabIndex=3;
        formObj.adminPasswdConfirm.tabIndex=4;
        formObj.securityPW.tabIndex=5;
        formObj.securityPWConfirm.tabIndex=6;
        formObj.appUserUsername.tabIndex=6;
        formObj.appUserPW.tabIndex=7;
        formObj.appUserPWConfirm.tabIndex=8;
        formObj.certOrg.tabIndex=9;
        formObj.certUnit.tabIndex=10;
        formObj.certLoc.tabIndex=11;
        formObj.certState.tabIndex=12;
        formObj.certCon.tabIndex=13;
        formObj.smtpEnabled.tabIndex=14;
        formObj.smtpLocation.tabIndex=15;

        // Primary
        formObj.autoNegConfPrimary.tabIndex=16;
        formObj.nicSpeedPrimary.tabIndex=17;
        formObj.nicDuplexPrimary.tabIndex=18;
		formObj.changeMtuSizePrimary.tabIndex=19;
        formObj.nicMtuSizePrimary.tabIndex=20;
        formObj.enableDHCPPrimary.tabIndex=21;
        formObj.hostNamePrimary.tabIndex=22;
        formObj.hostIPPrimary.tabIndex=23;
        formObj.hostMaskPrimary.tabIndex=24;
        formObj.hostGatewayPrimary.tabIndex=25;
        formObj.enableDNSPrimary.tabIndex=26;
        formObj.primaryDNSPrimary.tabIndex=27;
        formObj.secondaryDNSPrimary.tabIndex=28;
        formObj.domainNamePrimary.tabIndex=29;
        formObj.timeZonePrimary.tabIndex=30;
        formObj.externalNTP.tabIndex=31;
        formObj.ntpServer1.tabIndex=32;
        formObj.ntpServer2.tabIndex=33;
        formObj.ntpServer3.tabIndex=34;
        formObj.ntpServer4.tabIndex=35;
        formObj.ntpServer5.tabIndex=36;

        // Secondary
        formObj.autoNegConfSecondary.tabIndex=37;
        formObj.nicSpeedSecondary.tabIndex=38;
        formObj.nicDuplexSecondary.tabIndex=39;
		formObj.changeMtuSizeSecondary.tabIndex=40
		formObj.nicMtuSizeSecondary.tabIndex=41;
        formObj.enableDHCPSecondary.tabIndex=42;
        formObj.hostNameSecondary.tabIndex=43;
        formObj.hostIPSecondary.tabIndex=44;
        formObj.hostMaskSecondary.tabIndex=45;
        formObj.hostGatewaySecondary.tabIndex=46;
        formObj.enableDNSSecondary.tabIndex=47;
        formObj.usePrimaryDNSSetting.tabIndex=48;
        formObj.primaryDNSSecondary.tabIndex=49;
        formObj.secondaryDNSSecondary.tabIndex=50;
        formObj.domainNameSecondary.tabIndex=51;
        formObj.sameTimeZone.tabIndex=52;
        formObj.timeZoneSecondary.tabIndex=53;
        formObj.hostNameList.tabIndex=54;
        formObj.addSecondary.tabIndex=55;
        formObj.deleteSecondary.tabIndex=56;

        // Buttons
        formObj.generateXML.tabIndex=57;
        formObj.clearFields.tabIndex=58;


        // W1
        //formObj.w1Upgrade.tabIndex=0;
        //formObj.endUserPIN.tabIndex=0;
        //formObj.endUserPW.tabIndex=0;
}


// the content of the over help provided for the tool

var overallHelp =["<p>"+
                  "  <ul>"+
                  "    <li>Values entered in the form are only validated for syntactical correctness.</li>"+
                  "    <li>Disabled (grayed out) fields are ignored and are not used for answer file generation.</li>"+
                  "    <li>This web application ensures that all nodes in the cluster have the same common parameters:</li>"+
                  " 	 <ul>"+
                  "        <li>Administrator ID and Password</li>"+
                  "	   <li>SMTP settings</li>"+
                  "	   <li>Cisco Unified Communications Application username and password</li>"+
                  "      </ul>"+
                  "    <li>All the certificates get generated by using the same certificate information.</li>"+
                  "    <li>Ensure, at a minimum, that the primary node and clusterwide parameters are entered; this will result in a single answer file for the primary node and in your being prompted for download of the answer file immediately after you click the <b>Generate Answer Files</b> button.</li>"+
                  "    <li>To generate a secondary node answer file, you must enter the primary node parameters as well as those for at least one secondary node. You can enter parameters for multiple secondary nodes to generate the same number of secondary node answer files. When secondary node data is entered, a subsequent screen will appear for downloading the secondary node answer files.</li>"+
                  "    <li>You must save each answer file in a separate directory when more than one answer file is generated.</li>"+
                  "    <li>You must not modify the filename and contents of saved answer files. Ensure the answer file filename is <i>platformConfig.xml</i>.</li>"+
                  "    <li>Clicking the <b>Clear All Fields</b> button results in the loss of all entered data and cannot be undone; exercise caution.</li>"+
                  "  </ul>"+
                  "</p>"+
                  "<p>To modify existing secondary node parameters"+
                  "  <ol>"+
                  "    <li>Click the host name of the secondary node to be modified. The secondary node parameters get populated in the appropriate parameter fields.</li>"+
                  "    <li>Modify the desired parameters and click the <b>Add Secondary Node</b> button.</li>"+
                  "  </ol>"+
                  "</p>"+
                  "<p>To delete an existing secondary node"+
                  "  <ol>"+
                  "    <li>Click the host name of the secondary node to be modified; the secondary node parameters get populated in the appropriate parameter fields.</li>"+
                  "    <li>To delete the selected secondary node, click the <b>Delete Secondary Node</b> button.</li>"+
                  "  </ol>"+
                  "</p>"+
                  "<p>Credits"+
                  "  <ul>"+
                  "    <li>This web application uses a modified version of the DES encryption source code that was originally written by Eric Young.</li>"+
                  "  </ul>"+
                  "</p>"+
                  "<p>References"+
                  "  <ul>"+
                  "    <li><a href='http://www.cisco.com/en/US/products/sw/voicesw/ps556/prod_installation_guides_list.html' target='_new'>Installing Cisco Unified Communications Manager</a></li>"+
                  "    <li><a href='http://www.cisco.com/en/US/products/sw/voicesw/ps556/prod_maintenance_guides_list.html' target='_new'>Cisco Unified Communications Manager Administration Guide</a></li>"+
                  "    <li><a href='http://www.cisco.com/en/US/products/sw/voicesw/ps556/prod_maintenance_guides_list.html' target='_new'>Cisco Unified Communications Manager Bulk Administration Guide</a></li>"+
                  "    <li><a href='http://www.cisco.com/en/US/products/sw/voicesw/ps556/prod_maintenance_guides_list.html' target='_new'>Cisco Unified Communications Operating System Administration Guide</a></li>"+
                  "  </ul>"+
                   "</p>"];

// the titles for help provided with each parameters.
var helpTitles = ["Use Auto Negotiation",
                                  "NIC Speed",
                                  "NIC Duplex",
                                  "Use DHCP for IP Address Resolution",
                                  "Host Name",
                                  "IP Address",
                                  "IP Mask",
                                  "Gateway Address",
                                  "Configure Client DNS",
                                  "Primary DNS",
                                  "Secondary DNS",
                                  "Domain Name",
                                  "Time Zone",
                                  "Network Time Protocol",
                                  "NTP Server",
                                  "Windows Upgrade (W1)",
                                  "End User PIN",
                                  "End User Password",
                                  "Use Primary DNS Settings",
                                  "Use Primary Time Zone",
                                  "Secondary Nodes",
                                  "Administrator ID",
                                  "Administrator Password",
                                  "Security Password",
                                  "Application User Password",
                                  "Organization",
                                  "Unit",
                                  "Location",
                                  "State",
                                  "Country",
                                  "SMTP Host Configuration",
                                  "SMTP Location",
                                  "Application Username",
                                  "Product to be installed",
                                  "Region",
                                  "Node Type Selection",
                                  "Upgrade from Windows CUCM System", //36
                                  "Download Option", //37
                                  "IP Address of the Download Server", //38
                                  "User Name to access the Download Server", //39
                                  "Password of the User Name", //40
                                  "DMA Tarball Location", //41
                                  "DMA Tarball File Name", //42
								  "CER Primary Route Point", //43
								  "CER End User Language", //44
								  "Change MTU Size", //45
								  "CER CCM Version", //46
								  "MTU Size", //47
								  "Version" //48
                                ];

// the text for help provided with each parameters.
var helpMessages= [" You can negotiate the speed and duplex settings of the Ethernet network interface card (NIC)"+
                                   " automatically if the opposite access point (for examlpe, hub or Ethernet switch) to which this node is attached"+
                                   " supports this activity. Auto negotiation will negotiate the highest speed that is supported by both access points and favors full over half duplex.<BR>"+
                                   " <BR>If you want to configure a speed of 1000 Mega bits per second (Mbps) and it is supported by the opposite access point,"+
                                   " you must choose auto negotiation because 1000 Mbps cannot be configured manually; any explicit speed and duplex settings will get ignored, and full duplex will get chosen if 1000 Mbps is negotiated.<BR>"+
                                   " <BR>If you do not know what the speed and duplex settings for your NIC should be, <b>check the check box</b> to enable automatic negotiation.<BR>"+
                                   " <BR>If you want to enforce a particular speed and duplex and know what they should be, <b>uncheck the check box</b> to disable automatic negotiation and choose a speed and duplex setting.",// end of auto neg
                                   " <b> Caution: </b>  If you do not know what the NIC Speed setting should be, enable auto negotiation by checking the Auto Negotiation check box.  If you configure the NIC Speed or Duplex setting incorrectly, network performance will be compromised.<BR>"+
                                   " <BR> If you want to configure a speed of 1000 Mega bits per second (Mbps) and it is supported by the opposite access point, you must choose auto negotiation because 1000 Mbps cannot be configured manually; any explicit speed and duplex settings will get ignored, and full duplex will get chosen if 1000 Mbps is negotiated.<BR>"+
                                   " <BR> You can select <b>10 or 100 Mbps</b> when you are manually setting the NIC speed. ",// end of nic speed
                                   " <b> Caution: </b> If you do not know what the NIC Duplex setting should be, enable auto negotiation by checking the Auto Negotiation check box.  If you configure the NIC Speed or Duplex setting incorrectly, network performance will be compromised.<BR>"+
                                   " <BR> You can select <b> Full </b> or <b>Half</b> duplex when you are manually setting the NIC duplex.",// end of nic duplex
                                   " Dynamic Host Configuration Protocol (DHCP) reduces the complexity of configuring nodes on your network <BR>"+
                                   " <BR> You can configure a DHCP server to provide the IP address, net mask, default gateway, "+
                                   " and possibly DNS servers and domain information when a machine first boots.  If you have a DHCP server that is configured for this node, you can enable DHCP.<BR>"+
                                   " <BR> <b> Check the check box </b> if DHCP server is enabled and you want to use DHCP; otherwise, "+
                                   " <b> Uncheck the check box </b> to manually configure static networking information for this node.<BR>",// end enable DHCP
                                   " This <b>mandatory field</b> specifies a host name that is an alias that is assigned to an IP address to identify it. <BR>"+
                                   " The host name can comprise up to 63 characters and can contain alphanumeric "+
                                   " characters and hyphens. It must start with an alphabetic character.<BR>",// end of hostname
                                   " This IP address of the node will uniquely identify the node on this network."+
                                   " If another node in this network is using this address, you will get unpredictable results.<BR>"+
                                   " <BR> You must enter the IP address in the format ddd.ddd.ddd.ddd where ddd can have a value between 0 and 255 <b>(except 0.0.0.0)</b>.<BR>"+
                                   " <BR> <b> If DHCP is unchecked, consider this field as mandatory. </b>",// end of ip address
                                   " This item specifies the IP mask of the node. It will define the part of the address that forms the base IP address.<BR>"+
                                   " <BR> You must enter the IP mask in the format ddd.ddd.ddd.ddd where ddd can have a value between 0 and 255 <b> (except 0.0.0.0).</b><BR>"+
                                   " <BR> A valid IP mask should have contiguous '1' bits on left side and contiguous '0' bits on the right.<BR>"+
                                   " <BR> <i> Example of a valid mask</i> <BR>"+
                                   " 255.255.240.0 (11111111.11111111.11110000.00000000)<BR>"+
                                   " <BR> <i> Example of an invalid mask </i><BR>"+
                                   " 255.255.240.240 (11111111.11111111.11110000.11110000)<BR>"+
                                    "<BR> <b> If DHCP is not checked, consider this field as mandatory.</b>",// end of ip mask
                                   " A Gateway represents a network point that acts as an entrance to another network.<BR>"+
                                   " <BR> Configure the address of the gateway here, and outbound packets will get"+
                                   "  send to the gateway, which will forward them to their final destination.<BR>"+
                                   " <BR> You must enter the gateway address in the format ddd.ddd.ddd.ddd where ddd can have a value"+
                                   "  between 0 and 255 <b> (except 0.0.0.0).</b><BR>"+
                                   " <BR> You may set the field to 255.255.255.255 if you do not want or have a gateway."+
                                   " <BR> Doing so may limit you to only being able to communicate with devices on your subnet.<BR>"+
                                   " <BR> <b> If DHCP is not checked, consider this field as mandatory.</b>",// end of gateway
                                   " Domain Name System (DNS) Client allows your computer to translate names of other computers on the network to IP addresses if a DNS server is available."+
                                   " When DNS is not configured, you should enter only the IP address for all network references.<BR>"+
                                   " <BR><b>Check the check box</b> if you want to configure your DNS client and have one or more available DNS servers."+
                                   " <BR><BR>You may disable DNS. Doing so limits the server's ability to resolve some domain names."+
                                   " DHCP can also configure the DNS Client.  If you are using DHCP to configure your DNS Client, you can leave DNS disabled.<BR>"+
                                   " <BR><b>Uncheck the check box</b> if you want to configure all hosts manually in /etc/hosts or if you have configured DHCP to provide your DNS Client information.",//end of DNS enable
                                   " The Primary DNS provides the IP address of the primary DNS server."+
                                   " <BR> <BR> You must enter the Primary DNS in the format ddd.ddd.ddd.ddd where ddd can have a value between 0 and 255 <b>(except 0.0.0.0)</b>."+
                                   " <BR> <BR> <b>If DNS is checked, consider this field as mandatory. </b>",// end of primary DNS
                                   " For this optional field, the Secondary DNS provides the IP address of the secondary DNS server."+
                                   " <BR> <BR> You must enter the Secondary DNS in the format ddd.ddd.ddd.ddd where ddd can have a value between 0 and 255 <b>(except 0.0.0.0)</b>.",//end of secondary dns
                                   " The Domain Name provides the name of the Domain in which this node is located."+
                                   " <BR><BR><b>If DNS is checked, consdier this field as mandatory.<b>",// end of domain name
                                   " This <b>mandatory</b> field specifies the time zone in which the node is located. Time Zone comprises a list of time zones for the selected region. Scroll through the list to select the appropriate time zone.<BR>",// end time zone ()
                                   " Network Time Protocol (NTP) helps keep the machine clock accurate.  A node that uses NTP will periodically query NTP server(s) for a time update."+
                                   " <BR><BR><b> Check the check box </b> if you want to configure NTP servers; otherwise, <b>uncheck it</b>."+
                                   " <BR><BR><b>Caution:</b> The server uses the machine hardware clock if NTP is not used. Be aware that the hardware clock may be inaccurate and is susceptible to change.",// NTP servers
                                   " Enter the IP address, NTP server name, or NTP Server Pool name for at least one external NTP server."+
                                   " <BR><BR><b>Note, Cisco recommends that you use a minimum of three external NTP servers.</b>"+
                                   " <BR> <BR> <b> If Use Network Time Protocol (NTP) is checked, you must specify at least one NTP server.</b>",//end of ntp client
                                   " Is the Upgrade of type W1? (from Windows to Linux)"+
                                   " <BR> <BR><b> Select the checkbox </b> if Upgrade Type is W1."+
                                   " <BR> <b> Un-select the checkbox </b> if Upgrade Type is not W1.",//end w1 upgrade
                                   " The system uses this <b> mandatory </b> End User PIN field to reset the PIN for" +
                                   " all end users that were configured on the Windows-based Cisco Unified CallManager.", //end user pin
                                   " The system uses this <b> mandatory </b> End User Password field to reset the password for" +
                                   " all end users that were configured on the Windows-based Cisco Unified CallManager." +
                                   " <BR> <BR>The password must be at least 6 charaters long and can contain alphanumeric characters, hyphens and underscores.", //end user password
                                   " When configuring secondary node DNS parameters, the primary node's DNS settings can be used for secondary nodes. When this check box is checked the user is not required to enter DNS parameters as they are automatically copied from the primary DNS settings.<BR><BR>" +
                                   " <BR>Note, if the primary node's DNS settings are changed after creating secondary node DNS settings, these secondary node settings are automatically updated to the primary node's modified settings when this check box is checked.  Any changes made to these secondary DNS settings will be discarded as this check box enforces using the same settings as for the primary node."+
                                   " <BR> <BR> <b> Check this check box </b> to use primary node DNS settings for secondary nodes."+
                                   " <BR> <b> Uncheck this check box </b> if different DNS settings are to be used for secondary nodes.",// end same as primary DNS
                                   " When configuring the Time Zone for the Secondary Node, user can choose to use the Primary Time Zone value."+
                                   " When this setting is checked, the Time Zone for the Secondary Node automatically gets set to Primary Node Time Zone value."+
                                   " <BR>Note, if the user changes the Primary Nodes Time Zone after Secondary Node(s) is created by using the preceding functionality the new Primary Time Zone will automatically get applied to the already created Secondary Node(s)."+
                                   " <BR>Note, if the user changes the Secondary Time Zone value that was loaded from the Primary Time Zone value when this functionality is enabled, the changes that the user will get, discarded and the Primary Time Zone value will continue to get used."+
                                   " <BR> <BR> <b> Select the checkbox </b> if user wants to user Primary node's Time Zone for the Secondary Node."+
                                   " <BR> <b> Un-select the checkbox </b> if user wants to select a different Time Zone for Secondary Node.",// end same as primary time zone (12)
                                   " This list identifies the secondary nodes (subscribers) in the cluster by host name."+
                                   " <BR> <BR>&nbsp;&nbsp;&nbsp;-Enter parameters that are required for the secondary node and use the <BR> &nbsp;&nbsp;&nbsp;&nbsp;\'<b>Add Node</b>\' button to add the secondary node."+
                                   " <BR>&nbsp;&nbsp;&nbsp;-Use the \'<b>Delete Node</b>\' button to delete an added secondary node"+
                                   " <BR>&nbsp;&nbsp;&nbsp;-Click a secondary node in the list to view that secondary node parameters."+
                                   " <BR><BR><i> Consider configuring secondary nodes as optional.</i>",// end secondary nodes
                                   " This <b> mandatory </b> field provides the ID of the administrator who is to be assigned to the administrator account."+
                                   " <BR> <BR> Ensure this ID is unique.  It may contain alphanumeric characters, hyphens, and underscores.",// end admin name
                                   " This <b>mandatory</b> field provides the password that is assigned to the administrator account. This password allows a user to log in to the Command Line Interface (CLI) on the console."+
                                   " <BR> <BR> Ensure the password is at least 6 characters long. It may contain alphanumeric characters, hyphens and underscores.",
                                   " This <b>mandatory </b>field provides the security password that is required for communication between nodes. This password also acts as the primary node database access password."+
                                   " <BR> <BR> Ensure the password is at least 6 characters long. It must start with an alphanumeric character and may contain alphanumeric characters, hyphens, and underscore.",
                                   " This <b> mandatory </b>field provides the password that is assigned to the Cisco Unified Communications Manager application user. This password allows the user to log in to the Cisco Unified Communications Manager GUI."+
                                   " <BR> <BR>Ensure the password is at least six characters long. It may contain alphanumeric characters, hyphens, and underscores.",
                                   " This <b> mandatory </b> organization field is used to create the Certificate Signing Request.<BR><BR>Allowable characters for Organization include alphanumerics, spaces, tabs, and the following special characters: <b>. , - _ : ; { } ( ) [ ] </b>",
                                   " This <b> mandatory </b> unit field is used to create the Certificate Signing Request.<BR><BR>Allowable characters for Unit include alphanumerics, spaces, tabs, and the following special characters: <b>. , - _ : ; { } ( ) [ ] </b>",
                                   " This <b> mandatory </b> location field is used to create the Certificate Signing Request.<BR><BR>Allowable characters for Location include alphanumerics, spaces, tabs, and the following special characters: <b>. , - _ : ; { } ( ) [ ] </b>",
                                   " This <b> mandatory </b> state field is used to create the Certificate Signing Request.<BR><BR>Allowable characters for State include alphanumerics, spaces, tabs, and the following special characters: <b>. , - _ : ; { } ( ) [ ] </b>",
                                   " Use the country field to create the Certificate Signing Request. <BR><BR>Select a country by scrolling through the list of countries in the list.",
                                   " Use Simple Mail Transfer Protocol (SMTP) for outbound e-mail. "+
                                   " <BR> <BR><b> Check the check box </b> to configure a SMTP host."+
                                   " <BR> <b> Uncheck the check box </b> to leave a SMTP host not configured.",
                                   " This field provides the name of the Simple Mail Transfer Protocol (SMTP) host that is used for outbound e-mail."+
                                   " <BR> <BR>You can specify the name as a host name or IP address."+
                                   " <BR> <BR>A host name can contain alphanumeric characters, hyphens, or periods and must start and end with an alphanumeric character."+
                                   " <BR> Ensure an IP address is in the format ddd.ddd.ddd.ddd, where each ddd is 255 or less.",
                                   " This <b> mandatory </b> field provides the names of the Application User. Application users log in to the Application Administration web pages to configure Cisco Unified Communication services."+
                                   " <BR> <BR> The Application Username must start with a letter and may contain alphanumeric characters, hyphens, and underscore.",
                                   " This <b> mandatory </b> field specifies the product to be installed on the node. Users can choose from standalone Cisco Unified Communications Manager, standalone Cisco Unified Presence, standalone Cisco Unity Connection, standalone Cisco Unified Expert Advisor, or Cisco Unified Communications Business Edition (coresident) installations.<BR>",
                         //Region
                                   " This field lets you select a region for your time zone. Once you select a region, the Time Zone drop down list is populated with time zones for that region.<BR>",
                         //Node Type Selection
                                   " This field lets you select a node type for Cisco Unified Expert Advisor.  The High Availability Server is the additional Runtime Server. The Reporting Server is required for CUEA reporting features.<BR>",
                         //Upgrade from Windows CUCM System
                                   " Upgrade from Windows CUCM System" +
                                   " This field is mandatory for performing Cisco Unified Communications Manager Windows system upgrade to Linux system.", //end upgrade from windows cucm system
                         //Download Option                                
                                   " This <b> mandatory </b> field specifies the upgrade retrieval mechanism to use to retrieve the DMA tarball file.", // download option 
                         //IP Address of the Download Server
                                   " This <b> mandatory </b> field specifies the IP address of the download server.  This node will uniquely identify the node on this network."+
                                   " If another node in this network is using this address, you will get unpredictable results.<BR>"+
                                   " <BR> You must enter the IP address in the format ddd.ddd.ddd.ddd where ddd can have a value between 0 and 255 <b>(except 0.0.0.0)</b>.", //IP address
                         //User Name                                              
                                   " This <b>mandatory</b> field specifies the user name used to access the download server.", // user name
                         //Password
                                   " The <b> mandatory </b> field specifies the password for the user name provided to access the download server.", //password
                         //DMA Tarball Location
                                   " This <b>mandatory</b> field specifies the DMA Tarball path in this download server."+
                                   " <BR> <BR>If the upgrade file is located on a Windows server, remember that you are connecting to an FTP or SFTP server, so use the appropriate syntax."+
                                   " <BR> <BR>The following are examples: "+      
                                   " <BR> Begin the pathname with a forward slash (/), and use forward slashes throughout the pathname."+                               
                                   " <BR> The pathname must start from the FTP or SFTP root directory on the server, so you cannot enter a Windows absolute pathname, which starts with a drive letter (for example, C:).",                              
                         //DMA Tarball File Name
                                   " This <b>mandatory</b> field specifies the DMA Tarball File Name in this download server."+
                                   " <BR> <BR>For example, DMAExportSuccess08-01-08#12-27.tar", // DMA Tarball File Name                                   
						//CER Primary Route Point
								   " This field indicates the primary emergency number that is dial-able and is handled by CER."+
								   "<BR> All characters must either be numeric, a '*' or a '#'", //end CER Primary Route Point
						//CER End User Language
								   " This field specifies the language the user would like to use for CER.", //end CER End User Language
						//Change MTU Size
								   " This field indicates if the MTU size is to be changed.", //end Change MTU Size
						//CER CCM Version
								   " This field indicates the version of CER CCM.", //end CER CCM Version
						//MTU Size
								   " This field indicates the size of the MTU", //end MTU Size
                        //Version
                                   " This <b> mandatory </b> field specifies the version of the product to be installed on the node." // end Version
                                   ];

// this function is called when Help is clicked for the parameters.
function fnHelp(strHelpIndex)
{

        var strTitle = "Sorry";
        var strMessage = "We are currently unable to provide the help you are looking for.";

        if (strHelpIndex == -1)
        {
                strTitle = "Help";
                strMessage = overallHelp;
        }
        else if ( strHelpIndex >= 0)
        {
                strTitle = helpTitles[strHelpIndex];
                strMessage = helpMessages[strHelpIndex];
        }

        if (popUpHelp != null)
        {
                popUpHelp.close();
                //alert('not null pop');
        }

        fnDisplayHelp(strTitle,strMessage);

}


// this function validates the secondary node parameters keyed in
// and add the secondary nodes to the list if all parameters are valid.
function fnAddSubs()
{

        var autoNeg = formObj.autoNegConfSecondary.checked;
        var nicSpeed = "";
        var nicDuplex = "";
		var changeMtuSize = formObj.changeMtuSizeSecondary.checked;
		var nicMtuSize = "";

        if (autoNeg == false)
        {
                nicSpeed = formObj.nicSpeedSecondary.options[formObj.nicSpeedSecondary.selectedIndex].value;
                nicDuplex = formObj.nicDuplexSecondary.options[formObj.nicDuplexSecondary.selectedIndex].value;
				if(changeMtuSize == true)
				{
					nicMtuSize = formObj.nicMtuSizeSecondary.value;
				}
		}

        var enableDHCP = formObj.enableDHCPSecondary.checked;

        var hostName = formObj.hostNameSecondary.value;
        var ipAddress="";
        var ipMask = "";
        var hostGateway = "";
        var enableDNS="";

        var usePrimaryDNS="";

        var primaryDNS="";
        var secondaryDNS="";
        var domainName="";

        var timeZoneType = formObj.sameTimeZone;
        var timeZoneObj = formObj.timeZoneSecondary;

        var mmcaSecondaryNodeType = "unknown";
        // mmca node selection
        if (formObj.mmcanodeselectionfield.style.display != "none")
        {
                tempObj = formObj.mmcaSecondaryNodeType;
                mmcaSecondaryNodeType = tempObj.options[tempObj.selectedIndex].value;
        }
		
		if(autoNeg == false)
		{


			if(changeMtuSize == true)
			{
				if(nicMtuSize == "" || nicMtuSize.length == 0)
				{
					alert("Please enter MTU size");
					formObj.nicMtuSizeSecondary.focus();
					return false;
				}
				else if(!fnValidateNicMtuSize(nicMtuSize))
				{
					alert("Invalid MTU Size");
					formObj.nicMtuSizeSecondary.focus();
					return false;
				}
			}	
		}
		
        if (hostName == "" || hostName.length ==0)
        {
                alert("Please enter the Host Name of the Secondary Node");
                formObj.hostNameSecondary.focus();
                return false;
        }
        hostName = fnTrim(hostName);
        if (!fnValidateHostName(hostName))
        {
                alert("Please enter a Host Name for the Secondary Node that is between 2 and 63 characters");
                //formObj.hostNameSecondary.value = "";
                formObj.hostNameSecondary.focus();
                return false;
        }

        // find if host with same name already added to list
        subObjs = formObj.hostNameList.options;
        for (i=0;i<subObjs.length;i++)
        {
                subParams = subObjs[i].value;
                subParamList = subParams.split('!');
		    if (subParamList[5] == formObj.hostNameSecondary.value)
                {
                        alert("Secondary Node with same Host Name already added.");
                        formObj.hostNameSecondary.focus();
				return false;
                }

        }

		//check to see that secondary hostname different from primary
		if(formObj.hostNameSecondary.value == formObj.hostNamePrimary.value)
		{
			alert("Secondary Host Name cannot be the same as Primary Host Name.");
			formObj.hostNameSecondary.focus();
			return false;
		}	

        if (enableDHCP == false)
        {
                ipAddress = formObj.hostIPSecondary.value;

                if (ipAddress == "" || ipAddress.length ==0)
                {
                        alert("Please enter the IP Address of the Secondary Node");
                        formObj.hostIPSecondary.focus();
                        return false;
                }
                ipAddress = fnTrim(ipAddress);
				
                if(ipAddress == formObj.hostIPPrimary.value)
                {
                        alert("The Secondary IP address cannot be the same as the Primary IP address.");
                        formObj.hostIPSecondary.focus();
                        return false;
                }
				
                if (!fnValidateIP(ipAddress))
                {
                        alert("Invalid IP Address for the Secondary Node");
                        //formObj.hostIPSecondary.value = "";
                        formObj.hostIPSecondary.focus();
                        return false;
                }

                // find if a host with same ip already added to list
                subObjs = formObj.hostNameList.options;
                for (i=0;i<subObjs.length;i++)
                {
                        subParams = subObjs[i].value;
                        subParamList = subParams.split('!');
                        if (subParamList[7] != "" && subParamList[7] == ipAddress)
                        {
                                alert("Secondary Node with same IP Address already added.");
                                return false;
                        }

                }

                ipMask = formObj.hostMaskSecondary.value;

                if (ipMask == "" || ipMask.length ==0)
                {
                        alert("Please enter the IP Mask of the Secondary Node");
                        formObj.hostMaskSecondary.focus();
                        return false;
                }
                ipMask = fnTrim(ipMask);
                if (!fnValidateMask(ipMask))
                {
                        alert("Invalid Mask for the Secondary Node");
                        //formObj.hostMaskSecondary.value = "";
                        formObj.hostMaskSecondary.focus();
                        return false;
                }

                hostGateway = formObj.hostGatewaySecondary.value;

                if (hostGateway == "" || hostGateway.length ==0)
                {
                        alert("Please enter the Gateway Address of the Secondary Node");
                        formObj.hostGatewaySecondary.focus();
                        return false;
                }
                hostGateway = fnTrim(hostGateway);
                if (!fnValidateIP(hostGateway))
                {
                        alert("Invalid Gateway Address for the Secondary Node");
                        //formObj.formObj.hostGatewaySecondary.value = "";
                        formObj.hostGatewaySecondary.focus();
                        return false;
                }


                enableDNS = formObj.enableDNSSecondary.checked;

                if (enableDNS == true)
                {

                        usePrimaryDNS = formObj.usePrimaryDNSSetting.checked;

                        // if primary DNS setting is used then the DNS paramters are set
                        // the string 'Primary DNS Settings' so that the even if the user
                        // modifies these values just before submit, the secondary nodes
                        // created already also correctly reflect these changes.
                        if (usePrimaryDNS == true)
                        {
                                primaryDNS = "Primary DNS Settings";
                                secondaryDNS = "Primary DNS Settings";
                                domainName = "Primary DNS Settings";
                        }

                        else
                        {
                                primaryDNS = formObj.primaryDNSSecondary.value;

                                if (primaryDNS == "" || primaryDNS.length == 0)
                                {
                                        alert("Please enter the Primary DNS server for the Secondary Node");
                                        formObj.primaryDNSSecondary.focus();
                                        return false;
                                }
                                primaryDNS=fnTrim(primaryDNS);
                                if(!fnValidateIP(primaryDNS))
                                {
                                        alert("Invalid Primary DNS Server Address for Secondary Node");
                                        //formObj.primaryDNSSecondary.value = "";
                                        formObj.primaryDNSSecondary.focus();
                                        return false;
                                }

                                secondaryDNS = formObj.secondaryDNSSecondary.value;

                                if (secondaryDNS == "" || secondaryDNS.length == 0)
                                {
                                        ;
                                }
                                else
                                {
                                        secondaryDNS=fnTrim(secondaryDNS);
                                        if(!fnValidateIP(secondaryDNS))
                                        {
                                                alert("Invalid Secondary DNS Server Address for Secondary Node");
                                                //formObj.secondaryDNSSecondary.value = "";
                                                formObj.secondaryDNSSecondary.focus();
                                                return false;
                                        }
                                }

                                domainName	= formObj.domainNameSecondary.value;

                                if (domainName == "" || domainName.length == 0)
                                {
                                        alert("Please enter the Domain Name for the Secondary Node");
                                        formObj.domainNameSecondary.focus();
                                        return false;
                                }
                                domainName == fnTrim(domainName);
                                if (!fnValidateDomain(domainName))
                                {
                                        alert("Invalid Domain Name for Secondary Node");
                                        //formObj.domainNameSecondary.value = "";
                                        formObj.domainNameSecondary.focus();
                                        return false;
                                }
                        }

                }
        }

        // if primary TimeZone setting is used then the Timezone paramter is set
        // the string 'Primary Node Time Zone' so that the even if the user
        // modifies these primary TimeZone just before submit, the secondary nodes
        // created already also correctly reflect this change.
        if (timeZoneType.checked == true)
        {
                timeZoneValue="Primary Node Time Zone";
        }
        else
        {
                timeZoneValue=timeZoneObj.options[timeZoneObj.selectedIndex].value;
        }

        var secOptionValues="";

        secOptionValues = autoNeg + "!" + nicSpeed + "!" + nicDuplex + "!" + changeMtuSize + "!" + nicMtuSize + "!" +
                                          hostName + "!" + enableDHCP + "!" + ipAddress + "!" +
                                          ipMask + "!" + hostGateway + "!" + enableDNS + "!" +
                                          primaryDNS + "!" + secondaryDNS + "!" + domainName + "!"+
                                          timeZoneValue + "!" + mmcaSecondaryNodeType;

        var optionHostName = new Option(hostName, secOptionValues);

        var lenOptions = formObj.hostNameList.options.length;

        formObj.hostNameList.options[lenOptions]=optionHostName;
        formObj.hostNameList.disabled = false;
        formObj.hostNameList.style.backgroundColor='white';

        // Enable primary IP address just in case DHCP was checked 
        // and therefore the field would be disabled.  The primary 
        // IP address is required when subs are added even if 
        // DHCP is enabled for the primary node.
        formObj.hostIPPrimary.disabled=false;
        formObj.hostIPPrimary.style.backgroundColor='white';
        
        // disable the product/version field now that a secondary node was added
        formObj.productName.disabled=true;
        formObj.productName.style.backgroundColor='lightgrey';
        formObj.productVersion.disabled=true;
        formObj.productVersion.style.backgroundColor='lightgrey';
}

// the function is called when the delete button is checked after selecting
// one of the secondary nodes from the list. it deletes the secondary node.
function fnDeleteSubs()
{
        var selectedIndex = formObj.hostNameList.options.selectedIndex;

        if (selectedIndex == -1 )
        {
                alert("Please select the secondary node to be deleted");
                return false;
        }

        formObj.hostNameList.options[selectedIndex] = null;

        var lenOptions = formObj.hostNameList.options.length;

        if (lenOptions < 1)
        {
                formObj.hostNameList.disabled = true;
                formObj.hostNameList.style.backgroundColor='lightgrey';
        
            // enable the product/version field
            formObj.productName.disabled=false;
            formObj.productName.style.backgroundColor='white';
            formObj.productVersion.disabled=false;
            formObj.productVersion.style.backgroundColor='white';
        }
}

// this function is called when the use primary DNS setting is used.
// this is used to populate the secondary DNS parameters with the
// corresponding primary DNS parameter values ( for viewing by the user).
function usePrimaryDNSValues()
{
        var select = formObj.usePrimaryDNSSetting.checked;

        if (select == true)
        {
                formObj.primaryDNSSecondary.value=formObj.primaryDNSPrimary.value;
                formObj.secondaryDNSSecondary.value=formObj.secondaryDNSPrimary.value;
                formObj.domainNameSecondary.value=formObj.domainNamePrimary.value;
        }
        /*else
        {
                formObj.primaryDNSSecondary.value="";
                formObj.secondaryDNSSecondary.value="";
                formObj.domainNameSecondary.value="";
        }*/
}

// this function is called when the user clicks on a secondary node in the list.
// this displays the parameter values used to configure the secondary node
// by populating the parameter fields with the values.
function fnDisplayParameters()
{
        var selectedIndex = formObj.hostNameList.options.selectedIndex;
        var paramValuesString = formObj.hostNameList.options[selectedIndex].value;
        // alert(paramValuesString);
        var paramValues = paramValuesString.split("!");

        if (paramValues[0] == "true")
                formObj.autoNegConfSecondary.checked = true;
        else
                formObj.autoNegConfSecondary.checked = false;

        if (paramValues[1] == "10")
                formObj.nicSpeedSecondary.selectedIndex=0;
        else if (paramValues[1] == "100")
                formObj.nicSpeedSecondary.selectedIndex=1;
        /*
        else if (paramValues[1] == "1000")
                formObj.nicSpeedSecondary.selectedIndex=2;
        */

        if (paramValues[2] == "Half")
                formObj.nicDuplexSecondary.selectedIndex=0;
        else if (paramValues[2] == "Full")
                formObj.nicDuplexSecondary.selectedIndex=1;
		if(paramValues[3] == "true")
				formObj.changeMtuSizeSecondary.checked= true;
		else
				formObj.changeMtuSizeSecondary.checked= false;
        
		formObj.nicMtuSizeSecondary.value= paramValues[4];
		formObj.hostNameSecondary.value= paramValues[5];

        if (paramValues[6] == "true")
                formObj.enableDHCPSecondary.checked= true;
        else
                formObj.enableDHCPSecondary.checked= false;

        formObj.hostIPSecondary.value= paramValues[7];
        formObj.hostMaskSecondary.value= paramValues[8];
        formObj.hostGatewaySecondary.value= paramValues[9];

        if (paramValues[10] == "true")
                formObj.enableDNSSecondary.checked = true;
        else
                formObj.enableDNSSecondary.checked = false;

        if (paramValues[11] == "Primary DNS Settings")
        {
                formObj.usePrimaryDNSSetting.checked=true;
                formObj.primaryDNSSecondary.value=formObj.primaryDNSPrimary.value;
                formObj.secondaryDNSSecondary.value=formObj.secondaryDNSPrimary.value;
                formObj.domainNameSecondary.value=formObj.domainNamePrimary.value;
        }
        else
        {
                formObj.usePrimaryDNSSetting.checked=false;
                formObj.primaryDNSSecondary.value= paramValues[11];
                formObj.secondaryDNSSecondary.value= paramValues[12];
                formObj.domainNameSecondary.value= paramValues[13];
        }

        if (paramValues[14]== "Primary Node Time Zone")
        {
                formObj.sameTimeZone.checked=true;
                formObj.timeZoneSecondaryRegion.selectedIndex = formObj.timeZonePrimaryRegion.selectedIndex;
                // refresh secondary timezone lists after setting the region
                fnTimeZoneRegion(SECONDARY_TZ_REGION_ID, SECONDARY_TZ_ID);
                formObj.timeZoneSecondary.selectedIndex = formObj.timeZonePrimary.selectedIndex;
        }
        else
        {
                var timeZoneObj = formObj.timeZoneSecondary;
                var timeZoneRegionObj = formObj.timeZoneSecondaryRegion;

                // Set the "use primary node" flag
                formObj.sameTimeZone.checked=false;

                // Determine the region
                var region = "";
                var components = paramValues[14].split('/');
                if (components.length == 1) {
                    region = otherRegion;
                } else {
                    region = components[0];
                }

                // Set the selectedIndex for the region
                for (var i = 0; i < timeZoneRegionObj.options.length; i++) {
                    if (timeZoneRegionObj.options[i].value == region) {
                        timeZoneRegionObj.selectedIndex = i;
                        break;
                    }
                }

                // Refresh the time zone list now that the region was selected
                fnTimeZoneRegion(SECONDARY_TZ_REGION_ID, SECONDARY_TZ_ID);

                // Set the selectedIndex for the time zone
                for (var i = 0; i < timeZoneObj.options.length; i++) {
                    if (timeZoneObj.options[i].value == paramValues[14]) {
                        timeZoneObj.selectedIndex = i;
                        break;
                    }
                }
        }

        // called to set the fields states (enable/disable) based on current settings.
        fnNIC('2');
        fnStatic('2');
        fnDNSOption('2');
        fnMTU('2');

}


// this functions clear all the parameters values input by the user
// and restores to the default values.
function fnClear()
{

        var strMessage = "All the field values will be reset to default. Do you want to continue?";

        if (!confirm(strMessage))
        {
                return;
        }
        
        // Only some interfaces support W1 upgrades.  Check the w1 flag 
        // to avoid creating any confusing javascript errors.
        tempObj = formObj.w1Upgrade;
        w1Upgrade = tempObj.checked;
        if (!(w1Upgrade == "true" || w1Upgrade == true)) {
			formObj.productName.selectedIndex=0;
        } else {
            
			formObj.downloadOption.selectedIndex=1;
            formObj.downloadServerIP.value="";
            formObj.downloadServerUserName.value="";
            formObj.downloadServerUserPW.value="";
            formObj.downloadServerUserPWConfirm.value="";
            formObj.dmaTarballLocation.value="";
            formObj.dmaTarballName.value="";    
			
            if(formObj.productName.value=="callmanager")
			{
				formObj.endUserPIN.value="";
				formObj.endUserPINConfirm.value="";
				formObj.endUserPW.value="";
				formObj.endUserPWConfirm.value="";
			}
			
            formObj.w1Upgrade.checked=true;
        }

        formObj.autoNegConfPrimary.checked=true;
        formObj.nicSpeedPrimary.selectedIndex=1;
        formObj.nicDuplexPrimary.selectedIndex=1;
		formObj.changeMtuSizePrimary.checked=false;
		formObj.nicMtuSizePrimary.value="";
        formObj.enableDHCPPrimary.checked=false;
        formObj.hostNamePrimary.value="";
        formObj.hostIPPrimary.value="";
        formObj.hostMaskPrimary.value="";
        formObj.hostGatewayPrimary.value="";
        formObj.enableDNSPrimary.checked=false;
        formObj.primaryDNSPrimary.value="";
        formObj.secondaryDNSPrimary.value="";
        formObj.domainNamePrimary.value="";
        formObj.externalNTP.checked=true;
        formObj.ntpServer1.value="";
        formObj.ntpServer2.value="";
        formObj.ntpServer3.value="";
        formObj.ntpServer4.value="";
        formObj.ntpServer5.value="";

        formObj.autoNegConfSecondary.checked=true;
        formObj.nicSpeedSecondary.selectedIndex=1;
        formObj.nicDuplexSecondary.selectedIndex=1;
		formObj.changeMtuSizeSecondary.checked=false;
		formObj.nicMtuSizeSecondary.value="";
        formObj.enableDHCPSecondary.checked=false;
        formObj.hostNameSecondary.value="";
        formObj.hostIPSecondary.value="";
        formObj.hostMaskSecondary.value="";
        formObj.hostGatewaySecondary.value="";
        formObj.enableDNSSecondary.checked=false;
        formObj.usePrimaryDNSSetting.checked=false;
        formObj.primaryDNSSecondary.value="";
        formObj.secondaryDNSSecondary.value="";
        formObj.domainNameSecondary.value="";
        formObj.sameTimeZone.checked=false;

        var lenOptions = formObj.hostNameList.options.length;

        for(var index=lenOptions-1;index>=0;index--)
        {
                formObj.hostNameList.options[index] = null;
        }

        formObj.adminName.value="";
        formObj.adminPasswd.value="";
        formObj.adminPasswdConfirm.value="";
        formObj.securityPW.value="";
        formObj.securityPWConfirm.value="";
        formObj.appUserUsername.value="";
        formObj.appUserPW.value="";
        formObj.appUserPWConfirm.value="";
        formObj.certOrg.value="";
        formObj.certUnit.value=	"";
        formObj.certLoc.value="";
        formObj.certState.value="";
        formObj.certCon.options.selectedIndex=defCountryIndex;
        formObj.smtpEnabled.checked=false;
        formObj.smtpLocation.value="";

        formObj.hostNameList.size = 5;
        formObj.hostNameList.disabled = true;
		
		if(formObj.productName.value == "cer")
		{
			formObj.primaryRoutePoint.value="";
			formObj.endUserLanguage.selectedIndex=defLanguageIndex;
			formObj.cerCcmVersion.selectIndex=1;
	    }

        initializePage();
}

// this function is called when the Generate button is clicked.
// it generate either a single xml file or multiple files
// depending on the secondary nodes list
function fnGenerate()
{
        if (!validateParameters())
                return;

        readParameters();

        var len = formObj.hostNameList.options.length;

        //when this code is call by DMA AFG, the formObj.productName.selectedIndex is
        //undefined (since there is no product name dropdown box in UI).  Change 
        //this to conditional statement to elminate potential IE browser 
        //version that could display error for undefined object as a precaution
        //W1Upgrade
        tempObj = formObj.w1Upgrade;
        w1Upgrade = tempObj.checked;
        if (!(w1Upgrade == "true" || w1Upgrade == true))
        {
        //Product name drop down list is displayed for AFG site
        //added for muster
        var productIndex = formObj.productName.selectedIndex;
        }

        // setting non-persistent values into persistent variable
        // to be used when returned back to this page.
        setAsPersistentValues();
        // generating multiple xml files
        generateXMLsPage();
}

// this function validates all the parameters values supplied
// by the user and prompts user for correct values.
function validateParameters()
{
		//MTU Size
		tempObj = formObj.autoNegConfPrimary;
		autoNeg = tempObj.checked;
		if(autoNeg == false)
		{
			tempObj = formObj.changeMtuSizePrimary;
			changeMtuSize = tempObj.checked;
			if(changeMtuSize == true)
			{
				tempObj = formObj.nicMtuSizePrimary;
				nicMtuSize = tempObj.value;
				if(nicMtuSize == "" || nicMtuSize.length == 0)
				{
					alert("Please enter MTU size");
					tempObj.focus();
					return false;
				}
				else if(!fnValidateNicMtuSize(nicMtuSize))
				{
					alert("Invalid MTU Size");
					tempObj.focus();
					return false;
				}
			}	
		}
		
        // Host Name
        tempObj = formObj.hostNamePrimary;
        hostName = tempObj.value;

        if (hostName == "" || hostName.length == 0)
        {
                alert("Please enter the Host Name");
                tempObj.focus();
                return false;
        } else if (!fnValidateHostName(hostName))
        {
                alert("Please enter a Host Name that is between 2 and 63 characters");
                tempObj.focus();
                return false;
        }

        // DHCP enable
        tempObj = formObj.enableDHCPPrimary;
        enableDHCP = tempObj.checked;

        if (enableDHCP == false)
        {

                // Host IP
                tempObj = formObj.hostIPPrimary;
                hostIP = tempObj.value;

                if (hostIP == "" || hostIP.length == 0)
                {
                        alert("Please enter the IP Address of Primary Node");
                        tempObj.focus();
                        return false;
                } else if (!fnValidateIP(hostIP))
                {
                        alert("Invalid Host IP Address for Primary Node");
                        tempObj.focus();
                        return false;
                }


                // Host Mask
                tempObj = formObj.hostMaskPrimary;
                hostMask = tempObj.value;

                if (hostMask == "" || hostMask.length == 0)
                {
                        alert("Please enter the IP Mask of Primary Node");
                        tempObj.focus();
                        return false;
                } else if (!fnValidateMask(hostMask))
                {
                        alert("Invalid Host IP Mask for Primary Node");
                        tempObj.focus();
                        return false;
                }

                // Gateway
                tempObj = formObj.hostGatewayPrimary;
                hostGateway = tempObj.value;

                if (hostGateway == "" || hostGateway.length == 0)
                {
                        alert("Please enter the Gateway Address of Primary Node");
                        tempObj.focus();
                        return false;
                } else if (!fnValidateIP(hostGateway))
                {
                        alert("Invalid Gateway Address for Primary Node");
                        tempObj.focus();
                        return false;
                }

                tempObj = formObj.enableDNSPrimary;
                enableDNS = tempObj.checked;

                if  (enableDNS == true)
                {
                        // Primary DNS
                        tempObj = formObj.primaryDNSPrimary;
                        primaryDNS = tempObj.value;

                        if (primaryDNS == "" || primaryDNS.length == 0)
                        {
                                alert("Please enter the Primary DNS Server Address of Primary Node");
                                tempObj.focus();
                                return false;
                        } else if (!fnValidateIP(primaryDNS))
                        {
                                alert("Invalid Primary DNS Server Address for Primary Node");
                                tempObj.focus();
                                return false;
                        }

                        // Secondary DNS
                        tempObj = formObj.secondaryDNSPrimary;
                        secondaryDNS = tempObj.value;


                        if (secondaryDNS == "" || secondaryDNS.length == 0)
                        {
                                //alert("going into this");
                                ;
                        } else if (!fnValidateIP(secondaryDNS))
                        {
                                alert("Invalid Secondary DNS Server Address for Primary Node");
                                tempObj.focus();
                                return false;
                        }

                        // Domain
                        tempObj = formObj.domainNamePrimary;
                        domainName = tempObj.value;

                        if (domainName == "" || domainName.length == 0)
                        {
                                alert("Please enter the Domain Name of Primary Node");
                                tempObj.focus();
                                return false;
                        } else if (!fnValidateDomain(domainName))
                        {
                                alert("Invalid Domain Name for Primary Node");
                                tempObj.focus();
                                return false;
                        }
                }
        }
        if (enableDHCP == true)
        {
                // check if the list of secondary nodes is empty
                // if not then ip address should be provided
                var noOfSecondaryNodes = formObj.hostNameList.options.length;
                if (noOfSecondaryNodes > 0)
                {
                        // Host IP
                        tempObj = formObj.hostIPPrimary;
                        hostIP = tempObj.value;

                        if (hostIP == "" || hostIP.length == 0)
                        {
                                alert("Please enter the IP Address of Primary Node.  This is required even if DHCP has been enabled for the Primary Node.");
                                tempObj.focus();
                                return false;
                        } else if (!fnValidateIP(hostIP))
                        {
                                alert("Invalid Host IP Address for Primary Node");
                                tempObj.focus();
                                return false;
                        }
                }
        }


        // ntp servers
        tempObj = formObj.externalNTP;
        externalNTP = tempObj.checked;

        if (externalNTP == true)
        {

                var emptyNTPServer = 0;

                tempObj = formObj.ntpServer1;
                ntpServer1 = tempObj.value;

                //alert(enableDHCP);
                //alert(enableDNS);

                if (ntpServer1 == "" || ntpServer1.length == 0)
                {
                        emptyNTPServer = emptyNTPServer+1;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && (!fnValidateIP(ntpServer1)&&!fnValidateDomain(ntpServer1)))
                {
                        alert("Invalid NTP Sever Address/Domain");
                        tempObj.focus();
                        return false;
                }
                else if (enableDHCP==false && enableDNS == false && !fnValidateIP(ntpServer1))
                {
                        alert("Invalid NTP Sever Address");
                        tempObj.focus();
                        return false;
                }
                //else
                //{
                        //alert("none of these entered");
                        //alert(fnValidateIP(ntpServer1));
                        //alert(fnValidateDomain(ntpServer1));
                //}

                tempObj = formObj.ntpServer2;
                ntpServer2 = tempObj.value;

                if (ntpServer2 == "" || ntpServer2.length == 0)
                {
                        emptyNTPServer = emptyNTPServer+1;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && (!fnValidateIP(ntpServer2)&&!fnValidateDomain(ntpServer2)))
                {
                        alert("Invalid NTP Sever Address/Domain");
                        tempObj.focus();
                        return false;
                }
                else if (enableDHCP==false && enableDNS == false && !fnValidateIP(ntpServer2))
                {
                        alert("Invalid NTP Sever Address");
                        tempObj.focus();
                        return false;
                }

                tempObj = formObj.ntpServer3;
                ntpServer3 = tempObj.value;

                if (ntpServer3 == "" || ntpServer3.length == 0)
                {
                        emptyNTPServer = emptyNTPServer+1;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && (!fnValidateIP(ntpServer3)&&!fnValidateDomain(ntpServer3)))
                {
                        alert("Invalid NTP Sever Address/Domain");
                        tempObj.focus();
                        return false;
                }
                else if (enableDHCP==false && enableDNS == false && !fnValidateIP(ntpServer3))
                {
                        alert("Invalid NTP Sever Address");
                        tempObj.focus();
                        return false;
                }

                tempObj = formObj.ntpServer4;
                ntpServer4 = tempObj.value;

                if (ntpServer4 == "" || ntpServer4.length == 0)
                {
                        emptyNTPServer = emptyNTPServer+1;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && (!fnValidateIP(ntpServer4)&&!fnValidateDomain(ntpServer4)))
                {
                        alert("Invalid NTP Sever Address/Domain");
                        tempObj.focus();
                        return false;
                }
                else if (enableDHCP==false && enableDNS == false && !fnValidateIP(ntpServer4))
                {
                        alert("Invalid NTP Sever Address");
                        tempObj.focus();
                        return false;
                }

                tempObj = formObj.ntpServer5;
                ntpServer5 = tempObj.value;

                if (ntpServer5 == "" || ntpServer5.length == 0)
                {
                        emptyNTPServer = emptyNTPServer+1;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && (!fnValidateIP(ntpServer5)&&!fnValidateDomain(ntpServer5)))
                {
                        alert("Invalid NTP Sever Address/Domain");
                        tempObj.focus();
                        return false;
                }
                else if (enableDHCP==false && enableDNS == false && !fnValidateIP(ntpServer5))
                {
                        alert("Invalid NTP Sever Address");
                        tempObj.focus();
                        return false;
                }


                if (emptyNTPServer == 5)
                {
                        alert("Please provide atleast one NTP server");
                        formObj.ntpServer1.focus();
                        return false;
                }
        }


        // W1 Upgrade
        tempObj = formObj.w1Upgrade;
        w1Upgrade = tempObj.checked;

        if (w1Upgrade == "true" || w1Upgrade == true)
        {
			// Download Option
			tempObj = formObj.downloadOption;
			downloadOption = tempObj.value
				
			if (downloadOption != "TAPE")
			{
                // Download Server IP
                tempObj = formObj.downloadServerIP;
                downloadServerIP = tempObj.value;

                if (downloadServerIP == "" || downloadServerIP.length == 0)
                {
                        alert("Please enter the IP Address of Download Server");
                        tempObj.focus();
                        return false;
                } else if (!fnValidateIP(downloadServerIP))
                {
                        alert("Invalid Host IP Address for Download Server");
                        tempObj.focus();
                        return false;
                }    
                
                // Download Server user name
                tempObj = formObj.downloadServerUserName;
                downloadServerUserName = tempObj.value;
                if (downloadServerUserName == "" || downloadServerUserName.length == 0)
                {
                    alert("Please enter the Download Server User Name");
                    tempObj.focus();
                    return false;
                } 
                else if (!fnValidateUserName(downloadServerUserName))
                {
                    alert("Invalid Download Server User Name");
                    tempObj.focus();
                    return false;
                }  
                
                // download server user pw
               tempObj = formObj.downloadServerUserPW;
               downloadServerUserPW = tempObj.value;
               if (downloadServerUserPW == "" || downloadServerUserPW.length == 0)
               {
                   alert("Please enter the Download Server User Password");
                   tempObj.focus();
                   return false;
               } else if (!fnValidatePW(downloadServerUserPW))
               {
                   alert("Invalid Download Server User Password");
                   tempObj.focus();
                   return false;
               }
              //CHECK THAT PASSWD MATCHES CONFIRM
              tempObj = formObj.downloadServerUserPWConfirm;
              downloadServerUserPWConfirm = tempObj.value;

              if (downloadServerUserPWConfirm == "" || downloadServerUserPWConfirm.length == 0)
              {
                  alert("Please confirm the Download Server User Password");
                  tempObj.focus();
                  return false;
              }

              if (downloadServerUserPW != downloadServerUserPWConfirm)
              {
                  alert("Download Server User Password does not match the Confirmed Password");
                  tempObj.focus();
                  return false;
              }    
               
             //DMA Tarball Location
             tempObj = formObj.dmaTarballLocation;
             dmaTarballLocation = tempObj.value;
 
             if (dmaTarballLocation == "" || dmaTarballLocation.length == 0)
             {
                alert("Please enter the DMA Tarball Location");
                tempObj.focus();
                return false;
             } else if (!fnValidateDirectory(dmaTarballLocation))
             {
                alert("Invalid DMA Tarball Location");
                tempObj.focus();
                return false;
             }  
             
             //DMA Tarball Name
             tempObj = formObj.dmaTarballName;
             dmaTarballName = tempObj.value;
 
             if (dmaTarballName == "" || dmaTarballName.length == 0)
             {
                alert("Please enter the DMA Tarball File Name");
                tempObj.focus();
                return false;
             } else if (!fnValidateFileName(dmaTarballName))
             {
                alert("Invalid DMA Tarball File Name");
                tempObj.focus();
                return false;
             }                                       
         }
 
         if(formObj.productName.value=="callmanager")
			{
					// end user PIN
	                tempObj=formObj.endUserPIN;
	                endUserPIN= tempObj.value;
	                if (endUserPIN == "" || endUserPIN.length ==0)
	                {
	                        alert("Please enter the End User PIN");
	                        tempObj.focus();
	                        return false;
	                }// this the only validation for PIN

					// CSCsu49316 - Add validation for End User Pin field (Max length is 31, only numbers are allowed)
					if (endUserPIN.length > 31)
					{
						alert("The End User Pin cannot be more than 31 numbers.  Please shorten the length of the pin.");
						tempObj.focus();
						return false;
					}
					if(isNaN(endUserPIN))
					{
						alert("The End User Pin may only contain numbers.  Please correct the pin.");
						tempObj.focus();
						return false;
					}
	                // end user PIN Confirm

	                // check if passwords match confirm
	                tempObj=formObj.endUserPINConfirm;
	                endUserPINConfirm= tempObj.value;
	                if (endUserPINConfirm == "" || endUserPINConfirm.length ==0)
	                {
	                        alert("Please confirm the End User PIN");
	                        tempObj.focus();
	                        return false;
	                }
	                if (endUserPIN != endUserPINConfirm)
	                {
	                        alert("End User PIN does not match the PIN confirmed");
	                        tempObj.focus();
	                        return false;
	                }

	                // end User PW
	                tempObj=formObj.endUserPW;
	                endUserPW= tempObj.value;
	                if (endUserPW == "" || endUserPW.length ==0)
	                {
	                        alert("Please enter the End User Password");
	                        tempObj.focus();
	                        return false;
	                }
	                else if (!fnValidatePW(endUserPW))
	                {
	                        alert("Invalid End User Password");
	                        tempObj.focus();
	                        return false;
	                }
				    // end User PW Confirm

	                // check if password matches confirm

	                tempObj=formObj.endUserPWConfirm;
	                endUserPWConfirm= tempObj.value;
	                if (endUserPWConfirm == "" || endUserPWConfirm.length ==0)
	                {
	                        alert("Please confirm the End User Password");
	                        tempObj.focus();
	                        return false;
	                }
	                else if (endUserPW != endUserPWConfirm)
	                {
	                        alert("End User Password does not match the Confirmed Password");
	                        tempObj.focus();
	                        return false;
	                }
				}
				else
				{
					tempObj=formObj.primaryRoutePoint;
					primaryRoutePoint= tempObj.value;
					if(primaryRoutePoint == "" || primaryRoutePoint.length ==0)
					{
						alert("Please enter the Primary Route Point");
						tempObj.focus();
						return false;
					}
					else if(!fnValidatePRP(primaryRoutePoint))
					{
						alert("Invalid Primary Route Point");
	                    tempObj.focus();
						return false;
					}
				}
        }
        // Admin
        tempObj = formObj.adminName;
        adminName = tempObj.value;

        if (adminName == "" || adminName.length == 0)
        {
                alert("Please enter the Administrator ID");
                tempObj.focus();
                return false;
        } else if (!fnValidateAdmin(adminName))
        {
                alert("Invalid Administrator Name");
                tempObj.focus();
                return false;
        }

        // Password
        tempObj = formObj.adminPasswd;
        adminPasswd = tempObj.value;

        if (adminPasswd == "" || adminPasswd.length == 0)
        {
                alert("Please enter the Password");
                tempObj.focus();
                return false;
        } else if (!fnValidatePW(adminPasswd))
        {
                alert("Invalid Administrator Password");
                tempObj.focus();
                return false;
        }

        //CHECK THAT PASSWD MATCHES CONFIRM
        tempObj = formObj.adminPasswdConfirm;
        adminPasswdConfirm = tempObj.value;

        if (adminPasswdConfirm == "" || adminPasswdConfirm.length == 0)
        {
                alert("Please confirm the Administrator Password");
                tempObj.focus();
                return false;
        }

        if (adminPasswd != adminPasswdConfirm)
        {
                alert("Administrator Password does not match the Confirmed Password");
                tempObj.focus();
                return false;
        }

        // sftp pw
        tempObj = formObj.securityPW;
        securityPW = tempObj.value;

        if (securityPW == "" || securityPW.length == 0)
        {
                alert("Please enter the Security Password for the node");
                tempObj.focus();
                return false;
        } else if (!fnValidatePW(securityPW))
        {
                alert("Invalid Security Password");
                tempObj.focus();
                return false;
        }

        //CHECK THAT PASSWD MATCHES CONFIRM
        tempObj = formObj.securityPWConfirm;
        securityPWConfirm = tempObj.value;

        if (securityPWConfirm == "" || securityPWConfirm.length == 0)
        {
                alert("Please confirm the Security Password");
                tempObj.focus();
                return false;
        }

        if (securityPW != securityPWConfirm)
        {
                alert("Security Password does not match the Confirmed Password");
                tempObj.focus();
                return false;
        }

        // muster parameter
        // Appl user username
        tempObj = formObj.appUserUsername;
        appUserUsername = tempObj.value;
        if (appUserUsername == "" || appUserUsername.length == 0)
        {
                alert("Please enter the Application User Username");
                tempObj.focus();
                return false;
        } else if (!fnValidateAdmin(appUserUsername))
        {
                alert("Invalid Application User Username");
                tempObj.focus();
                return false;
        }

        // appln user pw
        tempObj = formObj.appUserPW;
        appUserPW = tempObj.value;
        if (appUserPW == "" || appUserPW.length == 0)
        {
                alert("Please enter the Application User Password");
                tempObj.focus();
                return false;
        } else if (!fnValidatePW(appUserPW))
        {
                alert("Invalid Application User Password");
                tempObj.focus();
                return false;
        }
        //alert("app pw reached");
        //CHECK THAT PASSWD MATCHES CONFIRM
        tempObj = formObj.appUserPWConfirm;
        appUserPWConfirm = tempObj.value;

        if (appUserPWConfirm == "" || appUserPWConfirm.length == 0)
        {
                alert("Please confirm the Application User Password");
                tempObj.focus();
                return false;
        }

        if (appUserPW != appUserPWConfirm)
        {
                alert("Application User Password does not match the Confirmed Password");
                tempObj.focus();
                return false;
        }


        //Organization
        tempObj = formObj.certOrg;
        certOrg = tempObj.value;

        if (certOrg == "" || certOrg.length == 0)
        {
                alert("Please enter the Certificate Signing Request Organization name");
                tempObj.focus();
                return false;
        } else if (!fnValidateCSR(certOrg))
        {
                alert("Invalid Certificate Signing Request Organization name");
                tempObj.focus();
                return false;
        }


        //Unit
        tempObj = formObj.certUnit;
        certUnit = tempObj.value;

        if (certUnit == "" || certUnit.length == 0)
        {
                alert("Please enter the Certificate Signing Request Unit name");
                tempObj.focus();
                return false;
        } else if (!fnValidateCSR(certUnit))
        {
                alert("Invalid Certificate Signing Request Unit name");
                tempObj.focus();
                return false;
        }

        //Location
        tempObj = formObj.certLoc;
        certLoc = tempObj.value;

        if (certLoc == "" || certLoc.length == 0)
        {
                alert("Please enter the Certificate Signing Request Location name");
                tempObj.focus();
                return false;
        } else if (!fnValidateCSR(certLoc))
        {
                alert("Invalid Certificate Signing Request Location name");
                tempObj.focus();
                return false;
        }

        //State
        tempObj = formObj.certState;
        certState = tempObj.value;

        if (certState == "" || certState.length == 0)
        {
                alert("Please enter the Certificate Signing Request State name");
                tempObj.focus();
                return false;
        } else if (!fnValidateCSR(certState))
        {
                alert("Invalid Certificate Signing Request State name");
                tempObj.focus();
                return false;
        }

        // smtp host name
        tempObj = formObj.smtpEnabled;
        smtpEnabled = tempObj.checked;

        if (smtpEnabled == true)
        {
                tempObj = formObj.smtpLocation;
                smtpLocation = tempObj.value;

                if (smtpLocation == "" || smtpLocation.length == 0)
                {
                        alert("Please enter the SMTP location");
                        tempObj.focus();
                        return false;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && (!fnValidateIP(smtpLocation)&&!fnValidateDomain(smtpLocation)))
                {
                        alert("Invalid SMTP Sever Address/Domain");
                        tempObj.focus();
                        return false;
                }
                else if (((enableDHCP==false && enableDNS == true) || enableDHCP ==true) && fnValidateDomain(smtpLocation))
                {
                        // this condition is entered if the Primary DHCP is disabled and DNS is enabled
                        // and a valid domain is given for SMTP location

                        // additional check done to see that DNS is enabled for all secondary nodes
                        // to be able to use host name for SMTP

                        var objList = formObj.hostNameList.options;
                        var objLen = objList.length;

                        //alert(objLen);

                        for (var count=0; count<objLen; count++)
                        {
                                var paramString = objList[count].value;
                                //alert(paramString);

                                var paramLst = paramString.split("!");

                                //alert(paramLst[4]);
                                //alert(paramLst[8]);

                                if (paramLst[4] == "false" && paramLst[8] == "false")
                                {
                                        alert("Please provide an IP Address for the SMTP location as one or more Secondary Nodes donot have DNS enabled.");
                                        tempObj.focus();
                                        return;
                                }
                        }

                }
                else if (enableDHCP==false && enableDNS == false && !fnValidateIP(smtpLocation))
                {
                        alert("Invalid SMTP Sever Address");
                        tempObj.focus();
                        return false;
                }
        }


        return true;

}

// this functions read all the different parameters required for
// generating the config file after validation is over.
function readParameters()
{
        // w1 Upgrade
        tempObj = formObj.w1Upgrade;
        w1Upgrade = tempObj.checked;

        // product info
        productName = formObj.productName.value;
        productVersion = formObj.productVersion.value;

        // NIC Auto Config
        tempObj = formObj.autoNegConfPrimary;
        autoNeg = tempObj.checked;

        if (autoNeg == false)
        {
                // Manual NIC Speed
                tempObj = formObj.nicSpeedPrimary;
                nicSpeed = tempObj.options[tempObj.selectedIndex].value;

                // Manual NIC Duplex
                tempObj = formObj.nicDuplexPrimary;
                nicDuplex = tempObj.options[tempObj.selectedIndex].value;
				
				//Change MTU Size
				tempObj = formObj.changeMtuSizePrimary;
				changeMtuSize = tempObj.checked;
				
				if(changeMtuSize == true)
				{
					tempObj = formObj.nicMtuSizePrimary;
					nicMtuSize = fnTrim(tempObj.value);
				}
		}

        // Host Name
        tempObj = formObj.hostNamePrimary;
        hostName = fnTrim(tempObj.value);

        // DHCP enable
        tempObj = formObj.enableDHCPPrimary;
        enableDHCP = tempObj.checked;

        if (enableDHCP == false)
        {
                // Host IP
                tempObj = formObj.hostIPPrimary;
                hostIP = fnTrim(tempObj.value);

                // Host Mask
                tempObj = formObj.hostMaskPrimary;
                hostMask = fnTrim(tempObj.value);

                // Gateway
                tempObj = formObj.hostGatewayPrimary;
                hostGateway = fnTrim(tempObj.value);

                tempObj = formObj.enableDNSPrimary;
                enableDNS = tempObj.checked;

                if  (enableDNS == true)
                {
                        // Primary DNS
                        tempObj = formObj.primaryDNSPrimary;
                        primaryDNS = fnTrim(tempObj.value);

                        // Secondary DNS
                        tempObj = formObj.secondaryDNSPrimary;
                        secondaryDNS = fnTrim(tempObj.value);

                        // Domain
                        tempObj = formObj.domainNamePrimary;
                        domainName = fnTrim(tempObj.value);
                }
        }

        // Time Zone
        tempObj = formObj.timeZonePrimary;
        timeZone = tempObj.options[tempObj.selectedIndex].value;

        // ntp servers
        tempObj = formObj.externalNTP;
        externalNTP = tempObj.checked;

        if (externalNTP == true)
        {
                tempObj = formObj.ntpServer1;
                ntpServer1 = fnTrim(tempObj.value);

                tempObj = formObj.ntpServer2;
                ntpServer2 = fnTrim(tempObj.value);

                tempObj = formObj.ntpServer3;
                ntpServer3 = fnTrim(tempObj.value);

                tempObj = formObj.ntpServer4;
                ntpServer4 = fnTrim(tempObj.value);

                tempObj = formObj.ntpServer5;
                ntpServer5 = fnTrim(tempObj.value);
        }

        if (w1Upgrade == "true" || w1Upgrade == true)
        {
                 // DMA download option
                tempObj = formObj.downloadOption;
                downloadOption = tempObj.options[tempObj.selectedIndex].value;
 
                 // Download Server IP
                tempObj = formObj.downloadServerIP;
                downloadServerIP = fnTrim(tempObj.value);

                 // Download Server User Name
                tempObj = formObj.downloadServerUserName;
                downloadServerUserName = fnTrim(tempObj.value);

                 // Download Server User Password
                tempObj = formObj.downloadServerUserPW;
                downloadServerUserPW = fnTrim(tempObj.value);
 
                 // DMA Tarball Location
                tempObj = formObj.dmaTarballLocation;
                dmaTarballLocation = fnTrim(tempObj.value);

                // DMA Tarball Name
                tempObj = formObj.dmaTarballName;
                dmaTarballName = fnTrim(tempObj.value);              
        
				if(formObj.productName.value=="callmanager")
				{
					//End User PIN        
					tempObj = formObj.endUserPIN;
					endUserPIN = fnTrim(tempObj.value);

					//End User Password
					tempObj = formObj.endUserPW;
					endUserPW = fnTrim(tempObj.value);
				}
		}
		
		if(formObj.productName.value == "cer")
		{
			//Primary Route Point
			tempObj = formObj.primaryRoutePoint;
			primaryRoutePoint = fnTrim(tempObj.value);
			
			//Language
			tempObj = formObj.endUserLanguage;
			endUserLanguage = tempObj.options[tempObj.selectedIndex].value;
								
			//CER CCM Version
			tempObj = formObj.cerCcmVersion;
			cerCcmVersion = tempObj.options[tempObj.selectedIndex].value;
		}
        var len = formObj.hostNameList.options.length;
        hostNameLst = "";
        for (var i=0;i<len;i++)
        {
                hostNameLst=hostNameLst+',"'+ formObj.hostNameList.options[i].value+'"';
        }

        if (len > 0)
        {
                hostNameLst = hostNameLst.substr(1);
        }

        //alert("Length is ="+len);
        //alert("Host name List="+ hostNameLst);

        // Admin
        tempObj = formObj.adminName;
        adminName = fnTrim(tempObj.value);

        // Password
        tempObj = formObj.adminPasswd;
        adminPasswd = fnTrim(tempObj.value);

        // sftp pw
        tempObj = formObj.securityPW;
        securityPW = fnTrim(tempObj.value);

        // muster parameter
        // Appl user username
        tempObj = formObj.appUserUsername;
        appUserUsername = fnTrim(tempObj.value);

        // appln user pw
        tempObj = formObj.appUserPW;
        appUserPW = fnTrim(tempObj.value);

        //Organization
        tempObj = formObj.certOrg;
        certOrg = fnTrim(tempObj.value);

        //Unit
        tempObj = formObj.certUnit;
        certUnit = fnTrim(tempObj.value);

        //Location
        tempObj = formObj.certLoc;
        certLoc = fnTrim(tempObj.value);

        //State
        tempObj = formObj.certState;
        certState = fnTrim(tempObj.value);

        //Country
        tempObj = formObj.certCon;
        certCon = tempObj.options[tempObj.selectedIndex].value;


        // smtp host name
        tempObj = formObj.smtpEnabled;
        smtpEnabled = tempObj.checked;

        if (smtpEnabled == true)
        {
                tempObj = formObj.smtpLocation;
                smtpLocation = fnTrim(tempObj.value);
        }

}

// this function sets the parameters values which are not
// persistent on returning to this page (from the multiple file download
// page) into persistent objects to be used for re-displaying on return to the page
//
function setAsPersistentValues()
{
        formObj.hostLstSecondary.value=hostNameLst;
        formObj.hostLstSecondaryIndex.value=formObj.hostNameList.selectedIndex;
        formObj.primaryTimeZoneIndex.value=formObj.timeZonePrimary.selectedIndex;
        formObj.secondaryTimeZoneIndex.value=formObj.timeZoneSecondary.selectedIndex;
        formObj.countryLstIndex.value=formObj.certCon.selectedIndex;

		if(formObj.productName.value=="cer")
		{
			formObj.languageLstIndex.value = formObj.endUserLanguage.selectedIndex;
		}
}

// this function is called when multiple config files are to be generated.
// it generates a new page with multiple download buttons, one for each xml.
// the user is provided a back button to return to the main page.
function generateXMLsPage()
{

        if (downloadWindow != null)
        {
                downloadWindow.close();
        }

        downloadWindow = window.open("","downloadWindow","width=550,height=600,menubar=yes,status=yes,scrollbars=yes,resizable=yes,toolbar=no","_new");
        //var newWindow = window.open("","_new");
        //window.location.href = window.open("");
        var objDoc = downloadWindow.document.open("text/html","_new");
        var writeVar = "";


        // DOCUMENT-BODY

        // The entire download page code is assigned to a single string
        // and this string is used to write the code to the document
        // as using multiple 'writeln' statements for the same causes
        // the page to hang indefinitely without relieving the resources

        writeVar = writeVar + '\
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n\
            <html lang="en">\n\
                <head>\n\
                    <title>Cisco Unified Communications Answer Files</title>\n\
                    <meta http-equiv=Content-Type content="text/html; charset=windows-1252">\n\
                    <link rel="stylesheet" type="text\/css" href="\/web\/fw\/c\/libra.css">\n\
                    <link rel="stylesheet" type="text\/css" media="print" href="\/web\/fw\/c\/global_print.css">\n\
                    <script type="text/javascript" src="Int32Manipulator.js"><\/script>\n\
                    <script type="text/javascript" src="DesKey.js"><\/script>\n\
                    <script type="text/javascript" src="Des.js"><\/script>\n\
                    <script type="text/javascript" src="ByteUtils.js"><\/script>\n\
                    <script type="text/javascript" src="EncryptPassword.js"><\/script>\n\
                    <script type="text/javascript" src="XMLWriter.js"><\/script>\n\
                    <script type="text/javascript" src="WriteXML.js"><\/script>\n\
                    <link rel="stylesheet" type="text\/css" href="StandardView.css">\n\
                    <iframe id="SaveFrame" style="display:none"><\/iframe>\n\
                    <SCRIPT type="text/javascript" >\n\
                        // Variables for the user input\n\
                        var productName="'+productName+'";\n\
                        var productVersion="'+productVersion+'";\n\
                        var autoNeg="'+autoNeg+'";\n\
                        var nicSpeed="'+nicSpeed+'";\n\
                        var nicDuplex="'+nicDuplex+'";\n\
						var changeMtuSize="'+changeMtuSize+'"\n\
						var nicMtuSize="'+nicMtuSize+'";\n\
                        var enableDHCP="'+enableDHCP+'";\n\
                        var hostName="'+hostName+'";\n\
                        var hostIP="'+hostIP+'";\n\
                        var hostMask="'+hostMask+'";\n\
                        var hostGateway="'+hostGateway+'";\n\
                        var enableDNS="'+enableDNS+'";\n\
                        var primaryDNS="'+primaryDNS+'";\n\
                        var secondaryDNS="'+secondaryDNS+'";\n\
                        var domainName="'+domainName+'";\n\
                        var timeZone="'+timeZone+'";\n\
                        var adminName="'+adminName+'";\n\
                        var adminPasswd="'+adminPasswd+'";\n\
                        var certOrg="'+certOrg+'";\n\
                        var certUnit="'+certUnit+'";\n\
                        var certLoc="'+certLoc+'";\n\
                        var certState="'+certState+'";\n\
                        var certCon="'+certCon+'";\n\
                        var firstNode="'+firstNode+'";\n\
						var hostNamePrimary="'+hostName+'";\n\
                        var hostIPPrimary="'+hostIP+'";\n\
                        var securityPW="'+securityPW+'";\n\
                        var externalNTP="'+externalNTP+'";\n\
                        var ntpServer1="'+ntpServer1+'";\n\
                        var ntpServer2="'+ntpServer2+'";\n\
                        var ntpServer3="'+ntpServer3+'";\n\
                        var ntpServer4="'+ntpServer4+'";\n\
                        var ntpServer5="'+ntpServer5+'";\n\
                        var smtpEnabled="'+smtpEnabled+'";\n\
                        var smtpLocation="'+smtpLocation+'";\n\
                        var appUserUsername="'+appUserUsername+'";\n\
                        var appUserPW="'+appUserPW+'";\n\
                        \n\
                        var w1Upgrade="'+w1Upgrade+'";\n\
                        var downloadOption="'+downloadOption+'";\n\
                        var downloadServerIP="'+downloadServerIP+'";\n\
                        var downloadServerUserName="'+downloadServerUserName+'";\n\
                        var downloadServerUserPW="'+downloadServerUserPW+'";\n\
                        var dmaTarballLocation="'+dmaTarballLocation+'";\n\
                        var dmaTarballName="'+dmaTarballName+'";\n\
                        var endUserPIN="'+endUserPIN+'";\n\
                        var endUserPW="'+endUserPW+'";\n\
						var primaryRoutePoint="'+primaryRoutePoint+'";\n\
						var endUserLanguage="'+endUserLanguage+'";\n\
						var cerCcmVersion="'+cerCcmVersion+'";\n\
						\n\
                        var hostNameLst=['+hostNameLst+'];\n\
                        \n\
                        var popUpXmlFile;\n\
                        var popUpHelp;\n\
                        \n\
                        function writeToXMLPrimary()\n\
                        {\n\
                        writeToXML();\n\
                        }\n\
                        \n\
                        function writeToXMLSecondary(strIndex)\n\
                        {\n\
                            var autoNeg0 ="";\n\
                            var nicSpeed0 ="";\n\
                            var nicDuplex0 ="";\n\
							var changeMtuSize0 =""\n\
                            var nicMtuSize0 ="";\n\
							var enableDHCP0 ="";\n\
                            var hostName0 ="";\n\
                            var hostIP0 ="";\n\
                            var hostMask0 ="";\n\
                            var hostGateway0 ="";\n\
                            var enableDNS0 ="";\n\
                            var primaryDNS0 ="";\n\
                            var secondaryDNS0 ="";\n\
                            var domainName0 ="";\n\
							\n\
                            var index = parseInt(strIndex);\n\
                            var hostParamString = hostNameLst[index];\n\
                            var lenParamString = hostParamString.length;\n\
                            //hostParamString = hostParamString.substr(0,lenParamString-1);\n\
                            //alert(hostParamString);\n\
                            var paramVals = hostParamString.split("!");\n\
                            \n\
                            var autoNegSec ="";\n\
                            var nicSpeedSec ="";\n\
                            var nicDuplexSec ="";\n\
							var changeMtuSizeSec ="";\n\
                            var nicMtuSizeSec ="";\n\
							var enableDHCPSec ="";\n\
                            var hostNameSec ="";\n\
                            var hostIPSec ="";\n\
                            var hostMaskSec ="";\n\
                            var hostGatewaySec ="";\n\
                            var enableDNSSec ="";\n\
                            var primaryDNSSec ="";\n\
                            var secondaryDNSSec ="";\n\
                            var domainNameSec ="";\n\
                            var timeZoneSec ="";\n\
                            var mmcaSecondaryNodeTypeSec ="";\n\
                            \n\
                            autoNegSec =paramVals[0];\n\
                            if (autoNegSec == "false")\n\
                            {\n\
                                    nicSpeedSec =paramVals[1];\n\
                                    nicDuplexSec =paramVals[2];\n\
									changeMtuSizeSec =paramVals[3];\n\
									if(changeMtuSizeSec == "true")\n\
									{\n\
										nicMtuSizeSec =paramVals[4];\n\
									}\n\
							}\n\
                            hostNameSec =paramVals[5];\n\
                            \n\
                            enableDHCPSec =paramVals[6];\n\
                            if (enableDHCPSec == "false")\n\
                            {\n\
                                    hostIPSec =paramVals[7];\n\
                                    hostMaskSec =paramVals[8];\n\
                                    hostGatewaySec =paramVals[9];\n\
                                    enableDNSSec =paramVals[10];\n\
                                    if (enableDNSSec == "true")\n\
                                    {\n\
                                            primaryDNSSec =paramVals[11];\n\
                                            secondaryDNSSec =paramVals[12];\n\
                                            var domainNameSec =paramVals[13];\n\
                                    }\n\
                            }\n\
							timeZoneSec =paramVals[14];\n\
							\n\
							if (timeZoneSec == "Primary Node Time Zone")\n\
                            {\n\
                                    timeZoneSec = timeZone;\n\
							}\n\
                            mmcaSecondaryNodeTypeSec = paramVals[15];\n\
                            \n\
                            autoNeg0 = autoNeg;\n\
                            nicSpeed0 = nicSpeed;\n\
                            nicDuplex0 = nicDuplex;\n\
							changeMtuSize0 = changeMtuSize;\n\
                            nicMtuSize0 = nicMtuSize;\n\
							enableDHCP0 = enableDHCP;\n\
                            hostName0 = hostName;\n\
                            hostIP0 = hostIP;\n\
                            hostMask0 = hostMask;\n\
                            hostGateway0 = hostGateway;\n\
                            enableDNS0 = enableDNS;\n\
                            primaryDNS0 = primaryDNS;\n\
                            secondaryDNS0 = secondaryDNS;\n\
                            domainName0 = domainName;\n\
                            timeZone0 = timeZone;\n\
                            \n\
                            \n\
                            autoNeg = autoNegSec;\n\
                            nicSpeed = nicSpeedSec;\n\
                            nicDuplex = nicDuplexSec;\n\
							changeMtuSize = changeMtuSizeSec;\n\
                            nicMtuSize = nicMtuSizeSec;\n\
							enableDHCP = enableDHCPSec;\n\
                            hostName = hostNameSec;\n\
                            hostIP = hostIPSec;\n\
                            hostMask = hostMaskSec;\n\
                            hostGateway = hostGatewaySec;\n\
                            enableDNS = enableDNSSec;\n\
                            if (primaryDNSSec != "Primary DNS Settings")\n\
                            {\n\
                                    primaryDNS = primaryDNSSec;\n\
                                    secondaryDNS = secondaryDNSSec;\n\
                                    domainName = domainNameSec;\n\
                            }\n\
                            \n\
                            timeZone = timeZoneSec;\n\
                            firstNode = "no";\n\
							mmcaSecondaryNodeType = mmcaSecondaryNodeTypeSec;\n\
                            \n\
                            // set the host name and ip over here below\n\
                            \n\
                            if (popUpXmlFile != null)\n\
                            {\n\
                                    popUpXmlFile.close();\n\
                            }\n\
                            \n\
                            writeToXML();\n\
                            \n\
                            // reset variables back\n\
                            \n\
                            firstNode = "yes";\n\
							\n\
                            \n\
                            \n\
                            autoNeg = autoNeg0;\n\
                            nicSpeed = nicSpeed0;\n\
                            nicDuplex = nicDuplex0;\n\
							changeMtuSize = changeMtuSize0;\n\
                            nicMtuSize = nicMtuSize0;\n\
							enableDHCP = enableDHCP0;\n\
                            hostName = hostName0;\n\
                            hostIP = hostIP0;\n\
                            hostMask = hostMask0;\n\
                            hostGateway = hostGateway0;\n\
                            enableDNS = enableDNS0;\n\
                            primaryDNS = primaryDNS0;\n\
                            secondaryDNS = secondaryDNS0;\n\
                            domainName = domainName0;\n\
                            timeZone = timeZone0;\n\
                            \n\
                            \n\
                            \n\
                        }\n\
                    <\/script>\n\
                <\/head>\n\
                <body>\n\
                    <div id="framework-logo">\n\
                        <a href="/en/US/hmpgs/index.html">\n\
                            <img src="logo.gif" alt="Cisco Systems, Inc. &reg;" width="110" height="73"\/>\n\
                        <\/a>\n\
                    <\/div>\n\
                    \n\
                    <h1>Cisco Unified Communications Answer File Generator<\/h2>\n\
                    \n\
                    <p>\n\
                        Answer files are downloading one at a time.  Each downloaded answer files must be saved as <b>platformConfig.xml</b> for use in unattended installations.  Create separate folders for each answer file and save the answer file for each node in its respective folder.\n\
                    <\/p>\n\
                    <p>\n\
                        Please <b>do not modify</b> the contents of the answer files.\n\
                    <\/p>\n\
                    \n';

        // Add the correct browser specific download instructions
        if (getIEVersion() == 6)
        {
            writeVar = writeVar + '\
                    <p>\n\
                        Use the following steps to download an answer file:\n\
                        <ol>\n\
                            <li>Click on the Download File button.  A Save As window will appear.<\/li>\n\
                            <li>Select the appropriate directory.  Remeber to save each answer file in a different directory and always with the filename platformConfig.xml.<\/li>\n\
                        <\/ol>\n\
                    <\/p>\n';
	}
	else
	{	
            writeVar = writeVar + '\
                    <p>\n\
                        Use the following steps to download an answer file:\n\
                        <ol>\n\
                            <li>Click on the Download File button.  The answer file window will appear.<\/li>\n\
                            <li>Select the Source option or the Page Source option from the View menu.  A new window will appear.  Note, press the Alt key if the menubar is not immediately visible.<\/li>\n\
                            <li>Select the Save As option or the Save Page As option from the File menu.  Remeber to save each answer file in a different directory and always with the filename platformConfig.xml.<\/li>\n\
                            <li>Once saved, close the source and answer file windows using the Exit option or Close option from the File menu.<\/li>\n\
                        <\/ol>\n\
                    <\/p>\n';
	}

        writeVar = writeVar + '\
                    \n\
                    <form name="downLoadForm" id="downLoadForm" method=post>\n\
                        \n\
                        <fieldset>\n\
                            <legend>\n\
                                Answer Files for Download\n\
                            <\/legend>\n\
                            <table>\n\
                                <tr>\n\
                                    <td class="download-column-left">\n\
                                        <label for="primaryAnswerFile">\n\
                                            Primary Node\n\
                                        <\/label>\n\
                                    <\/td>\n\
                                    <td class="download-column-right">\n\
                                        <input name="primaryAnswerFile" id="primaryAnswerFile" type="button" value="Download File" onClick="writeToXMLPrimary()">\n\
                                    <\/td>\n\
                                <\/tr>\n';

        if (hostNameLst != "" && hostNameLst.length !=0)
        {

                var lenParamString;
                var paramVals;
                var hostParamString;

                var hostList = hostNameLst.split(',');
                var len = hostList.length;

                for (var count=0; count<len; count++)
                {
                        var writeSubVar = "";
                        hostParamString = hostList[count];
                        lenParamString = hostParamString.length;
                        hostParamString = hostParamString.substr(1,lenParamString-2),
                        paramVals = hostParamString.split('!');

                        writeSubVar = writeSubVar + '\
                                <tr>\n\
                                    <td class="download-column-left">\n\
                                        <label for="' + paramVals[5] + '">\n\
                                            Secondary Node (host = '+paramVals[5]+')\n\
                                        <\/label>\n\
                                    <\/td>\n\
                                    <td class="download-column-right">\n\
                                        <input name="' + paramVals[5] + '" id="' + paramVals[5] + '" type="button" value="Download File" onClick="writeToXMLSecondary(\'' + count + '\')">\n\
                                    <\/td>\n\
                                <\/tr>\n';

                        writeVar = writeVar + writeSubVar;
                }
        }

        var tempwriter = writeVar;

        writeVar = writeVar + ' \
                            <\/table>\n\
                        <\/fieldset>\n\
                    <\/form>\n\
                    <a href="javascript:window.close()">Close Download Window<\/a>\n\
                    <script type="text\/javascript">\n\
                        <!--\n\
                            document.downLoadForm.primaryAnswerFile.focus();\n\
                        -->\n\
                    <\/script>\n\
                <\/body>\n\
            <\/html>\n';

        //alert(writeVar);
        //if (tempwriter == writeVar)
        //	alert("equal");
        //else
        //	alert("unequal");
        objDoc.writeln(writeVar);

        // The document close is commented out as this causes the
        // page generation to hang with IIS servers. Also the contents
        // are not displayed\rendered once the document is closed.
        //objDoc.close();

        if (navigator.appName != "Microsoft Internet Explorer")
        {
                objDoc.close(); // this must be called to complete the HTML response
        }
}

// this function is called when the HTML page is loaded.
// it calls different functions to populate the time zone and country list,
// intialize the page and retrieve any non-persistent values stored.
function fnLoader()
{
        formObj = document.paramForm;
        populateOptions();
        initializePage();
}

// this function is called when the use primary zone check box is checked
// to display the primary zones time zone in the secondary zone's time zone list.
function usePrimaryTimeZone()
{
        if (formObj.sameTimeZone.checked == true)
        {
            formObj.timeZoneSecondaryRegion.selectedIndex = formObj.timeZonePrimaryRegion.selectedIndex;
            // first refresh the timezome list for that region
            fnTimeZoneRegion(SECONDARY_TZ_REGION_ID, SECONDARY_TZ_ID);
            // and then select the timezone
            formObj.timeZoneSecondary.selectedIndex = formObj.timeZonePrimary.selectedIndex;
        }
}

// this function is called to remove all options from a given <select> element.
function removeAllOptions(selections)
{
    var i;
    for(i = selections.options.length - 1; i >= 0; i--)
    {
        selections.remove(i);
    }
}

// this function is called to add an option to a given <select> element.
function addSelectOption(selections, optionText, optionValue)
{
    var newOption = document.createElement("OPTION");
    newOption.text = optionText;
    newOption.value = optionValue;
    selections.options.add(newOption);
}