///
/// Dock for eCast subscription
/// (c) 2006 Webo Pty. Ltd.
///

function eCast(id, nmgid, redirectto, signupbox)
{
	document.writeln('<input type=\"text\" size=\"12\" id=\"' + id + '\" name=\"' + id + '\" maxlength=\"100\">&nbsp;'
		+	'<a href=\"javascript:eCastAction(\'' + id + '\', \'' + nmgid + '\', \'' + redirectto + '\', \'' + signupbox + '\')\"><img src=\"/Portals/_default/Skins/eVideo/images/but_go.gif\" alt=\"Go\" width=\"30\" height=\"21\"></a>');

}


function eCastAction(id, nmgid, redirectto, signupbox)
{
	var thisForm;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		thisForm = document.Form;
	}
	else {
		thisForm = document.forms["Form"];
	}

	// Validate email
	var sEmail = new String(eval('thisForm.' + id + '.value'));
	if ((sEmail.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/)) || (sEmail.match(/^(")?(\w+([-+.\s]\w+)*(")?\s*[<(])\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*([)>])$/)))
	{
		//location.href='http://service.ecast.net.au/subscribe/?Email=' + sEmail + '&NMGID=' + nmgid + '&RedirectTo=' + redirectto + '&SignUpBox=' + signupbox;
		// for google tracking
		window.open('/asp/ecast.asp?e=' + sEmail + '&n=' + nmgid + '&r=' + redirectto + '&s=' + signupbox, 'oWin');
	}
	else
	{
		alert('Please retype your email again\n\nIt does not seems to be valid');
		eval('thisForm.' + id + '.focus();')
		return void(0);
	}
}
