// JavaScript Document

/*function GetCaptionAndDisplayText( prop_or_loc, id )
{
  var callbackCaption =
  {
  	success : function(o)
  	{
  	  if( o.responseText )
			{
				var theText = o.responseText;
				var theText_array = theText.split( '|-|', 2);
				var theCaption = document.getElementById('picture-viewer-text-caption-display');
				var theDisplayText = document.getElementById('picture-viewer-text-display');

				if( theCaption && theText_array ) theCaption.innerHTML = theText_array[0];
				if( theDisplayText ) theDisplayText.innerHTML = theText_array[1];
			} else {
        alert("Invalid return\n\nresponse: " + o.responseText);
			}
 	},
  	failure : function(o)
  	{
  	  alert('Failed: ' + url + '\n\n' + o.responseText);
  	}
  }

  var url='/widgets/picturebrowser/assets/php/gettext.php';
	var postvars = 'prop_or_loc=' + prop_or_loc + '&id=' + id;
  var request =
		YAHOO.util.Connect.asyncRequest('POST', url, callbackCaption, postvars);
}*/


	var doAutoPlay = function(strCarousel)
	{
		setCarouselItemsClassReset();
		switch(strCarousel)
		{
			case "locations":
				if(carouselB)
				{
					carouselB.startAutoPlay(100);
				}
				break;
			case "sample_homes":
				if(carouselA)
				{
					carouselA.startAutoPlay(100);
				}
				break;
		}
	}
	var doAutoStop = function(strCarousel)
	{
		switch(strCarousel)
		{
			case "locations":
				if(carouselB)
					carouselB.stopAutoPlay();
				break;
			case "sample_homes":
				if(carouselA)
					carouselA.stopAutoPlay();
				break;
		}
	}
	var reverseCarousel = function(strCarousel)
	{
		setCarouselItemsClassReset();
		switch(strCarousel)
		{
			case "locations":
				if(carouselB)
				{
					//get count of items in the carousel
					//scrollBackward not working
		//			carouselB.scrollTo(0);
				}
				break;
			case "sample_homes":
				if(carouselA)
				{
	//				carouselA.scrollTo(0);
				}
				break;
		}
	}


	/*
		this is called when a tab is selected on the picture browser
		the function will randomly select a set from the pertinent carousel
		and load it into the contentflow
	*/
	var pbAutoSelect = function(theCarousel, itemArray)
	{
		var itemCount = 1;
		var theRandomInt = 0;
		if(theCarousel)
		{
			//get number of items in the passed carousel
			allItems = theCarousel.getItems;
			if(itemArray)
			{
				itemCount = itemArray.length;
				//randomize and get a value for which item to select
				theRandomInt = getRandomInt(0, itemCount);
				//make sure everything is unselected in every carousel
				unselectCarouselItems();
				//move the carousel to view that item in the viewport & select the item
				//void scrollTo ( item , dontSelect )
				theCarousel.scrollTo(theRandomInt, false);
				var theItem = itemArray[theRandomInt];
				if(theItem)
				{
					var myItem = document.getElementById(theItem);
					myItem.className = '';

					var myATag = document.getElementById('href-' + theItem);
					if(myATag)
					{
						var theFunctionCall = myATag.onclick;
						if(theFunctionCall)
						{
							theFunctionCall(); //load the selected set into the contentflow
						}
					}
				}
			} // if(itemsArray)
		} //if(theCarousel
	}//var pbAutoSelect

	/* return an int generated by Math.random() that will be between intLow and intHigh inclusive */
	var getRandomInt = function(intLow, intHigh)
	{
		var r=Math.floor( Math.random() * ( (intHigh + 1) - intLow) );

		return r;
	}
