// JavaScript files for PCTS website - 20080523 v. 1

// --- namespace variables -------
pcts.clientHeight = 3000;
pcts.clientWidth = '';
pcts.readyState = '';
pcts.rotateInterval = 7000;
pcts.rotateTrigger = '';
pcts.rotatorImages = new Array('r001.jpg', 'r002.jpg', 'r003.jpg', 'r004.jpg', 'r005.jpg', 'r006.jpg', 'r007.jpg');
pcts.rotatorThumbs = new Array('r001_thumb.png', 'r002_thumb.png', 'r003_thumb.png', 'r004_thumb.png', 'r005_thumb.png', 'r006_thumb.pmg', 'r007_thumb.png');
pcts.rotatorFadeDuration = 100;
pcts.currentRotatorIndex = 1;
pcts.prevRotatorIndex = 0;
pcts.maxRotatorIndex = 6;
pcts.rotatorControlVisible = false;
pcts.rotatorThumbsVisible = false;
pcts.rotatorWidthConstant = 878;
pcts.singleRotatorThumb = new Array();
pcts.allRotatorThumbs = new Array();
pcts.thumbsVisible = false;
pcts.thumbOffset = 3;
pcts.thumbIterator = 4;
pcts.fadeTimer = '';
pcts.rotatorDivP1 = '<div id=\"';
pcts.rotatorDivP2 = '\" style=\"overflow:hidden; height:100px; width:100px; visibility:hidden; top:-150px; left:0px\"><img src=\"';
pcts.rotatorDivP3 = '\"/></div>';
pcts.currentSlideOpacity = 100;
pcts.rotatorOn = true;
pcts.rotatorThumbsOn = true;
pcts.rotatorStarted = false;
pcts.thumbFade = '';

// --- namespace functions -------

pcts.getClientHeight = function() {
	return document.documentElement.clientHeight;
}

pcts.handleReturnedRotatorData = function() {

	try {

		//first, make the rotator title assembly completely transparent
		
		pcts.setOpacity(0, 'rotatorTitleBlock');
		
		// handle date being returned from the rotator data accessor
		document.getElementById('rotatorHeadlineRow').style.display = pctsFramework.rotatorHeadDisplay;
		document.getElementById('rotatorSubheadRow').style.display = pctsFramework.rotatorSubDisplay;
		
		// if the headline and sub are displayed, set their values
		if (document.getElementById('rotatorHeadlineRow').style.display == 'block') {
			document.getElementById('rotatorHeadline').innerHTML = pctsFramework.rotatorHeadline;
			document.getElementById('rotatorHeadline').style.color = '#' + pctsFramework.rotatorNonIEHeadColor;
			if (pctsFramework.rotatorHeadShadowMode == 'noShadow') {
				document.getElementById('rotatorHeadline').className = 'rotatorHeadlineNoShadow';
			} else {
				document.getElementById('rotatorHeadline').className = 'rotatorHeadline';
			}
			
		}

		if (document.getElementById('rotatorSubheadRow').style.display == 'block') {
			document.getElementById('rotatorSubhead').innerHTML = pctsFramework.rotatorSubhead;
			document.getElementById('rotatorSubhead').style.color = '#' + pctsFramework.rotatorNonIESubColor;
			if (pctsFramework.rotatorHeadShadowMode == 'noShadow') {
				document.getElementById('rotatorSubhead').className = 'rotatorSubNoShadow';
			} else {
				document.getElementById('rotatorSubhead').className = 'rotatorSub';
			}
		}
		
		if (pctsFramework.browserPath == 'ie') {
			document.getElementById('rotatorHeadline').style.color = '#' + pctsFramework.rotatorHeadColor;
			document.getElementById('rotatorSubhead').style.color = '#' + pctsFramework.rotatorSubColor;
		}
	
		document.getElementById('rotatorTitleBlock').style.top = pctsFramework.rotatorTop + 'px';
		document.getElementById('rotatorTitleBlock').style.left = pcts.calculateTitleblockLeft(pctsFramework.rotatorLeft) + 'px';
		document.getElementById('rotatorTitleBlock').style.width = pctsFramework.rotatorWidth + 'px';
		
		// make the headline block visible
		document.getElementById('rotatorTitleBlock').style.visibility = 'visible';
		
		// set the onclick function of the more element
		if (pctsFramework.moreButtonAction != '') {
			document.getElementById('moreButton').onclick = function() {pctsFramework.presentExternalUnsecured(pctsFramework.moreButtonAction);};
			
		} else {
			document.getElementById('moreButton').onclick = function() {page.handlePressItemRetrieval(pctsFramework.asociatedPressID);};
			
		}
		
		// set the display state of the more button
		document.getElementById('moreButton').style.display = pctsFramework.moreButtonDisplay;
		
		// if this is IE, we do some additional trickery to get a nice glow effect
		// if (pctsFramework.browserPath == 'ie' && pctsFramework.rotatorHeadShadowMode != 'noShadow') {
		if (pctsFramework.browserPath == 'ie') {
			// display the back shadow in ie, only if shadow mode is on

			// make the BG transparent
			pcts.setOpacity(0, 'rotatorTitleBlockBG');

			document.getElementById('rotatorHeadlineBgRow').style.display = pctsFramework.rotatorHeadDisplay;
			document.getElementById('rotatorSubheadBgRow').style.display = pctsFramework.rotatorSubDisplay;
			
			// if the headline and sub are displayed, set their values
			if (document.getElementById('rotatorHeadlineBgRow').style.display == 'block') {
				document.getElementById('rotatorHeadlineBg').innerHTML = pctsFramework.rotatorHeadline;
			}
	
			if (document.getElementById('rotatorSubheadBgRow').style.display == 'block') {
				document.getElementById('rotatorSubheadBg').innerHTML = pctsFramework.rotatorSubhead;
			}

			document.getElementById('rotatorTitleBlockBG').style.top = pctsFramework.rotatorTop + 'px';
			document.getElementById('rotatorTitleBlockBG').style.left = pcts.calculateTitleblockLeft(pctsFramework.rotatorLeft) + 'px';
			document.getElementById('rotatorTitleBlockBG').style.width = pctsFramework.rotatorWidth - 5 + 'px';	
			
			document.getElementById('rotatorTitleBlockBG').style.visibility = 'visible';
		}

		// now fade the elements back in
		// if it is a mobile device, just setthe opacity to 100%
		if (pctsFramework.browserParent == 'iPhone') {
			pcts.setOpacity(100, 'rotatorTitleBlock');
			// pcts.fadeIn('rotatorTitleBlock', 0, 100, 520);
			
		} else {
			//pcts.fadeIn('rotatorTitleBlock', 0, 100, 520);
			jQuery("#rotatorTitleBlock").fadeTo("fast", 1.0);
		
		}
		
		// if this is IE we have to handle the background property too
		//if (pctsFramework.browserPath == 'ie' && pctsFramework.rotatorHeadShadowMode != 'noShadow') {
		if (pctsFramework.browserPath == 'ie') {
			//pcts.fadeIn('rotatorTitleBlockBG', 0, 70, 520);
			jQuery("#rotatorTitleBlockBG").fadeTo("fast", 0.70);
		}
		
		// rewrite the IE front text to get font smoothing to work
		if (pctsFramework.browserPath == 'ie') {
			//pcts.fadeIn('rotatorTitleBlockBG', 0, 70, 520);
			document.getElementById('rotatorHeadline').innerHTML = pctsFramework.rotatorHeadline;
			document.getElementById('rotatorSubhead').innerHTML = pctsFramework.rotatorSubhead;
		}
		
		// now fade in the loading animation
		// if it is IE, we fade it out almost instantly
		if(pctsFramework.browser == 'IE') {
			$('#rotatorSpinnerRt').fadeOut("normal", pcts.reconfigurePrimary);
			$('#rotateAnimationRt').fadeOut("normal");
		} else {
			$('#rotatorSpinnerRt').fadeOut("normal", pcts.reconfigurePrimary);
			$('#rotateAnimationRt').fadeOut("normal");
			
		}
		
	} catch(err) {
		// if we wind up here it is likely because a null value was returnd by the DB
		
	}
	
}

