<!-- hide from non js browsers

// Copyright Infologic Services Ltd 2004
//

//
// Version	Date		Description
// 3.05.002 25May2004	Initial Version
// 3.05.008 01Dec2004	Change to example body part
//


var AlternateLinkNumber = 0;

// *******************************************************************
// Search links array for matching href
// @param href is absolute matching href
// @returns index of link in links array or -1 if not found
function islSearchLinksForHref(href) { 
  for (var index=0; index<document.links.length; index++) {
    if (document.links[index].href == href) return index;
  }
  
  return -1;
}

// *************************************************
// Replace existing href with new.
// Uses id to find link, or oldHref for older browsers
function islReplaceHref(id,oldHref,newHref) {
  if (document.links.length > 0) {
    if (document.getElementById) {
	  //alert("islReplaceHref using getELementById");
      document.getElementById(id).href = newHref;
    }
    else if (document.all) {
	  //alert("islReplaceHref using document.all");
      document.all[id].href = newHref;
    }
    else {
      var index = islSearchLinksForHref(oldHref);
	  //alert("islReplaceHref using islSearchLinksForHref got "+index);
      if (index > -1)
        document.links[index].href = newHref;
    }
  }
}
// **********************************
// Appends an image link to the document, substituting an alternate image link
// if the first image can not be located. (eg. if server containing first image is unavailable)
// @param id is any unique id to be assigned to the link, If empty string, script will allocate automatically 
// @param imgSrc is prefered image to be displayed, eg "http://a.b.c.d/images/xyz.gif"
// @param imgTagAttr is other attributes for IMG tag, if any. eg. 'border="0"' or "".
// NB. src= and onError= are automatically generated
// @param href is "A" tag href link to be used if prefered image can be located
// @param aTagAttr is other attributes for A tag, if any. eg. 'target="_self"' or ""
// NB. href= and ID= are automatically generated
// @param altImage src will be displayed if prefered image is unavailable
// @param altHref is link to be used if prefered image is unavailable

function islAlternateLink(id, imgSrc, imgTagAttr, href, aTagAttr, altImage, altHref) {
	if (id == "") {
		AlternateLinkNumber = AlternateLinkNumber + 1;
		id = "islalternateLink"+AlternateLinkNumber;
	}
	document.write('<A HREF="'+href+'" id="'+id+'" '+aTagAttr+'>');
	document.write('<img src='+imgSrc+' '+imgTagAttr+'" onError="onError=\'null\'; this.src=\''+altImage+'\'; ');
	document.write('islReplaceHref(\''+id+'\', \''+href+'\', \''+altHref+'\');"></A>');
}

// Example head part
//      <script type="text/javascript" language="JavaScript" src="../js/alternateLink.js"></script>
// Example body part
//	  <script JavaScript>
//	  <!--
//		islAlternateLink("", 
// 		"http://host.name.com/images/demo.gif", 
//		 'width="60" height="40" border="0" alt="Link to Public Holiday Search Demonstration"',
// 		"http://host.name.com/index.html",
//		 'target="_self"',
//		 "../images/demo.gif",
//		 "#requestDemo");
//	  // -->
//	  </script>
	


