function processUrl(url,postdata){
var xmlHttp;
try  {  xmlHttp=new XMLHttpRequest();  } catch (e) {
  try    {    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }  catch (e) {
    try      {      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }    catch (e){
      alert("Your browser does not support AJAX!");
      return false;;
      }
    }
  }
xmlHttp.onreadystatechange=function() {

if(xmlHttp.readyState==4)
  {

  var rslt=xmlHttp.responseText;
alert(rslt);
  var i;
  rslt = rslt.replace("=",";;;");
  var ary = rslt.split(";;;");
  switch (ary[0])
  { case "faq":
  
    document.getElementById('id').value = ary[1];
    document.getElementById('question').value=ary[2];
    document.getElementById('answer').value=ary[3];
    document.getElementById('sequence').value = ary[4];
    break;
    case "agency":
    document.getElementById('id').value=ary[1];
    for (i=0;i<document.getElementById('category').options.length;i++){
       if (document.getElementById('category').options[i].value == ary[2]){
         document.getElementById('category').selectedIndex = i;
       }
    }
    //document.getElementById('category')=ary[2];
    document.getElementById('name').value=ary[3];
    document.getElementById('address').value=ary[4];
    document.getElementById('city').value=ary[5];
    document.getElementById('state').value=ary[6];
    document.getElementById('zip').value=ary[7];
    document.getElementById('url').value=ary[8];
    document.getElementById('email').value=ary[9];
    document.getElementById('phone').value=ary[10];
    document.getElementById('phone2').value=ary[11];
    document.getElementById('fax').value=ary[12];
    document.getElementById('description').value=ary[13];
    document.getElementById('html').value=ary[14];
    document.getElementById('metadata').value=ary[15];
    document.getElementById('contact').value=ary[16];
    if (ary[17] == 1){
      document.getElementById('internal').checked = true;
    } else {
      document.getElementById('internal').checked = false;
    }
    break;

    case "extra":
      for (i=0;i<document.getElementById('id').options.length;i++){
         if (document.getElementById('id').options[i].value == ary[1]){
             document.getElementById('id').selectedIndex = i;
         }
     }

    for (i=0;i<document.getElementById('agencyId').options.length;i++){
	if (document.getElementById('agencyId').options[i].value == ary[2]){
		document.getElementById('agencyId').selectedIndex = i;
        }
    }
    for (i=0;i<document.getElementById('volId').options.length;i++){
	if (document.getElementById('volId').options[i].value == ary[3]){
		document.getElementById('volId').selectedIndex = i;
        }
    }
    document.getElementById('hours').value = ary[4];
    document.getElementById('title').value = ary[6];
    document.getElementById('activityDate').value = ary[5];

    case "project":
    document.getElementById('id').value = ary[1];
    for (i=0;i<document.getElementById('agencyId').options.length;i++){
	if (document.getElementById('agencyId').options[i].value == ary[2]){
		document.getElementById('agencyId').selectedIndex = i;
        }
    }
    for (i=0;i<document.getElementById('coordId').options.length;i++){
	if (document.getElementById('coordId').options[i].value == ary[3]){
		document.getElementById('coordId').selectedIndex = i;
        }
    }
    document.getElementById('title').value = ary[4];
    document.getElementById('fromDate').value = ary[5];
    document.getElementById('toDate').value = ary[6];
    if (ary[7] == '999'){
      document.getElementById('volsRequired').value = 'N/A';
    } else {
      document.getElementById('volsRequired').value = ary[7];
    }
    document.getElementById('description').value = ary[8];
    document.getElementById('fromTime').value = ary[9];
    document.getElementById('toTime').value = ary[10];
    document.getElementById('fromTimeAmPm').value = ary[11];
    document.getElementById('toTimeAmPm').value = ary[12];
    document.getElementById('metadata').value = ary[13];
    document.getElementById('location').value = ary[14];
    document.getElementById('socialEvent').value = ary[15];
    if (ary[16] == 1){
      document.getElementById('trackHours').checked = true;
    } else { 
      document.getElementById('trackHours').checked = false;
    }
    document.getElementById('numberOfShifts').value = ary[17];
    if (ary[18] == 1){
      document.getElementById('memberLimit').checked = true;
    } else {
      document.getElementById('memberLimit').checked = false;
    }
    for (i=0;i<document.getElementById('ptype').options.length;i++){
	if (document.getElementById('ptype').options[i].value == ary[19]){
		document.getElementById('ptype').selectedIndex = i;
        }
    }
    var offset = 0;
    var tcnt = 1;
    var html = "<table><tr><td>Shift</td><td>From Date</td><td>From Time</td><td>ToDate</td><td>To Time</td><td>Vols Required</td></tr>";
    //alert (ary[17]);
    for (i=1;i<=ary[17];i++){
	html += "<tr><td>" + i + '<input type="hidden" name="shiftNumber' + i + '" id="shiftNumber' + i + '" value="' + i +
		 '"</td><td><input type="text" name="fromDate' + i + '" id="fromDate' + i + '"></td>' +
		'<td><input type="text" name="fromTime' + i + '" id="fromTime' + i + '">' + 
		'<select name="fromTimeAmPm' + i + '" id="fromTimeAmPm' + i + '"><option value="AM" selected >AM</option>' +
		'<option value="PM">PM</option></select></td>' + 
		'<td><input type="text" name="toDate' + i + '" id="toDate' + i + '"></td>' +
		'<td><input type="text" name="toTime' + i + '" id="toTime' + i + '">' + 
		'<select name="toTimeAmPm' + i + '" id="toTimeAmPm' + i + '"><option value="AM" selected >AM</option>' +
		'<option value="PM">PM</option></select></td>' + 
		'<td><input type="text" name="volsRequired' + i + '" id="volsRequired' + i + '"></td></tr>'
		;	

    }
    html += "</table>";
    
    document.getElementById('shiftTable').innerHTML = html;
    
    for (i=0;i<ary[17];i++){
	
	document.getElementById('fromDate'+tcnt).value=ary[20+offset];
	document.getElementById('fromTime'+tcnt).value=ary[21+offset];
	if (ary[22+offset] == "AM"){
		document.getElementById('fromTimeAmPm'+tcnt).selectedIndex = 0;
        } else {
		document.getElementById('fromTimeAmPm'+tcnt).selectedIndex = 1;
        }
	
	document.getElementById('toDate'+tcnt).value = ary[23+offset];
	document.getElementById('toTime'+tcnt).value = ary[24+offset];
	if (ary[25+offset] == "AM"){
		document.getElementById('toTimeAmPm'+tcnt).selectedIndex = 0;
        } else {
		document.getElementById('toTimeAmPm'+tcnt).selectedIndex = 1;
        }
	if (ary[26+offset] == 999){
		document.getElementById('volsRequired'+tcnt).value = 'N/A';
        } else {
	        document.getElementById('volsRequired'+tcnt).value = ary[26+offset];
	}
	tcnt ++;
	offset += 7;
    }
    
    
    break;




    case "staticHtml":
    document.getElementById('id').value=ary[1];
    document.getElementById('title').value=ary[2];
    document.getElementById('name').value=ary[3];
    document.getElementById('html').value=ary[4];
    document.getElementById('metadata').value = ary[5];
    break;




    case "perms":
    var i;
    var possibles = document.getElementById('possibles').value;
    var ary2 = possibles.split(';;;');

    for (i=0;i<ary2.length;i++){
      document.getElementById(ary2[i]).checked = false;
    }
    for (i=1;i<ary.length;i++){
      if (ary[i] != ''){
	document.getElementById(ary[i]).checked = true;
      }
    }
    break;
    case "loginOK":

      document.getElementById('loginOK').value = ary[1];
  
      break;
    case "emailOK":
     document.getElementById('emailOK').value = ary[1];
      break;
    case "vols":
	//alert (rslt);
	var tstr = '<select name="volunteer" id="volunteer"><option value="">Select...</option>';
	var i = 1;
        var j = 1;
        
	while (i < ary.length - 1){
		tstr += '<option value="' + ary[i] + '">' + ary[i+1] + '</option>';
		i+=2;
		j += 1;
	}
	tstr += '</select>';
        document.getElementById('volsel').innerHTML = tstr;

      break;

    case 'opportunity':

       document.getElementById('id').value = ary[1];
       document.getElementById('agency').value = ary[2];
       document.getElementById('name').value = ary[4];
       document.getElementById('description').value = ary[6];
	document.getElementById('start_date').value = ary[7];
	document.getElementById('contact').value = ary[8];
        document.getElementById('contactphone').value = ary[9];
        document.getElementById('contactemail').value = ary[10];
       if (ary[5] == 1){
         document.getElementById('active').checked = true;
       } else {
         document.getElementById('active').checked = false;
       }
       myhtml = '<table><tr><th>Specific Date</th><th width="10px">Or</th><th>Day of Month</th><th width="10px">' 
	+ 'Or</th><th>Weekday</th><th>Which Week</th><th width="20px">&nbsp;&nbsp;</th><th>Start Time</th><th>AM/PM</th><th>End Time</th><th>AM/PM</th></tr>';
        var i;
       var j = 0;

     
       for (i=11;i<ary.length;i++){

	details = ary[i];
	details2 = details.split(',,,');
	j = i-10;

	val = details2[7];
	        myhtml += '<td><input type="text" name="specific_date' +j + '" id="specific_date' +j
			+ '" value="' + val + '" onChange="checkDate(this)" > </td><td></td>';
	 
	 val = details2[8];

         myhtml += '<td><input type="text" name="day_of_month' + j + '" id="day_of_month' + j + '"' 
		+ ' value= "' + val + '" > </td><td></td>';
	 val = details2[1];
	 weekdaysel = '<select name="weekday' + j + '"><option value="">Choose</option>';
         if (val == 'Sunday'){
		weekdaysel += '<option value="Sunday" selected>Sunday</option>';
	 } else {
		weekdaysel += '<option value="Sunday">Sunday</option>';
         }
         if (val == 'Monday'){
		weekdaysel += '<option value="Monday" selected>Monday</option>';
	 } else {
		weekdaysel += '<option value="Monday">Monday</option>';
         }
         if (val == 'Tuesday'){
		weekdaysel += '<option value="Tuesday" selected>Tuesday</option>';
	 } else {
		weekdaysel += '<option value="Tuesday">Tuesday</option>';
         }
         if (val == 'Wednesday'){
		weekdaysel += '<option value="Wednesday" selected>Wednesday</option>';
	 } else {
		weekdaysel += '<option value="Wednesday">Wednesday</option>';
         }
         if (val == 'Thursday'){
		weekdaysel += '<option value="Thursday" selected>Thursday</option>';
	 } else {
		weekdaysel += '<option value="Thursay">Thursday</option>';
         }
         if (val == 'Friday'){
		weekdaysel += '<option value="Friday" selected>Friday</option>';
	 } else {
		weekdaysel += '<option value="Friday">Friday</option>';
         }
         if (val == 'Saturday'){
		weekdaysel += '<option value="Saturday" selected>Saturday</option>';
	 } else {
		weekdaysel += '<option value="Saturday">Saturday</option>';
         }
	 myhtml += weekdaysel + '</select></td>';
	val = details2[2]
         whichweeksel = '<td><select name="whichweek' + j + '">option value="">Choose</option>';
	 if (val == 'every'){
		whichweeksel += '<option value="every" selected>every</option>';
	 } else {
		whichweeksel += '<option value="every">every</option>';
         }
         if (val == 'first'){
		whichweeksel += '<option value="first" selected>first</option>';
	 } else {
		whichweeksel += '<option value="first">first</option>';
         }	 
         if (val == 'second'){
		whichweeksel += '<option value="second" selected>second</option>';
	 } else {
		whichweeksel += '<option value="second">second</option>';
         }
	if (val == 'third'){
		whichweeksel += '<option value="third" selected>third</option>';
	 } else {
		whichweeksel += '<option value="third">third</option>';
         }
         if (val == 'fourth'){
		whichweeksel += '<option value="fourth" selected>fourth</option>';
	 } else {
		whichweeksel += '<option value="fourth">fourth</option>';
         }	  
         if (val == 'fifth'){
		whichweeksel += '<option value="fifth" selected>fifth</option>';
	 } else {
		whichweeksel += '<option value="fifth">fifth</option>';
         }	 
  
	myhtml += whichweeksel + '</select></td>';
	myhtml += '<td width="20px"></td>';
	val = details2[3];
	myhtml += '<td><input type="text" name="start_time' + j + '" id="start_time' + j + 
		'" value = "' + val + '" onChange="checkTime(this)"></td>';
	ampmsel1 = '<td><select name="start_ampm' + j + '" id="start_ampm' + j + 
		'" ><option value="">Choose</option>';
	if (details2[4] == 'AM'){
		ampmsel1 += '<option value="AM" selected>AM</option';
	} else {
		ampmsel1 += '<option value="AM">AM</option';
        }
	if (details2[4] == 'PM'){
		ampmsel1 += '<option value="PM" selected>PM</option';
	} else {
		ampmsel1 += '<option value="PM">PM</option';
        }
	myhtml += ampmsel1 + '</select></td>';

	val = details2[5];
	myhtml += '<td><input type="text" name="end_time' + j + '" id="end_time' + j + 
		'" value = "' + val + '" onChange="checkTime(this)"></td>';
	ampmsel2 = '<td><select name="end_ampm' + j + '" id="end_ampm' + j + 
		'" ><option value="">Choose</option>';
	if (details2[6] == 'AM'){
		ampmsel2 += '<option value="AM" selected>AM</option';
	} else {
		ampmsel2 += '<option value="AM">AM</option';
        }
	if (details2[6] == 'PM'){
		ampmsel2 += '<option value="PM" selected>PM</option';
	} else {
		ampmsel2 += '<option value="PM">PM</option';
        }
	myhtml += ampmsel2 + '</select><input type="hidden" name="id' + j + '" name="id' + 
		j + '" value="' + details2[0] + '"></td></tr>';	
       }
       max = j+5;
       for (j=j+1;j<max;j++){
	

	val = "";
	        myhtml += '<td><input type="text" name="specific_date' +j + '" id="specific_date' +j
			+ '" value="' + val + '"  onChange="checkDate(this)"> </td><td></td>';

         myhtml += '<td><input type="text" name="day_of_month' + j + '" id="day_of_month' + j + '"' +
		+ ' value= "' + val + '" > </td><td></td>';

	 weekdaysel = '<select name="weekday' + j + '"><option value="">Choose</option>';
         if (val == 'Sunday'){
		weekdaysel += '<option value="Sunday" selected>Sunday</option>';
	 } else {
		weekdaysel += '<option value="Sunday">Sunday</option>';
        }
         if (val == 'Monday'){
		weekdaysel += '<option value="Monday" selected>Monday</option>';
	 } else {
		weekdaysel += '<option value="Monday">Monday</option>';
        }
         if (val == 'Tuesday'){
		weekdaysel += '<option value="Tuesday" selected>Tuesday</option>';
	 } else {
		weekdaysel += '<option value="Tuesday">Tuesday</option>';
        }
         if (val == 'Wednesday'){
		weekdaysel += '<option value="Wednesday" selected>Wednesday</option>';
	 } else {
		weekdaysel += '<option value="Wednesday">Wednesday</option>';
        }
         if (val == 'Thursday'){
		weekdaysel += '<option value="Thursday" selected>Thursday</option>';
	 } else {
		weekdaysel += '<option value="Thursay">Thursday</option>';
        }
         if (val == 'Friday'){
		weekdaysel += '<option value="Friday" selected>Friday</option>';
	 } else {
		weekdaysel += '<option value="Friday">Friday</option>';
        }
         if (val == 'Saturday'){
		weekdaysel += '<option value="Saturday" selected>Saturday</option>';
	 } else {
		weekdaysel += '<option value="Saturday">Saturday</option>';
        }
	 myhtml += weekdaysel + '</select></td>';

         whichweeksel = '<td><select name="whichweek' + j + '">option value="">Choose</option>';
	 if (val == 'every'){
		whichweeksel += '<option value="every" selected>every</option>';
	 } else {
		whichweeksel += '<option value="every">every</option>';
         }
         if (val == 'first'){
		whichweeksel += '<option value="first" selected>first</option>';
	 } else {
		whichweeksel += '<option value="first">first</option>';
         }	 
         if (val == 'second'){
		whichweeksel += '<option value="second" selected>second</option>';
	 } else {
		whichweeksel += '<option value="second">second</option>';
        }
	if (val == 'third'){
		whichweeksel += '<option value="third" selected>third</option>';
	 } else {
		whichweeksel += '<option value="third">third</option>';
        }
         if (val == 'fourth'){
		whichweeksel += '<option value="fourth" selected>fourth</option>';
	 } else {
		whichweeksel += '<option value="fourth">fourth</option>';
        }	  
         if (val == 'fifth'){
		whichweeksel += '<option value="fifth" selected>fifth</option>';
	 } else {
		whichweeksel += '<option value="fifth">fifth</option>';
        } 
    
	myhtml += whichweeksel + '</select></td>';
	myhtml += '<td width="20px"></td>';

	myhtml += '<td><input type="text" name="start_time' + j + '" id="start_time' + j + 
		'" value = "' + val + '" onChange="checkTime(this)"></td>';
	ampmsel1 = '<td><select name="start_ampm' + j + '" id="start_ampm' + j + 
		'" ><option value="">Choose</option>';
	ampmsel1 += '<option value="AM">AM</option><option value="PM">PM</option>';


	myhtml += ampmsel1 + '</select></td>';


	myhtml += '<td><input type="text" name="end_time' + j+ '" id="end_time' + j + 
		'" value = "' + val + '" onChange="checkTime(this)"></td>';
	ampmsel2 = '<td><select name="end_ampm' + j + '" id="end_ampm' + j + 
		'" ><option value="">Choose</option>';
	ampmsel2 += '<option value="AM">AM</option><option value="PM">PM</option>';


	myhtml += ampmsel2 + '</select><input type="hidden" name="id' + j + 
		'" id="id' + j + '" ></td></tr>';	
	}
	myhtml += '</table>';
	document.getElementById('timestable').innerHTML = myhtml;
       break;


      
  }
  }

}
url = url + "?" + postdata;
//alert(url);
xmlHttp.open("GET",url,true);
xmlHttp.setRequestHeader("content-type","application/x-www-form-url-encoded");
xmlHttp.send(null);

//xmlHttp.send(postdata);



//xmlHttp.send("Content-Type: application/x-www-form-url-encoded\n\n");
//xmlHttp.send(postdata);

};

