function gtaInit() {
	$("gtaFetch").value = "false";
	$("gtaLeftIndex").value = "-1";
	setProgressBar();

	var progressDrag = new Drag.Move("indicator", {'container': $("progress")});
	
	progressDrag.addEvent('onStart', function() {

        if (isBlurOn() || (areWeInRegularSearch() && SearchAjax.inProgress)) return false;

        DISPATCHER.fire("STOPALL");
        DISPATCHER.fire("START_SLIDER");

        ELOCKS.set("UI_IS_BUSY");
        if ($("traffic_light").value == "go") return false;

        $("gti_toggle_wrapper").className = "hidden";
		$("updateProgressBarNumbers").value = "true";
		$("check_hash_history").value = "false";

		var gti = $("gti_wrapper");
		if (gti.className == "visible") {
			gti.className = "hidden";
			$("progress_indicator").className = "visible";
			$("gti_toggle").innerHTML = i18n.gtaGoToPosition;
		}

	});

    progressDrag.addEvent('onComplete', function() {

        $("updateProgressBarNumbers").value = "false";
		$("check_hash_history").value = "true";

		var gti_wrap = $("gti_toggle_wrapper");
		var indicator = $("indicator");

		if ($("dynamic_tracker").value != "false") {
			iWidth = parseInt(indicator.style.width);
					
			if (iWidth < 110)
				iWidth = 110;

			gti_wrap.style.left = parseInt(indicator.style.left) + iWidth + "px";
		}

		gti_wrap.className = "visible";

		if (!isBlurOn() && $("traffic_light").value != "go") {
			closeFeatureImage();

			sliderLeft = parseInt($("progress_left").innerHTML);

			setLastAction(application.events.GTA);

			slideTo(sliderLeft);
		}
		return true;
	});	
	
	
	/*************************************************************************/
	/** Go-to-index.														**/
	
	$("gti_toggle").onclick = function(e) {	
		var gti = $("gti_wrapper");
		var prog = $("progress_indicator");
		if (gti.className == "hidden") {
			gti.className = "visible";
			this.innerHTML = i18n.gtaHidePosition;
		} else {
			gti.className = "hidden";
			prog.className = "visible";
			this.innerHTML = i18n.gtaGoToPosition;
		}
	
		// Prevent this from bubbling up to the GTA handle.
		if (!e) var e = window.event;
		e.cancelBubble = true;
		if (e.stopPropagation) e.stopPropagation();
		
		return false;
	}
	$("gti_form").onsubmit = function() {
		var pos = 0;

		if (this.gti_type.value == "i") {
			pos = parseInt(this.gti.value);
			setLastAction(application.events.GTI);
		} else {
			setLastAction(application.events.GTP);
			var gti = parseInt(this.gti.value);
			
			if (gti > 100) gti = 100;
			else if (gti < 0) gti = 0;
			
			var ntr = parseInt($("totalNumResults").value);
			
			pos = (gti / 100) * ntr;

			var leftIndex = getLeftIndex();
			var nps = getRightIndex(leftIndex) - leftIndex;
			
			pos -= nps / 2;
			pos = Math.round(pos);
		}
		
		$("gti_wrapper").className = "hidden";
		$("progress_indicator").className = "visible";

		$("gti_toggle").innerHTML = i18n.gtaGoToPosition;

		if (pos == 0)
			pos++;
			
		if (!pos)
			return false;
				
		window.setTimeout("closeFeatureImage(); slideTo(" + --pos + ");", 10);
		return false;		
	}
	
}

function slideTo(rawIndex) {

    debug ( "*********** slideTo UI_IS_BUSY ");
    ELOCKS.set("UI_IS_BUSY");

    var gtaFetch = $("gtaFetch");
	gtaFetch.value = "true";

	// this is the same calculation used in resetVisibility() -- someday we should abstract this a lot more than it currently is
	var currentPage = getCurrentPage();
	offScreenFactor = getOffScreenFactor();
	leftIndex = getLeftIndex();
	rightIndex = getRightIndex(leftIndex);
	
	leftIndex -= offScreenFactor;
	rightIndex += offScreenFactor;

	// insurance policy
	while ($("img_" + leftIndex))
		leftIndex--;
	
	while ($("img_" + rightIndex))
		rightIndex++;

	$("gcLeftIndex").value = leftIndex;
	$("gcRightIndex").value = rightIndex;

	index = parseInt(rawIndex);
    if(isNaN(index)) index = 0; //must slide somewhere EM-716
	
	if (index > parseInt($(currentPage.id + "_offset").value) + application.colSize * Math.floor(Math.abs(parseInt(currentPage.style.left)) / application.squareSize))
		$("direction").value = -1;
	else
		$("direction").value = 1;
	
	numResults = parseInt($("totalNumResults").value);
	rps = parseInt($("resultsPerSheet").value);
	
	rpp = getRightIndex(0) + 1;  // same thing, right?
	
	if (numResults <= rpp) {
		debug("[slideTo] numResults (" + numResults + ") is less than results per page (" + rpp + ")");

        ELOCKS.unset("UI_IS_BUSY");
        debug ("------------------- slideTo unset UI_IS_BUSY 1");
        return;
	}
	
	var lastPage = false;
	
	if (index < 0) 
		index = 0;
	else if (index >= numResults - rpp) {
		index = numResults - rpp;
		lastPage = true;
	}
	
	while (index % application.colSize != 0)
		index--;

	//debug("[SLIDE] Sliding. Requested value: " + rawIndex + ", refined value: " + index);


	// figure out which page we're on
	pageNum = Math.floor(index / rps)
	
	if (pageNum % 2 == 0) { // even
		pageID = "search_results_a";
		altpageID = "search_results_b";
	} else {
		pageID = "search_results_b";
		altpageID = "search_results_a";
	}
	
	$(pageID + "_offset").value = newOffset = pageNum * rps;
	
	newLeft = -1 * (index - newOffset) * application.squareSize / application.colSize;
	
	if (lastPage)
		newLeft -= application.squareSize; // - (ww() % application.squareSize); <-- EM-573: we now align to left at the end of results.
	
	$(pageID).style.left = newLeft + "px";
	
	if (index % rps > rps / 2) {
		$(altpageID).style.left = (newLeft + rps * application.squareSize / application.colSize) + "px";
		$(altpageID + "_offset").value = newOffset + rps;
	} else {
		$(altpageID).style.left = (newLeft - rps * application.squareSize / application.colSize) + "px";
		$(altpageID + "_offset").value = newOffset - rps;
	}
	
	//debug("[SLIDE] Primary page [" + pageID + "] left/offset is " + newLeft + "/" + newOffset);
	//debug("[SLIDE] Alternate page [" + altpageID + "] left/offset is " + $(altpageID).style.left + "/" + $(altpageID + "_offset").value);	

	resetVisibility({complete:true});
	setProgressBar();

	gtaFetch.value = "false";
	
	if (!isBlurOn())
		$("gtaLeftIndex").value = "-1";


}

