$(function()
		{		 
		$("li.menu").mouseover(function(){
				document.body.style.cursor = 'pointer';
		      $(this).css('background-color','#D8D8D8'); 
		    }).mouseout(function(){
		      document.body.style.cursor = 'default';
		      $(this).css('background-color','#ffffff'); 
		    }).click(function(){
		      var link = this.title;
		      window.location.replace(link);
		    });
});

$(function()
		{		 
		$("a.letterlink").click(function(){
			var letter = this.id;
			var hideletter = $('input.hideletter').attr('value');
			var hidediv = $('div.childterms' + hideletter).hide();
			$('input.hideletter').attr('value',letter);
			var displaydiv = $('div.childterms' + letter).show();
			return false;
		    });
});
 

function CHECKCONTACTUS()
{
	if (document.contact_us.name.value.length == 0)
	{
		alert('Please enter a name.');
	}
	else if((document.contact_us.email.value.length == 0) || (document.contact_us.email.value.indexOf('@')==-1)) 

	{
		alert('Please enter a valid email email address.');
	}
	else if(document.contact_us.content.value.length == 0)

	{
		alert('Please enter a message.');
	}
	else
	{
		document.contact_us.submit();
	}
}

function CHECKEMAILLIST()
{
	if (document.join_email_list.name.value.length == 0)
	{
		alert('Please enter a name.');
	}
	else if((document.join_email_list.email.value.length == 0) || (document.join_email_list.email.value.indexOf('@')==-1)) 
	{
		alert('Please enter a valid email email address.');
	}
	else
	{
		document.join_email_list.submit();
	}
}

function CHECKPAGECONTENT()
{
//if (document.page_content.content.value.length == 0)
//	{
//	alert('You must have text.');
//	document.page_content.content.focus();
//	}		
//else 
//	{
	document.page_content.submit();
//	} 
}

function CHECKPASSWORD()
{
	document.change_password.submit();
	
//	if (document.change_password.password.value.length == 0)
//	{
//		alert('You must enter a password.');
//	}
//	else 
//	{
//		document.change_password.submit();
//	}

}

function CHECKADDTERMS()
{
	document.childterms.submit();	
}

function CHECKDELETEEMAILS()
{
	document.delete_emails.submit();	
}

function CHECKEMAIL()
{
	if (document.send_email.subject.value.length == 0)
	{
		alert('Please enter a subject for this email.');
	}
	else if (document.send_email.content.value.length == 0)
	{
		alert('Please enter a body for this email.');
	}
	else
	{
		var answer = confirm ("Are you sure you want to send this message?  It will be sent to everyone in the email list.")
		if (answer)
		{	
			document.send_email.submit();
		}	
	}
}

function CHECKADDEVENTS()
{
	document.events.submit();	
}

