function download_action() {
	detect_platform();
	if (! (platformId.indexOf('Mac') >= 0 || platformId.indexOf('Windows XP') >= 0 || platformId.indexOf('Vista') >= 0 || platformId.indexOf('Linux') >= 0 || platformId.indexOf('x86') >= 0) ) {
		 window.location = '/pt_BR/downloads/all.jsp';
	} else if(platformId.indexOf('Mac PPC') >= 0 || platformId.indexOf('Linux') >= 0 || platformId.indexOf('Solaris') >= 0) {
		var javafxElement = document.getElementById('javafx-download');
		if(javafxElement) {
			javafxElement.style.visibility="hidden";
		} 
	} 
}

function downloadMobile(evt) {
    if (document.download_form.fx_mobile_license.checked == false)	{
		//Alert statement will be handled by javafx.js.attachToDownloadButton();
		//Just cancel this event and return;
		evt.preventDefault();
		return false;
	} else {
		download_value('javafx_mobile');
	}

}

function toggleLicenseDisplay() {
	var licenseElement = document.getElementById('fx_mobile_license');

	if(licenseElement) {
		licenseElement.style.visibility="hidden";
		for (var i=0; i<document.download_form.ProductRef.length; i++)  {
			if (document.download_form.ProductRef[i].checked)  {

			    var product = document.download_form.ProductRef[i].value;
				if (product == "javafx_mobile")	{
					licenseElement.style.visibility="visible";
				} 
			}
		}
	} 
	 
}

