var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS6 = (bName == "Netscape" && bVer >= 5);
 var NS4 = (bName == "Netscape" && bVer >= 4 && bVer < 5);
 var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);
 var intTop=128
 if (NS4) {intTop=126;}
 var intLeft=0

// SHOW MENU
function imgPos(imgName){
 img = getImage(imgName);
 imgLeft = getImagePageLeft(img)+5; // LEFT POSITION
 intLeft=imgLeft
 return imgLeft;
}
function imgPos2(imgName){
 img = getImage(imgName);
 imgTop = getImagePageTop(img)+14; // LEFT POSITION
 intTop=imgTop
 return imgTop;
}
function getImage(name) {
  if (NS4 || NS6) {
    return findImage(name, document);
  }
  if (IE4 || NS6)
    return eval('document.all.' + name);
  return null;
}

function findImage(name, doc) {
  var i, img;
  for (i = 0; i < doc.images.length; i++)
    if (doc.images[i].name == name)
      return doc.images[i];
  for (i = 0; i < doc.layers.length; i++)
    if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  return null;
}

function getImagePageLeft(img) {
  var x, obj;
  if (NS4) {
    if (img.container != null)
      return img.container.pageX + img.x - 1;
    else
      return img.x - 1;
  }
  if (IE4 || NS6) {
    x = 0;
    obj = img;
    while (obj.offsetParent != null) {
      x += obj.offsetLeft;
      obj = obj.offsetParent;
    }
    x += obj.offsetLeft;
    return x;
  }
  return -1;
}

function getImagePageTop(img) {
  var y, obj;
  if (NS4) {
    if (img.container != null)
      return img.container.pageY + img.y;
    else
      return img.y;
  }
  if (IE4 || NS6) {
    y = 0;
    obj = img;
    while (obj.offsetParent != null) {
      y += obj.offsetTop;
      obj = obj.offsetParent;
    }
    y += obj.offsetTop;
    return y;
  }
  return -1;
}

function openTermsWin(subj) {
    // alert(subj);

    var winParam = "width=600,height=600,toolbar=no, menubar=no, status=no, resizable=yes";
    winParam += ",screenX=" + (screen.availWidth-800)/2;
    winParam += ",screenY=0";

    var Win = subj + ".shtml";
    var newwin = eval('Win');
    termwin = window.open(newwin,"termwindow",winParam);

    // center the report form
    if (document.all) {
        termwin.moveTo((screen.availWidth-600)/2, 0);
    }

    termwin.focus();

}

function openSubjWin(subj) {
    // alert(subj);

    var winParam = "scrollbars, width=600,height=600,toolbar=no,  menubar=no, status=no, resizable=yes";
    winParam += ",screenX=" + (screen.availWidth-800)/2;
    winParam += ",screenY=0";

    var Win = subj + ".shtml";
    var newwin = eval('Win');
    subjwin = window.open(newwin,"subjwindow",winParam);

    // center the report form
    if (document.all) {
        subjwin.moveTo((screen.availWidth-600)/2, 0);
    }

    subjwin.focus();

}

function openFinWin(subj) {
    // alert(subj);

    var winParam = "width=600,height=300,toolbar=no, menubar=no, status=no, resizable=yes";
    winParam += ",screenX=" + (screen.availWidth-800)/2;
    winParam += ",screenY=0";

    var Win = subj + ".shtml";
    var newwin = eval('Win');
    termwin = window.open(newwin,"termwindow",winParam);

    // center the report form
    if (document.all) {
        termwin.moveTo((screen.availWidth-600)/2, 0);
    }

    termwin.focus();

}

function edit_klc_record(id, stype, status) {
	var stype = stype;
	var status = status;
	var urlline = "/cgi-bin/klc_students.pl?id=" + id + "&stype=" + stype + "&status=" + status;
	// alert(urlline);
	parent.location = urlline;
}

function update_klc_record(id) {
	var Me = top.document.klc_students;
	var last_name = Me.last_name.value;
	var first_name = Me.first_name.value;
	var date_of_birth = Me.date_of_birth.value;
	var active = Me.active.value;
	var disability_type = Me.disability_type.value;
	var guardian_first_name = Me.guardian_first_name.value;
	var guardian_last_name = Me.guardian_last_name.value;
	var address_1 = Me.address_1.value;
	var address_2 = Me.address_2.value;
	var city = Me.city.value;
	var pin_code = Me.pin_code.value;
	var phone_1 = Me.phone_1.value;
	var phone_2 = Me.phone_2.value;
	var phone_c = Me.phone_c.value;
	var date_of_joining = Me.date_of_joining.value;
	var date_of_leaving = Me.date_of_leaving.value;
	var stype = Me.stype.value;
	var status = Me.status.value;

	var urlline = "/cgi-bin/update_klc_students.pl?id=" + id +"&last_name=" + last_name + "&first_name=" + first_name;
	urlline    += "&date_of_birth=" + date_of_birth + "&active=" + active + "&disability_type=" + disability_type;
	urlline    += "&guardian_first_name=" + guardian_first_name + "&guardian_last_name=" + guardian_last_name;
	urlline    += "&address_1=" + address_1 + "&address_2=" + address_2 + "&city=" + city + "&pin_code=" + pin_code;
	urlline    += "&phone_1=" + phone_1 + "&phone_2=" + phone_2 + "&phone_c=" + phone_c + "&date_of_joining=" + date_of_joining;
	urlline    += "&date_of_leaving=" + date_of_leaving + "&stype=" + stype + "&status=" + status;
	// alert(urlline);
	parent.location = urlline;
}

function get_info() {
	var Me     = top.document.admin;
	var id     = 0;
	var stype  = Me.stype.options[Me.stype.selectedIndex].value;
	var status = Me.status.options[Me.status.selectedIndex].value;

  var urlline = "/cgi-bin/klc_students.pl?id=" + id + "&stype=" + stype + "&status=" + status;
  parent.location = urlline;
}

function get_roster(stype, status) {
	var Me     = top.document.admin;
	var id     = 0;
	var stype  = stype;
	var status = status;

  var urlline = "/cgi-bin/klc_students.pl?id=" + id + "&stype=" + stype + "&status=" + status;
  parent.location = urlline;
}	

function get_donor_detail () {
  var urlline = "/cgi-bin/get_donor_detail.pl";
  parent.location = urlline;
}	

function insert_donation () {
	// alert("Here");
	var Me         = top.document.donation_input;
	var donor_name = Me.donor_name.value;
	var donor_type;
	for ( var i = 0; i < Me.donor_type.length; i++ ) {
    	if ( Me.donor_type[0].checked = true ) {
    		donor_type = "C";
    	} else {
    		donor_type = "I";
    	}
    }
  var address    = Me.address.value;
  var city       = Me.city.value;
  var state      = Me.state.value;
  var zip_code   = Me.zip_code.value;
  var country    = Me.country.value;
  var gift_type  = Me.gift_type.value;
  var curr_code  = Me.curr_code.value;
  var amount     = Me.amount.value;
  var date_given = Me.date_given.value;
  var urlline = "/cgi-bin/insert_donation.pl?donor_name=" + donor_name + "&donor_type=" + donor_type + "&address=" + address;
  urlline    += "&city=" + city + "&state=" + state + "&zip_code=" + zip_code + "&country=" + country + "&gift_type=" + gift_type;
  urlline    += "&curr_code=" + curr_code + "&amount=" + amount + "&date_given=" + date_given;
  parent.location = urlline;
}	