//***********************************************//
// Navigation Requires

/*

startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

*/

//***********************************************//



// Login Requirements
function freg () {
	var str = document.frmReg.txtU.value;
	var str2 = document.frmReg.txtE.value;
	var str3 = document.frmReg.txtE2.value;
	
	str = str.replace(/^\s*|\s*$/g,"");
	str2 = str2.replace(/^\s*|\s*$/g,"");
	str3 = str3.replace(/^\s*|\s*$/g,"");

	if (str.length == 0 ) {
		alert ("Please enter a username.");
		return;
	}

	if (str2.length == 0 ) {
		alert ("Please enter an email address.");
		return;
	}

	
	if (str2 != str3) {
		alert ("Email addresses do not match");
		return;
	}

	document.frmReg.txtAction.value = "R";
	document.frmReg.submit();

}


function flogin() {
var str = document.frmLogin.txtU.value;
var str2 = document.frmLogin.txtP.value;
	
	str = str.replace(/^\s*|\s*$/g,"");
	str2 = str2.replace(/^\s*|\s*$/g,"");

	if ((str.length != 0) && (str2.length != 0)) {
		document.frmLogin.txtAction.value = "L";
		document.frmLogin.submit();
	}

}

// Logout Requirements
function flogout () {

	document.frmLogin.txtAction.value = "O";
	document.frmLogin.submit();

}

// Article.ASP Requires this
function AddComment () {
	var str = document.frmComment.txtComment.value;
	str = str.replace(/^\s*|\s*$/g,"");

	if (str == "") {
		alert ("Comment box is empty");
		return;
	}
	if (document.frmComment.txtComment.value.length > 5000) {
		alert ("Articles must be no longer than 5000 charaters");
		return;
	}

	document.frmComment.submit();
}



 function changeval()
{
	if (document.frmDo.optDo.value == 1) {
		document.frmDo.action = "premierleague.asp";
	}
	if (document.frmDo.optDo.value == 2) {
		document.frmDo.action = "championshipleague.asp";
	}
	if (document.frmDo.optDo.value == 3) {
		document.frmDo.action = "leagueone.asp";
	}
 	if (document.frmDo.optDo.value == 4) {
	    document.frmDo.action = "leaguetwo.asp";
	}
 	if (document.frmDo.optDo.value == 5) {
	    document.frmDo.action = "scotpremleague.asp";
	}
	if (document.frmDo.optDo.value == 6) {
	    document.frmDo.action = "scotone.asp";
	}
	if (document.frmDo.optDo.value == 7) {
	    document.frmDo.action = "scottwo.asp";
	}
	if (document.frmDo.optDo.value == 8) {
	    document.frmDo.action = "scotthree.asp";
	}
	if (document.frmDo.optDo.value == 9) {
	    document.frmDo.action = "nonleague.asp";
	}
	document.frmDo.submit();
}

function LoginMeIn (sFromForum) {

	var str = document.frmRegister.txtFirst.value;
	str = str.replace(/^\s*|\s*$/g,"");
	var str2 = document.frmRegister.txtSecond.value;
	str2 = str2.replace(/^\s*|\s*$/g,"");

	if (str.length == 0 || str2.length == 0) {
		alert ('Both a first name and a second name are required.')
		return;																								  
	}
	
	str = document.frmRegister.txtEmail.value 
	str = str.replace(/^\s*|\s*$/g,"");
	if (str.length == 0 ) {
		alert ('An valid email address is required.')
		return;																								  
	}
	
	if (document.frmRegister.txtEmail.value != document.frmRegister.txtEmail2.value) {
		alert ('Your email entries do not match.')
		return;
		}
		
	str = document.frmRegister.txtUname.value 
	str = str.replace(/^\s*|\s*$/g,"");
	if (str.length == 0) {
		alert ('An user name is required.')
		return;																								  
	}	
	
	str = document.frmRegister.txtP.value 
	str = str.replace(/^\s*|\s*$/g,"");
	if (str.length == 0) { 
		alert ('Both password fields should be completed.')
		return;																								  
	}
	
	str = document.frmRegister.txtP2.value 
	str = str.replace(/^\s*|\s*$/g,"");
	if (str.length == 0) { 
		alert ('Both password fields should be completed.')
		return;																								  
	}
	
	if (document.frmRegister.txtP.value != document.frmRegister.txtP2.value) {
		alert ('Your password entries do not match.')
		return;
		}

	if (sFromForum == "NO") {

		if (document.frmRegister.optTeam.options[document.frmRegister.optTeam.selectedIndex].value == 0) {
			alert ('Please select a team value from the drop down list.')
			return;
			}
	}

	if (document.frmRegister.chkAccept.checked == false) {
		alert ('Please read and accept the terms and conditions.')
		return;
		}
	
	document.frmRegister.txtProcess.value = "YES"
	document.frmRegister.submit();
}

function fopt() {
	document.frmLegal.chkOpt.value = window.document.frmOpt.chkOpt.checked;
}

function reject() {
	document.frmLegal.action = 'login.asp';
	document.frmLegal.txtProcess.value='NO'
	document.frmLegal.submit();
}

function acceptlegal() {
	document.frmLegal.action = 'login.asp';
	document.frmLegal.txtProcess.value='YES'
	document.frmLegal.submit();
}


