/*created by fwgood*/
if (M1LIST_LIST==undefined) {
    var M1LIST_LIST = 1;
}
if (MSG_SUBSCRIBING==undefined) {
    var MSG_SUBSCRIBING = 'Subscribing...';
}
if (MSG_SUBSCRIBING_SUCCESS==undefined) {
    var MSG_SUBSCRIBING_SUCCESS = 'You are successfully subscribed!';
}
if (M1LIST_FREEDOWNLOAD==undefined) {
    var M1LIST_FREEDOWNLOAD = 0;
}
function checkform() 
{
  if (!is_valid_email(document.getElementById('email').value)) {
	alert ('Please enter a valid email address') ;
	return false ;
  }
  for(i in M1LIST_FIELDS) {
	if (M1LIST_FIELDS[i].required == true ) {
		if (document.getElementById(i).value == '') {
			alert ('Please enter your ' +  M1LIST_FIELDS[i].name) ;
			return false ;
		}
	}
  }
  document.getElementById('m1list_subscribe_iframe').posted = 1;
  document.getElementById('m1list_subscribeform').style.display = 'none';
  document.getElementById('m1list_subscribe_message').innerHTML = MSG_SUBSCRIBING;
  return true;
}
function subscribe_success(iframe)
{
    if (iframe.posted) {
        document.getElementById('m1list_subscribe_message').innerHTML = MSG_SUBSCRIBING_SUCCESS;
		if (typeof(M1LIST_REDIRECT) != 'undefined') {
		window.location = M1LIST_REDIRECT;
		}
    }
}
function is_valid_email(email) {
	if(email.match(/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/) == null) {
		return false;
	} else {
		return true;
	}
}
var attributes = '' ;
for(i in M1LIST_FIELDS) {
	var required = '' ;
	if (M1LIST_FIELDS[i].required == true ) required = '*' ;
	attributes += 
		'<tr>' + 
			'<td align="right" valign="top"><font size="1">' + required + '&nbsp;</font><font size="2">'+ M1LIST_FIELDS[i].name +'</font></td>' + 
			'<td align="left"><input type="text" name="' + i + '" id="' + i + '"/></td>' + 
		'</tr>' ;  
}
document.write(
'<iframe name="m1list_subscribe" id="m1list_subscribe_iframe" onload="subscribe_success(this)" style="display: none;"></iframe>' + 
'<form name="m1list_subscribeform" id="m1list_subscribeform" method="post" action="http://list.magneticone.com/?p=subscribe&id=2" target="m1list_subscribe">' +
	'<input type="hidden" value="signup" name="list[' + M1LIST_LIST + ']"/>' + 
	'<input type="hidden" value="test" name="listname[' + M1LIST_LIST + ']"/>' + 
	'<input type="hidden" value="' + M1LIST_FREEDOWNLOAD + '" name="free_download"/>' +
	'<table cellspacing="0" cellpadding="5" border="0">' + 
		'<tr>' + 
			'<td align="right" valign="top"><font size="1">*&nbsp;</font><font size="2">Email</font></td>' + 
			'<td align="left">' + 
				'<input type="text" name="email" id="email"/>' + 
			'</td>' + 
		'</tr>' + 
		attributes + 
		'<tr>' + 
			'<td>&nbsp;</td>' + 
			'<td><font size="1">*</font><font size="2"> = Required Field</font></td>' + 
		'</tr>' + 
		'<tr>' + 
			'<td>&nbsp;</td>' + 
			'<td><input type="submit" onclick="return checkform();" value="Submit" name="subscribe"/></td>' + 
		'</tr>' + 
	'</table>' + 
'</form>' +
'<div id="m1list_subscribe_message"></div>' ) ;