
/**
 * Convert a Clickbank nickname into the HTML or URL for me.
 * @param affiliateID The textfield with the affiliate Clickbank nickname.
 * @param htmlCode The textfield to contain the HTML code for the hoplink.
 * @param emailCode The textfield to contain the URL for the hoplink.
 */
function generateHoplink(affiliateID, htmlCode, emailCode)
{
	//__Sanity check.
	if (!affiliateID || affiliateID.value == "" || affiliateID.value == "Your Clickbank nickname") 
	{
		//__The affiliate ID is null or its value is empty.
		htmlCode.value = "";
		emailCode.value = "";
		alert("You didn't type in a Clickbank nickname!");
		return;
	}
	
	//__All is well.  Generate the codes.
	var URL = "http://" + affiliateID.value + ".randying.hop.clickbank.net";
	var HTML = '<a href="' + URL + '" target="_top">Click here to see Randy Ingermanson\'s fiction courses!</a>';
	htmlCode.value = HTML;	
	emailCode.value = URL;
}	//__End generateHoplink().

/**
 * Convert a Clickbank nickname into a URL and test it.
 * @param affiliateID The textfield with the affiliate Clickbank nickname.
 * @param htmlCode The textfield to contain the HTML code for the hoplink.
 * @param emailCode The textfield to contain the URL for the hoplink.
 */
function testHoplink(affiliateID, htmlCode, emailCode)
{
	//__Sanity check.
	if (!affiliateID || affiliateID.value == "" || affiliateID.value == "Your Clickbank nickname") 
	{
		//__The affiliate ID is null or its value is empty.
		htmlCode.value = "";
		emailCode.value = "";
		alert("You didn't type in a Clickbank nickname!");
		return;
	}
	
	//__All is well.  Generate and test the code.
	var URL = "http://" + affiliateID.value + ".randying.hop.clickbank.net";
	window.open(URL);
}	//__End testHoplink().
