// Requires: guiLibrary.js


// Global variables used for interior/exterior picture galleries.
var currPicture = 0;
var numPictures = 0;
var thePictures = new Array(10);
var theTexts = new Array(10);


// Function: setLinkColor.
// Sets the color of a link to "emulate" that it's active.
function setLinkColor(linkName)
{
	var color = 0xf0037f;
	var theLink = fetchObjectById(linkName);
	theLink.style.color = "#" + color.toString(16);
}

// Function: initializeInteriorPictures.
// Initializes the picture arrays used for holding the picture collection.
function initializeInteriorPictures()
{
	// Add the pictures.
  thePictures[0] = "LivingRm_small.jpg";
	thePictures[1] = "dining-living_small.jpg";
	thePictures[2] = "balcony_small.jpg";
	thePictures[3] = "kitchen_small.jpg";
	thePictures[4] = "MasterBed_small.jpg";
	thePictures[5] = "2ndBedroom_small.jpg";
	thePictures[6] = "2ndBedroom2_small.jpg";
  
  // Add the picture descriptions. 
  theTexts[0] = "<b>Living room</b>&nbsp; Sunlit and serene, with windows and balcony looking out over panoramic views of the city, ocean, and mountains.";
	theTexts[1] = "<b>Dining & living room</b>&nbsp; Decorated with the simple elegance of rattan and bamboo, blended with warm-colored Mexican décor.";
	theTexts[2] = "<b>Balcony</b>&nbsp; Bright, spacious balcony with breathtaking views.";
	theTexts[3] = "<b>Kitchen</b>&nbsp; Fully-equipped for all your cooking and dining needs. Laundry room is adjoining.";
	theTexts[4] = "<b>Master bedroom</b>&nbsp; Furnished with a king-size bed, with adjoining walk-in closet, ensuite bathroom, and large window overlooking the landscaped grounds.";
	theTexts[5] = "<b>Second bedroom</b>&nbsp; Bright and cheerful, furnished with 2 single beds and a large closet.";
	theTexts[6] = "<b>Second bedroom</b>&nbsp; A colorful stained glass window adds to the charm.";
	
	numPictures = 7;
	
	theTextObject = fetchObjectById('numPicturesText');
	theTextObject.innerHTML = "Pictures in gallery: " + numPictures;
}

// Function: initializeExteriorPictures.
function initializeExteriorPictures()
{
	var theTextObject;

	// Add the pictures.
  thePictures[0] = "entrance_small.jpg";
	thePictures[1] = "walkway_small.jpg";
  thePictures[2] = "pool_small.jpg";
	thePictures[3] = "palapa_small.jpg";
	thePictures[4] = "landscaping_small.jpg";
	thePictures[5] = "view_small.jpg";
	
  // Add the picture descriptions.
  theTexts[0] = "<b>Entrance</b>&nbsp; A grand 100-year old banyan tree greets you at the entrance.";
	theTexts[1] = "<b>Landscaped grounds</b>&nbsp; flourish with tropical flowers and fruit trees.";
	theTexts[2] = "<b>Infinity pool</b>, swim-up bar and Jacuzzi, with stunning 360=degree views of the blue Banderas, pueblo-like town of Vallarta and the surrounding Sierra Madre.";
	theTexts[3] = "Relax in the shade of the large poolside palapa.";
	theTexts[4] = "Hibiscus, buganvilias, jasmine, mango, banana and papaya trees create a colorful and fragrant landscape.";
	theTexts[5] = "Lush tropical greenery offers privacy and calm from the bustle of the town below.";

	numPictures = 6;
}

// Function: displayNextPicture.
function displayNextPicture()
{
	// Move to the next picture in the collection.
	if (currPicture < numPictures-1)
		currPicture++;
	else
		currPicture = 0;
	
	// Display the new current picture.
	displayCurrPicture();
}

// Function: displayPrevPicture.
function displayPrevPicture()
{
	// Move to the next picture in the collection.
	if (currPicture > 0)
		currPicture--;
	else
		currPicture = numPictures-1;
	
	// Display the new current picture.
	displayCurrPicture();
}

// Function: displayCurrPicture.
function displayCurrPicture()
{
	var theTextObject;
	var theImageObject;	
	
	// Set the picture description.
	theTextObject = fetchObjectById("pictureDescription");
	theTextObject.innerHTML = theTexts[currPicture];
	
	theTextObject = fetchObjectById('numPicturesText');
	theTextObject.innerHTML = "Picture " + (currPicture + 1) + " of " + numPictures;
	
	// Calculate name of the big version of the picture.
	bigPictureName = thePictures[currPicture].substring(0, thePictures[currPicture].length - 10);
	bigPictureName += "_big.jpg";
	bigPictureName = "img/photos/" + bigPictureName;
	
	// Load the current picture into the image element.
	theImageObject = fetchObjectById("pictureHolder");
	theImageObject.onclick = function() { openInNewWindow('pictureEnlarged.php?picture=' + bigPictureName, 618, 372); }
	theImageObject.src = "img/photos/" + thePictures[currPicture];
}

// Function: validateContactPage.
function validateContactPage()
{
	var theForm = document.forms["contactForm"];
	
	if (theForm.senderName.value == "" || theForm.senderEmail.value == "" || theForm.arrivalDate.value == "" || theForm.departureDate.value == "" || theForm.senderPhoneNumber.value == "")
	{
		alert("The following fields are mandatory and must be filled in:\n\n- Your name\n- Your email address\n- Arrival date\n- Departure date\n- Your phone number");
		return false;
	}
	
	return true;
}
