function openWin(url, name, w, h, perc, scroll, resize) {
	var winX = (screen.availWidth - w)*perc*.01;
	var winY = (screen.availHeight - h)*perc*.01;
	popupWin = window.open(url, name,'width=' + w + ',height=' + h + ',left=' + winX + ',top=' + winY + ',scrollbars=' + scroll + ',resizable=' + resize);
}

function openWinCentered(mypage, myname, w, h, scroll, resize) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resize;
	win = window.open(mypage, myname, winprops)
}

function isValidEmail(p_strEmail) {
	var regexp = /^\S+\@[a-zA-Z0-9\.-]+\.[a-zA-Z0-9]{2,4}$/;
	return regexp.test(p_strEmail);
}

function isValidURL(p_URL) {
	var regexp = /^http\:\/\//;
	return regexp.test(p_URL);
}

function isCheckedRadio(obj) {
	var radio_choice = false;
	for (counter = 0; counter < obj.length; counter++) {
		if (obj[counter].checked) radio_choice = true; 
		
	}
	return radio_choice;
}

function validateBandReg(frm) {
	if (frm.BAND_NAME.value == '') { alert('Please enter your band name.'); frm.BAND_NAME.focus(); return false; }
	return true;
}

function validateAcct1(frm) {
	if (frm.MP3_URL1.value != '' && !isValidURL(frm.MP3_URL1.value)) { alert('Please enter the URL to your MP3 with a leading http://'); frm.MP3_URL1.focus(); return false; }
	if (frm.MP3_URL2.value != '' && !isValidURL(frm.MP3_URL2.value)) { alert('Please enter the URL to your MP3 with a leading http://'); frm.MP3_URL2.focus(); return false; }
	if (frm.MP3_URL3.value != '' && !isValidURL(frm.MP3_URL3.value)) { alert('Please enter the URL to your MP3 with a leading http://'); frm.MP3_URL3.focus(); return false; }
	return true;
}

function validateAcct2(frm) {
	if (frm.EMAIL.value != frm.EMAIL_ORIG.value) return confirm('Changing your e-mail address will require that you reconfirm your account. Are you sure you want to do this?');
	return true;
}

function openPlayer(u, n) {
	openWinCentered('player.php?u='+u+'&n='+n, 'player', 350, 230, 0, 0);
}

function validateRating(frm) {
	if (frm.REVIEW.value == '') { alert('Please enter your review of the band.'); frm.REVIEW.focus(); return false; }
	if (!isCheckedRadio(frm.RATING)) { alert('Please select a rating of 1 to 10.'); return false; }
	
	return true;
}