pcts.reconfigurePrimary = function() {
	// reconfigure the primary image after a load and start the next load sequence
	
	// first set up the source of the primary image to equal the source of the secondary image
	var imageToGet = pcts.rotatorImages[pcts.currentRotatorIndex];
	var sourceStem = "images/rotate/";
	document.getElementById('primaryImageBody').src = sourceStem + imageToGet;
	
}

pcts.calculateTitleblockLeft = function(theOffset) {
	// determine what the ctual left position should be based on the actual client width
	
	var theOverhangLeft = 0;
	
	try {
		// first, determine the actual client width, subtracting the width of the 
		// body block
		theOverhang = pctsFramework.clientWidth - 878;
		
		// now determine how much overhang per side
		theOverhangLeft = theOverhang / 2; 
		 
	} catch(err) {
		// if we wound up here, the window is likely < 878 px wide.
		
	}
	
	// return the value 
	
	return ((theOffset * 1) + (theOverhangLeft * 1));
}

pcts.getFirstRotatorSlides = function() {
	// get the data for the first rotator, and also store the first two slides

	// first, create an accessor calling string
	// the image to get is going to be the first entry in the rotatorImages array
	var theRan = pctsFramework.randomNumber();
	var theImageRef = pcts.rotatorImages[0];
	var theAccessor = '../accessors/getRotatorData.php?imageName=' + theImageRef + '&contentRegion=' + pctsFramework.contentRegion + '&anticache=' + theRan;

	// alert(theAccessor);
	
	// now get the data
	pctsFramework.getData(theAccessor);
	
	// some funky hack because the iPhone seems to get the index count
	// wrong for the first slide
	if(pctsFramework.browserParent == 'iPhone') {
		// pcts.currentRotatorIndex = pcts.currentRotatorIndex - 1;
	}
	
}
	
pcts.getClientWidth = function() {
	return document.documentElement.offsetWidth;
}

pcts.changeLocation = function(theLocation) {
	// traverse the window to a new page location, loading a page
	// appropriate to the sensed browser
	// alert(pctsFramework.browserPath + '/' + theLocation);
	window.location = pctsFramework.browserPath + '/' + theLocation + "?frameworkState=" + pctsFramework.orphanMode;
}

pcts.initiateRotateInterval = function() {
	// initiate a rotate interval for the main page rotator.  This interval
	// will continuously fire the interval that drives the rotator to
	// change from picture to picture.
	if(pctsFramework.browser == 'IE' && pctsFramework.browserVersion < 7) {
		var noRotate = true;
	} else {
		var noRotate = false;
	}

	if (!noRotate) {
		pcts.rotateTrigger = setInterval("pcts.updateRotatorSequence()", pcts.rotateInterval);
	}

	// also at this point we want to load up a temporary object with the last slide of the rotator sequence, 
	// as this will be used for traversing backwards in the rotator sequene manually
	
	// first we determine what image is the last in the sequence.
	// var theImageRef = pcts.rotatorImages[pcts.maxRotatorIndex];

	// create a source string
	// theSourceString = "../images/rotate/" + theImageRef;

	// now load the image into the temp holder
	// document.getElementById('tempRotatorImage').src = theSourceString;

}

pcts.pauseRotator = function() {
	// stop the rotator from advancing
	var int = window.clearInterval(pcts.rotateTrigger);
	document.getElementById('pButton').className = 'play_btnMoused';
}	

pcts.stopRotator = function() {
	// stop the rotator from advancing
	var int = window.clearInterval(pcts.rotateTrigger);
}

pcts.resumeRotator = function() {
	// resume the rotator advancing
	pcts.rotateTrigger = setInterval("pcts.updateRotatorSequence()", 16000);
	document.getElementById('pButton').className = 'pause_btnMoused';

}

pcts.startRotator = function() {
	// resume the rotator advancing
	pcts.rotateTrigger = setInterval("pcts.updateRotatorSequence()", 16000);

}

pcts.createDynamicSlidePane = function(theIndex) {
	// given a rotator index, create a container for that slide in the browser DOM
	// It will initially have no display state and no Z-index, but when the rotator is
	// advanced or reversed, these will be used for seamless transitions

	var theImageRef = pcts.rotatorImages[theIndex];
	
	// consruct a source string for the image to be utilized
	var theSourceString = "../images/rotate/" + theImageRef;

	// construct an ID to use for the slide
	var theId = 'rotatorSlide' + theIndex;

	// now construct HTML for the new object
	var theSlide = pcts.rotatorDivP1 + theId + pcts.rotatorDivP2 + theSourceString + pcts.rotatorDivP3;

	// now we want to add the HTML for the slide to the end of the DOM, just before the closing body tag.
	// we do this only if the slide pane does not already exist.
	if (document.getElementById(theId) == null) {
		var newElement = document.createElement("div");
		newElement.id = theId;
		newElement.style.position = "absolute";
		newElement.style.top = "-150px";
		newElement.style.left = "0px";
		newElement.style.height = "102px";
		newElement.style.width = "102px";
		newElement.style.overflow = "hidden";
		newElement.style.visibility = "hidden";
		newElement.style.zindex = 4300;
		newElement.innerHTML = "<img src=\"" + theSourceString + "\"/>";
	
		if(window.attachEvent) {
			document.body.insertAdjacentElement("beforeEnd", newElement); 
			//alert(document.getElementById(newElement.id).outerHTML);

		} else {
			document.body.appendChild(newElement);
			//alert(document.getElementById(newElement.id).innerHTML);

		}	
		
	}
	
}

pcts.pause = function(thePeriod) {
	// pause for thePeriod miliseconds
	var date = new Date();
	var curDate = null;

	do { curDate = new Date(); } 
	while(curDate-date < thePeriod);

} 

