function openNewWindow(windowURL, windowName, windowFeatures, w, h, center)
{ 
	var left = 0;
	var top = 0;
	
	if(w!=null && h!=null)
	{
		if(center !=null)
		{
			if(center)
			{
				left = (screen.width) ? (screen.width-w)/2 : 0;
				top = (screen.height) ? (screen.height-h)/2 : 0;
			}
		}
		
		windowFeatures += ",width="+w+",height="+h;
	}
	
	windowFeatures += ",left="+left+",top="+top;
	
	var wnd=window.open(windowURL, windowName, windowFeatures);
}

function checkAge()
{
	var valid = false;
	var now = new Date();
	
	var intBirthDay = document.getElementById("BirthDay");
	var intBirthMonth = document.getElementById("BirthMonth");
	var intBirthYear = document.getElementById("BirthYear");
	var agree = document.getElementById("ageconfirm");
	
	if(intBirthDay.value=="Day")
	{ 
		alert('Please fill in your Date of Birth.');
		return false;
	}
	
	if(intBirthMonth.value=="Month")
	{
		alert('Please fill in your Month of Birth.');
		return false;
	}
	
	if(intBirthYear.value=="Year")
	{
		alert('Please fill in your Year of Birth.');
		return false;
	}
	
	var intAge=now.getFullYear()-intBirthYear.value-1;
	
	if (now.getMonth()>intBirthMonth.value)
	{
		intAge=intAge+1;
	}
	else if((now.getMonth()==intBirthMonth.value) && (now.getDate()>=intBirthDay.value))
	{
		intAge=intAge+1;
	}
	
	if(!agree.checked)
	{
		alert('You must agree with the Terms of Use and Privacy Policy');
		return false;
	}

	if (intAge>20)
	{
		openNewWindow('tropical-banana.html','info','toolbar=no,menu=no,scrollbars=no', 800, 580, true);
		valid = true;
	}
	else
	{
		window.location.href = "index2.html";
		valid = false;
	}
	
	return valid;
}

function checkSendToFriend()
{
	var name = document.getElementById("name").value;
	var email = document.getElementById("e-mail").value;
	var fmail = document.getElementById("f-mail").value;
	var message = document.getElementById("message").value;
	
	var errCode = -1;
	
	
	if(message.length==0)errCode = 3;
	if(!checkEmail(fmail))errCode = 2;
	if(!checkEmail(email))errCode = 1;
	if(name.length==0)errCode = 0;
	
	switch(errCode)
	{
		case 0:
		{
			alert("Your name is too small or not specified!");
		};break;
		case 1:
		{
			alert("Your email address is invalid!");
		};break;
		case 2:
		{
			alert("Your friend's email address is invalid!");
		};break;
		case 3:
		{
			alert("Your message is not specified!");
		};break;
		default:break;
	}
	
	if(errCode!=-1)return false;
	
	return true;
}

function checkEmail(str)
{
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}