function deleteConfirm() {

	confirm_message = "Are you sure you would like to delete this item?";

	if (confirm(confirm_message)) {
		return true;
	}

	return false;
}

function addLoadListener(fn)
{
	if (typeof window.addEventListener != 'undefined')
	{
	window.addEventListener('load', fn, false);
}
else if (typeof document.addEventListener != 'undefined')
{
	document.addEventListener('load', fn, false);
}
else if (typeof window.attachEvent != 'undefined')
{
	window.attachEvent('onload', fn);
}
else
{
	var oldfn = window.onload;
	if (typeof window.onload != 'function')
	{
	window.onload = fn;
	}
	else
	{
	window.onload = function()
	{
	oldfn();
	fn();
	};
	}
	}
}

document.onclick = function(e)
{
  var target = e ? e.target : window.event.srcElement;

  while (target && !/^(a|body)$/i.test(target.nodeName))
  {
    target = target.parentNode;
  }

  if (target && target.getAttribute('rel')
      && target.rel == 'external')
  {
    var external = window.open(target.href);

    return external.closed;
  }
return e;
}


//Used in the search.php page.
function toggleLayer( whichLayer )
{
var full, small, visF, visS;
if( document.getElementById ) // this is the way the standards work
{
  full = document.getElementById( "full_" + whichLayer );
  small = document.getElementById( "small_" + whichLayer );
}
else if( document.all ) // this is the way old msie versions work
{
	  full = document.all( "full_" + whichLayer );
    small = document.all( "small_" + whichLayer );
}
visF = full.style;
visS = small.style;
if (visF.display==''||visF.display=='block')
{
	  visF.display='none';
	  visS.display='block';
}
else
{
	  visF.display='block';
	  visS.display='none';
}

}

function changeDisplay(id) {
	var element = document.getElementById(id);
	if (element.style.display != 'block')
		$("#"+id).show();
	else
		$("#"+id).hide();
}

function changeScheduleDisplay(id) {
	changeDisplay(id);
	if (document.getElementById(id).style.display == "block")
		//document.getElementById('schedule_add_new').scrollTop = document.getElementById('schedule_add_new').offsetTop;
		window.scroll(0, document.getElementById('schedule_add_new').offsetTop);
}

function changeCheckboxStatus(field) {
	list = document.getElementsByName(field);
	for (i = 0; i < list.length; i++)
		if (list[i].checked)
			list[i].checked = false;
		else
			list[i].checked = true;
}

function alternateElementHighlighting(containerID, elementID, highlightColour){
	var bgColour;
	
	if(highlightColour != null){
		bgColour = highlightColour;
	} else {
		bgColour = '#FC0';
	}
	
	$(containerID).find(elementID+':even').css('background-color',bgColour);
}

function addPDFIcons(containerID, attribute){
	/*this function's output is dependant upon
	  the style for "div.content_right ul.pdf_list li.pdf" 
	  in screen.css*/
	$(containerID).find(attribute).addClass('pdf');
}

function addDOCIcons(containerID, attribute){
	/*this function's output is dependant upon
	  the style for "div.content_right ul.pdf_list li.pdf" 
	  in screen.css*/
	$(containerID).find(attribute).addClass('doc');
}

function addZIPIcons(containerID, attribute){
	/*this function's output is dependant upon
	  the style for "div.content_right ul.pdf_list li.pdf" 
	  in screen.css*/
	$(containerID).find(attribute).addClass('zip');
}

function textInputSelection (elementID) {
	$(elementID).each(function(){
		var elm = $(this);
		var preFill = elm.val();
		elm.focus(function(){
			if($(this).val() == preFill){$(this).val('').css({color:'#898989'});}
		}).blur(function(){
			if($(this).val() == ''){$(this).val(preFill).css({color:'#dbdbdb'});}
		})
	});
}

function addActiveClass (opt) {
	if(opt.className == null){
		opt.className = 'active';
	}
	$(opt.elm).each(function(){
		var e = $(this);
		if(e.attr('href')){
			if(e.attr('href') == document.location.href)
			{
				e.addClass(opt.className)
			}
		}
	});
}
