// JavaScript Document

function updateFieldset(input)
{
	UA = navigator.userAgent;
	toUpdate = input.split(',');
	
	if (UA.indexOf("Chrome") != -1)
	{
		// Google Chrome
		c = "fieldsetChrome";
	}
	else if (UA.indexOf("Opera") != -1)
	{
		// Opera
		c = "fieldsetOpera";
	}
	else if (UA.indexOf("Safari") != -1)
	{
		// Safari
		c = "fieldsetSafari";
	}
	else if (UA.indexOf("MSIE") != -1)
	{
		// Microsoft Internet Explorer
		c = "fieldsetIE";
	}
	else if (UA.indexOf("Firefox") != -1)
	{
		// Mozilla Firefox
		c = "fieldsetFF";
	}
	else
	{
		// Some other browser... no luck
		// Take a wild stab in the dark
		c = "fieldsetOthers";
	}
	
	// Loop and update all those fieldsets
	for (i=0;i<toUpdate.length;i++)
	{
		f = document.getElementById(toUpdate[i]);
		f.className += " "+c;
	}
}

/* Image gallery functions */

// Inspired from http://www.frenchpropertyonline.eu/index.php?option=com_hotproperty&task=view&id=178&Itemid=28
function show_photo (this_object, photo_arr, photo_index) {
	
	// Get the required objects
	photodisplay_div = document.getElementById("photo"+photo_arr['id']+"display");
	photolabel_div = document.getElementById("photo"+photo_arr['id']+"label");
	
	// Change the photo displayed and change the label
	photodisplay_div.innerHTML = '<img src="' + photo_arr[photo_index][0] + '">';
	photolabel_div.innerHTML = photo_arr[photo_index][1] + '&nbsp;';
	
	// Select the thumbnail with a blue box
	photo_preview_unselect(photo1);
	this_object.className = "imgselect";
	
}

function photo_preview_unselect (photo_arr) {
	
	photopreview_div = document.getElementById('photo'+photo_arr['id']+'preview');
	photopreview_imgs = photopreview_div.getElementsByTagName("img");
	
	for (i=0; i<photopreview_imgs.length; i++) {
		// Runs for every <img> tag in preview section
		// In other words, for every thumbnail
		photopreview_imgs[i].className = "imgunselect";
	}
	
}