pcts.fadeSlide = function() {
	// recursively call this function until the current slide opacity is zero, then
	// move to the next stage of a rotator transition
	// alert('fading slide');

	var theTargetOpacity = pcts.currentSlideOpacity - 5;
	var theSpeed = Math.round(pcts.rotatorFadeDuration / 100);
	
	if ( pcts.currentSlideOpacity > 0) {
		// set the opacity level of the front rotator slide
		pcts.setOpacity(theTargetOpacity, 'pctsWebMainContent2');
		
		pcts.currentSlideOpacity = pcts.currentSlideOpacity - 5;

		// set a timeout to call this function again
		window.setTimeout(pcts.fadeSlide, 0);

		
	} else {
		// set up the rotator for the next slide.
		pcts.currentSlideOpacity = 100;

		// trigger the next step in the slide process
		pcts.advanceRotator();

	} 
}

pcts.jumpToNextSlide = function() {
	// for devices such as iPhone, jump to the next slide rather than fade
	// this is because these devices do not have the CPU power to run these transitions

	pcts.setOpacity(0, 'pctsWebMainContent2');
		
	// trigger the next step in the slide process
	pcts.advanceRotator();
 
}

pcts.fadeToSlide = function(theSlide) {
	// recursively call this function until the current slide opacity is zero, then
	// move to the next stage of a rotator transition
	// used when fading to a specific slide

	var theTargetOpacity = pcts.currentSlideOpacity - 5;
	var theSpeed = Math.round(pcts.rotatorFadeDuration / 100);
	
	if ( pcts.currentSlideOpacity > 0) {
		// set the opacity level of the front rotator slide
		pcts.setOpacity(theTargetOpacity, 'pctsWebMainContent2');
		
		pcts.currentSlideOpacity = pcts.currentSlideOpacity - 5;

		// set a timeout to call this function again
		window.setTimeout(pcts.fadeToSlide, 0);

		
	} else {
		// set up the rotator for the next slide.
		pcts.currentSlideOpacity = 100;

		// trigger the next step in the slide process
		pcts.configureRotatorResume(theSlide);

	} 
}

pcts.configureRotatorResume = function(theCurrentSlide) {
	// after fading to a specific slide, configure the rotator to resume rotation at
	// what would ordinarily be the next slide in the sequence.
	
	// first, we set the previous rotator index to whatever comes through as the 
	// the slide we are currently displaying, and we set the current rotator to the current slide + 1
	// pcts.currentRotatorIndex = theCurrentSlide + 1;
	// pcts.prevRotatorIndex = theCurrentSlide;

	// now we set up for the resumption of rotation
	// first we set the front pane to the back pane, and then restore its opacity
	var theBackSlide = document.getElementById('pctsWebMainContent').innerHTML;
	document.getElementById('pctsWebMainContent2').innerHTML = theBackSlide;
	
	// now set the front slide back to 100% opacity
	pcts.setOpacity(100, 'pctsWebMainContent2');

	// and now we load up the back pane to point to the next slide in a resumed rotator cycle
	var theContainer = 'rotatorSlide' + pcts.currentRotatorIndex;
	var theImage = document.getElementById(theContainer).innerHTML;

	// fill the back slide with the next slide image
	document.getElementById('pctsWebMainContent').innerHTML = theImage;

	// now we should be ready at this point to resume rotation, so we simply execute a call to
	// restart the rotation interval
	pcts.rotateTrigger = setInterval("pcts.updateRotatorSequence()", 7000);
	
}

pcts.fadeSlideToPrevious = function() {
	// recursively call this function until the current slide opacity is zero, then
	// move to the next stage of a rotator transition
	// alert('fading slide');

	var theTargetOpacity = pcts.currentSlideOpacity - 5;
	var theSpeed = Math.round(pcts.rotatorFadeDuration / 100);
	
	if ( pcts.currentSlideOpacity > 0) {
		// set the opacity level of the front rotator slide
		pcts.setOpacity(theTargetOpacity, 'pctsWebMainContent2');
		
		pcts.currentSlideOpacity = pcts.currentSlideOpacity - 5;

		// set a timeout to call this function again
		window.setTimeout(pcts.fadeSlideToPrevious, 0);

		
	} else {
		// set up the rotator for the next slide.
		pcts.currentSlideOpacity = 100;

		// trigger the next step in the slide process
		pcts.decrementRotator();

	} 
}

pcts.decrementRotator = function() {
	// decrement the rotator in response to a reverse action.  Essentially, this involves
	// resetting counters and also setting up the slides for proper resumption of
	// the rotation sequence.

	// first, corrctly decrement the rotator counters
	pcts.currentRotatorIndex = pcts.currentRotatorIndex - 1; 
	pcts.prevRotatorIndex = pcts.prevRotatorIndex - 1;
	
	if(pcts.currentRotatorIndex < 0) {
		pcts.currentRotatorIndex = pcts.maxRotatorIndex;
	}

	if(pcts.prevRotatorIndex < 0) {
		pcts.prevRotatorIndex = pcts.maxRotatorIndex;
	}

	// now we need to set up the rotator to resume rotation.  First, we get the content of the back slide,
	// and dump it into the front.
	
	var theBackSlide = document.getElementById('pctsWebMainContent').innerHTML;
	document.getElementById('pctsWebMainContent2').innerHTML = theBackSlide;
	
	// now set the front slide back to 100% opacity
	pcts.setOpacity(100, 'pctsWebMainContent2');
	
	// now that we have reset the front rotator and restored it's opacity, we set up the
	// back slide for resumption of the rotator sequence
	var theContainer = 'rotatorSlide' + pcts.currentRotatorIndex;
	var theImage = document.getElementById(theContainer).innerHTML;

	// fill the back slide with the next slide image
	document.getElementById('pctsWebMainContent').innerHTML = theImage;
	
	// alert(theImage);
	// alert('current rotator is now ' + pcts.currentRotatorIndex + ' and the previous is ' + pcts.prevRotatorIndex);
	
	// resume the rotator sequence
	pcts.rotateTrigger = setInterval("pcts.updateRotatorSequence()", 7000);
}

pcts.advanceRotator = function() {
	// advance to the next slide after a fade
	
	// first, set the top slide to the current slide
	var theContainer = 'rotatorSlide' + pcts.currentRotatorIndex;
	var theImage = document.getElementById(theContainer).innerHTML;

	// fill the front slide with the current slide image and restore it's opacity
	document.getElementById('pctsWebMainContent2').innerHTML = theImage;
	pcts.setOpacity(100, 'pctsWebMainContent2');

	// get the next data component
	// var theAccessor = '../accessors/getRotatorData.php?imageName=' + pcts.rotatorImages[pcts.currentRotatorIndex];
	// pctsFramework.getData(theAccessor);

	// now that we have restored the front slide to the current image, we need to fill the back slide with the
	// next image.  to do that, we first determine what the next imageSequence should be.
	// alert(pcts.currentRotatorIndex);
	var nextSlide = pcts.currentRotatorIndex + 1;
	if (nextSlide > pcts.maxRotatorIndex) {
		nextSlide = 0;
	}

	var theContainer = 'rotatorSlide' + nextSlide;
	var theImage = document.getElementById(theContainer).innerHTML;

	// fill the back slide with the next slide image
	document.getElementById('pctsWebMainContent').innerHTML = theImage;

	// update the current and previous counters
	pcts.prevRotatorIndex = pcts.currentRotatorIndex;
	pcts.currentRotatorIndex = pcts.currentRotatorIndex + 1;

	// if the currentRotatorIndex is greater than max Rotator, reset it to zero
	if (pcts.currentRotatorIndex > pcts.maxRotatorIndex) {
		pcts.currentRotatorIndex = 0;
	}

	// if the previousRotator index is greater than maxRotatorIndex
	if (pcts.prevRotatorIndex > pcts.maxRotatorIndex) {
		pcts.prevRotatorIndex = 0;
	}

}

