// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, scrollbar) {

           var winl = (screen.width - w) / 2;
           var wint = (screen.height - h) / 2;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar ;
		   win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) { 
              	win.window.focus(); 
           } 
}

function jumpMenu(target,object,restore){ 
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  var p,i,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n);
  return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

function submitDoc(formName) { 
  var obj;
 
	if (obj=findObj(formName)!=null) 
	{
		findObj(formName).submit(); 
	}
	else 
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}
function chkdate ()
{
        var dobd = document.getElementById('dobd');
        var doby = document.getElementById('doby');
        var firstName = document.getElementById('firstName');
        var lastName = document.getElementById('lastName');
        var mother = document.getElementById('Mother');
        var father = document.getElementById('Father');
        var address = document.getElementById('Address');
        var city = document.getElementById('City');
        var zip = document.getElementById('ZipCode');
        var phone = document.getElementById('HomePhone');
        var chkaddr = document.getElementById('chkaddr');
        var today = new Date();
        var chkyr = today.getFullYear()-5;
        if (firstName.value == '' || lastName.value == '' || mother.value == '') {
                alert( "Please make sure all required fields are completed.");
                return false;
        }
        if (!chkaddr.checked && (address.value == '' || city.value == '' ||
                zip.value == '' || phone.value == '')) {
                alert( "Please make sure all required fields are completed.");
                return false;
        }
        if (dobd.value < 1 || dobd.value > 31) {
                alert( "Please check your child's birth day.");
                dobd.focus();
                return false;
        }
        if (doby.value < 1996 || doby.value > chkyr) {
                alert( "Please check your child's birth year. (must be between 1996 and "+chkyr+")" );
                doby.focus();
                return false;
        }
	return true;
}
function selectChild ( id )
{
    var childid = document.getElementById('child_id');
    if (childid.value != id){
        window.location="index.php?act=child&selChild="+id;
    }
    return true;
}
function confirmdel ( nme, id )
{
    d = confirm('Are you sure you want to delete '+nme+'?');
    if (d == true) {
        window.location="index.php?act=child&delChild="+id;
    }
    else {return false;}
    return true;
}
function addachild ( )
{
    window.location="index.php?act=child&newChild=1";

    return true;
}
function release()
{
    var rel = document.getElementById('release');
    var code = document.getElementById('code');
    if (!rel.checked) {
        alert('You must check the release of liability checkbox before continuing.');
    }
    else if (!code.checked) {
        alert('You must check the Parents Code of Conduct checkbox before continuing.');
    }
    else {
        submitDoc('addtobasket');
    }
}
function ckamount()
{
    var newprice = document.getElementById('newprice');
    if (parseInt(newprice.value).toString() != newprice.value) {
        alert('Amount entered must be an integer number (no decimal).');
    }
    else if (newprice.value < 100) {
        alert('Amount must be at least $100.');
    }
    else {
        submitDoc('addtobasket');
    }
}
function opendoc(file)
{
    window.open(file, '',
        'width=900, height=600, top=120, left=120, resizable=yes, scrollbars=yes');
}
function shownames()
{
    var el1 = document.getElementById('options');
    var el2 = document.getElementById('golfnames');
    if (el1.options[el1.selectedIndex].text.search('Foursome') != -1) el2.style.display = "block";
    else el2.style.display = "none";
}
function sponsform()
{
//    if (sess !== '') s = '?s='+sess;
    var hst = '';
    if (document.domain != 'localhost') hst = 'http://www.scfootball.org/';
    var file = hst+'../admin/sponsform.php';
    window.open(file, '', 'width=900, height=600, top=80, left=120, resizable=yes, scrollbars=no');
}