// JavaScript Document

//contentflow_vtour.php ~60 onclick="getSlideShow( ~79 onclick="getSlideShow(
//contentflow.php ~106 onClick='getVirtualTour( ~111 onClick='getPropLoc( ~125 onClick='getVirtualTour(
//cflowvtour_page.js ~114 getSlideShow
//myflow.js ~105 getVirtualTour and ~119 getPropLoc

/*
dev_prop_id: string: id from the property or devcode table in vdprop (required)
prop_or_loc: is this a property or a location/resort? prop=property, loc=location/resort. default: loc (optional)
display_setLabel: the set label is the box that appears in the upper right corner of the image display. this setting allows you to turn it of and on. true = on false = off default is false. (optional)
label_text: text to display on the set label (optional)
label_link: link to link to from the set label (optional)
display_title: show titles or not. true =  show titles. false = dont show titles. default = false  (optional)
title_position: top, bottom, both. default null  (optional)
display_nav_buttons: show slideshow/vtour/location/video button set that is on the left side of the display. true=display, false = do not display. default=true (optional)
display_proploc_button: show location button on the left side of the display. true=display, false = do not display. default=false (optional)
proploc_link_id: if it is a property (prop_or_loc == 'prop') we dont need to pass this. if it is a loc we need to know which prop to link back to--so DO need to pass it then (optional)
slideshow_speed: slideshow interval. default: 5000
display_photo_date: boolean. show the date from the photo file in the content flow. default: false
*/

function GetNewImageSet( el, dev_prop_id, prop_or_loc, display_set_label, label_text, label_link, display_title, title_position,
                          display_nav_buttons, display_proploc_button, proploc_link_id, slideshow_speed, display_photo_date )
{
	if ( label_link === undefined ) { label_link = ''; }
	if ( display_proploc_button === undefined ) { display_proploc_button = 'false'; }
	if ( slideshow_speed === undefined ) { slideshow_speed = null; }
	if ( display_photo_date === undefined ) { display_photo_date = null; }

	//grey out the non-selected items in the carousel (or all carousels)
	var selectedElement = document.getElementById(el);
	if(selectedElement)
	{
		unselectCarouselItems();
		var theClassName = selectedElement.className;
		if( theClassName == '' || theClassName.indexOf('not_selected',0) != -1 )
			selectedElement.className = '';
	}

//we are going to end up with multiple contentflows. how do we differentiate effectively?
  var url='/widgets/contentflow/init.php';
 	url = url + '?id=' + dev_prop_id + '&prop_or_loc=' + prop_or_loc + '&display_setLabel=' + display_set_label + '&label_text=' + label_text + '&label_link=' + label_link + '&display_title=' + display_title + '&title_position=' + title_position +	'&display_nav_buttons=' + display_nav_buttons + '&display_proploc_button=' + display_proploc_button + '&proploc_link_id=' + proploc_link_id + "&slideshow_speed=" + slideshow_speed + "&display_photo_date=" + display_photo_date;

	theIframe = document.getElementById('picbrowser-iframe');
	theIframe.src = url;

	//use the prop_or_loc bool tro determine which query to use
	//use prop_loc_id to find the property or the location
	//GetCaptionAndDisplayText( prop_or_loc, prop_loc_id );
}

/*
  el is selected element

*/
function getAVideo( el, dev_prop_id, prop_or_loc, display_photo_date )
{
	//grey out the non-selected items in the carousel (or all carousels)
	var selectedElement = document.getElementById(el);
	if(selectedElement)
	{
		unselectCarouselItems();
		selectedElement.className = '';
	}

  var url='/widgets/contentflow/videoplayer.php';
 	url = url + '?id=' + dev_prop_id + '&prop_or_loc=' + prop_or_loc + '&display_setLabel=false&label_text=&label_link=&display_title=false&display_nav_buttons=false&display_photo_date=' + display_photo_date;

	theIframe = document.getElementById('picbrowser-iframe');
	theIframe.src = url;

}


/**
 * Called when the carousel has determined that the previous button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: prevButtonStateHandler
 **/
var handlePrevButtonState = function(type, args) {

	var enabling = args[0];
	var leftImage = args[1];
	if(enabling) {
		leftImage.src = "/widgets/carousels/assets/images/go_back_icon.png";
	} else {
		leftImage.src = "/widgets/carousels/assets/images/go_back_disabled_icon.png";
	}
};

/**
 * Called when the carousel has determined that the next button
 * state should be changed.
 * Specified to the carousel as the configuration
 * parameter: nextButtonStateHandler
 **/
var handleNextButtonState = function(type, args) {

	var enabling = args[0];
	var rightImage = args[1];

	if(enabling) {
		rightImage.src = "/widgets/carousels/assets/images/go_forward_icon.png";
	} else {
		rightImage.src = "/widgets/carousels/assets/images/go_forward_disabled_icon.png";
	}
};

var unselectCarouselItems = function()
{
	var items_array = new Array();

	try{
		if(carousel_items_video_homepage)
		{
			items_array = carousel_items_video_homepage;
			for(var i in items_array)
			{
				var theElement = document.getElementById(items_array[i]);
				if(theElement) theElement.className = 'not_selected';
			}
		}
	}catch(e){}

	try{
		if(carousel_items_info)
		{
			items_array = carousel_items_info;
			for(var i in items_array)
			{
				var theElement = document.getElementById(items_array[i]);
				if(theElement) theElement.className = 'not_selected';
			}
		}
	}catch(e){}

	try{
		if(carousel_items_locations)
		{
			items_array = carousel_items_locations;
			for(var i in items_array)
			{
				var theElement = document.getElementById(items_array[i]);
				if(theElement) theElement.className = 'not_selected';
			}
		}
	}catch(e){}

	try{
		if(carousel_items_sample_homes)
		{
			items_array = carousel_items_sample_homes;
			for(var i in items_array)
			{
				var theElement = document.getElementById(items_array[i]);
				if(theElement) theElement.className = 'not_selected';
			}
		}
	}catch(e){}

	try{
		if(carousel_items_aboutus)
		{
			items_array = carousel_items_aboutus;
			for(var i in items_array)
			{
				var theElement = document.getElementById(items_array[i]);
				if(theElement) theElement.className = 'not_selected';
			}
		}
	}catch(e){}

}

var setCarouselItemsClassReset = function()
{
	var items_array = new Array();

	items_array = carousel_items_video_homepage;
	for(var i in items_array)
	{
		var theElement = document.getElementById(items_array[i]);
		if(theElement) theElement.className = '';
	}

	items_array = carousel_items_info;
	for(var i in items_array)
	{
		var theElement = document.getElementById(items_array[i]);
		if(theElement) theElement.className = '';
	}

	items_array = carousel_items_locations;
	for(var i in items_array)
	{
		var theElement = document.getElementById(items_array[i]);
		if(theElement) theElement.className = '';
	}

	items_array = carousel_items_sample_homes;
	for(var i in items_array)
	{
		var theElement = document.getElementById(items_array[i]);
		if(theElement) theElement.className = '';
	}

	items_array = carousel_items_aboutus;
	for(var i in items_array)
	{
		var theElement = document.getElementById(items_array[i]);
		if(theElement) theElement.className = '';
	}
}
