/*
 * Copyright 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.
 * 
 */

function writeToXML()
{
	
	// initial xml string
	var strXML = new String ();
	strXML = '<?xml version="1.0"?>\n';
	var tempObj;

	try
	{

		var XML=new XMLWriter();
		
		// default tag
		XML.BeginNode("PlatformData",0);

		// default tag
		XML.Node("Version",productVersion,1);
		
		// muster parameter
		// the product to be installed
		
		// Small work around for CER -- they need the ProductDeployment element
        // to contain callmanager instead of their product name
		if(productName=="cer")
		{
			XML.BeginNode("ProductDeployment",1);
			XML.Node("ParamNameText", "Deployment",2);
			XML.Node("ParamDefaultValue", "CallManager",2);
			XML.Node("ParamValue","callmanager",2);
			XML.EndNode(1);
		}
		else{
			XML.BeginNode("ProductDeployment",1);
			XML.Node("ParamNameText", "Deployment",2);
			XML.Node("ParamDefaultValue", "CallManager",2);
			XML.Node("ParamValue",productName,2);
			XML.EndNode(1);
		}
		
		// default platform config
		XML.BeginNode("PlatformConfigurationDone",1);
		XML.Node("ParamNameText", "Status of platform configuration",2);
		XML.Node("ParamDefaultValue", "no",2);
		// XML.Node("ParamValue","yes",2);
		// changed to 'no' as per Steve Barrera's suggestion
		XML.Node("ParamValue","no",2);
		XML.EndNode(1);

		// default preloaded node
		XML.BeginNode("PreLoadedSoftware",1);
		XML.Node("ParamNameText", "Create a pre loaded software node",2);
		XML.Node("ParamDefaultValue", "no",2);
		XML.Node("ParamValue","yes",2);
		XML.EndNode(1);

		if ((w1Upgrade == "true" || w1Upgrade == true) && (firstNode == "yes"))
		{
		    // default W1 install type
		    XML.BeginNode("InstallType",1);
		    XML.Node("ParamNameText", "Install or upgrade type",2);
		    XML.Node("ParamDefaultValue", "basic",2);
		    XML.Node("ParamValue","Windows Upgrade",2);
		    XML.EndNode(1);
		}
		else
		{
		    // default install type
		    XML.BeginNode("InstallType",1);
		    XML.Node("ParamNameText", "Install or upgrade type",2);
		    XML.Node("ParamDefaultValue", "basic",2);
		    XML.Node("ParamValue","Basic Install",2);
		    XML.EndNode(1);
		}

		// NIC Auto Config
		XML.BeginNode("LocalHostNICAuto",1);
		XML.Node("ParamNameText", "Auto Configure speed and duplex",2);
		XML.Node("ParamDefaultValue", "yes",2);
		XML.Node("ParamValue",autoNeg=="true"||autoNeg==true?"yes":"no",2);
		XML.EndNode(1);
		
		if (autoNeg == "false" || autoNeg == false)
		{
			// Manual NIC Speed
			XML.BeginNode("LocalHostNICSpeed",1);
			XML.Node("ParamNameText", "Auto Configure speed and duplex",2);
			XML.Node("ParamDefaultValue", "100",2);
			XML.Node("ParamValue",nicSpeed,2);
			XML.EndNode(1);

			// Manual NIC Duplex
			XML.BeginNode("LocalHostNICDuplex",1);
			XML.Node("ParamNameText", "Auto Configure speed and duplex",2);
			XML.Node("ParamDefaultValue", "Full",2);
			XML.Node("ParamValue",nicDuplex,2);
			XML.EndNode(1);
			
			// Change MTU Size
			XML.BeginNode("ChangeMTUSize", 1);
			XML.Node("ParamNameText", "MTU Size changed from OS default", 2);
			XML.Node("ParamDefaultValue", "no", 2);
			XML.Node("ParamValue", changeMtuSize=="true"||changeMtuSize==true?"yes":"no", 2);
			XML.EndNode(1);
		}
		
		if(changeMtuSize == "true"|| changeMtuSize == true)
		{
			XML.BeginNode("LocalHostMTUSize", 1);
			XML.Node("ParamNameText", "MTU Size", 2);
			XML.Node("ParamDefaultValue", "1500", 2);
			XML.Node("ParamValue", nicMtuSize, 2);
			XML.EndNode(1);
		}	

		// Host Name
		XML.BeginNode("LocalHostName",1);
		XML.Node("ParamNameText", "Host Name for this machine",2);
		XML.Node("ParamDefaultValue", "localhost",2);
		XML.Node("ParamValue",hostName,2);
		XML.EndNode(1);

		// DHCP enable
		XML.BeginNode("LocalHostDHCP",1);
		XML.Node("ParamNameText", "Is DHCP enabled for this machine",2);
		XML.Node("ParamDefaultValue", "no",2);
		XML.Node("ParamValue",enableDHCP=="true"|| enableDHCP == true?"yes":"no",2);
		XML.EndNode(1);
		
		if (enableDHCP == "false" || enableDHCP == false)
		{
			// Host IP
			XML.BeginNode("LocalHostIP0",1);
			XML.Node("ParamNameText", "Host IP0 addr for this node",2);
			XML.Node("ParamDefaultValue", "127.0.0.1",2);
			XML.Node("ParamValue",hostIP,2);
			XML.EndNode(1);

			// Host Mask
			XML.BeginNode("LocalHostMask0",1);
			XML.Node("ParamNameText", "Host IP0 mask for this node",2);
			XML.Node("ParamDefaultValue", "255.255.255.0",2);
			XML.Node("ParamValue",hostMask,2);
			XML.EndNode(1);

			// Gateway
			XML.BeginNode("LocalHostGW0",1);
			XML.Node("ParamNameText", "Gateway for this node",2);
			XML.Node("ParamDefaultValue", "127.0.0.1",2);
			XML.Node("ParamValue",hostGateway,2);
			XML.EndNode(1);

			if  (enableDNS == "true" || enableDNS == true)
			{
				// Primary DNS
				XML.BeginNode("LocalHostDnsPrimary",1);
				XML.Node("ParamNameText", "Primary DNS server IP address",2);
				XML.Node("ParamDefaultValue", "0.0.0.0",2);
				XML.Node("ParamValue",primaryDNS,2);
				XML.EndNode(1);

				// Secondary DNS
				XML.BeginNode("LocalHostDnsSecondary",1);
				XML.Node("ParamNameText", "Secondary DNS server IP address",2);
				XML.Node("ParamDefaultValue", "0.0.0.0",2);
				XML.Node("ParamValue",secondaryDNS,2);
				XML.EndNode(1);

				// Domain
				XML.BeginNode("LocalHostDomain",1);
				XML.Node("ParamNameText", "Domain name for this machine",2);
				XML.Node("ParamDefaultValue", "cisco.com",2);
				XML.Node("ParamValue",domainName,2);
				XML.EndNode(1);
			}
		}
		
		// Timezone
		XML.BeginNode("LocalHostTimezone",1);
		XML.Node("ParamNameText", "Timezone for this node",2);
		XML.Node("ParamDefaultValue", "America/Los_Angeles",2);
		XML.Node("ParamValue",timeZone,2);
		XML.EndNode(1);

		var tzComponents = timeZone.split("/");

		// Continent (for pre-unison installs)
		XML.BeginNode("LocalHostContinent",1);
		XML.Node("ParamNameText", "Continent for this node",2);
		XML.Node("ParamDefaultValue", "America",2);
		XML.Node("ParamValue",tzComponents[0],2);
		XML.EndNode(1);

		// City (for pre-unison installs)
		XML.BeginNode("LocalHostCity",1);
		XML.Node("ParamNameText", "City for this node",2);
		XML.Node("ParamDefaultValue", "Los_Angeles",2);
		XML.Node("ParamValue",tzComponents[1],2);
		XML.EndNode(1);


		// Admin
		XML.BeginNode("LocalHostAdminName",1);
		XML.Node("ParamNameText", "Administrator name for this node",2);
		XML.Node("ParamDefaultValue", "administrator",2);
		XML.Node("ParamValue",adminName,2);
		XML.EndNode(1);

		// Password
		
		// encrypt password
		var encryptAdminPW = encryptPassword(adminPasswd);
		// adminPasswd = encryptAdminPW[0];

		XML.BeginNode("LocalHostAdminPwCrypt",1);
		XML.Node("ParamNameText", "Admin PW for this node",2);
		XML.Node("ParamDefaultValue", "password",2);
		XML.Node("ParamValue",encryptAdminPW,2);
		XML.EndNode(1);

		// Certificate
		XML.BeginNode("CertX509",1);
		
		// Organization
		XML.BeginNode("Org",2);
		XML.Node("ParamNameText", "Certification Signing Request Organization",3);
		XML.Node("ParamDefaultValue", "none",3);
		XML.Node("ParamValue",certOrg,3);
		XML.EndNode(2);

		// Unit
		XML.BeginNode("Unit",2);
		XML.Node("ParamNameText", "Certification Signing Request Unit",3);
		XML.Node("ParamDefaultValue", "none",3);
		XML.Node("ParamValue",certUnit,3);
		XML.EndNode(2);

		// Location
		XML.BeginNode("Location",2);
		XML.Node("ParamNameText", "Certification Signing Request Location",3);
		XML.Node("ParamDefaultValue", "none",3);
		XML.Node("ParamValue",certLoc,3);
		XML.EndNode(2);

		// State
		XML.BeginNode("State",2);
		XML.Node("ParamNameText", "Certification Signing Request State",3);
		XML.Node("ParamDefaultValue", "none",3);
		XML.Node("ParamValue",certState,3);
		XML.EndNode(2);

		// Country
		XML.BeginNode("Country",2);
		XML.Node("ParamNameText", "Certification Signing Request Country",3);
		XML.Node("ParamDefaultValue", "none",3);
		XML.Node("ParamValue",certCon,3);
		XML.EndNode(2);

		// Ending Cert
		XML.EndNode(1);

		// default locale identifier
		XML.BeginNode("LocaleId",1);
		XML.Node("ParamNameText", "Microsoft assigned locale identifier value",2);
		XML.Node("ParamDefaultValue", "00000409",2);
		XML.Node("ParamValue","",2);
		XML.EndNode(1);

		if(productName=="cer")
		{
                        // default CER version backed up
                        XML.BeginNode("CERCCMVersion",1);
                        XML.Node("ParamNameText", "CCM Version which is being supported by CER",2);
                        XML.Node("ParamDefaultValue", "5.0",2);
                        XML.Node("ParamValue",cerCcmVersion,2);
                        XML.EndNode(1);

                        // first CER node
                        XML.BeginNode("CERFirstNode",1);
                        XML.Node("ParamNameText", "First CER node in the cluster",2);
                        XML.Node("ParamDefaultValue", "yes",2);
                        XML.Node("ParamValue",firstNode,2);
                        XML.EndNode(1);

                        // primaryRoutePoint
                        XML.BeginNode("CERPrimaryRoutePoint", 1);
                        XML.Node("ParamNameText", "Address of the CER Primary Route Point", 2);
                        XML.Node("ParamDefaultValue", "911", 2);
                        XML.Node("ParamValue", primaryRoutePoint, 2);
                        XML.EndNode(1);

                        // endUserLanguage
                        XML.BeginNode("CEREndUserLanguage", 1);
                        XML.Node("ParamNameText", "Security End User Language", 2);
                        XML.Node("ParamDefaultValue", "English", 2);
                        XML.Node("ParamValue", endUserLanguage, 2);
                        XML.EndNode(1);
		}
		else
		{
                        // default CCM version backed up
                        XML.BeginNode("CCMVersion",1);
                        XML.Node("ParamNameText", "CM version on the server backed up",2);
                        XML.Node("ParamDefaultValue", "CCM ver 5.0",2);
                        XML.Node("ParamValue","",2);
                        XML.EndNode(1);

                        // first CCM node
                        XML.BeginNode("CcmFirstNode",1);
                        XML.Node("ParamNameText", "First CCM node in the cluster",2);
                        XML.Node("ParamDefaultValue", "yes",2);
                        XML.Node("ParamValue",firstNode,2);
                        XML.EndNode(1);
		}
		
		if (firstNode == "yes")
		{
			// sftp pw
			// encrypt password
			var encryptSecurityPW = encryptPassword(securityPW);
			// securityPW = encryptSecurityPW[0];
			XML.BeginNode("SftpPwCrypt",1);
			XML.Node("ParamNameText", "Security PW for this node",2);
			XML.Node("ParamDefaultValue", "password",2);
			XML.Node("ParamValue",encryptSecurityPW,2);
			XML.EndNode(1);
			
			// default first IPSec node based on firstNode value
			XML.BeginNode("IPSecFirstNode",1);
			XML.Node("ParamNameText", "First IPSec node in the cluster",2);
			XML.Node("ParamDefaultValue", "yes",2);
			XML.Node("ParamValue",firstNode,2);
			XML.EndNode(1);
			
			// default IPSec enabled
			XML.BeginNode("IPSecEnabled",1);
			XML.Node("ParamNameText", "IPSec Configuration for this node",2);
			XML.Node("ParamDefaultValue", "no",2);
			XML.Node("ParamValue","no",2);
			XML.EndNode(1);

			// ipsec pw ( based on sftp p/w)
			XML.BeginNode("IPSecSecurityPwCrypt",1);
			XML.Node("ParamNameText", "Security PW for this node",2);
			XML.Node("ParamDefaultValue", "password",2);
			XML.Node("ParamValue",encryptSecurityPW,2);
			XML.EndNode(1);
			// ntp servers
			if (externalNTP == "true" || externalNTP == true)
			{

				if (ntpServer1 != "" && ntpServer1.length  != 0)
				{
					XML.BeginNode("NtpServer",1);
					XML.Node("ParamNameText", "Address Range for NTP server",2);
					XML.Node("ParamDefaultValue", "none",2);
					XML.Node("ParamValue",ntpServer1,2);
					XML.EndNode(1);
				}
				if (ntpServer2 != "" && ntpServer2.length  != 0)
				{
					XML.BeginNode("NtpServer",1);
					XML.Node("ParamNameText", "Address Range for NTP server",2);
					XML.Node("ParamDefaultValue", "none",2);
					XML.Node("ParamValue",ntpServer2,2);
					XML.EndNode(1);
				}
				if (ntpServer3 != "" && ntpServer3.length  != 0)
				{
					XML.BeginNode("NtpServer",1);
					XML.Node("ParamNameText", "Address Range for NTP server",2);
					XML.Node("ParamDefaultValue", "none",2);
					XML.Node("ParamValue",ntpServer3,2);
					XML.EndNode(1);
				}
				if (ntpServer4 != "" && ntpServer4.length  != 0)
				{
					XML.BeginNode("NtpServer",1);
					XML.Node("ParamNameText", "Address Range for NTP server",2);
					XML.Node("ParamDefaultValue", "none",2);
					XML.Node("ParamValue",ntpServer4,2);
					XML.EndNode(1);
				}
				if (ntpServer5 != "" && ntpServer5.length  != 0)
				{
					XML.BeginNode("NtpServer",1);
					XML.Node("ParamNameText", "Address Range for NTP server",2);
					XML.Node("ParamDefaultValue", "none",2);
					XML.Node("ParamValue",ntpServer5,2);
					XML.EndNode(1);
				}
			}

			// Added for W1 upgrade support
			if (w1Upgrade == "true" || w1Upgrade == true)
			{
				// DMA download option
				XML.BeginNode("BackupPathOption",1);
				XML.Node("ParamNameText", "Download Option",2);
				XML.Node("ParamDefaultValue", "SFTP",2);
				XML.Node("ParamValue",downloadOption,2);
				XML.EndNode(1);

				// DMA download server IP
				XML.BeginNode("BackupIPAddress",1);
				XML.Node("ParamNameText", "Download Server IP",2);
				XML.Node("ParamDefaultValue", "0.0.0.0",2);
				XML.Node("ParamValue",downloadServerIP,2);
				XML.EndNode(1);

				// DMA download server user name
				XML.BeginNode("BackupServerLoginId",1);
				XML.Node("ParamNameText", "Download Server User Name",2);
				XML.Node("ParamDefaultValue", "root",2);
				XML.Node("ParamValue",downloadServerUserName,2);
				XML.EndNode(1);

				// DMA download server user password
				// encrypt password
				var encryptDownloadServerUserPW = encryptPassword(downloadServerUserPW);

				XML.BeginNode("BackupServerLoginPw",1);
				XML.Node("ParamNameText", "Download Server User Password",2);
				XML.Node("ParamDefaultValue", "password",2);
				XML.Node("ParamValue",encryptDownloadServerUserPW,2);
				XML.EndNode(1);
				
				// DMA tarball location
				XML.BeginNode("BackupPath",1);
				XML.Node("ParamNameText", "DMA Tarball Location",2);
				XML.Node("ParamDefaultValue", "/tmp",2);
				XML.Node("ParamValue",dmaTarballLocation,2);
				XML.EndNode(1);

				// DMA Tarball File Name
				XML.BeginNode("BackupFileName",1);
				XML.Node("ParamNameText", "DMA Tarball Name",2);
				XML.Node("ParamDefaultValue", "DMA.tar",2);
				XML.Node("ParamValue",dmaTarballName,2);
				XML.EndNode(1);
				
				if(productName=="callmanager")
				{
					// encrypt pin
					var encryptEndUserPIN = encryptPassword(endUserPIN);
					// endUserPIN = encryptEndUserPIN[0];

					// end user PIN
					XML.BeginNode("EndUserPINCrypt",1);
					XML.Node("ParamNameText", "DB End User PIN",2);
					XML.Node("ParamDefaultValue", "pin",2);
					XML.Node("ParamValue",encryptEndUserPIN,2);
					XML.EndNode(1);

					// encrypt password
					var encryptEndUserPW = encryptPassword(endUserPW);
					// endUserPW = encryptEndUserPW[0];

					// end user PW
					XML.BeginNode("EndUserPwCrypt",1);
					XML.Node("ParamNameText", "DB End User Password",2);
					XML.Node("ParamDefaultValue", "password",2);
					XML.Node("ParamValue",encryptEndUserPW,2);
					XML.EndNode(1);
				}	
			}
		}
		
		else if (firstNode == "no")
		{
			// sftp pw
			// encrypt password
			var encryptSecurityPW = encryptPassword(securityPW);
			// securityPW = encryptSecurityPW[0];

			XML.BeginNode("SftpPwCrypt",1);
			XML.Node("ParamNameText", "Security PW for this node",2);
			XML.Node("ParamDefaultValue", "password",2);
			XML.Node("ParamValue",encryptSecurityPW,2);
			XML.EndNode(1);

			// default first IPSec node based on firstNode value)
			XML.BeginNode("IPSecFirstNode",1);
			XML.Node("ParamNameText", "First IPSec node in the cluster",2);
			XML.Node("ParamDefaultValue", "yes",2);
			XML.Node("ParamValue",firstNode,2);
			XML.EndNode(1);
			
			// default IPSec enabled
			XML.BeginNode("IPSecEnabled",1);
			XML.Node("ParamNameText", "IPSec Configuration for this node",2);
			XML.Node("ParamDefaultValue", "no",2);
			XML.Node("ParamValue","no",2);
			XML.EndNode(1);

			// ipsec pw ( based on sftp p/w)
			XML.BeginNode("IPSecSecurityPwCrypt",1);
			XML.Node("ParamNameText", "Security PW for this node",2);
			XML.Node("ParamDefaultValue", "password",2);
			XML.Node("ParamValue",encryptSecurityPW,2);
			XML.EndNode(1);
			
			if(productName=="cer")
			{
				// pause on successful subconnect
				XML.BeginNode("PauseOnSuccessSubConnect",1);
				XML.Node("ParamNameText", "Pause install on Successful connect from sub to pub",2);
				XML.Node("ParamDefaultValue", "no",2);
				XML.Node("ParamValue","no",2);
				XML.EndNode(1);
			}	
			
			// ccm db host
			XML.BeginNode("CcmDBHost",1);
			XML.Node("ParamNameText", "Host Name for DataBase",2);
			XML.Node("ParamDefaultValue", "none",2);
			XML.Node("ParamValue",hostNamePrimary,2);
			XML.EndNode(1);
			// ccm db ip
			XML.BeginNode("CcmDBIpAddr",1);
			XML.Node("ParamNameText", "Host IP Addr for DataBase",2);
			XML.Node("ParamDefaultValue", "none",2);
			XML.Node("ParamValue",hostIPPrimary,2);
			XML.EndNode(1);
			// ipsec master host
			XML.BeginNode("IPSecMasterHost",1);
			XML.Node("ParamNameText", "Host name for IPSec",2);
			XML.Node("ParamDefaultValue", "none",2);
			XML.Node("ParamValue",hostNamePrimary,2);
			XML.EndNode(1);

			// ipsec master ip
			XML.BeginNode("IPSecMasterIpAddr",1);
			XML.Node("ParamNameText", "Host IP Addr for IPSec",2);
			XML.Node("ParamDefaultValue", "none",2);
			XML.Node("ParamValue",hostIPPrimary,2);
			XML.EndNode(1);

			// ntpserver host
			XML.BeginNode("NTPServerHost",1);
			XML.Node("ParamNameText", "Cluster NTP Server Host name",2);
			XML.Node("ParamDefaultValue", "none",2);
			XML.Node("ParamValue",hostNamePrimary,2);
			XML.EndNode(1);

			// ntpserver ip
			XML.BeginNode("NTPServerIpAddr",1);
			XML.Node("ParamNameText", "Cluster NTP Server Host IP Addr",2);
			XML.Node("ParamDefaultValue", "none",2);
			XML.Node("ParamValue",hostIPPrimary,2);
			XML.EndNode(1);

                        // mmca node selection
                        if (productName == "expertadvisor")
                        {
                                XML.BeginNode("MMCASecondaryNodeType",1);
                                XML.Node("ParamNameText", "MMCA Secondary node type of this server",2);
                                XML.Node("ParamDefaultValue", "unknown",2);
                                XML.Node("ParamValue",mmcaSecondaryNodeType,2);
                                XML.EndNode(1);
                        }
		}
		// smtp host name
		if (smtpEnabled == "true" || smtpEnabled == true)
		{
			XML.BeginNode("SMTPHostName",1);
			XML.Node("ParamNameText", "SMTP location for this node",2);
			XML.Node("ParamDefaultValue", "smtp.host",2);
			XML.Node("ParamValue",smtpLocation,2);
			XML.EndNode(1);
		}
                
                // uccx deployment selection
                if (productName == "contactcenterxpress")
                {
                        XML.BeginNode("CCXDeploymentType",1);
                        XML.Node("ParamNameText", "CCX deployment type of this server",2);
                        XML.Node("ParamDefaultValue", "none",2);
                        XML.Node("ParamValue",ccxdeploymentType,2);
                        XML.EndNode(1);
                }
	
		if(productName=="cer")
		{
                        // muster parameter
                        // appln user username
                        XML.BeginNode("ApplUserUsername",1);
                        XML.Node("ParamNameText", "Application User Username",2);
                        XML.Node("ParamDefaultValue", "CERAdministrator",2);
                        XML.Node("ParamValue",appUserUsername,2);
                        XML.EndNode(1);
		}
		else if (productName == "contactcenterxpress")
                {
                        XML.BeginNode("ApplUserUsername",1);
                        XML.Node("ParamNameText", "Application User Username",2);
                        XML.Node("ParamDefaultValue", "UCCXAdministrator",2);
                        XML.Node("ParamValue",appUserUsername,2);
                        XML.EndNode(1);
		}
		else
                {
                        // muster parameter
                        // appln user username
                        XML.BeginNode("ApplUserUsername",1);
                        XML.Node("ParamNameText", "Application User Username",2);
                        XML.Node("ParamDefaultValue", "CCMAdministrator",2);
                        XML.Node("ParamValue",appUserUsername,2);
                        XML.EndNode(1);
		}
	
		// appln user pw
		// encrypt password
		var encryptAppUserPW = encryptPassword(appUserPW);
		// appUserPW = encryptAppUserPW[0];
		XML.BeginNode("ApplUserPwCrypt",1);
		XML.Node("ParamNameText", "Application User Password",2);
		XML.Node("ParamDefaultValue", "password",2);
		XML.Node("ParamValue",encryptAppUserPW,2);
		XML.EndNode(1);
		// Commenting out the DB password as per Bobs suggestion
		/*
		if (firstNode == "yes" )
		{
			var encrytAppDBUserPW = encryptPassword("","password");
			//var appDBUserPW = encrytAppDBUserPW[0];
			// default DB app user pw
			XML.BeginNode("ApplUserDbPwCrypt",1);
			XML.Node("ParamNameText", "DB Application User Password",2);
			XML.Node("ParamDefaultValue", "password",2);
			XML.Node("ParamValue",encrytAppDBUserPW,2);
			XML.EndNode(1);
		}*/

		/* commenting out until W1 Upgrade is also enabled
		// CAR Major Version
		XML.BeginNode("CARMajorVersion",1);
		XML.Node("ParamNameText", "CAR Major version on the server backed up",2);
		XML.Node("ParamDefaultValue", "4.0",2);
		XML.Node("ParamValue","",2);
		XML.EndNode(1);

		// CAR Minor Version
		XML.BeginNode("CARMinorVersion",1);
		XML.Node("ParamNameText", "CAR Minor version on the server backed up",2);
		XML.Node("ParamDefaultValue", "0.00",2);
		XML.Node("ParamValue","",2);
		XML.EndNode(1);*/

        // Add License MAC
		if (generateLicenseMac == "true") {
	        XML.BeginNode("LicenseMAC",1);
	        XML.Node("ParamNameText", "License MAC used for VM provisioning/installing only.  This value is NOT kept in sync with post install changes.",2);
	        XML.Node("ParamDefaultValue", "none",2);
	        XML.Node("ParamValue",licenseMac,2);
	        XML.EndNode(1);
		}

		XML.EndNode();
		XML.Close();
	
	}
	catch(Err)
	{
		alert("Error: " + Err.description);
	}


	strXML = strXML + XML.ToString().replace(/>/g,">\n");

	strXML = strXML.replace(/<ParamNameText>\n/g,"<ParamNameText>");
	strXML = strXML.replace(/<ParamDefaultValue>\n/g,"<ParamDefaultValue>");
	strXML = strXML.replace(/<ParamValue>\n/g,"<ParamValue>");

	// fixing the version
	strXML = strXML.replace(/<Version>\n/g,"<Version>");

	SaveVarAsFile(strXML);

}

