var MarketingData;

function getMarketingData(){
	var myAjax = new Ajax.Request('/common/include/php/function.getmarketingdata.php', { method: 'get', parameters: 'msn=' + $F('msn') + '&program=thor'
		, onSuccess: function (originalResponse) {
			JSONresponse = originalResponse.responseJSON;
			$('msn_status').update(JSONresponse.StatusData);
			$('msn_status').show();
			
			if(JSONresponse.Status == "Good"){
				$('validatemsn').hide();
				$('marketing_data').update(JSONresponse.MarketingData);
				$('confirminfo').show();
			} else {
				$('validatemsn').show();
			}
		}
	});	
}



function onEnter(evt, frm) {
	var keyCode = null;

	if (evt.which) {
		keyCode = evt.which;
	} else if( evt.keyCode ) {
		keyCode = evt.keyCode;
	}
	
	if( 13 == keyCode ) {
		getMarketingData();
		return false;
	}
	
	return true;
}



Event.observe(window,"load", function(){
	Event.observe('thor_signup', 'submit', function(event) {
		validInput = true;

		if ($F('signature') == "" && validInput) {
			alert("You need to e-sign the form."); 
			$('signature').activate();
			validInput = false;
		}			
		
		if (!$('agree').checked) {
			alert("You need to agree to put your book into Thor Distribution."); 
			$('agree').activate();
			validInput = false;
		}	
	
		
		if (!validInput) {
			Event.stop(event);
		} else {
			$('submit').value = "Please Wait";
			$('submit').disable();
		}
		
	});
});
