/*
Useful JavaScript tools
*/
//----------------------------------------------------------------------------------
try {
	// fix Internet Explorer 6 bug with background image flicker
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
//----------------------------------------------------------------------------------

function highlight(idName) {
	document.getElementById(idName).style.color = "#fff";
	//document.getElementById(idName).style.textDecoration = "underline";
	document.getElementById(idName).style.backgroundColor = "#008b3c";
	//document.getElementById(idName).style.borderBottomColor = "#fb6";
}
//----------------------------------------------------------------------------------
// JavaScript that preloads the  page images in memory
function Preload_Images() {
/*
Loads images into the browser's cache for later use.
Author: Daniel Servranckx, Admaris Inc.
Usage: Preload_Images('image1 URL', 'image2 URL', 'image3 URL', ...);
*/
  var image_lib = new Array(); // empty cache
 
  // Loop through all the arguments passed to the function.
  var argLength = Preload_Images.arguments.length;
  for(argNo=0; argNo<argLength; argNo++) {
    // For each arggument in the function param list, create a new image.
    image_lib[argNo] = new Image(); // define this array element as an image object
    // Set the source of that image object to the image URL passed in that argument
    image_lib[argNo].src = Preload_Images.arguments[argNo];
  }
}
//----------------------------------------------------------------------------------
function mail(recipient,email,name) {
	/*
		Purpose:
			This function generates a mailto:user@domain string 
			- an "anti-email-harvesting" trick
			usage example: mail('DServranckx', 'admaris.com','Daniel Servranckx at Admaris Inc.')
					will produce the mailto tag for DServranckx @ admaris.com
		Created by:
		 	Dan Servranckx on 4 Nov 2006
	*/
	var mailto = '<a href="mailto:';
	var atsign = "@";
	document.write(mailto + recipient + atsign + email + 
			'" title="Click to open an email window">' + name + '<\/a>');
	return true;
}
//----------------------------------------------------------------------------------

function date_modified() {
	/*
		Purpose:
			This function picks up and displays the date from the dc.date.modired meta data
		Created by:
		 	Dan Servranckx on 4 Nov 2006
	*/
	meta = document.getElementsByName("dc.date.modified");
	if (meta.length == 1) {
		document.write(meta[0].content);
	}
	return true;
}
//----------------------------------------------------------------------------------

function change_image(idName,picture) {
	/*
		Purpose:
			This function replaces an image source based on its id name
		Created by:
		 	Dan Servranckx on 8 Nov 2006
	*/
	document.getElementById(idName).src = picture;
	return true;
}
//----------------------------------------------------------------------------------

function pop_up_window(url, width, height) {
	/*
		Purpose:
			Use this function to pop up a non-navigational window containing page "url" 
			of specific size width and height in pixels. 
		Created by:
		 	Dan Servranckx on 14 May 2006
	*/

  //define browser window characteristics//
  charac = 	"height=" + height + ",width=" + width + ",top=200,left=200,toolbar=1," +
						"location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
	// Open a new window  named information for the URL, with above 
	//	characteristics, and give it focus to pop it on top. 
  var w = window.open(url,'Information',charac);
  w.focus();
}
//----------------------------------------------------------------------------------

function target(url) {
  /*
		Purpose:
			Use this function to pop up a new window named _New with URL "url".
			Replaces the deprecated anchor "target" tag.
		Created by:
			Dan Servranckx on 11 Nov 2006.
		Usage: instead of
				<a href="http://admaris.com" target="_New">Admaris.com</a>
			use
				<a href="javascript:target('http://admaris.com')">Admaris.com</a>
	*/
  var w = window.open(url,'_New');
  w.focus(); // make sure new window gets focus
}
//----------------------------------------------------------------------------------
