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);
}

var addPDFIcons = function (object){
	
	obj = {
		selector : '[href*=.pdf]',
		appendOrInsert : 'append',
		beforeOrAfter : '',
		iconURL : '',
		additionalCSS:''
	};

	
	/* Set Options if they have been passed correctly otherwise
	 * send an error to console.log()
	 */
	for (var i in obj) {
		
		if(object[i] != null) {
			
			if(i == 'selector') {
				
				/*wrap option in jQuery object if needed*/
				obj[i] = $(object[i]);
				/*log to console if debugging*/
				//console.log(this.obj[i]);
				
			} else {
				
				/*regular option var*/
				obj[i] = object[i];
				
			}/*end if > else*/
		}/*end if*/
		
	}/*end for*/
	
	/*create jQuery useable vars from this.obj vars*/
	
	/*create and attach pdf images to selected elements*/
	$(obj.selector).each(function(){
		var pdfIcon = $(document.createElement('img')).attr({
				'alt':'',
				'title':'',
				'src':obj.iconURL
			});
		
		if (obj.additionalCSS != '') {
			
			pdfIcon.css(obj.additionalCSS);
			
		}
		
		if (obj.appendOrInsert == 'append') {
			
			$(this).append(pdfIcon);
			
		} else if (obj.appendOrInsert == 'insert') {
			
			if (obj.beforeOrAfter == 'before') {
				
				pdfIcon.insertBefore($(this));
				
			} else if (obj.beforeOrAfter == 'after') {
				
				pdfIcon.insertAfter($(this));
				
			}
		}/*end if > else if*/
	});/*end .each()*/
}

function textInputSelection (elementID) {
	$(elementID).each(function(){
		var elm = $(this);
		var preFill = elm.val();
		$(this).focus(function(){
			if($(this).val() == preFill){$(this).val('').css({color:'#414141'});}
		}).blur(function(){
			if($(this).val() == ''){$(this).val(preFill).css({color:'#b1b1b1'});}
		})
	});
}

$().ready(function(){
	
	/*alternateElementHighlighting('ul.pdf_list', 'li', '#CCEEFF');*/
	
	var approvalPagePDFs = new addPDFIcons ({
		selector:'li[title*="PDF"] p a',
		appendOrInsert:'append', 
		iconURL:'./images/back/pdf.gif',
		additionalCSS:{
				display:'inline',
				position:'relative',
				top:'3px',
				left:'4px'
			}
	});
	
	var utilibond = new addPDFIcons ({
		selector:'body.keyhole_technology a[href*=".pdf"],' +
					'body.utilibond a[href*=".pdf"],' +
					'div.the_green_alternative a[href*=".pdf"],' +
					'body.equipment div.content_right a[href*=".pdf"]',
		appendOrInsert:'insert',
		beforeOrAfter:'after',
		iconURL:'./images/back/pdf.gif',
		additionalCSS:{
				display:'inline',
				position:'relative',
				top:'3px',
				left:'4px'
			}
	});
	
	$('#faq').makeFAQ({
		displayIndex:true,
		collapseIndex:true,
		indexLink:'./contact-us.php'
	});
	
	textInputSelection('form#contact_us input text, form#contact_us textarea');
	
});

	Cufon.replace ('#navigation, .helvetica_medium', {hover:true, fontFamily: 'Helvetica Medium'});
	Cufon.replace ('.helvetica_light', {hover:true, fontFamily: 'Helvetica Light'});
	Cufon.replace ('.helvetica_roman', {hover:true, fontFamily: 'Helvetica Roman'});

