// OPEN NEW WINDOW (GENERIC)

function openWindow(pageloc,pagename) {

	window.open(pageloc,pagename,'width=500,height=550,scrollbars=yes,menubar=yes');

}

// CONFIRM ACTION (GENERIC)

function confirmAction(message) {

	var confirmation = confirm(message);
	if (confirmation) 
		return true;
	else
		return false;
}

// VALIDATE SIGNUP FORMS (SPECIFIC TO AIMMACHINE)

function paidFormValidate() {

// PAID REGISTRATION BLOCK

	if (document.paid_registration.bname.value == "") {
	
		alert("Please fill in the Name field. What, you don't have a name?");
		
		document.paid_registration.bname.focus();
		
		return false;
	
	}
	
	if (document.paid_registration.baddr1.value == "") {
	
		alert("Don't you have a home? Please fill out your address.");
		
		document.paid_registration.baddr1.focus();
		
		return false;
	}
	
	if (document.paid_registration.bcity.value == "") {
	
		alert("Where you live, dude? Please fill out the City field.");
	
		document.paid_registration.bcity.focus();
		
		return false;
	
	}
	
	if (document.paid_registration.bstate.value == "") {
	
		alert("Be proud of your state. Let us know which state you hail from.");
	
		document.paid_registration.bstate.focus();
		
		return false;
	
	}
	
	if (document.paid_registration.bzip.value == "") {
	
		alert("ZIP codes rule! Come on, you don't have one of those? You should--they're totally in.");
	
		document.paid_registration.bzip.focus();
		
		return false;
	
	}
	
	if (document.paid_registration.bcountry.value == "") {
	
		alert("Be proud of your country. Let us know where you're from.");
	
		document.paid_registration.bcountry.focus();
		
		return false;
	
	}
	
	if (document.paid_registration.cardnumber.value == "" || isNaN(document.paid_registration.cardnumber.value)) {
	
		alert("Don't worry; it's secure! Please provide your credit card number, and make sure the field is composed only of numbers.");
	
		document.paid_registration.cardnumber.focus();
		
		return false;
	
	}
	
	if (document.paid_registration.cvm.value == "") {
	
		alert("Please fill in the CVV2 number (the 3-digit security code on the back of your card). It safer for all of us!");
	
		document.paid_registration.cvm.focus();
		
		return false;
	}

	if (isNaN(document.paid_registration.cvm.value) == true) {
	
		alert("That 8 may look like a B, but there are no letters in your security code. Please enter only numbers.");
	
		document.paid_registration.cvm.focus();
		
		return false;
	
	}

return true;

}

function generalFormValidate() {

// FREE REGISTRATION BLOCK

	if (document.general_registration.f_age.value == "" || isNaN("document.general_registration.f_age.value") == "true") {

		alert("Okay, we definitely know you have an age. Please remember you have to be at least 13 years old to ride the AIMMachine.");

		document.general_registration.f_age.focus();	

		return false;
	
	}
	
	if (document.general_registration.f_age.value < 13 || document.general_registration.f_age.value > 110) {

		alert("Sorry, you must be at least 13 years old to ride the AIMMachine! And please no exhorbitant ages. You're not immortal.");
		
		document.general_registration.f_age.focus();
		
		return false;
	
	}

	if (document.general_registration.f_email.value == "") {
	
		alert("Please input your email address. If you don't have one, you can get a GIG of free email space at gmail.google.com!");
	
		document.general_registration.f_email.focus();
		
		return false;
	}
	
	if (document.general_registration.f_screenname.value == "") {

		alert("Can't use the system without a screenname! Please provide your SN.");
	
		document.general_registration.f_screenname.focus();
		
		return false;
	
	}

	if (document.general_registration.f_password.value == "") {

		alert("Please choose a password. We recommend that it not be the same as your AIM password, for security reasons.");
	
		document.general_registration.f_password.focus();
		
		return false;
	
	}
	
	if (document.general_registration.f_password2.value == "") {

		alert("Please confirm the password you chose in the second Password field.");
	
		document.general_registration.f_password2.focus();
		
		return false;
	
	}

	if (document.general_registration.f_password.value != document.general_registration.f_password2.value) {
	
		alert("Please confirm your password; the two password fields did not match.");
	
		document.general_registration.f_password.focus();
		
		return false;
	
	}
	
	
	if ((document.general_registration.f_password.value < 6) || (document.general_registration.f_password2.value < 6)) {
	
		alert("We recommend your password be at least 6 characters long. Try adding some numbers if you can't decide on one; it makes it more secure!");
	
		document.general_registration.f_password.focus();
		
		return false;
	
	}

	if (document.general_registration.f_terms_agreed.checked == false) {
	
		alert("You cannot proceed if you do not agree to the Terms of Use.");
	
		document.general_registration.f_terms_agreed.focus();
		
		return false;
	
	}
	
	return true;

}

function dmValidate(){

	if(document.send_dm.f_dm.value == ""){
		alert('You need to enter some text for your message!');
		return false;
	}	
	if(document.send_dm.f_to_sn.value == ""){
		alert('You need to enter a buddy screenname for your message!');
		return false;
	}	
	else{
	
		document.send_dm.submit();

	}
}
function switchSendImage(action){

	if(action=="on"){

		document.send_img.src="images/send_on.gif";

	}
	else{

		document.send_img.src="images/send.gif";

	}


}

var supportsKeys = false;
function tick() { 
	 calcCharLeft(document.forms[0]) 
	 if (!supportsKeys) timerID = setTimeout("tick()",1000) 
	} 
	
function calcCharLeft(sig) { 
	 clipped = false; 
	 maxLength = 500;
	 if (document.send_dm.f_dm.value.length > maxLength) 
	   { 
	   document.send_dm.f_dm.value = document.send_dm.f_dm.value.substring(0,maxLength);
	   charleft = 0;
	   clipped = true; 
	   } 
	 else 
	   { 
	   charleft = maxLength - document.send_dm.f_dm.value.length;
	   } 
	   document.send_dm.msgCL.value = charleft;
	   return clipped;
 } 