function getLoginOK(){
  var login = document.getElementById("login").value;
  var url = "checkLogin.pl";
  var tpostdata = "login="+login;
  processUrl(url, tpostdata);
}

function getEmailOK(){
  var email = document.getElementById("email").value;
  var firstname = document.getElementById('firstname').value;
  var lastname = document.getElementById('lastname').value;
  var url = "checkEmail.pl";
  var tpostdata = "email=" + email + "&firstname=" + firstname + "&lastname=" + lastname;
  processUrl(url, tpostdata);
}

function getFaqData(){
  var idx = document.getElementById("faq").selectedIndex;
  var selId = document.getElementById("faq").options[idx].value;
  var url = "getFaq.pl";
  var tpostdata = "id="+selId;
  if (selId != ''){
  processUrl(url,tpostdata);
  } else {
    document.getElementById('id').value = '';
    document.getElementById('question').value = '';
    document.getElementById('answer').value = '';
    document.getElementById('sequence').value = '';
  }
}


function getAgencyData(){

  var idx = document.getElementById("agency").selectedIndex;
  var selId = document.getElementById("agency").options[idx].value;
  var url = "getAgency.pl";
  var tpostdata = "id="+selId;

  if (selId != ''){
    processUrl(url,tpostdata);
  } else {
    document.getElementById('id').value='';
    document.getElementById('category').selectedIndex = 0;
    document.getElementById('name').value='';
    document.getElementById('address').value='';
    document.getElementById('city').value='';
    document.getElementById('state').value='';
    document.getElementById('zip').value='';
    document.getElementById('url').value='';
    document.getElementById('email').value='';
    document.getElementById('phone').value='';
    document.getElementById('phone2').value='';
    document.getElementById('fax').value='';
    document.getElementById('description').value='';
    document.getElementById('html').value='';
    document.getElementById('metadata').value = '';
    document.getElementById('contact').value = '';
    document.getElementById('internal').checked = false;
  }
}



