var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function processSendToFriend() {
	//alert('processSendToFriend fired');
	//document.sendToFriend.Subject.value = "Come play Twilight Pixie Glide!";
	//document.sendToFriend.Body.value = "It's the bees knees.";
	//console.log(document.sendToFriend.Body.value);
	document.sendToFriend.submit();
	
	//document.sendToFriend.bodyTxt.value = "It's the bees knees.";
	return true;
}

// Handles all the FSCommand messages from the button bar swf
function buttons_DoFSCommand(command, args) {
	var buttonsObj = isInternetExplorer ? document.all.buttons : document.buttons;
	
	switch(command) {
		case "watch":
			// Embed holiday animation SWF
			var flashvars = {
				config: "swf/movie/config.xml"
			};
			var params = {
				wmode: 			"transparent",
				allowScriptAccess:	"sameDomain",
				menu:			"false"
			};
			var attributes = {
			  id:		"mainSwf",
			  name: 		"mainSwf"
			};
		
			document.getElementById('wrapper').className = "movieWrapper"; 

			swfobject.embedSWF("swf/movie/app.swf", "mainSwf", "802", "480", "9.0.0", false, flashvars, params, attributes);

			break;
		case "game":
			// Embed game SWF
			var flashvars = {
				config: "swf/game/config.xml"
			};
			var params = {
				wmode: "transparent",
				allowScriptAccess: "sameDomain",
				menu: "false"
			};
			var attributes = {
			  id: "mainSwf",
			  name: "mainSwf"
			};

			document.getElementById('wrapper').className = "gameWrapper"; 
			
			swfobject.embedSWF("swf/game/app.swf", "mainSwf", "766", "450", "9.0.0", false, flashvars, params, attributes);

			break;		
		case "send":
			//alert('Jesse needs to buld a Send To A Friend window here!');
			processSendToFriend();
			break;
		case "visit":
			top.location.href = "http://www.plexipixel.com/";
			break;
		
		default:
			alert("Clicked: " + command);
			top.location.href = "http://www.plexipixel.com";
			break;
	}
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub buttons_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call buttons_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}



