function buildHtml(){
	// cancel any outstanding timer
	if(txtLogoUrl_timerID){
		window.clearTimeout(txtLogoUrl_timerID);
	}
	txtLogoUrl_timerID = 0;

	var oForm = document.forms["oHtmlBuilderForm"];
	var sLogoName = "Secure Site";
	var sLogo = "large";
	var sCode = "SBS";
	var sAutoMove = "none";
	oForm.txtHtml.value = 
	"<!-" + "- " + "SBS Secure Plus Code " + "-" + "-" + ">\n"
	+ "<script type=\"text/javascript\">TrustLogo("
	+ "\"" + htmlEncode(oForm.txtLogoUrl.value) + "\", " 
	+ "\"" + sCode + "\", "
	+ "\"" + sAutoMove 
	+ "\");</script>";
	 if(oForm.txtLogoUrl.value.match(/^https?\:\/\/.*\/.*/)){
  		document.images["imgLogoUrl"].src = oForm.txtLogoUrl.value;
		 }
}

// HTML-encodes certain characters.
function htmlEncode(str){
	// replace all ' with &apos; and all " with &quot;
	// also all < with &lt; and all > with &gt;
	// but first all &amp; with &amp;
	return String(str)
		.replace(/\&/g, "&amp;")
		.replace(/\</g, "&lt;")
		.replace(/\>/g, "&gt;")
		.replace(/\'/g, "&#27;")
		.replace(/\"/g, "&#22;")
		;
}


function form_onsubmit(){
	buildHtml();
}

var txtLogoUrl_timerID = 0;
function txtLogoUrl_onKeyPress(){
	if(txtLogoUrl_timerID){
		window.clearTimeout(txtLogoUrl_timerID);
		txtLogoUrl_timerID = 0;
	}
	txtLogoUrl_timerID = window.setTimeout("buildHtml();", 500);
	
}