function getProjectData(){
  var idx = document.getElementById('project').selectedIndex;
  var selId = document.getElementById('project').options[idx].value;
  var url = "getProject.pl";
  var tpostdata = "id="+selId;
  if (selId != ''){
    processUrl(url,tpostdata);
  } else {
    document.getElementById('id').value = '';
    document.getElementById('agencyId').selectedIndex = 0;
    document.getElementById('coordId').selectedIndex = 0;
    document.getElementById('title').value = '';
    document.getElementById('fromDate').value  = '';
    document.getElementById('toDate').value = '';
    document.getElementById('volsRequired').value  = '';
    document.getElementById('description').value = '';
    document.getElementById('fromTime').value = '';
    document.getElementById('toTime').value = '';
    document.getElementById('fromTimeAmPm').value = '';
    document.getElementById('toTimeAmPm').value = '';
    document.getElementById('metadata').value = '';
    document.getElementById('location').value = '';
    document.getElementById('socialEvent').value = '';
    document.getElementById('trackHours').checked = false;
    document.getElementById('numberOfShifts').value = '';
    document.getElementById('memberLimit').checked = false;
    document.getelementById('ptype').selectedIndex = 0;
  }
}


function getStaticHtmlData(){
  var idx = document.getElementById('page').selectedIndex;
  var selId = document.getElementById('page').options[idx].value;
  var url = "getStaticHtml.pl";
  var tpostdata = "id="+selId;
  if (selId != ''){
    processUrl(url,tpostdata);
  } else {
    document.getElementById('id').value = '';
    document.getElementById('title').value = '';
    document.getElementById('name').value = '';
    document.getElementById('html').value = '';
    document.getElementById('metadata').value = '';
  }
}