pcts.updateRotatorSequence = function() {
	// update the rotator assembly with the next rotator in the sequence
	
	// first, pause the rotator sequence so it isn't trying to update during our asynchronous updates
	pcts.stopRotator();
	
	// indicate that rotator operations have started
	pcts.rotatorStarted = true;
	
	// make the headline and headline BG blocks hidden
	try {
		document.getElementById('rotatorTitleBlock').style.visibility = 'hidden';
		document.getElementById('rotatorTitleBlockBG').style.visibility = 'hidden';
	} catch(err) {
		
	}
	
	// rewrite the classes if this is IE
	if (pctsFramework.browser == 'IE') {
		pcts.reWriteSpinnerBG();
	}
	
	// now fade in the loading animation
	// if it is IE, we bring it in almost instantly
	if(pctsFramework.browser == 'IE') {
		$('#rotatorSpinnerRt').fadeIn("fast");
		$('#rotateAnimationRt').fadeIn("fast");
	} else {
		$('#rotatorSpinnerRt').fadeIn("normal");
		$('#rotateAnimationRt').fadeIn("normal");
		
	}
	
	// now determine what the next rotator in the sequence should be.  
	// this will be the next item key in the rotator array, which will have been populated shortly after page load.
	
	// first, increment the current rotator index
	if (pcts.currentRotatorIndex + 1 <= pcts.maxRotatorIndex) {
		pcts.currentRotatorIndex = pcts.currentRotatorIndex + 1;
	
	} else {
		pcts.currentRotatorIndex = 0;
	}
	
	// now set the image to get
	var imageToGet = pcts.rotatorImages[pcts.currentRotatorIndex];
	
	// set the source of the secondary rotator image
	var sourceStem = "images/rotate/";
	document.getElementById('secondaryImageBody').src = sourceStem + imageToGet;
	
}

pcts.decrementRotatorSequence = function() {
	// update the rotator assembly with the next rotator in the sequence
	
	// first, pause the rotator sequence so it isn't trying to update during our asynchronous updates
	pcts.stopRotator();
	
	// indicate that rotator operations have started
	pcts.rotatorStarted = true;
	
	// make the headline and headline BG blocks hidden
	try {
		document.getElementById('rotatorTitleBlock').style.visibility = 'hidden';
		document.getElementById('rotatorTitleBlockBG').style.visibility = 'hidden';
	} catch(err) {
		
	}
	
	// rewrite the classes if this is IE
	if (pctsFramework.browser == 'IE') {
		pcts.reWriteSpinnerBG();
	}
	
	// now fade in the loading animation
	// if it is IE, we bring it in almost instantly
	if(pctsFramework.browser == 'IE') {
		$('#rotatorSpinnerRt').fadeIn("fast");
		$('#rotateAnimationRt').fadeIn("fast");
	} else {
		$('#rotatorSpinnerRt').fadeIn("normal");
		$('#rotateAnimationRt').fadeIn("normal");
		
	}
	
	// now determine what the previous rotator in the sequence should be.  
	// this will be the previous item key in the rotator array, which will have been populated shortly after page load.
	
	// first, decrement the current rotator index
	if (pcts.currentRotatorIndex - 1 >= 0) {
		pcts.currentRotatorIndex = pcts.currentRotatorIndex - 1;
	
	} else {
		pcts.currentRotatorIndex = pcts.maxRotatorIndex;
	}
	
	// now set the image to get
	var imageToGet = pcts.rotatorImages[pcts.currentRotatorIndex];
	
	// set the source of the secondary rotator image
	var sourceStem = "images/rotate/";
	document.getElementById('secondaryImageBody').src = sourceStem + imageToGet;
	
}

pcts.goToSpecificRotator = function(theRotator) {
	// update the rotator assembly with the next rotator in the sequence
	
	// first, pause the rotator sequence so it isn't trying to update during our asynchronous updates
	pcts.stopRotator();
	
	// indicate that rotator operations have started
	pcts.rotatorStarted = true;
	
	// make the headline and headline BG blocks hidden
	try {
		document.getElementById('rotatorTitleBlock').style.visibility = 'hidden';
		document.getElementById('rotatorTitleBlockBG').style.visibility = 'hidden';
	} catch(err) {
		
	}
	
	// rewrite the classes if this is IE
	if (pctsFramework.browser == 'IE') {
		pcts.reWriteSpinnerBG();
	}
	
	// now fade in the loading animation
	// if it is IE, we bring it in almost instantly
	if(pctsFramework.browser == 'IE') {
		$('#rotatorSpinnerRt').fadeIn("fast");
		$('#rotateAnimationRt').fadeIn("fast");
	} else {
		$('#rotatorSpinnerRt').fadeIn("normal");
		$('#rotateAnimationRt').fadeIn("normal");
		
	}
	
	// now determine what the previous rotator in the sequence should be.  
	// this will be the previous item key in the rotator array, which will have been populated shortly after page load.
	
	// first, decrement the current rotator index
	pcts.currentRotatorIndex = theRotator;
	
	// now set the image to get
	var imageToGet = pcts.rotatorImages[pcts.currentRotatorIndex];
	
	// set the source of the secondary rotator image
	var sourceStem = "images/rotate/";
	document.getElementById('secondaryImageBody').src = sourceStem + imageToGet;
	
}

pcts.rotatorImageLoaded = function() {
	// respond to a rotator image being loaded by fading the slide, 
	// getting the rotator text, and setting up for the next rotator in sequence
	
	$('#primaryImageBody').fadeOut("slow", pcts.setUpNextImage());
	
}

pcts.setUpNextImage = function() {
	// set up the next rotator image in a sequence of images
	var theRan = pctsFramework.randomNumber();
	
	var theAccessor = '../accessors/getRotatorData.php?imageName=' + pcts.rotatorImages[pcts.currentRotatorIndex] + '&contentRegion=' + pctsFramework.contentRegion + '&anticache=' + theRan;
	pctsFramework.getData(theAccessor);
	
}

pcts.primaryImageLoaded = function() {
	// respond to a load event on the primary rotator
	$('#primaryImageBody').fadeIn("fast");
	
	if (pcts.rotatorStarted == true) {
		pcts.startRotator();
	}
	
}

