
/****************************************
 ** Feature Rotator
 ** 01/17/2008
 ** Sunil Karve, on behalf of LexisNexis
 ****************************************/

var rotateImageID; // ID of the image to be rotated; set in the <head> of the calling document
var featImg; // Reference to the rotating image
var featLink; // Reference to the target url of rotating image
var rotateInterval = 5000; // Rotation delay period in milliseconds, defaults to 5 seconds
var featCounter = 0;  // Index of current feature

function initFeature() { // Load JS and check compatibility

	if(!document.getElementById) { return; } // Stop execution if getElementById not supported

	featImg = document.getElementById( rotateImageID ); // Get reference to specified image
	
	if( featImg.parentNode.nodeName == "A") { // Check if rotating image is hyperlinked and get reference to the link
		featLink = featImg.parentNode;		
	}
	
	preloadRotateImages(); // Preload all images for quick response

	
	rotateFeature(); // Begin initial rotation
	var rotateTimer = setInterval("rotateFeature()", rotateInterval); //  Repeat at specified interval

}

function rotateFeature() { // Change attributes of rotating image, and its link target if available

		featImg.setAttribute("src", featureArray[featCounter][0]);
		featImg.setAttribute("alt", featureArray[featCounter][1]);
		
		if( featLink != null ) { // Assign stored href to parent node (if it exists)
			featLink.setAttribute("href", featureArray[featCounter][2]);
		}

	featCounter++;
	
	// Reset rotation index if end of list reached
    if( featCounter == featureArray.length ) { featCounter = 0 };

}

function preloadRotateImages() {
	
	var preloadArray = new Array();
	for( var k=0; k < featureArray.length; k++ ) {
		preloadArray[k] = new Image();
		preloadArray[k].src = featureArray[k][2];
	} 
}

// Rotating script that  usually goes in the <head> of the page:

/************* Set rotating script variables *************/ 

rotateImageID = "rotateImage"; // Specify the ID of the rotating image
rotateInterval = 7500; // Override rotation interval (if necessary)

var featureArray = new Array(); // Define array of attributes, controlling image location, alt text and URL target

featureArray = [
/* Each feature must have at least an image location and alt text.  The third position stores where the image links to.

Example:
[
"{path to image}",
"{ALT text for image}",
"{HREF of link - optional}"   <--- If there is no link on the image, leave the third value as ""
],  <--- Each group above must be separated by a comma except the final group

*/

[
"/commonimages/121707_Brand ID_us-3.jpg",
"Lead with confidence.  Influence change in your industry through a commitment to innovation together with LexisNexis.",
"http://www.lexisnexis.com/hp-maincampaign/"
],

[
"/commonimages/121707_Brand ID_us-2.jpg",
"Grow with confidence.  Exceed business goals by improving productivity with solutions tailored to your workflow.",
"http://www.lexisnexis.com/hp-maincampaign/"
],

[
"/commonimages/121707_Brand ID_us-1.jpg",
"Work With Confidence. Make critical business decisions with complete confidence using LexisNexis industry solutions.",
"http://www.lexisnexis.com/hp-maincampaign/"
]

];

addOnLoadEvent(initFeature);


function addOnLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