function projectShifts(){
  if (document.getElementById('numberOfShifts').value == 1){
     return ;
  }
  var idx = document.getElementById('project').selectedIndex;
  var project = document.getElementById('project').options[idx].value;
  idx = document.getElementById('coordId').selectedIndex;
  var coordId = document.getElementById('coordId').options[idx].value;
  idx = document.getElementById('agencyId').selectedIndex;
  var agencyId = document.getElementById('agencyId').options[idx].value;
  var title = document.getElementById('title').value;
  var fromDate = document.getElementById('fromDate').value;
  var toDate = document.getElementById('toDate').value;
  var volsRequired = document.getElementById('volsRequired').value;
  var description = document.getElementById('description').value;
  var fromTime = document.getElementById('fromTime').value;
  var toTime = document.getElementById('toTime').value;
  var fromTimeAmPm = document.getElementById('fromTimeAmPm').value;
  var toTimeAmPm = document.getElementById('toTimeAmPm').value;
  var metadata = document.getElementById('metadata').value;
  var location = document.getElementById('location').value;
  var socialEvent = document.getElementById('socialEvent').value;
  var numberOfShifts = document.getElementById('numberOfShifts').value;
  var trk;
  if (document.getElementById('trackHours').checked){
    trk = "&trackHours=on";
  } else {
    trk = "";
  }
  var url="project.pl?action=showForm";
  url = url +
	"&project="+project+"&agencyId="+agencyId+"&coordId="+coordId;
  url = url + 
	"&title="+title+"&fromDate="+fromDate+"&toDate="+toDate;
  url = url + 
	"&volsRequired="+volsRequired+"&description="+description;
  url = url + 
	"&fromTime="+fromTime+"&toTime="+toTime+"&fromTimeAmPm="+fromTimeAmPm;
  url = url + 
	"&toTimeAmPm="+toTimeAmPm+"&metadata="+metadata+"&location="+location;
  url = url + 
	"&socialEvent="+socialEvent+"&numberOfShifts="+numberOfShifts+trk; 
  var tcnt = 1;
  var t1;
  var t2;

  while (document.getElementById('fromDate'+tcnt)){
    t1 = document.getElementById('fromTimeAmPm'+tcnt).selectedIndex;
    t2 = document.getElementById('toTimeAmPm'+tcnt).selectedIndex;
    url = url + '&fromDate' + tcnt + '=' + document.getElementById('fromDate'+tcnt).value +
	'&fromTime' + tcnt + '=' + document.getElementById('fromTime'+tcnt).value + 
	'&fromTimeAmPm' + tcnt + '=' + document.getElementById('fromTimeAmPm'+tcnt).options[t1].value + 
	'&toDate' + tcnt + '=' + document.getElementById('toDate'+tcnt).value + 
	'&toTime' + tcnt + '=' + document.getElementById('toTime'+tcnt).value + 
	'&toTimeAmPm' + tcnt + '=' + document.getElementById('toTimeAmPm' + tcnt).options[t2].value +
	'&volsRequired' + tcnt + '=' + document.getElementById('volsRequired' + tcnt).value;
    tcnt++;
  }  
    


  document.location=url;	
  
}



