function signupRedir() {
	// For Opera browsers, need to refresh parent page after clearcard page loads
	self.location.href='/signup.php';
}

function validateForm() {
	// Check validity of signup form
	var user  = document.getElementById('user');
	var pass  = document.getElementById('pass');
	var email = document.getElementById('email');
	var error = '';

	// Check for emptiness
	if (user.value == '') {
		error += '* Missing Username<br>\n';
		user.value = '';
	}

	if (pass.value == '') {
		error += '* Missing Password<br>\n';
		user.value = '';
	}

	// Do the username and password match?
	if (user.value == pass.value) {
		error += '* Username and Password cannot match<br>\n';
		user.value = '';
		pass.value = '';
		pass.style.backgroundColor = '#C12869';
		user.style.backgroundColor = '#C12869';
	}

	if (echeck(email.value) == false) {
		error += '* Invalid Email Address<br>\n';
		email.value = '';
		email.style.backgroundColor = '#C12869';
	}

	if (error.length > 1) {
		document.getElementById('top_level_container').style.opacity = '0.4';
		document.getElementById('top_level_container').style.filter = 'alpha(opacity=40)';
		document.getElementById('error_display').style.display = '';
		document.getElementById('error_display').style.visibility = 'visible';
		document.getElementById('error_display').style.backgroundColor = '#000000';
		document.getElementById('error_display').innerHTML = '<br><b>ERROR:</b><br><br>'+error+'<br><div align="center" valign="bottom" style="vertical-align: bottom"><a href="javascript:closeError()">Close</a></div>';
		return false;
	} else {
		return true;
	}
}
function closeError() {
	document.getElementById('error_display').style.display = 'none';
	document.getElementById('error_display').style.visibility = 'visible';
	document.getElementById('top_level_container').style.opacity = '1.0';
	document.getElementById('top_level_container').style.filter = 'alpha(opacity=100)';
}
function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   //alert("Invalid E-mail ID")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    //alert("Invalid E-mail ID")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    //alert("Invalid E-mail ID")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    //alert("Invalid E-mail ID")
	    return false
	 }

 	 return true					
}
