// Handle wft CD-ROM purchase drop-down menu on wftonline/index.html
function GoToWFTCDROM(windowObj) {
    index  = windowObj.document.WFTCDROM.WFTVOLUME.selectedIndex
    volume = windowObj.document.WFTCDROM.WFTVOLUME.options[index].value

    // default url for individual wft subscription
    url    = "/_wft" + volume + "_facd.html"

    // redirect
    windowObj.location = "http://familytreemaker.genealogy.com" + url
}

// Handle wft download drop-down menu on wftonline/index.html
function GoToDownload(windowObj) {
    index  = windowObj.document.WFTDOWNLOAD.WFTVOLUME.selectedIndex
    volume = windowObj.document.WFTDOWNLOAD.WFTVOLUME.options[index].value

    // default url for individual wft subscription
    url = "/wftonline/v" + volume + "/index.html"

    // set special url if it is the all-50 volume
    if (volume == "A50") { url = "/wftonline/v50/index.html" }

    // redirect
    windowObj.location = "http://familytreemaker.genealogy.com" + url
}

// Handle wft subscription drop-down menu on wftonline/index.html
function GoToStore(windowObj) {
    index  = windowObj.document.WFTPURCHASE.WFTVOLUME.selectedIndex
    volume = windowObj.document.WFTPURCHASE.WFTVOLUME.options[index].value
    wftpatt = /^\d{7}10(\d{3})$/;
    fcodepatt = /^f\d(\d{3})$/i
    // default url for individual wft subscription
    url = "/wftonline/v" + volume + "/index.html"
    product_code = "f9"+ (700 + volume)

	if (volume.length < 2){
		volume = "00" +volume
	}
    else if (volume.length < 3){
        volume = "0" + volume
    }
    // set special url if it is the all-50 volume
    if (volume == "A50") {
        url = "/wftonline/v50/index.html"
        product_code = "f9950"
    }
    if (volume.length == 5) {
       var match_result = volume.match(fcodepatt);
       if (match_result != null) { 
           product_code = volume
           volume = match_result[1] - 0;
           url = "/wftonline/v" + volume + "/index.html"
       }
    }
    if (volume.length > 5 ) {
        url = "/wftonline/index.html#3"
        product_code = volume
        var match_result = volume.match(wftpatt);
        if (match_result != null) {
            volume = match_result[1] - 0;
            url = "/wftonline/v" + volume + "/index.html"
        }
    }
    // redirect
    script = "/cgi-bin/store.cgi"
    windowObj.location = "http://familytreemaker.genealogy.com" + script + 
                         "?product=" + product_code + 
                         "&url=" + url 
}