function gotchoice(survey,qno, showSubmit){

  var choice = document.getElementById(qno).options[document.getElementById(qno).selectedIndex].value;
  var ary = choice.split("-");

  if (ary[1] == 'Thankyou'){
	sub1.className = 'visibledata';
  } else if (ary[1] != null) {
    var mydiv = document.getElementById(ary[1]);

    mydiv.className = 'visibledata';

  }
  if (showSubmit == 1){
	sub1.className = 'visibledata';
  }

}

function makeSubmitVisible(){
  sub1.className = 'visibledata';
}

function gottext(survey,nextitem,curdiv){


  if (nextitem == 'Thankyou'){
	sub1.className = 'visibledata';
   } else if (nextitem != '') {
	var mydiv = document.getElementById(nextitem);
        mydiv.className = 'visibledata';

   }
  var lastdiv = document.getElementById('lastdiv').value
  if (mydiv == lastdiv){
    sub1.className = 'visibledata';
   }
}


function getUserPerms(){
  var idx = document.getElementById('user').selectedIndex;
  var selId = document.getElementById('user').options[idx].value;
  var url="getUserPerms.pl"
  var tpostdata = "id="+selId;
  if (selId != ''){
    processUrl(url,tpostdata);
  } else {
    var possibles = document.getElementById('possibles').value;
    var ary = possibles.split(';;;');
    var i;
    for (i=0;i<ary.length;i++){
      document.getElementById(ary[i]).checked = false;
    }
  }
}  


