/*________________________________________________________________________
Image Flipping Functions
________________________________________________________________________*/
function imageItem(image_location) {
	this.image_item = new Image();
	this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
	return(imageObj.image_item.src)
}
function generate(x, y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}
function getNextImage() {	
	if (random_display) {
		image_index = generate(0, number_of_image-1);
	}else{
		image_index = (image_index+1) % number_of_image;
	}
	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
}
function rotateImage(place) {
	var new_image = getNextImage();
	document[place].src = new_image;
	var recur_call = "rotateImage('"+place+"')";
	setTimeout(recur_call, interval);
}
function detectBrowser()	{
	var browserName = '';
	var browserVersion = '';
	
	//test for Browser Name/x.x (ignoring remaining digits)
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
		browserName = 'FireFox';
		browserVersion = new Number(RegExp.$1) // capture x.x portion and store as a number		 	
	}	
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		browserName = 'Internet Explorer';
	 	browserVersion = new Number(RegExp.$1) // capture x.x portion and store as a number	 	
	}
	if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
		browserName = 'Opera';
	 	browserVersion = new Number(RegExp.$1) // capture x.x portion and store as a number	 			
	}
	if (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Chrome/x.x or Chrome x.x (ignoring remaining decimal places);
		browserName = 'Chrome';
	 	browserVersion = new Number(RegExp.$1) // capture x.x portion and store as a number	 			
	}	
	return(browserName);
}
String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
function showPicture(location, timeframe, damSize, waterDepth, installationTime, manpower, imageName)	{
	if (document.images) {
		document.getElementById('divLocation').innerHTML = location;
		document.getElementById('divTimeframe').innerHTML = timeframe;
		document.getElementById('divDamSize').innerHTML = damSize;
		document.getElementById('divWaterDepth').innerHTML = waterDepth;
		document.getElementById('divInstallationTime').innerHTML = installationTime;
		document.getElementById('divManpower').innerHTML = manpower;
		document['damitdam_image'].src = imageName;
	}
}