function updateDomainPreview(inputId) {
	
	// Get the string
	var usernameString = document.getElementById(inputId).value;
	
	// Get the length of the string
	var usernameStringLength = usernameString.length;
	
	var domain = '';
	
	// Loop the string
	for(var i = 0; i < usernameStringLength; i++) {
		
		// Get the current character
		var character = usernameString.substr(i, 1);
		
		// If the character is not valid for a domain name
		if(!stringIsValidForDomain(character)) {
			
			// replace space with &nbsp;
			if(character == " ") {
				character = "&nbsp;&nbsp;";
			}
			
			// Style the character
			character = '<span>' + character + '</span>';
			
		}
		
		// Add the character to the string
		domain += character;
		
	}
	
	// Set string
	document.getElementById('domainPreviewUsername').innerHTML = domain;
	
}

function CreateAffiliateLink(F) {
  var findstring = "XXXXX";
  var ts='var replacewith=document.'+F.name+'.AffCode.value';
  eval(ts);
  if(replacewith.length < 1) { return; }
  var re = new RegExp(findstring,"g")
  for(i=0;i<F.length;i++) {
    var s = new String(F.elements[i].value);
    if(s.length > 0) {
      var newstr=s.replace(re,replacewith);
      F.elements[i].value = newstr;
    }
  }
}