var xmlhttp

function showChild(arrow, child_id, edit)
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("We're sorry but your browser does not support AJAX!");
  return;
  }
var cid = document.getElementById('cid');
var url="admin/getchild.php";
if (edit == 'edit') {url = "admin/getchildinput.php";}
if (cid == null) {url=url+"?dir="+arrow+"&cid="+1;}
else {url=url+"?dir="+arrow+"&cid="+cid.value;}
if (child_id != null) {url=url+"?dir="+arrow+"&cid="+child_id;}
if (edit == 'delete') {url=url+"&edit="+edit;}
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
document.body.onclick = chkbx;
}

function chfind ( lname ) {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("We're sorry but your browser does not support AJAX!");
  return;
  }
var url = "admin/chfind.php?lname="+lname;
xmlhttp.onreadystatechange=searchbx;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
bxfocus();
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("inside").innerHTML=xmlhttp.responseText;
  }
}
function searchbx () {
if (xmlhttp.readyState==4)
  {
  var e = document.getElementById("searchbx");
  e.style.visibility = 'visible';
  e.innerHTML=xmlhttp.responseText;
//  e.style.zIndex = 1;
  }
}
function hidesearch() {
  var e = document.getElementById("searchbx");
  e.style.visibility = 'hidden';
}
function chkbx(){
  var el = document.getElementById("searchbx");
  if (el.style.visibility == 'visible') {
      el.style.visibility = 'hidden';
      document.getElementById("lastName").value = document.getElementById("lastName").name;
      hidesearch();
  }
}
function bxfocus () {
    document.getElementById("searchbx").style.visibility = 'visible';
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}
function arrw(nme, fn){
    document.images[nme].src = 'widgets/'+fn;
}
function delch(cid){
    ans = confirm('Are you sure you want to delete this record?\n\
(Deleted records are recoverable.)');
    if (ans == true) {
        showChild('none',cid,'delete');
        return true;
    }
    return false;
}
function excel() {
    window.open("https://www.scfootball.org/includes/export_excel.inc.php");
}
function vfind ( vid, strt ) {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("We're sorry but your browser does not support AJAX!");
  return;
  }
var st = '';
if (strt != null) {st = '&strt='+strt;}
var url = "videodata.php?vid="+vid+st;
xmlhttp.onreadystatechange=getvideo;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
}
function getvideo()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("player").innerHTML=xmlhttp.responseText;
  }
}
function capp(yr) {
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("We're sorry but your browser does not support AJAX!");
  return;
  }
var url = "admin/capp.php";
if (yr != null) url = url + '?y='+yr;
xmlhttp.onreadystatechange=displayform;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
}
function displayform()
{
  if (xmlhttp.readyState==4)
    if (xmlhttp.responseText == "") {
        alert('You must login to submit a coach application.');
    }
    else {
        if (xmlhttp.responseText.substr(-3) == 's=1') {
            ans = confirm('You have already submitted a coach application.  Do you want to revise it?');
            if (!ans) {
                return;
            }
        }
        url = 'admin/cappform.php'+xmlhttp.responseText;
        window.open(url, '',
            'width=900, height=600, top=100, left=100');
    }
}
function opendoc(file)
{
    window.open(file, '',
        'width=900, height=600, top=120, left=120, resizable=yes, scrollbars=yes');
}
function opendocv(file)
{
    window.open(file, '',
        'width=900, height=600, top=120, left=120, menubar=yes, resizable=yes, scrollbars=yes');
}
function chkcappform ()
{
    var dobd = document.getElementById('dobd');
    var doby = document.getElementById('doby');
    var code = document.getElementById('code');
    var scfl_rules = document.getElementById('scfl_rules');
    var el = document.forms[0].elements;
    var submitted = document.getElementById('submitted');
    var today = new Date();
    var chkyr = today.getFullYear()-21;
    for (i=0; i< el.length; i++) {
        if (el[i].type == 'radio') {
            radiogroup = el[el[i].name];
            itemchecked = false;
            for (j=0; j < radiogroup.length; j++) {
                if (radiogroup[j].checked) {
                    itemchecked = true;
                    break;
                }
            }
            if (!itemchecked) {
                if (el[i].focus) el[i].focus();
                ans = confirm('Form is not complete.\nDo you want to save it and complete your application later?');
                if (ans) {
                    submitted.value = 0;
                    return true;
                }
                else return false;
            }
        }
        if (el[i].type == 'text') {
            if (el[i].value == '') {
                if (el[i].focus) el[i].focus();
                ans = confirm('Form is not complete.\nDo you want to save it and complete your application later?');
                if (ans) {
                    submitted.value = 0;
                    return true;
                }
                else return false;
            }
        }
    }
    if (dobd.value < 1 || dobd.value > 31) {
            alert( "Please check your birth day.");
            dobd.focus();
            return false;
    }
    if (doby.value == "" || doby.value > chkyr) {
            alert( "Please check your birth year. (must be less than or equal to "+chkyr+")" );
            doby.focus();
            return false;
    }
    if (!code.checked) {
        alert('You must check the Code of Conduct box to submit your application.');
        code.focus();
        return false;
    }
    if (!scfl_rules.checked) {
        alert('You must check the SCFL Rules box to submit your application.');
        scfl_rules.focus();
        return false;
    }
	return true;
}
function faqdel(id)
{
    ans = confirm('Do you really want to delete this FAQ?');
    if (ans) {
        window.location.href = 'index2.php?id=32&faq='+id+'&act=del';
    }
}
function faqedit(id)
{
    window.location.href = 'index2.php?id=32&faq='+id+'&act=edit';
}