pcts.reWriteSpinnerBG = function() {
	// re-write the spinner BG classes using alpha image loader if not already done.
	//var theLftClassName = document.getElementById('rspinLeftContainer').className;
	var theRtClassName = document.getElementById('rspinRightContainer').className;
	
	// if (theLftClassName == 'rotateSpinLeftBG') {
		//document.getElementById('rspinLeftContainer').className = 'rotateSpinLeftBGAlpha';
		// alert('set left classname');
		
	//}
	
	if (theRtClassName == 'rotateSpinRightBG') {
		document.getElementById('rspinRightContainer').className = 'rotateSpinRightBGAlpha';
		// alert('set right classname');
	}
}

pcts.updateRotator = function() {
	// update the rotator whenever the rotator interval fires

	// remember the previous rotator index as the current index
	pcts.prevRotatorIndex = pcts.currentRotatorIndex;

	// advance the current rotatorIndex
	pcts.currentRotatorIndex = pcts.currentRotatorIndex + 1;

	// if the currentRotatorIndex is greater than max Rotator, reset it to zero
	if (pcts.currentRotatorIndex > pcts.maxRotatorIndex) {
		pcts.currentRotatorIndex = 0;
	}

	// if the previousRotator index is greater than maxRotatorIndex
	if (pcts.prevRotatorIndex > pcts.maxRotatorIndex) {
		pcts.prevRotatorIndex = 0;
	}

	// pcts.createDynamicSlidePane(pcts.currentRotatorIndex);

	// before fade, hide the rotatorTitleAssembly
	// it will be shown again after the fade completes
	document.getElementById('rotatorTitleBlock').style.visibility = 'hidden';
	
	// if this is IE, we also need to hide the titleBlock BG
	if (pctsFramework.browserPath == 'ie') {
		document.getElementById('rotatorTitleBlockBG').style.visibility = 'hidden';
	}

	// fade the foreground image to nothing so as to reveal the next image in the sequence
	pcts.fadeOut('rotatorImage2', 100, 0, pcts.rotatorFadeDuration);

	// get and process the rotator data for this image
	
	// first, create an accessor calling string
	var theAccessor = '../accessors/getRotatorData.php?imageName=' + pcts.rotatorImages[pcts.currentRotatorIndex] + '&contentRegion=' + pctsFramework.contentRegion + '&anticache=' + theRan;

	// now get the data
	pctsFramework.getData(theAccessor);
	
	// set the top rotator pane to the currently displayed rotator image
	// first set the image reference
	var theImageRef = pcts.rotatorImages[pcts.prevRotatorIndex];

	// now create a source string
	var theSourceString = "../images/rotate/" + theImageRef;
	
	// finally, load up the image
	document.getElementById('rotatorImage2').src = theSourceString;

	// now set the opacity to so that we are prepared for the next fade
	pcts.setOpacity(100, 'rotatorImage2');

	// alert('foreground image was set to ' + theImageRef);

	// now set up to load the new image into the backgraound rotator pane
	theImageRef = pcts.rotatorImages[pcts.currentRotatorIndex];

	// first, set the source of the rotator image to the propper source
	theSourceString = "../images/rotate/" + theImageRef;

	// now load the background image
	document.getElementById('rotatorImage').src = theSourceString;

}

pcts.setBasicClientData = function() {
	// get and retain basic information about the client
	
	// first, get the height
	pcts.clientHeight = pcts.getClientHeight();

	// now get the width
	pcts.clientWidth = pcts.getClientWidth();

}

pcts.setElementHeights = function() {
	// set the heights of certain page elements
	try {
		document.getElementById('mainBody').style.height = pcts.clientHeight + 'px';

	} catch(err) {

	}
}

pcts.performLoadOperations = function() {
	// perform certain load operations that are desired
	
	try {
		// start a ready timer to tell us when the browser is done loading the page
		pcts.setReadyStateInterval();

	} catch (err) {

	}
	
	// determine if this is IE6 and also if it is SP2 or SP3 - AIloader crshes 6.0 SP1 or less, so we don't want the rotators on
	if(pctsFramework.browser == 'IE' && pctsFramework.browserVersion == 6) {
		if(pctsFramework.minorVersion == ';SP2;' || pctsFramework.minorVersion == ';SP3;') {
			pcts.rotatorOn = false;
			pcts.rotatorThumbsOn = false;
			
		} else {
			pcts.rotatorOn = false;
			pcts.rotatorThumbsOn = false;
			
		}
	}
	
	// turn on the rotator buttons if they are off
	if (!pcts.rotatorOn) {
		// document.getElementById('prev_btn').style.display = 'none';
		// document.getElementById('pButton').style.display = 'none';
		// document.getElementById('next_btn').style.display = 'none';
	}

}

pcts.fadeIn = function(theId, theStart, theEnd, theTime) {
	// fade an object in from one specified opacity to another
	// set the speed of fade
	var theSpeed = Math.round(theTime / 100);
	var theTimer = 0;

	for(i = theStart; i <= theEnd; i++) {
		pcts.fadeTimer = setTimeout("pcts.setOpacity(" + i + ",'" + theId + "')",(theTimer * theSpeed));
		theTimer++;
	}
}

pcts.fadeOut = function(theId, theStart, theEnd, theTime) {
	// fade an object in from one specified opacity to another
	// set the speed of fade
	var theSpeed = Math.round(theTime / 100);
	var theTimer = 0;

	for(i = theStart; i >= theEnd; i--) {
		setTimeout("pcts.setOpacity(" + i + ",'" + theId + "')",(theTimer * theSpeed));
		theTimer++;
	}
}

pcts.setOpacity = function(theOpacity, theId) {
	// this is a cross-browser capable method for setting the opacity of an object
	try {
		var theObject = document.getElementById(theId).style; 
	
		// safari
		theObject.opacity = (theOpacity / 100);
	
		// mozilla
		theObject.MozOpacity = (theOpacity / 100);
	
		// IE
		theObject.filter = "alpha(opacity=" + theOpacity + ")";
	
	} catch(err) {
		// if we wind up here, it is likely the object was not found
		
	}
}

pcts.showSpinner = function() {
	// show the pcts spinner
	var theTop = pcts.clientHeight / 2 - 35 + 'px';
	var theLeft = pcts.clientWidth / 2 - 35 + 'px';

	document.getElementById('pctsSpinner').style.top = theTop;
	document.getElementById('pctsSpinner').style.left = theLeft;

}

pcts.hideSpinner = function() {
	// hide the pcts spinner
	document.getElementById('pctsSpinner').style.top = '-100px';
	document.getElementById('pctsSpinner').style.left = '-100px';

}

pcts.setReadyStateInterval = function() {
	// set up a ready state interval that will keep firing until the document has completely loaded
	// check every 100MS
	pcts.readyState = setInterval("pcts.readyMonitor()", 100);

}