function removefrommailing () {
	var str = document.frmRemove.txtEmail.value 
	str = str.replace(/^\s*|\s*$/g,"");
	
	if (str.length == 0) {
		alert ("Please enter your email address.");
		return;
	}
	document.frmRemove.submit();
}

function RemindPassword () {
	var str = document.frmRemind.txtEmail.value 
	str = str.replace(/^\s*|\s*$/g,"");
	
	if (str.length == 0) {
		alert ("Please enter your email address.");
		return;
	}
	document.frmRemind.submit();
}

function routeme (sPath) {
	window.location=sPath;
}

function updateprofile () {

	var str = document.frmProfile.txtFirst.value;
	str = str.replace(/^\s*|\s*$/g,"");

	if (str.length == 0) {
		alert ('A name is required.')
		return;																								  
	}
	
	str = document.frmProfile.txtEmail.value 
	str = str.replace(/^\s*|\s*$/g,"");
	if (str.length == 0 ) {
		alert ('An valid email address is required.')
		return;																								  
	}
	
	if (document.frmProfile.txtEmail.value != document.frmProfile.txtEmail2.value) {
		alert ('Your email entries do not match.')
		return;
		}
		
	str = document.frmProfile.txtOPwd.value 
	str = str.replace(/^\s*|\s*$/g,"");
	if (str.length == 0) { 
		alert ('Please enter your current password in order to update your profile.')
		return;																								  
	}

	
	document.frmProfile.txtProcess.value = "UPD"
	document.frmProfile.submit();
}

function emailart() {
	var str = document.frmEmail.txtE.value;

	if (str.length == 0 ) {
		alert ("Please enter an email address");	
		return;
	}
	document.frmEmail.txtAction.value="E"
	document.frmEmail.submit();

}


//***********************************************//
// Forum Requirements

function openWindow(url) {
	popupWin = window.open(url,'new_page','width=500,height=400')
}
function openWindow2(url) {
	popupWin = window.open(url,'new_page','width=500,height=450')
}
function openWindow3(url) {
	popupWin = window.open(url,'new_page','width=500,height=450,scrollbars=yes')
}
function openWindow4(url) {
	popupWin = window.open(url,'new_page','width=500,height=525')
}
function openWindow5(url) {
	popupWin = window.open(url,'new_page','width=550,height=525,scrollbars=yes,toolbars=yes,menubar=yes,resizable=yes')
}
function openWindow6(url) {
	popupWin = window.open(url,'new_page','width=500,height=450,scrollbars=yes')
}
function openWindowHelp(url) {
	popupWin = window.open(url,'new_page','width=570,height=200,scrollbars=yes')
}

function valpollsug() {

	if (document.frmSugPoll.txtIn.value == "") {
		alert ("You must be logged in to suggest a poll.");
		return;
	}

	var icount = 0;
	var str = document.frmSugPoll.txtPoll.value;
	var strp1 = document.frmSugPoll.txtP1.value;
	var strp2 = document.frmSugPoll.txtP2.value;
	var strp3 = document.frmSugPoll.txtP3.value;
	var strp4 = document.frmSugPoll.txtP4.value;
	var strp5 = document.frmSugPoll.txtP5.value;
	var strp6 = document.frmSugPoll.txtP6.value;

	str = str.replace(/^\s*|\s*$/g,"");
	strp1 = strp1.replace(/^\s*|\s*$/g,"");
	strp2 = strp2.replace(/^\s*|\s*$/g,"");
	strp3 = strp3.replace(/^\s*|\s*$/g,"");
	strp4 = strp4.replace(/^\s*|\s*$/g,"");
	strp5 = strp5.replace(/^\s*|\s*$/g,"");
	strp6 = strp6.replace(/^\s*|\s*$/g,"");

	if (str.length == 0) {
		alert ("Please supply a poll title");
		return;
	}

	if (strp1.length > 0) {
		icount = icount +1;
	}
	if (strp2.length > 0) {
		icount = icount +1;
	}
	if (strp3.length > 0) {
		icount = icount +1;
	}
	if (strp4.length > 0) {
		icount = icount +1;
	}
	if (strp5.length > 0) {
		icount = icount +1;
	}
	if (strp6.length > 0) {
		icount = icount +1;
	}

	if (icount < 2) {
		alert ("Please supply at least two poll options.")
		return;
	}
	document.frmSugPoll.txtAction.value = "ADDPOLL";
	document.frmSugPoll.submit();
}

function valartsug() {
		
	if (document.frmSugArt.txtIn.value == "") {
		alert ("You must be logged in to suggest an article.");
		return;
	}

	var str = document.frmSugArt.txtArtTitle.value;
	var strp1 = document.frmSugArt.txtArtProse.value;
	

	str = str.replace(/^\s*|\s*$/g,"");
	strp1 = strp1.replace(/^\s*|\s*$/g,"");

	if (str.length == 0) {
		alert ("Please supply an article title");
		return;
	}

	if (strp1.length > 4000) {
		alert ("Article text must be less than 4000 characters");		
		return;
	}

	document.frmSugArt.txtAction.value = "ADDART";
	document.frmSugArt.submit();
}

function seasonchange(l) {
var iSeason;

     	iSeason = document.frmSeason.optSeason.value;
	document.frmSeason.action = "results.asp?season=" + iSeason + "&l=" +l;
	document.frmSeason.submit();
}