function getVolunteers(){
  var idx = document.getElementById('event').selectedIndex;
  var selIdShift = document.getElementById('event').options[idx].value;
  var url = "getVols.pl";
  var ary = selIdShift.split(',');
  var tpostdata = "id="+ary[0]+"&shift="+ary[1];
//alert("in getVolunteers "+tpostdata+"  " + url);
  processUrl(url,tpostdata);
}
function getExtraData(){
  var indx = document.getElementById('id').selectedIndex;

  var id = document.getElementById('id').options[indx].value;
  var url="getExtra.pl";
  var tpostdata = "id="+id;

  if (id != ''){
     processUrl(url,tpostdata);
  } else {
    document.getElementById('agencyId').selectedIndex = 0;
    document.getElementById('volId').selectedIndex = 0;
    document.getElementById('hours').value = 0;
    document.getElementById('activityDate').value = "";
    document.getElementById('title').value = '';
  }
}


function getOpportunity(){

  var idx = document.getElementById('id').selectedIndex;
  var selId = document.getElementById('id').options[idx].value;
  var url = 'getOpportunityData.pl';
  var tpostdata = "id="+selId;

  if (selId != ''){
    processUrl(url, tpostdata);
  } else {
    document.getElementById('agency').value = '';
    document.getElementById('name').value = '';
    document.getElementById('active').checked = false;
    document.getElementById('description').value = '';
    document.getElementById('contact').value = '';
    document.getElementById('contactphone').value = '';
    document.getElementById('contactemail').value = '';
    document.getElementById('start_date').value = '';

    var max = 5;
    var i = 1;
    var j;
    var myhtml;
       myhtml = '<table><tr><th width="60px">Specific Date</th><th width="10px">Or</th><th width="40px">Day of Month</th><th width="10px">' 
	+ 'Or</th><th>Weekday</th><th>Which Week</th><th width="20px">&nbsp;&nbsp;</th><th width="60px">Start Time</th><th>AM/PM</th><th width="60px">End Time</th><th>AM/PM</th></tr>';
       max = i+5;
       for (i=1;i<max;i++){
	j = i;

	val = "";
	        myhtml += '<tr><td width="60px"><input type="text" name="specific_date' +j + '" id="specific_date' +j
			+ '" value="' + val + '" onChange="checkDate(this)"> </td><td width="10px"></td>';

         myhtml += '<td width="40px"><input type="text" name="day_of_month' + j + '" id="day_of_month' + j + '"' +
		+ ' value= "' + val + '" > </td><td width="10px"></td>';

	 weekdaysel = '<td width="60px"><select name="weekday' + j + '"><option value="">Choose</option>';
         if (val == 'Sunday'){
		weekdaysel += '<option value="Sunday" selected>Sunday</option>';
	 } else {
		weekdaysel += '<option value="Sunday">Sunday</option>';
        }
         if (val == 'Monday'){
		weekdaysel += '<option value="Monday" selected>Monday</option>';
	 } else {
		weekdaysel += '<option value="Monday">Monday</option>';
        }
         if (val == 'Tuesday'){
		weekdaysel += '<option value="Tuesday" selected>Tuesday</option>';
	 } else {
		weekdaysel += '<option value="Tuesday">Tuesday</option>';
        }
         if (val == 'Wednesday'){
		weekdaysel += '<option value="Wednesday" selected>Wednesday</option>';
	 } else {
		weekdaysel += '<option value="Wednesday">Wednesday</option>';
        }
         if (val == 'Thursday'){
		weekdaysel += '<option value="Thursday" selected>Thursday</option>';
	 } else {
		weekdaysel += '<option value="Thursay">Thursday</option>';
        }
         if (val == 'Friday'){
		weekdaysel += '<option value="Friday" selected>Friday</option>';
	 } else {
		weekdaysel += '<option value="Friday">Friday</option>';
        }
         if (val == 'Saturday'){
		weekdaysel += '<option value="Saturday" selected>Saturday</option>';
	 } else {
		weekdaysel += '<option value="Saturday">Saturday</option>';
        }
	 myhtml += weekdaysel + '</select></td>';

         whichweeksel = '<td><select name="whichweek' + j + '">option value="">Choose</option>';
	 if (val == 'every'){
		whichweeksel += '<option value="every" selected>every</option>';
	 } else {
		whichweeksel += '<option value="every">every</option>';
         }
         if (val == 'first'){
		whichweeksel += '<option value="first" selected>first</option>';
	 } else {
		whichweeksel += '<option value="first">first</option>';
         }	 
         if (val == 'second'){
		whichweeksel += '<option value="second" selected>second</option>';
	 } else {
		whichweeksel += '<option value="second">second</option>';
        }
	if (val == 'third'){
		whichweeksel += '<option value="third" selected>third</option>';
	 } else {
		whichweeksel += '<option value="third">third</option>';
        }
         if (val == 'fourth'){
		whichweeksel += '<option value="fourth" selected>fourth</option>';
	 } else {
		whichweeksel += '<option value="fourth">fourth</option>';
        }	  
         if (val == 'fifth'){
		whichweeksel += '<option value="fifth" selected>fifth</option>';
	 } else {
		whichweeksel += '<option value="fifth">fifth</option>';
        } 
    
	myhtml += whichweeksel + '</select></td>';
        myhtml += '<td width="20px"></td>';

	myhtml += '<td width="60px"><input type="text" name="start_time' + i + '" id="start_time' + i + 
		'" value = "' + val + '" onChange="checkTime(this)"></td>';
	ampmsel1 = '<td><select name="start_ampm' + i + '" id="start_ampm' + i + 
		'" ><option value="">Choose</option>';
	ampmsel1 += '<option value="AM">AM</option><option value="PM">PM</option>';


	myhtml += ampmsel1 + '</select></td>';


	myhtml += '<td ><input type="text" name="end_time' + i + '" id="end_time' + i + 
		'" value = "' + val + '" onChange="checkTime(this)"></td>';
	ampmsel2 = '<td><select name="end_ampm' + i + '" id="end_ampm' + i + 
		'" ><option value="">Choose</option>';
	ampmsel2 += '<option value="AM">AM</option><option value="PM">PM</option>';


	myhtml += ampmsel2 + '</select><input type="hidden" name="id' + i + 
		'" id="id' + i + '" ></td><tr>';	
	}
	myhtml += '</table>';
	
	document.getElementById('timestable').innerHTML = myhtml;
  }
}