pcts.readyMonitor = function() {
	// check to see if the page has fully loaded / rendered in IE
	// in mozilla, onload doesn't fire until the DOM is loaded.
	var theState = document.readyState;
	
	if (pctsFramework.browserPath == 'ie') {
		if (theState == "complete") {
			
			// clear the readystate interval
			clearInterval(pcts.readyState);
	
			// do some other IE related thing here
			// pcts.setLoadedData();

			// get the first rotator slide data
			pcts.getFirstRotatorSlides();

			// set the opacity state of the rotator buttons
			// pcts.setOpacity(100, 'rotatorButtons');

			// make it visible
			// document.getElementById('rotatorButtons').style.visibility = 'visible';

			// execute any page methods that have been attached
			page.initialOperations();
			
			// record client hit
			// pcts.recordClientHit();
			
		}
	} else {
		clearInterval(pcts.readyState);
		// pcts.setLoadedData();

		// get the first rotator slide data
		pcts.getFirstRotatorSlides();

		// set the opacity state of the rotator buttons
		// pcts.setOpacity(100, 'rotatorButtons');

		// make it visible
		// document.getElementById('rotatorButtons').style.visibility = 'visible';

		// execute any page methods that have been attached
		page.initialOperations();
		
		// record client hit
		// pcts.recordClientHit();
			
	}
}

pcts.recordClientHit = function() {
	// post client hit data to the server for storage
	
	// package up a post statement
	var params = "ip=" + pctsFramework.currentIP;
	params = params + "&userString=" + pctsFramework.userAgent;
	params = params + "&browser=" + pctsFramework.browserParent;
	params = params + "&platform=" + pctsFramework.platform;
	params = params + "&majorVersion=" + pctsFramework.browseCapMajorVersion;
	params = params + "&minorVersion=" + pctsFramework.browseCapMinorVersion;
	params = params + "&isMobile=" + pctsFramework.mobileDevice;
	
	// now set an accessor to post the data
	var theAccessor = "accessors/insertClientHit.php?recordHit=true";
	
	// add a random number so as to prevent IE from using a chached accessor return
	var theRan = pctsFramework.randomNumber();
	theAccessor = theAccessor + "&anticache=" + theRan;
	
	pctsFramework.postData(theAccessor, params);
	
}

pcts.positionElements = function() {
	// position elements upon attached events

	// position the primary footer
	
	// get the window rectangle
	var theHeight = pctsFramework.getClientHeight();

	// get the scrollHeight
	var theScrollHeight = document.body.scrollHeight;

	// alert('window height is: ' + theHeight + ', content height is: ' + theScrollHeight);

	// position based either on scroll height or window height,
	// using the larger value.  This forces the footer always to the bottom
	if( theHeight > theScrollHeight ) {
		document.getElementById('primaryFooter').style.top = theHeight - 120 + 'px';

	} else {
		document.getElementById('primaryFooter').style.top = theScrollHeight - 120 + 'px';
	}
	
	// make the footer visible
	document.getElementById('primaryFooter').style.visibility = 'visible';

}

pcts.positionRotator = function() {
	// position the rotator assembly

	var theWidth = pcts.getClientWidth();
		
	// try to set the left
	try {
		var theLeft = (theWidth - 878) / 2;
		if(document.getElementById('rotatorThumbsLeft')) {
			document.getElementById('rotatorThumbsLeft').style.left = theLeft + 'px';
		}
		
		var theRight = (theWidth / 2) + 70; 
		if(document.getElementById('rotatorThumbsRight')) {
			document.getElementById('rotatorThumbsRight').style.left = theRight + 'px';
		}
		
	} catch(err) {
		// if we wind up here, it is likely because the left got calculated as less than 0;
		var theLeft = 0;
	}
	
	// document.getElementById('pctsWebMainContent2').style.left = theLeft + 'px';

	try {
		// now adjust the position of the rotatorAssembly title block
		
		// first, determine the proper title block left
		var theLeft = pcts.calculateTitleblockLeft(pctsFramework.rotatorLeft);

		// if it is less than 21 px, set it to 21
		if (theLeft < 21) {
			theLeft = 21;
		}
	
		document.getElementById('rotatorTitleBlock').style.left = theLeft + 'px';

		// if this is IE, we also adjust the totle block BG
		if (pctsFramework.browserPath == 'ie') {
			document.getElementById('rotatorTitleBlockBG').style.left = theLeft + 'px';
		}

	} catch(err) {
		// if we wind up here it is most likely because pctsFramework.rotatorLeft has
		// not yet been established.
	}

}

pcts.handleMenuMouse = function(theId, theAction) {
	// handle mouse actions across a main menubar item

	// first create an id for the underline of the menu item
	var theUnder = theId + '_under';

	if (theAction == 'in') {
		// this is a mouse enter event
		document.getElementById(theUnder).className = 'lsep_lbl';
	} else {
		document.getElementById(theUnder).className = '';
	}
		
}

pcts.observeCursorPosition = function(e)	{
	// observe mouse movements and determine the cursor location.
	// if the cursor is within the bounds of a specific region (the rotator),
	// show the rotator controls.
	
	// only do this if the rotator is active
	if (pcts.rotatorThumbsOn) {

		// we get the clientY and the scrollTop, but because IE has to be different we calculate it
		// differently for IE
		if (pctsFramework.browserPath == 'ie') {
			// this is IE
			var theClientY = event.clientY;
			var theClientX = event.clientX;
			var theScroll = document.documentElement.scrollTop;
	
		} else {
			// this is not IE
			var theClientY = e.clientY;
			var theClientX = e.clientX;
			var theScroll = window.pageYOffset;
		}
	
		// we always want to work with numbers offset by the scrollTop so we know
		// where the mouse is with respect to the document not the viewPort.  So, we add
		// theScroll to the Y.
		var theRealPosition = theClientY + theScroll;
	
		// now that we have the actual mouse position, if it is inside the range of the rotator
		// AND the control is not already shown, fade it in.  Otherwise, fade it out.
		
		// first calculate the padding on the left and right.
		var theExcess = (pcts.clientWidth - 878) / 2;
		var theLeftEdge = theExcess;
		var theRightEdge = theExcess + pcts.rotatorWidthConstant;
		
		if (theRealPosition > 88 && theRealPosition < 430 && theClientX > theLeftEdge && theClientX < theRightEdge) {
			window.status = theRealPosition;
	
			// check to see if the control is visible, and if not, fade it in.
			if (pcts.rotatorControlVisible == false) {
				
				// make sure it is entirely transparent
				// pcts.setOpacity(0, 'rotatorButtons');
				
				// set it visible
				// document.getElementById('rotatorButtons').style.visibility = 'visible';
				
				// set the the controlStatus to visible so we only fire once
				// pcts.rotatorControlVisible = true;
	
				// fade in the control
				// pcts.fadeIn('rotatorButtons', 0, 100, 700);
			}
	
		} else {
			// check to see if the control is visible, and if so, fade it out.
			if (pcts.rotatorControlVisible == true) {
				
				// set the the controlStatus to visible so we only fire once
				// pcts.rotatorControlVisible = false;
	
				// set opacity to nothing
				// pcts.setOpacity(0, 'rotatorButtons');
	
				// set it hidden
				// document.getElementById('rotatorButtons').style.visibility = 'hidden';
			}
		}
		
		// handle exposure of the rotatorAssembly thumbs bar
		if (theRealPosition > 327 && theRealPosition < 390 && theClientX > theLeftEdge && theClientX < theRightEdge) {
			if (pcts.rotatorThumbsVisible == false) {
				// display the thumbs bar
				pcts.rotatorThumbsVisible = true;
				pcts.displayRotatorThumbs();	
				
			}
			
		} else {
			// hide the thumbs bar but we do this only if an adjusted criteria is met of > 390 and < 250
			if (theRealPosition < 250 || theRealPosition > 390 || theClientX < theLeftEdge || theClientX > theRightEdge) {
				pcts.rotatorThumbsVisible = false;
				pcts.hideRotatorThumbs();
				
			}
		}
	
	} else {
		// rotator is off, so hide the controls
		// document.getElementById('prev_btn').style.display = 'none';
		// document.getElementById('pButton').style.display = 'none';
		// document.getElementById('next_btn').style.display = 'none';
		
	}
}