function SaveVarAsFile(someVar)
{
        if (getIEVersion() != 0)
	{
            SaveFrame.document.charset = "UTF-8";
            SaveFrame.document.open("text/html:charset=UTF-8","replace");
            SaveFrame.document.writeln(someVar);
            SaveFrame.document.close();
            SaveFrame.focus();
            SaveFrame.document.execCommand('SaveAs',1,'platformConfig.xml');
	}
	else
	{	
            popUpXmlFile = window.open("","xmlwindow","width=550,height=600,menubar=yes,status=yes,scrollbars=yes,resizable=yes,toolbar=no");
            var xmlDoc = popUpXmlFile.document.open("content-type: text/html","replace");
            xmlDoc.writeln(someVar);
            xmlDoc.close();
            popUpXmlFile.focus();
	}
}

function fnDisplayHelp(strTitle,strMessage)
{

	popUpHelp = window.open("","helpwindow","width=550,height=250,menubar=yes,status=yes,scrollbars=yes,resizable=yes,toolbar=no");
	helpDoc = popUpHelp.document.open("text/html");
	helpDoc.writeln('<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">');
	helpDoc.writeln('<html lang=\"en\">');
	helpDoc.writeln('    <head>');
	helpDoc.writeln('        <title>Cisco Unified Communications Answer File Generator<\/title>');
	helpDoc.writeln('        <meta http-equiv=Content-Type content=\"text\/html; charset=windows-1252\" \/>');
	helpDoc.writeln('        <link rel=\"stylesheet\" type=\"text/css\" href=\"HelpView.css\" \/>');
	helpDoc.writeln('    <\/head>');
	helpDoc.writeln('    <body>');
	helpDoc.writeln('	<fieldset>');
	helpDoc.writeln('	    <legend>');
	helpDoc.writeln('	        ' + strTitle);
	helpDoc.writeln('	    <\/legend>');
	helpDoc.writeln('	    <div class=\"helpcontent\">');
	helpDoc.writeln('           ' + strMessage);
	helpDoc.writeln('	    <\/div>');
	helpDoc.writeln('	<\/fieldset>');
	helpDoc.writeln('       <a href="javascript:window.close()">Close Help Window<\/a>');
	helpDoc.writeln('    <\/body>');
	helpDoc.writeln('<\/html>');
	
	if (navigator.appName != "Microsoft Internet Explorer")
	{
		helpDoc.close(); // this must be called to complete the HTML response
	}
	popUpHelp.focus();
}

// Determines the IE version or 0 for non IE broswers
function getIEVersion() {
        var userAgent = window.navigator.userAgent;
        var ieVerIndex = userAgent.indexOf("MSIE ");
 
        if (ieVerIndex > 0) 
        {
            return parseInt(userAgent.substring(ieVerIndex + 5, userAgent.indexOf (".", ieVerIndex)));
        } else {
            return 0;
        }
}

// Determines is the current browser is supported
function isSupportedBrowser() {
    var userAgent = window.navigator.userAgent;
    if (userAgent.indexOf("Firefox") == -1 && userAgent.indexOf("MSIE") == -1) {
        return false;
    } else {
        return true;
    }
}