function addEvent()
{
  var tbl = document.getElementById('tblEvents');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  var cellone = row.insertCell(0);
  cellone.className = "pagecontent2";
  var e1 = document.createElement('input');
  e1.type = 'text';
  e1.name = 'namenew[' + iteration + ']';
  
  var celltwo = row.insertCell(1);
  celltwo.className = "pagecontent2";
  var month = document.createElement('select');
  var month_array = {
		    1 : 'January',
		    2 : 'February',
		    3 : 'March',
		    4 : 'April',
		    5 : 'May',
		    6 : 'June',
		    7 : 'July',
		    8 : 'August',
		    9 : 'September',
		    10: 'October',
		    11: 'November',
		    12: 'December'
		};
  for(index in month_array) {
	    month.options[month.options.length] = new Option(month_array[index], index);
	}
  
  var day = document.createElement('select');
  for(var i=1; i<=31; i++) {
	    day.options[day.options.length] = new Option(i, i);
	}
  
  var year = document.createElement('select');
  var d = new Date();
  var curyear = d.getFullYear();
  var nextyear = curyear + 1;
  year.options[year.options.length] = new Option(curyear, curyear);
  year.options[year.options.length] = new Option(nextyear, nextyear);
  
  var hour = document.createElement('select');
  for(var i=1; i<=12; i++) {
	  hour.options[hour.options.length] = new Option(i, i);
	}
  
  var minutes = document.createElement('select');
  for(var i=0; i<=59; i++) {
	  if (i < 10)
	  {
		  var mins = '0' + i;
	  }  
	  else
	  {
		  var mins = i;
	  } 
	  minutes.options[minutes.options.length] = new Option(mins, mins);
	}
  
  var ampm = document.createElement('select');
  ampm.options[ampm.options.length] = new Option('AM', 'AM');
  ampm.options[ampm.options.length] = new Option('PM', 'PM');
  
  var cellthree = row.insertCell(2);
  cellthree.className = "pagecontent2";
  var e3 = document.createElement('input');
  e3.type = 'text';
  e3.name = 'locationnew[' + iteration + ']';
  
  var cellfour = row.insertCell(3);
  var e4 = document.createElement('textarea');
  e4.rows = 5;
  e4.cols = 10;
  e4.name = 'notesnew[' + iteration + ']';
  
  var cellfive = row.insertCell(4);
  cellfive.className = "pagecontent2";
  var e5 = document.createElement('input');
  e5.type = 'checkbox';
  e5.name = 'checkboxnew[' + iteration + ']';
  e5.value = iteration;
  
  month.name = 'monthnew[' + iteration + ']';
  day.name = 'daynew[' + iteration + ']';
  year.name = 'yearnew[' + iteration + ']';
  hour.name = 'hournew[' + iteration + ']';
  minutes.name = 'minutesnew[' + iteration + ']';
  ampm.name = 'ampmnew[' + iteration + ']';
  
  cellone.appendChild(e1); 
  celltwo.appendChild(month);
  celltwo.appendChild(day);
  celltwo.appendChild(year);
  celltwo.appendChild(hour);
  celltwo.appendChild(minutes);
  celltwo.appendChild(ampm);
  cellthree.appendChild(e3);
  cellfour.appendChild(e4);
  cellfive.appendChild(e5);
}




function change(mydiv)
{
  if(document.getElementById(mydiv).style.display="none")
    document.getElementById(mydiv).style.display="block";
  else 
    document.getElementById(mydiv).style.display="none";
}

function addRowToTable()
{
  var tbl = document.getElementById('tblSample');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  // left cell
  var cellLeft = row.insertCell(0);
  var el = document.createElement('input');
  el.type = 'text';
  el.name = 'songnew[' + iteration + ']';
  el.size = 35;
  
  // middle cell
  var cellMiddle = row.insertCell(1);
  var em = document.createElement('input');
  em.type = 'text';
  em.name = 'artistnew[' + iteration + ']';
  em.size = 35;
  
  var cellRight = row.insertCell(2);
  var er = document.createElement('input');
  er.type = 'checkbox';
  er.name = 'checkboxnew[' + iteration + ']';
  er.value = iteration;
  
  el.onkeypress = keyPressTest;
  cellLeft.appendChild(el);
  cellMiddle.appendChild(em);
  cellRight.appendChild(er);
}
   
function addRowToTableImage(stringgroups,stringkeys) 
{
  var aryGroups = new Array();
  aryGroups = stringgroups.split(",");
  
  var aryKeys = new Array();
  aryKeys = stringkeys.split(",");
  
  var tbl = document.getElementById('tblImage');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  var cellone = row.insertCell(0);
  var e1 = document.createElement('select');
  e1.name = 'groupnew[' + iteration + ']';
  for (var i=0; i < aryGroups.length;++i)
  {
	  var myvar = aryGroups[i].replace("||","'");
	  var oOption = document.createElement("OPTION");
	  var t = document.createTextNode(myvar);
	  oOption.setAttribute("value", aryKeys[i]);
	  oOption.appendChild(t);
	  e1.appendChild(oOption);
  }
   
  var celltwo = row.insertCell(1);
  var e2 = document.createElement('input');
  e2.type = 'text';
  e2.name = 'notesnew[' + iteration + ']';
  
  var cellthree = row.insertCell(2);
  var e3 = document.createElement('text');
  
  var cellfour = row.insertCell(3);
  var e4 = document.createElement('input');
  e4.type = 'file';
  e4.name = 'imagenew[' + iteration + ']';
  
  var cellfive = row.insertCell(4);
  var e5 = document.createElement('input');
  e5.type = 'checkbox';
  e5.name = 'checkboxnew[' + iteration + ']';
  e5.value = iteration;
  
  cellone.appendChild(e1);
  celltwo.appendChild(e2);
  cellthree.appendChild(e3);
  cellfour.appendChild(e4);
  cellfive.appendChild(e5);
}