pcts.displayRotatorThumbs = function() {
	// display the rotator thumbnail bar
	// alert('display rotator thumbs');
	
	// first, set the display to block
	document.getElementById('rotatorThumbsFade').style.display = 'block';
	
	if (pctsFramework.browser != 'IE') {
		// make sure opacity is zero
		pcts.setOpacity(0, 'rotatorThumbsFade');
		
		// set it visible
		document.getElementById('rotatorThumbsFade').style.visibility = 'visible';
		
		// fade it in
		jQuery("#rotatorThumbsFade").fadeTo("fast", 1.00);
		
	} else {
		
		document.getElementById('rotatorThumbsFade').style.visibility = 'visible';
		// pcts.setOpacity(100, 'rotatorThumbsFade');
		jQuery("#rotatorThumbsFade").fadeTo("fast", 1.00);
		
	}
	
	// show the actual thumbs
	pcts.showRotatorThumbs();
	
}

pcts.hideRotatorThumbs = function() {
	// hide the rotator thumbnail bar
	
	try {
		// set it hidden
		document.getElementById('rotatorThumbsFade').style.visibility = 'hidden';
		
		// make sure opacity is zero
		pcts.setOpacity(0, 'rotatorThumbsFade');
		
		// set the display to none
		document.getElementById('rotatorThumbsFade').style.display = 'none';
		
		// now set the elements visible
		document.getElementById('rotatorThumbsLeft').style.visibility = 'hidden';
		document.getElementById('rotatorThumbsRight').style.visibility = 'hidden';
	
		// iterate through all of the thumb containers and set their opacity to zero
		for (i = 0; i <= 7; i ++ ) {
			var theTargetID = 'rThumbBlock_' + i;
			pcts.setOpacity(0, theTargetID);
		}
		
		// apply the top to the thumbs assemblies
		document.getElementById('rotatorThumbsLeft').style.top = '-120px';
		document.getElementById('rotatorThumbsRight').style.top = '-120px';
	
		// indicate that the thumbs are not shown
		pcts.thumbsVisible = false;
	
		// reset the iterators
		pcts.thumbIterator = 4;
		pcts.thumbOffset = 3;

		// deal with the rotator balloon, which may be orphaned by quick mouse movements
		// hide the balloon if shown
		document.getElementById('rBalloon').style.visibility = 'hidden';
		document.getElementById('balloonBody').style.visibility = 'hidden';
		document.getElementById('balloonHead').style.visibility = 'hidden';
			
		// clear any timrouts for the fade function
		window.clearTimeout(pcts.fadeTimer);
			
		// set its opacity then move it
		pcts.setOpacity(0, 'rBalloon');
		document.getElementById('rBalloon').style.top = '-120px';

	} catch(err) {
		// in many browsers an event like this will get caled several times, sometimes before page load is complete and
		// then again after.  Winding up here means this likely occurred.
	}
	
}

pcts.setNoPropogate = function(theEvent) {
	// cancel an event and stop it from bubbling
	var theEvent; // the event fired
	
	try {// first figure out if this is IE and set the cancelBubble property
		if (pctsFramework.browserPath == 'ie' ) {
			theEvent.cancelBubble = true;
			
		}
		
		// if it isn't IE stopPropagation
		if (theEvent.stopPropagation) {
			//alert('this is firefox');
			theEvent.stopPropagation();
	}
	
	} catch(err) {
		// if we wind up here, there was no bubbled event to cancel
	}
}

pcts.constructRotatorThumbs = function() {
	// construct the rotator thumbnail bar
	// alert('building thumbs');
	var theThumbs = pcts.allRotatorThumbs.length;
	// alert(pcts.allRotatorThumbs);
	
	var thumbSrc1 = "<div id=\"";
	var thumbSrc2 = "\" style=\"width:";
	var thumbSrc3 = "px; height:";
	var thumbSrc4 = "px;\" class=\"";
	var thumbSrc5 = "\" onClick=\"page.handleThumbClick(this.id);\"";

	if (pctsFramework.browserPath == 'ie') {
		var mouseIn = " onmouseenter";
		var mouseOut = " onmouseleave";
	} else {
		var mouseIn = " onmouseover";
		var mouseOut = " onmouseout";
	}

	var thumbSrc6 = mouseIn + "=\"page.handleThumbMouseAction(this.id, 'in');\"";
	var thumbSrc7 = mouseOut + "=\"page.handleThumbMouseAction(this.id, 'out');\"";

	var thumbSrc8 = "></div>";
	
	// walk through the array of thumbnail data and construct the HTML for those thumbs.
	for( i = 0; i < theThumbs; i ++) {
		var theString = pcts.allRotatorThumbs[i];
		var theComponents = theString.split(',');
		
		var theId = theComponents[0];
		var theClass = theComponents[1];
		var theWidth = theComponents[2];
		var theHeight = theComponents[3];
		
		// we now have the basic parts for a DIV to contain the thumbnail
		// so, we construct it
		var theDiv = thumbSrc1 + theId + '_' + i + thumbSrc2 + theWidth + thumbSrc3 + theHeight + thumbSrc4 + theClass + thumbSrc5 + thumbSrc6 + thumbSrc7 + thumbSrc8;
		
		
		// store the HTML in the thumb array
		pcts.allRotatorThumbs[i] = theDiv;

	}
	
	// distribute the items to the rotator thumbnail assemblies
	pcts.distributeRotatorThumbs();
	
}

pcts.showRotatorThumbs = function() {
	// display the rotator thumbnails
	
	// first make sure the assemblies to display:block
	// document.getElementById('rotatorThumbsLeft').style.display = 'block';
	// document.getElementById('rotatorThumbsRight').style.display = 'block';

	// now determine what the height of the assemblies is
	var theHeight = document.getElementById('rotatorThumbsLeft').offsetHeight - 7;
	
	// now calculate what the top should be
	var theTop = 367 - theHeight;
	
	// alert(theTop);
	
	// apply the top to the thumbs assemblies
	document.getElementById('rotatorThumbsLeft').style.top = theTop + 'px';
	document.getElementById('rotatorThumbsRight').style.top = theTop + 'px';
	
	// now set the elements visible
	document.getElementById('rotatorThumbsLeft').style.visibility = 'visible';
	document.getElementById('rotatorThumbsRight').style.visibility = 'visible';
	
	// perform a load animation for the thumbs
	pcts.doThumbAnimation();
}

