// JavaScript Document
function getFlashVars() {
	var flashVars = 'heart_color=' + document.createForm.heart_color.value + '&';
	if (selectedValue(document.createForm.message) == "Y") {
		flashVars += 'message=Send%20me%20a%20heart&';
	}
	return flashVars;
}
	
function getHtmlFromFlashVars(myFlashVars, mode) {
	var html = 
		  '<embed src="http://www.stunme.com/flash/heart.swf" quality="high" menu="false" ' +    
		  'pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" ' +
		  'type="application/x-shockwave-flash" width="150" height="170" wmode="transparent" ' +
		  'FlashVars="' + myFlashVars + '"/><br />';
	if (mode == 'myspace') {
		html +='<a href="http://www.myspace.com/send_hearts" target="_top"><img src="http://www.stunme.com/images/heart/send_hearts.gif" alt="Stun Me" width="150" height="30" border="0" /></a><br /><a href="http://www.stunme.com" target="_blank">stunme.com</a>';
	}
	else if (mode == 'sample') {
		html +='<a href="javascript:alert(\'This is just a sample. The actual button will be clickable.\');"><img src="http://www.stunme.com/images/heart/send_hearts.gif" alt="Stun Me" width="150" height="30" border="0" /></a><br /><a href="http://www.stunme.com" target="_blank">stunme.com</a>';
	}
	else {
		   html +='<a href="http://www.stunme.com" target="_top"><img src="http://www.stunme.com/images/stunme_bar_heart.gif" alt="Stun Me" width="150" height="18" border="0" /></a><br />';
	}
	return html;
}
function getCode() {
	if (validateColor(document.createForm.heart_color.value, 'heart color')) {
		var flashVars = getFlashVars();
		document.createForm.embed_code.value = getHtmlFromFlashVars(flashVars, 'stunme');
		document.getElementById('code').style.display = 'block';
	}
}
function preview() {
	if (validateColor(document.createForm.heart_color.value, 'heart color')) {
		var flashVars = getFlashVars();
		var thisHtml = getHtmlFromFlashVars(flashVars, 'stunme');
		document.getElementById('preview').innerHTML = thisHtml;
		document.createForm.embed_code.value = thisHtml;
	}
}