function popitup(url) {
	newwindow=window.open(url,'name','height=400,width=400,status=1,scrollbars=1');
	if (window.focus) {newwindow.focus()}
		return false;
}

function checkMeNews(url){
	var formElements = document.forms.addNews.elements;
	isValid=true;
	msgStr="";
	
	if(formElements[1].value==""){
		msgStr+="Please enter the title to appear on the home page\n";
		isValid=false;
	}
	if(formElements[2].value==""){
		msgStr+="Please enter a title for your article\n";
		isValid=false;
	}
	if(isNaN(formElements[3].value) || isNaN(formElements[4].value) || isNaN(formElements[5].value) || formElements[3].value > 31 || formElements[4].value > 12 || formElements[5].value < 2008 || formElements[5].value > 2020){
		msgStr+="Please enter a valid date for the article to appear\n";
		isValid=false;
	}
	if(formElements[6].value==""){
		msgStr+="Please enter in a blurb for your article\n";
		isValid=false;
	}
	if(formElements[9].value!="" && formElements[9].value.lastIndexOf(".jpg")==-1){
		msgStr+="Please upload a JPG image\n";
		isValid=false;
	}
	if(formElements[10].value==""){
		msgStr+="Please select an author for your article\n";
		isValid=false;
	}
	
	if(msgStr !="")
		alert(msgStr);
	
	if(isValid==true){
		document.forms.addNews.action=url;
		document.forms.addNews.method="POST";
		document.forms.addNews.submit();
	}
	else{
		return isValid;
	}	
	
}

function checkMeResult(url){
	var formElements = document.forms.addResult.elements;
	isValid=true;
	msgStr="";
	
	if(formElements[3].value==formElements[6].value && formElements[4].value!="D"){
		msgStr+="Please check the score, we scored the same as the OPP and you don't have the result as a Draw\n";
		isValid=false;
	}
	else if((formElements[3].value<formElements[6].value) && formElements[4].value=="W"){
		msgStr+="Please check the score, we scored less and you have the result as a Win\n";
		isValid=false;
	}
	else if(formElements[3].value>formElements[6].value && formElements[4].value=="L"){
		msgStr+="Please check the score, we scored more than the OPP and you have the result as a Loss\n";
		isValid=false;
	}
	if(formElements[5].value=="XXX"){
		msgStr+="Please enter in the Abreviation for the team we played. Eg. EAS = Eastern\n";
		isValid=false;
	}
	if(isNaN(formElements[7].value) || isNaN(formElements[8].value) || isNaN(formElements[9].value) || formElements[7].value > 31 || formElements[8].value > 12 || formElements[9].value < 2008 || formElements[9].value > 2020){
		msgStr+="Please enter a valid date for the game\n";
		isValid=false;
	}
	if(formElements[10].value==""){
		msgStr+="Please enter in a short description for the game\n";
		isValid=false;
	}
	if(formElements[14].options.length<7 || formElements[14].options.length>16){
		msgStr+="Please enter the players who played in this game\n";
		isValid=false;
	}
	
	if(msgStr !="")
		alert(msgStr);
	if(isValid==true){
		for(i=0;i<formElements[14].options.length; i++){
			formElements[14].options[i].selected=true;
		}
		document.forms.addResult.action=url;
		document.forms.addResult.method="POST";
		document.forms.addResult.submit();
	}
	else{
		return isValid;
	}	
}

function checkMeGoals(url,goals){
	var formElements = document.forms.addGoals.elements;
	tmpCount=0;
	isValid=true;
	
	for(i=1;i<formElements.length-1; i++){
		if(formElements[i].value!="" && formElements[i].value >=0){
			tmpCount += parseInt(formElements[i].value);
		}
	}
	if(tmpCount!=goals){
		alert("The Assigned Goals Must Add Up To "+goals+" / "+tmpCount);
		isValid = false;
	}
	if(isValid==true){
		document.forms.addGoals.action=url;
		document.forms.addGoals.method="POST";
		document.forms.addGoals.submit();
	}
	else{
		return isValid;
	}
}

function checkMeSocial(url){
	var formElements = document.forms.addSocial.elements;
	isValid=true;
	msgStr="";
	
	if(formElements[1].value==""){
		msgStr+="Please enter in the Short Title to appear on the home page\n";
		isValid=false;
	}
	if(formElements[2].value==""){
		msgStr+="Please enter in the Full Title to appear on the event page\n";
		isValid=false;
	}
	if(formElements[3].value==""){
		msgStr+="Please enter in a short description of the event\n";
		isValid=false;
	}
	
	if(isNaN(formElements[6].value) || isNaN(formElements[7].value) || isNaN(formElements[8].value) || formElements[6].value > 31 || formElements[7].value > 12 || formElements[8].value < 2008 || formElements[8].value > 2020){
		msgStr+="Please enter a valid date for the game\n";
		isValid=false;
	}
	if(formElements[9].value.lastIndexOf(".jpg")==-1 && formElements[9].value!=""){
		msgStr+="Please upload a JPG image\n";
		isValid=false;
	}
	if(formElements[10].value.lastIndexOf(".pdf")==-1 && formElements[10].value!=""){
		msgStr+="Please upload a PDF file\n";
		isValid=false;
	}
	
	if(msgStr !="")
		alert(msgStr);
	if(isValid==true){
		document.forms.addSocial.action=url;
		document.forms.addSocial.method="POST";
		document.forms.addSocial.submit();
	}
	else{
		return isValid;
	}	
}

function checkMeRegNew(url){
	var formElements = document.forms.regNew.elements;
	isValid=true;
	msgStr="";
	
	if(formElements[1].value==""){
		msgStr+="Please enter in your first name\n";
		isValid=false;
	}
	if(formElements[2].value==""){
		msgStr+="Please enter in your surname\n";
		isValid=false;
	}
	if(formElements[12].value==""){
		msgStr+="Please enter in your email address\n";
		isValid=false;
	}
	if(formElements[13].value=="" || formElements[14].value=="" || formElements[15].value=="" || formElements[16].value==""){
		msgStr+="Please enter in your postal address\n";
		isValid=false;
	}
	if(formElements[17].value==""){
		msgStr+="Please select your playing intentions\n";
		isValid=false;
	}
	
	if(msgStr !="")
		alert(msgStr);
	if(isValid==true){
		document.forms.regNew.action=url;
		document.forms.regNew.method="POST";
		document.forms.regNew.submit();
	}
	else{
		return isValid;
	}	
}