function lg_init() {
	initDHTMLAPI();
}

function showbird(which) {
	setDisplay(which.id + "_bird");
}

function hidebird(which) {
	unsetDisplay(which.id + "_bird");
}

function showarrow(which) {
	setDisplay(which.id + "_arrow");
}

function hidearrow(which) {
	unsetDisplay(which.id + "_arrow");
}


//VALIDATE FORM
function validateForm(which){
	var f=document[which.id];
	var errstr = '';
	switch (which.id) {
		case 'login':
			if (!emailCheck(f['login_email'].value, false)) {
				errstr += "Please ensure that your email address is correct." + "\n";
			}
			if (f['login_password'].value.length==0){
				errstr += "Please enter your password.\n";
			}
		break;
		case 'create':
		case 'newpass':
			if (!emailCheck(f['create_email'].value, false)) {
				errstr += "Please ensure that your email address is correct." + "\n";
			}
			if (f['create_password'].value.length==0){
				errstr += "Please enter a password.\n";
			} else if (f['create_password'].value.length<8){
				errstr += "Please make your password at least 8 characters long.\n";
			} else if (!f['create_password'].value.match(/^[\da-zA-Z@#$%^&+=]+$/)) {
				errstr += "I'm sorry, but passwords can only contain letters, numbers, and the characters @ # $ % ^ & + and =\n";
			} else if (f['create_password'].value != f['create_passwordconfirm'].value){
				errstr += "Please type your password twice to ensure that it's correct.\n";
			}
		break;
		case 'resetP':
			if (!emailCheck(f['reset_email'].value, false)) {
				errstr += "Please ensure that your email address is correct." + "\n";
			}
		break;
		case 'appform':
			var mand = {
				"CLfname" : "child's first name",
				"CLlname" : "child's last name",
				"CLdob" : "child's date of birth",
				"CLstreet" : "street address",
				"CLcity" : "city",
				"CLstate" : "state",
				"CLzip" : "ZIP code",
				"CLp1_fname" : "parent's first name",
				"CLp1_lname" : "parent's last name"
			};
		
		//check for mandatory items
			for (var item in mand) {
				if (f[item].value.length==0){
					errstr += mand[item] + "\n";
				}
			}
			if (errstr.length > 0) {
				errstr = "Please enter the following:\n" + errstr;
				errstr += "\n";
			}
			if (!f['CLdob'].value.match(/^\d{1,2}\/\d{1,2}\/\d{4}$/)) {
				errstr += "Please make sure your child's birth date is in the format 'mm/dd/yyyy'." + "\n";
			}
			
			if (f['CLphone_home'].value.length == 0 && f['CLphone_work'].value.length == 0 && f['CLphone_mobile'].value.length == 0) {
				errstr += "Please enter at least one phone number." + "\n";
			} else {
				var ph = {
					"CLphone_home" : "home phone number",
					"CLphone_work" : "work phone number",
					"CLphone_mobile" : "mobile phone number"
				};
				for (var item in ph) {
					var stripped = f[item].value.replace(/[\(\)\.\-\ ]/g, '');
					if (f[item].value.length != 0 && stripped.length < 10) {
						errstr += "The " + ph[item] + " is the wrong length. Please include an area code." + "\n";
					}
				}
			}
		
			if (getRadioValue(f.elements['CLgender[]']) == '') {
				errstr += "Please indicate your child's gender." + "\n";
			}
			
			if (f['CLemail'].value != f['email_confirm'].value) {
				errstr += "Please type your email address twice to ensure that it's correct." + "\n";
			} else if (!emailCheck(f['CLemail'].value, false)) {
				errstr += "Please ensure that your email address is correct." + "\n";
			}
			checkboxChecked = false;
			$$('.multisummer_checkbox').each(function(s) {
				checkboxChecked = (checkboxChecked || s.checked);
			});
			if (($$('.multisummer_checkbox').size() && !checkboxChecked) || (f['CLenrollment[]'].value === undefined && getRadioValue(f.elements['CLenrollment[]']) == '')) {
				errstr += "Please choose an enrollment schedule." + "\n";
			}
		break;
	}

	if (errstr.length > 0) {
		alert (errstr);
		return false;
	}
	return true;
}

function logout() {
	var date = new Date();
	date.setTime(date.getTime()+(-1*24*60*60*1000));
	document.cookie = "user=; expires=" + date.toGMTString() + ";" + "path=/;";
	if (mymatch = /http:\/\/(.*?)dl_calendar/.exec(location.href)) {
		location.href = 'http://' + mymatch[1] + 'home';
	} else {
		location.reload(true);
	}
//	alert(location.href);
//	alert(mymatch);
//	location.reload(true);
}

