function pay_dues(){
	var dues=window.open('/dues.php','','scrollbars=yes,menubar=no,height=600,width=900,resizable=yes,toolbar=no,location=no,status=no');
	return false;
}

function upload_pictures() {
	var upload=window.open('/uploadForm.php','','scrollbars=yes,menubar=no,height=575,width=725,resizable=no,toolbar=no,location=no,status=no');
	return false;
}

function playRugby(){
	var play=window.open('/play.php','','scrollbars=yes,menubar=no,height=500,width=390,resizable=no,toolbar=no,location=no,status=no');
	return false;
}

function updateSchedule(value){
	if (value==""||value==null) {
		return false;
	}
	var input=value.split(","); 
	var year=input[1];
	var season=input[0];
	var myRequest = new ajaxObject('http://peoriarugby.com/schedule.php');
    myRequest.callback = function(responseText) {
		document.getElementById('schedule').innerHTML=responseText;
	}
	myRequest.update("season="+season+"&year="+year,'GET');
}

function validatePlay() {
	var errors=0;
	$('error').innerHTML="";
	if ($F('name')=="") {
		$('error').innerHTML=$('error').innerHTML+"<h2>Please leave us your name.</h2>";
		errors++;
	}
	if ($F('phone')=="" && $F('email')=="") {
		$('error').innerHTML=$('error').innerHTML+"<h2>Please give us a way to contact you.</h2>";
		$('email').focus();
		errors++;
	}
	if ($F('email')!="") {
		if (!isValidEmail($F('email'))) {
			$('error').innerHTML=$('error').innerHTML+"<h2>Please enter a valid e-mail address.</h2>";
			$('email').focus();
			errors++;
		}
	}
	if (errors==0) {
		return true;
	} else {
		return false;
	}
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function noExperience() {
    if ($('experience[0]').checked) {
		$('experience[1]').checked=false;
		$('experience[2]').checked=false;
		$('experience[3]').checked=false;
    }
}

function someExperience() {
	if (!($('experience[1]').checked||$('experience[2]').checked||$('experience[3]').checked)) {
		$('experience[0]').checked=true
	} else {
		$('experience[0]').checked=false
	}
}

function ajaxObject(url, callbackFunction) {
  var that=this;      
  this.updating = false;
  this.abort = function() {
    if (that.updating) {
      that.updating=false;
      that.AJAX.abort();
      that.AJAX=null;
    }
  }
  this.update = function(passData,postMethod) { 
    if (that.updating) { return false; }
    that.AJAX = null;                          
    if (window.XMLHttpRequest) {              
      that.AJAX=new XMLHttpRequest();              
    } else {                                  
      that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");
    }                                             
    if (that.AJAX==null) {                             
      return false;                               
    } else {
      that.AJAX.onreadystatechange = function() {  
        if (that.AJAX.readyState==4) {             
          that.updating=false;                
          that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);        
          that.AJAX=null;                                         
        }                                                      
      }                                                        
      that.updating = new Date();                              
      if (/post/i.test(postMethod)) {
        var uri=urlCall+'?'+that.updating.getTime();
        that.AJAX.open("POST", uri, true);
        that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        that.AJAX.setRequestHeader("Content-Length", passData.length);
        that.AJAX.send(passData);
      } else {
        var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime()); 
        that.AJAX.open("GET", uri, true);                             
        that.AJAX.send(null);                                         
      }              
      return true;                                             
    }                                                                           
  }
  var urlCall = url;        
  this.callback = callbackFunction || function () { };
}
