
function emailIsLoggedIn () {
	if (cookie.Get ("validated")) {
		return true;
	}
	else {
		return false;
	}
}

function emailLogin (url, divID, email) {
	var loginDiv = document.getElementById (divID);
	var email = email || "";

	if (emailIsLoggedIn ()) {
		if (url.indexOf ("?") > -1) {
			location.href = url + "&ead=" + cookie.Get ("validated");
		}
		else {
			location.href = url + "?ead=" + cookie.Get ("validated");
		}
	}
	else {
		loginDiv.innerHTML = "\
			<table cellpadding='0' cellspacing='0' border='0' width='434'>\
			<tr>\
				<td width='12' height='8'></td>\
				<td width='418' valign='top' style='background-repeat:no-repeat'><img src='http://www.acnepractice.com/includes/images/videoplayerHeader.gif'/></td>\
				<td width='4'></td>\
			</tr>\
			<tr>\
				<td>&nbsp;</td>\
				<td valign='top' background='http://www.acnepractice.com/includes/images/videoplayerbackground.jpg' width:350px;'>\
					<center><span class='newinquirytext'>Please enter your member ID for access</span></center><br/>\
					<div class='divisioninq1' style='font-family: Helvetica, Arial, sans-serif; font-size:smaller;'>\
						<form method='post' action='http://www.acnepractice.com/bootcamp/verify_redirect.php?type=firstcontact' onsubmit='return emailCheck(this.email.value)'>\
							<input type='hidden' name='redirect' value='" + url + "'>\
							<b>\
							Your Email&nbsp;<input type='text' name='email' value='" + email + "' size='22' style='height: 24px; font-size: 20px;'><br>\
							Member ID&nbsp;<input type='text' name='mem_id' size='22' style='height: 24px; font-size: 20px;'><br>\
							</b>\
							<br>\
							<span style='padding-left:80px;'><input type='image' src='http://www.acnepractice.com/includes/images/continue.gif'/></span>\
						</form>\
					</div>\
					<span class='forgot' style='font-family: Helvetica, Arial, sans-serif; font-size:smaller;'>Forgot ID? Click <a href='javascript:emailForgotID()'>here</a></span>\
				</td>\
				<td>&nbsp;</td>\
			</tr>\
			<tr>\
				<td height='9'></td>\
				<td valign='top'><img src='http://www.acnepractice.com/includes/images/videoplayerfooter.gif'/></td>\
				<td></td>\
			</tr>\
			</table>\
		";
	}
}

function emailLoginSimple (url, divID) {
	var loginDiv = document.getElementById (divID);

	if (cookie.Get ("validated")) {
		location.href = url;
	}
	else {
		loginDiv.innerHTML = "\
			<form method='post' action='http://www.acnepractice.com/bootcamp/verify_redirect.php?type=firstcontact' onsubmit='return emailCheck(this.email.value)'>\
			<input type='hidden' name='redirect' value='" + url + "'>\
			<b>Your Email</b><br/>\
			<input type='text' name='email' style='width: 95%'><br/><br/>\
			<img src='/includes/images/blank.gif' width='1' height='6' border='0'/>\
			<b>Member ID</b><br/>\
			<input type='text' name='mem_id' style='width: 95%'><br><br/>\
			<div align='center'>\
			<input type='image' src='http://www.acnepractice.com/includes/images/continue.gif'/><br/>\
			</form>\
			<span style='font-family: Helvetica, Arial, sans-serif; font-size:smaller;'>Forgot ID? Click <a href='javascript:emailForgotID()'>here</a></span>\
			</div>\
		";
	}
}

function emailForgotID () {
	window.open ('http://www.acnepractice.com/bootcamp/newinquiry.html','_blank','height=600,width=900, resizable, scrollbars');
}

function emailCheck (email){	
    var pattern = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;

    if (pattern.test (email)) {
		return true;   
    }
    else {   
    	alert ("Please enter a valid e-mail address");
		return false; 
    }
}