function download_value(chosenValue) {
        detect_platform();

		// Declare all the download urls
		var cdsDownload = new Array(4);
		for(var i=0; i<4; i++)
			cdsDownload[i] = new Array(4);
		cdsDownload[0][0] = "netbeans-6.8-javafx-1.2.1-oth-JPR_English_with_Windows@CDS-CDS_Developer";
		cdsDownload[0][1] = "netbeans-6.8-javafx-1.2.1-oth-JPR_English_with_Mac OS X@CDS-CDS_Developer";
		cdsDownload[0][2] = "netbeans-6.8-javafx-1.2.1-oth-JPR_English_with_Linux@CDS-CDS_Developer";
		cdsDownload[0][3] = "netbeans-6.8-javafx-1.2.1-oth-JPR_English_with_Solaris x86@CDS-CDS_Developer";
		cdsDownload[1][0] = "javafx_ps-1.2-oth-JPR_English_with_Windows@CDS-CDS_Developer";
		cdsDownload[1][1] = "javafx_ps-1.2-oth-JPR_English_with_Mac OS X@CDS-CDS_Developer";
		cdsDownload[1][2] = "linux";
		cdsDownload[1][3] = "solaris";
		cdsDownload[2][0] = "javafx_sdk-1.2.3-oth-JPR_English_with_Windows@CDS-CDS_Developer";
		cdsDownload[2][1] = "javafx_sdk-1.2.3-oth-JPR_English_with_Mac OS X@CDS-CDS_Developer";
		cdsDownload[2][2] = "javafx_sdk-1.2.3-oth-JPR_English_with_Linux@CDS-CDS_Developer";
		cdsDownload[2][3] = "javafx_sdk-1.2.3-oth-JPR_English_with_Solaris x86@CDS-CDS_Developer";
		cdsDownload[3][0] = "javafx_mobile1.2_windows.zip";
		cdsDownload[3][1] = "javafx_mobile1.2_windows.zip";
		cdsDownload[3][2] = "javafx_mobile1.2_windows.zip";
		cdsDownload[3][3] = "javafx_mobile1.2_windows.zip";

		// Declare all the download names
		var downloadNames = new Array(4);
		downloadNames[0] = "NetBeans IDE 6.8 for JavaFX 1.2";
		downloadNames[1] = "JavaFX 1.2 Production Suite";
		downloadNames[2] = "JavaFX 1.2.3 SDK";
		downloadNames[3] = "JavaFX Mobile 1.2 for Windows Mobile";

		// Declare all the download executable links
		var downloadLinks = new Array(4);
		for(var i=0; i<4; i++)
			downloadLinks[i] = new Array(4);
		downloadLinks[0][0] = "netbeans-6.8-ml-javafx-windows.exe";
		downloadLinks[0][1] = "netbeans-6.8-ml-javafx-macosx.dmg";
		downloadLinks[0][2] = "netbeans-6.8-ml-javafx-linux.sh";
		downloadLinks[0][3] = "netbeans-6.8-ml-javafx-solaris-x86.sh";
		downloadLinks[1][0] = "javafx_production_suite-1_2-windows-i586.exe";
		downloadLinks[1][1] = "javafx_production_suite-1_2-macosx-intel.dmg";
		downloadLinks[1][2] = "linux";
		downloadLinks[1][3] = "solaris";
		downloadLinks[2][0] = "javafx_sdk-1_2.3-windows-i586.exe";
		downloadLinks[2][1] = "javafx_sdk-1_2.3-macosx-universal.dmg";
		downloadLinks[2][2] = "javafx_sdk-1_2.3-linux-i586.sh";
		downloadLinks[2][3] = "javafx_sdk-1_2.3-solaris-i586.sh";
		downloadLinks[3][0] = "javafx_mobile1.2_windows.zip";
		downloadLinks[3][1] = "javafx_mobile1.2_windows.zip";
		downloadLinks[3][2] = "javafx_mobile1.2_windows.zip";
		downloadLinks[3][3] = "javafx_mobile1.2_windows.zip";

		// Declare all the Release Urls
		var releaseUrls = new Array(4);
		releaseUrls[0] = "http://java.sun.com/javafx/1/reference/releasenotes/javafx-netbeans6.8-release-notes-1-2.html";
		releaseUrls[1] = "http://java.sun.com/javafx/1/reference/releasenotes/production-suite-release-notes-1-2.html";
		releaseUrls[2] = "http://java.sun.com/javafx/1/reference/releasenotes/javafx-sdk-release-notes-1-2-3.html";
		releaseUrls[3] = "http://www.javafx.com/downloads/mobile/ReleaseNotes.pdf";

		// Declare all the Installation Urls
		var installUrls = new Array(4);
		installUrls[0] = "http://java.sun.com/javafx/1/reference/javafx-netbeans-install/install-nb-for-javafx-1-2.html";
		installUrls[1] = "http://java.sun.com/javafx/1/reference/production-suite-install/";
		installUrls[2] = "http://java.sun.com/javafx/1/reference/sdk-install/install-javafx-sdk-1-2.html";
		installUrls[3] = "http://www.javafx.com/downloads/mobile/InstallGuide.pdf";

		var chosen = "";
		var selIndex1 = 0;
		var selIndex2 = 0;
		var radioSelected = 0;

		if(chosenValue == null || chosenValue == '') {
			var len = document.download_form.ProductRef.length;
			for (var i = 0; i <len; i++) {
				if (document.download_form.ProductRef[i].checked) {
					chosen = document.download_form.ProductRef[i].value;
					radioSelected = i;
				}
			}
		} else {
			chosen = chosenValue;
		}

		if(chosen == 'netbeans') selIndex1 = 0;
		if(chosen == 'javafx') selIndex1 = 1;
		if(chosen == 'javafx_sdk') selIndex1 = 2;
		if(chosen == 'javafx_mobile') selIndex1 = 3;
		if(platformId.indexOf('Windows') >= 0 || platformId.indexOf('Vista') >= 0) selIndex2 = 0;
		if(platformId.indexOf('Mac') >= 0 ) selIndex2 = 1;
		if(platformId.indexOf('Linux') >= 0 ) selIndex2 = 2;
		if(platformId.indexOf('Solaris') >= 0 ) selIndex2 = 3;

        if (selIndex1 == 3)   {
			document.getElementById('downloadLink').href = "http://www.javafx.com/downloads/mobile/javafx_mobile1.2_windows.zip";
        } else {
		    document.getElementById('downloadLink').href = "https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=" + cdsDownload[selIndex1][selIndex2] + "&OClick=Immediate";
		}
		document.getElementById('downloadText').innerHTML="for downloading " + downloadNames[selIndex1];
		document.getElementById('releaseNotes').href = releaseUrls[selIndex1];
		document.getElementById('installationGuide').href = installUrls[selIndex1];

		if(chosenValue == null || chosenValue == '') {
			document.download_form.ProductRef[radioSelected].value = cdsDownload[selIndex1][selIndex2];
			if (selIndex1 == 3)	{
				document.download_form.action="http://www.javafx.com/downloads/mobile/javafx_mobile1.2_windows.zip";
			}
			s_linkType = 'd';
			s_linkName = downloadLinks[selIndex1][selIndex2];
			s_linkTrackVars = 'events,products,eVar3,eVar8,eVar14,eVar15,eVar16';
			s_linkTrackEvents='event7';
			s_events='event7';
			s_products='Download Products;' + downloadNames[selIndex1];
			s_eVar3='javafx.com';
			s_eVar8=downloadLinks[selIndex1][selIndex2];
			s_eVar14=location.hostname+location.pathname;
			s_eVar15='Not required';
			s_eVar16='Browser';
			s_lnk=s_co(this);
			s_gs(s_account);
		}

		var actionLink = "https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=";
		var inHtml = ""; 
		var bodyId = document.getElementById("homepage");
		/*
		 METHOD NOTES:
		 I changed the Markup to output just two list elements, and to inject BR tags when necessary to accomplish a two row listing.
		 
		 FROM:
		 <dd class='first'>Item</dd><dd> </dd>
		 <dd>Item 2</dd><dd> </dd>
		 
		 TO:
		 <dd class='top'>Item</dd><dd class='top'>Item 2</dd>
		 
		 
		 I had to add some padding or else the items run into eachother and its hard to read, so only one of the links now needs to add an extra space
		 
		 When they download javaFX, I add two breaks to the JavaFX SDK link.
		 
		 Output:
		 <a>JavaFX SDK<br/><br/></a>
		 
		*/
		
			
		
		// This is to show more downloads on thank you page
		if(chosen == 'netbeans') {
			inHtml = "<dd class=\"top\"><a href=\""+ actionLink + cdsDownload[1][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[1] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			
			inHtml = inHtml + "<dd class='top'><a href=\"" + actionLink + cdsDownload[2][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[2] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			
			inHtml = inHtml + "<dd><a href=\/downloads\/mobile\/" + cdsDownload[3][selIndex2] + ">";
			inHtml = inHtml + downloadNames[3] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			
		}
		if(chosen == 'javafx') {
			inHtml = "<dd class='top'><a href=\""+ actionLink + cdsDownload[0][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[0] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			inHtml = inHtml + "<dd class='top'><a href=\"" + actionLink + cdsDownload[2][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[2] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			
			inHtml = inHtml + "<dd><a href=\/downloads\/mobile\/" + cdsDownload[3][selIndex2] + ">";
			inHtml = inHtml + downloadNames[3] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
		}
		if(chosen == 'javafx_sdk') {
			inHtml = "<dd class='top'><a href=\""+ actionLink + cdsDownload[0][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[0] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			inHtml = inHtml + "<dd class='top'><a href=\"" + actionLink + cdsDownload[1][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[1] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			inHtml = inHtml + "<dd><a href=\/downloads\/mobile\/"  + cdsDownload[3][selIndex2] + ">";
			inHtml = inHtml + downloadNames[3] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
		}
		if(chosen == 'javafx_mobile') {
			inHtml = "<dd class='top'><a href=\""+ actionLink + cdsDownload[0][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[0] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			inHtml = inHtml + "<dd class='top'><a href=\"" + actionLink + cdsDownload[1][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[1] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
			inHtml = inHtml + "<dd><a href=\"" + actionLink + cdsDownload[2][selIndex2] + "&OClick=Immediate\">";
			inHtml = inHtml + downloadNames[2] + "<\/a><\/dd>";
			//if(bodyId) inHtml = inHtml + "<dd>&nbsp;<\/dd>";
		}

		var moreElement = document.getElementById('downloadMore');
		if(moreElement) {
			var divTag = document.createElement("div");
			divTag.innerHTML = inHtml;
			moreElement.appendChild(divTag);
		}

		if(bodyId) {
			if(platformId.indexOf('Windows') >= 0 || platformId.indexOf('Vista') >= 0) {
				var jdkDownload = document.getElementById('jdk-download');
				inHtml = "<dt>Download<\/dt><dd><a href=\"https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jdk-6u16-windows-1c-JPR_Multi-language_with_Windows@CDS-CDS_Developer&OClick=Immediate\" onclick=\"s_linkType='d';s_linkName='jdk-6u16-windows-i586.exe';s_linkTrackVars='events,products,eVar3,eVar8,eVar14,eVar15,eVar16';s_linkTrackEvents='event7';s_events='event7';s_products='Download Products;Java SE Development Kit 6u16';s_eVar3='javafx.com';s_eVar8='jdk-6u16-windows-i586.exe';s_eVar14=location.hostname+location.pathname;s_eVar15='Not required';s_eVar16='Browser';s_lnk=s_co(this);s_gs(s_account);\">JDK 6u16<\/a><\/dd>";
				var divTag = document.createElement("div");
				divTag.innerHTML = inHtml;
				jdkDownload.appendChild(divTag);
			}
		}

	}

