/*
Created By: Chris Campbell
Website: http://particletree.com
Date: 2/1/2006

Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
*/

/*-----------------------------------------------------------------------------------------------*/

function lbshow(actx) {
	ov=document.getElementById('overlay2');
	bd=document.getElementById('mainbody');
	lb=document.getElementById('lb2');

	if (actx==1) {
	topx=document.body.scrollTop;
	ov.style.top=topx;
	ov.style.display='block';
	lb.style.top=parseInt(document.body.clientHeight/2)+topx;
	lb.style.display='block';
	bd.style.overflow='hidden';

    lb.innerHTML=
 		'<div id="lbsignup"><div class="LargeHeading" style="float:left;">Signup to Save Favorites & Vote on Tips</div><div style="float:right;"><a onclick="lbshow(0);"><img src="'+localurl+'/images/icons/x10x10bw.png" border="0" /></a></div><div style="clear:both;"></div><div style="margin:20px 0 40px 0" class="SmallHeading"><a onclick=\'formShow(1);\'><img src="'+localurl+'/images/icons/lock.png" class="icon" border="0" /><b>Login</b></a> if you are already a FamilyZip Member.</div><div style="clear:both;"></div>' +
		'<div style="margin:10px 0 40px 80px;"><form method="POST" name="fmsignup" action="' + localurl + '/signup" onsubmit="return checkForm(this);"><div class="frow"><div style="float: left; width:110px;" class="MainBoldText">Firstname</div><div style="margin-left:110px;  padding-left:1px;"><input type="text" name="first" size="25" class="MainText" value=""></div></div>' +
		'<div class="frow"><div style="float: left; width:110px;"><span class="MainBoldText">Lastname</span></div><div style="margin-left:110px;  padding-left:1px;"><input type="text" name="last" size="25" class="MainText" value=""></div></div>' +
		'<div class="frow"><div style="float: left; width:110px;"><span class="MainBoldText">Email Address</span></div><div style="margin-left:110px;  padding-left:1px;"><input type="text" name="email" size="25" class="MainText" value=""></div></div>' +
		'<div class="frow"><div style="float: left; width:110px;"><span class="MainBoldText">Pick a Password</span></div><div style="margin-left:110px;  padding-left:1px;"><input type="text" name="userpass" size="25" class="MainText" value=""></div></div>' +
	'<div style="margin-top:3px; margin-left:80px;"><span class="bLinkContainer clearfix"><div class="bLinkBlueLeft"></div><div class="bLinkBlueBody"><input type="hidden" name="frm_submitted" value="1"><input type="submit" tabindex="5" class="bLink" style="cursor:pointer;" name="submitbtn" value="Give Me FREE Access Now"></div><div class="bLinkBlueRight"></div></span></div>' +
	'</form></div><div style="clear:both;"></div><div style="clear:both;"></div><div class="frow"><img src="'+localurl+'/images/banners/asseen.png" class="icon" border="0" style="margin-top:40px;" width="440px" /></div></div>' +

		'<div id="lblogin" style="display:none;"><div class="LargeHeading" style="float:left;">Login to Save Favorites & Vote on Tips</div><div style="float:right;"><a onclick="lbshow(0);"><img src="'+localurl+'/images/icons/x10x10bw.png" border="0" /></a></div><div style="clear:both;"></div><div style="margin:20px 0 40px 0" class="SmallHeading"><a onclick=\'formShow(0);\'><img src="'+localurl+'/images/icons/edit.png" class="icon" border="0" /><b>Sign Up</b></a> if you are not already a FamilyZip Member.</div><div style="clear:both;"></div><div style="margin:10px 0 0 80px;"><form method="POST" name="fmlogin"><div class="frowl"><div style="float: left; width:110px;"><span class="MainBoldText">Email Address</span></div><div style="margin-left:110px;  padding-left:1px;"><input type="text" name="username" size="25" class="MainText" value=""></div></div>' +
		'<div class="frowl"><div style="float: left; width:110px;"><span class="MainBoldText">Password</span></div><div style="margin-left:110px;  padding-left:1px;"><input type="password" name="password" size="25" class="MainText" value=""></div></div>' +
	'<div style="margin-top:40px; margin-left:70px;"><span class="bLinkContainer clearfix"><div class="bLinkBlueLeft"></div><div class="bLinkBlueBody"><input type="hidden" name="login" value="1"><input type="submit" class="bLink" style="cursor:pointer;" name="submitbtn" value="&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sign In &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"></div><div class="bLinkBlueRight"></div></span></div>' +
	'</form></div></div>' ;

	document.fmsignup.first.focus();
	}
	else {
	ov.style.display='none';
	lb.style.display='none';
	bd.style.overflow='scroll';
	}
}

function formShow(sForm) {
	li=document.getElementById('lblogin');
	su=document.getElementById('lbsignup');

	if (sForm==1) {
		li.style.display='block';
		su.style.display='none';
		document.fmlogin.username.focus();

	}
	else {
		li.style.display='none';
		su.style.display='block';
		document.fmsignup.first.focus();
	}
}

function checkForm(cForm) {
var emsg = "";

emsg+=checkLen(cForm.first.value,"-First Name\n",2);
emsg+=checkLen(cForm.last.value,"-Last Name (will NOT be public)\n",2);
emsg+=checkEmail(cForm.email.value,"-Valid Email as your Username (will NOT be public)\n");

if (emsg=="") return true;

alert("Please Enter:\n"+emsg);
return false;
}

function checkLen(field,msg,len) {
if (field.length < len)
	return(msg);
else return("");
}

function checkEmail (field,msg) {
var emailFilter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (emailFilter.test(field)) return("");
	else return(msg);
}

function jGo(url) {
	location.href=localurl+'/'+url;
}