pcts.doThumbAnimation = function() {
	// show the thumbs in an animated sequence
	
	//pcts.fadeIn('rotatorButtons', 0, 100, 700);
	// iterate through the thumbnail cotainers from the inside out, starting at the 4th
	// ID (#5)

	if (pctsFramework.browser != 'IE') {
		if ( pcts.thumbIterator <= 7 ) {
			// alert('executing thumb iteration');
	
			var id1 = '#rThumbBlock_' + pcts.thumbIterator; 
			var id2 = '#rThumbBlock_' + pcts.thumbOffset; 
	
			// var fadeInString1 = "pcts.fadeIn(" + "'" + id1 + "', " + 0 + ", " + 52 + ", " + 300 + ")";
			// var fadeInString2 = "pcts.fadeIn(" + "'" + id2 + "', " + 0 + ", " + 52 + ", " + 300 + ")";
	
			jQuery(id1).fadeTo("fast", 0.52);
			jQuery(id2).fadeTo("fast", 0.52);
			//pcts.setOpacity(52, id1);
			//pcts.setOpacity(52, id2);
	
			// setTimeout("pcts.fadeIn(" + "'" + id1 + "', " + 0 + ", " + 52 + ", " + 300 + ")", 300);
			// setTimeout("pcts.fadeIn(" + "'" + id2 + "', " + 0 + ", " + 52 + ", " + 300 + ")", 300);
			
			//	wait some time then trigger display of the next thumb set
			pctsFramework.thumbFade = setTimeout("pcts.doThumbAnimation()", 70);
			
			// advance the iterator
			pcts.thumbIterator = pcts.thumbIterator +  1;
	
			// decrement the offset
			pcts.thumbOffset = pcts.thumbOffset - 1;
	
		} else {
			// mark that the thumbs are shown
			pcts.thumbsVisible = true;
			window.clearTimeout(pctsFramework.thumbFade);
	
		}
		
	} else {
		jQuery('#rThumbBlock_0').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_1').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_2').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_3').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_4').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_5').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_6').fadeTo("fast", 0.52);
		jQuery('#rThumbBlock_7').fadeTo("fast", 0.52);
		pcts.thumbsVisible = true;
	}
}

pcts.distributeRotatorThumbs = function() {
	// distribute the rotator thumbnail content into the rotator assemblies
	// as appropriate to the number of rotators.
	
	// first, determine the number of thumbs
	var theThumbs = pcts.allRotatorThumbs.length;
	
	// now divide the thumbs by 2 to get the number of items for each assembly
	var theItemSplit = theThumbs / 2;
	
	// now we round down to the nearest integer, which gives us the number of items
	// for the left assembly
	var theLeftItems = Math.floor(theItemSplit);
	
	// round up for the left assembly
	// var theLeftItems = Math.round(theItemSplit);
	
	// the right assembly will now be the number of thumbs minus the left items
	var theRightItems = theThumbs - theLeftItems;
	// now distribute the items into the left and right assemblies.  
	// First, determine where to start.  This will be on the left, and will be the max
	// left items minus the actual.
	var theStart = 4 - theLeftItems;
	
	for (i = 0; i < theThumbs; i ++) {
		// step through the thumbs array and write the data into the thumbnail assemblies
		
		if (theStart > 0) {
			var theTarget = i + 1;
			
		} else {
			var theTarget = i;
			
		}
		var theContent = pcts.allRotatorThumbs[i];
		var theTargetID = 'rThumbBlock_' + theTarget;
		
		try {
			document.getElementById(theTargetID).innerHTML = theContent;
		
			// set the opacity of the thumbnail block
			pcts.setOpacity(52, theTargetID);
		} catch(err) {
			
		}
	
	}
	
	// finished distributing thumbs
	// alert('done distributing thumbs');
}

pcts.handleReturnedThumbInfo = function(parentObject, theLeft, theTop, thumbHead, thumbHeadDisplay, thumbBody, thumbBodyDisplay) {
	// show balloon content as the result of a content call to an accessor

	// first, set the element values
	document.getElementById('balloonHeadRow').style.display = thumbHeadDisplay;
	document.getElementById('balloonHead').innerHTML = thumbHead;
	document.getElementById('balloonBodyRow').style.display = thumbBodyDisplay;
	document.getElementById('balloonBody').innerHTML = thumbBody;

	// if there is anything to display, show the balloon
	// first determine how high the balloon is
	var theHeight = document.getElementById('rBalloon').offsetHeight;
	
	// calculate display offsets based upon the actual size of the balloon
	var theAdjustedTop = theTop - (theHeight - 12);
	var theAdjustedLeft = (theLeft * 1) + 21;
	
	// set the balloon top and left
	document.getElementById('rBalloon').style.top = theAdjustedTop + 'px';
	document.getElementById('rBalloon').style.left = theAdjustedLeft + 'px';

	// mak sure the primary balloon elements are visible
	document.getElementById('balloonBody').style.visibility = 'visible';
	document.getElementById('balloonHead').style.visibility = 'visible';
		
	// pcts.setOpacity(0, 'rBalloon');
	
}

// --- stupid hacks -------

// force firefox to listen for mousemovements
if (!window.attachEvent) {
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = pcts.observeCursorPosition;
}

// --- attached events -------

// we attach inside an if statement because IE handles event listeners differently from other browsers.

if (window.attachEvent) {
	// attached events for IE
	window.attachEvent("onload", pcts.setBasicClientData);
	window.attachEvent("onload", pcts.setElementHeights);
	window.attachEvent("onload", pcts.performLoadOperations);
	window.attachEvent("onload", pcts.positionElements);
	window.attachEvent("onload", pcts.positionRotator);
	window.attachEvent("onload", pcts.initiateRotateInterval);
	window.attachEvent("onresize", pcts.setBasicClientData);
	window.attachEvent("onresize", pcts.setElementHeights);
	window.attachEvent("onresize", pcts.positionRotator);
	document.attachEvent("onmousemove", pcts.observeCursorPosition)
} else {
	// attached events for other browsers
	window.addEventListener('load', pcts.setBasicClientData, false);
	window.addEventListener('load', pcts.setElementHeights, false);
	window.addEventListener('load', pcts.performLoadOperations, false);
	window.addEventListener('load', pcts.positionElements, false);
	window.addEventListener('load', pcts.positionRotator, false);
	window.addEventListener('load', pcts.initiateRotateInterval, false);
	window.addEventListener('resize', pcts.setBasicClientData, false);
	window.addEventListener('resize', pcts.setElementHeights, false);
	window.addEventListener('resize', pcts.positionRotator, false);
	window.addEventListener('mousemove', pcts.observeCursorPosition, false);
}