function addRowToTableGroup()
{
  var tbl = document.getElementById('tblGroup');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  var cellone = row.insertCell(0);
  var e1 = document.createElement('input');
  e1.type = 'text';
  e1.name = 'groupnew[' + iteration + ']';
   
  var celltwo = row.insertCell(1);
  var e2 = document.createElement('input');
  e2.type = 'checkbox';
  e2.name = 'checkboxnew[' + iteration + ']';
  e2.value = iteration;
  
  cellone.appendChild(e1); 
  celltwo.appendChild(e2);
}

function addRowToTableReading()
{
	  var tbl = document.getElementById('tblReading');
	  var lastRow = tbl.rows.length;
	  // if there's no header row in the table, then iteration = lastRow + 1
	  var iteration = lastRow;
	  var row = tbl.insertRow(lastRow);
	  
	  var cellone = row.insertCell(0);
	  var e1 = document.createElement('input');
	  e1.type = 'text';
	  e1.name = 'booknamenew[' + iteration + ']';
	  
	  var celltwo = row.insertCell(1);
	  var e2 = document.createElement('input');
	  e2.type = 'text';
	  e2.name = 'authornew[' + iteration + ']';
	  
	  var cellthree = row.insertCell(2);
	  var e3 = document.createElement('input');
	  e3.type = 'text';
	  e3.name = 'linknew[' + iteration + ']';
	   
	  var cellfour = row.insertCell(3);
	  var e4 = document.createElement('input');
	  e4.type = 'checkbox';
	  e4.name = 'checkboxnew[' + iteration + ']';
	  e4.value = iteration;
	  
	  cellone.appendChild(e1); 
	  celltwo.appendChild(e2);
	  cellthree.appendChild(e3);
	  cellfour.appendChild(e4);
}

function addRowToTableTerms()
{
  var tbl = document.getElementById('tblTerms');
  var lastRow = tbl.rows.length;
  // if there's no header row in the table, then iteration = lastRow + 1
  var iteration = lastRow;
  var row = tbl.insertRow(lastRow);
  
  var cellone = row.insertCell(0);
  cellone.vAlign="top";
  var e1 = document.createElement('input');
  e1.type = 'text';
  e1.name = 'wordnew[' + iteration + ']';
  e1.id = 'childterms';
  
  var celltwo = row.insertCell(1);
  celltwo.vAlign="top";
  var e2 = document.createElement('textarea');
  e2.rows = 10;
  e2.cols = 40;
  e2.name = 'definitionnew[' + iteration + ']';
  
  var cellthree = row.insertCell(2);
  cellthree.vAlign="top";
  var e3 = document.createElement('input');
  e3.type = 'checkbox';
  e3.name = 'checkboxnew[' + iteration + ']';
  e3.value = iteration;
  
  cellone.appendChild(e1);
  celltwo.appendChild(e2);
  cellthree.appendChild(e3);
}

function keyPressTest(e, obj)
{
  var validateChkb = document.getElementById('chkValidateOnKeyPress');
  if (validateChkb.checked) {
    var displayObj = document.getElementById('spanOutput');
    var key;
    if(window.event) {
      key = window.event.keyCode; 
    }
    else if(e.which) {
      key = e.which;
    }
    var objId;
    if (obj != null) {
      objId = obj.id;
    } else {
      objId = this.id;
    }
    displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
  }
}

function CHECKADDIMAGE()
{
	document.update_doula.submit();	
}

function CHECKADDREADING()
{
	document.reading.submit();
}


/***

function CHECKADDGIG()
{
if (document.add_gig_form.venue.value == 0)
	{
	alert('Please select a venue.');
	}	
else if (document.add_gig_form.month.value == 0)
	{
	alert('Please select a month.');
	}		
else if (document.add_gig_form.day.value == 0)
	{
	alert('Please select a day.');
	}	
else if (document.add_gig_form.hour.value == 0)
	{
	alert('Please select an hour.');
	}		
else 
	{
	document.add_gig_form.submit();
	}
}

function CHECKADDVENUE()
{
	if (document.add_venue_form.name.value.length == 0)
	{
		alert('Please enter a venue name.');
	}
	else 
	{
		document.add_venue_form.submit();
	}
}

***/
