/**********************************************************************
	Project: Farmboy Fine Arts
	Version: 0.0.1
	Author: Hze
	Netgenetix Media
 *********************************************************************/




/**********************************************************************
	Popups
 *********************************************************************/
function offsite(url) {
	return openWindow(url, 'offsite', 'directories,location,menubar,resizable,scrollbars,status,toolbar');
}

function popLearnMore(url) {
	return openCenteredWindow(url, 'fbfalearn', 375, 375, 0, 0, 0, 'fbfaopener');
}




/**********************************************************************
	Hide & Seek
 *********************************************************************/
function toggle( targetId ){
	if (document.getElementById){
		target = document.getElementById( targetId );
			if (target.style.display == 'none'){
				target.style.display = 'block';
			} else {
				target.style.display = 'none';
			}
	}
}


function togglehide( targetId ){
	if (document.getElementById){
		target = document.getElementById( targetId );
		target.style.display = 'none';
	}
}


function closeall(){
	for (var shotCount = 1; shotCount < maxShot+1; shotCount++) {
		togglehide ( 'shot'+ shotCount );
	}
}


function togged(targeted){
	closeall();
	if (document.getElementById){
		target = document.getElementById( targeted );
		target.style.display = 'block';
	}
}


function scanCurrentImages () {
	var currentImage;
	for (var shotCount = 1; shotCount < maxShot+1; shotCount++) {
		if (document.getElementById) {
			target = document.getElementById( 'shot' + shotCount );
			if (target.style.display == 'block') {
				currentImage = shotCount;
				return (currentImage);
			}
		}
	}
}


function btnGoBack() {
	var visibleImage = scanCurrentImages();
	var newDisplay = 1;
	if (visibleImage == 1) { 
		newDisplay = maxShot;
	} else {
		newDisplay = visibleImage - 1;
	}
	closeall();

	if (document.getElementById){
		target = document.getElementById( 'shot' + newDisplay );
		target.style.display = 'block';
	}
}


function btnGoForward() {
	var visibleImage = scanCurrentImages();
	var newDisplay = 2;

	if (visibleImage == maxShot) { 
		newDisplay = 1;
	} else {
		newDisplay = visibleImage + 1;
	}
	closeall();
	if (document.getElementById){
		target = document.getElementById( 'shot' + newDisplay );
		target.style.display = 'block';
	}
}




/**********************************************************************
	FORM VALIDATION
 *********************************************************************/

function outputErrors(form, errors) {
	var errorMessage = 'The form was not submitted due to the following problem' + ((errors.length > 1) ? 's' : '') + ':\n\n';
	for (var errorIndex = 0; errorIndex < errors.length; errorIndex++) {
		errorMessage += '*** ' + errors[errorIndex] + '\n';
	}
	errorMessage += '\nPlease fix ' + ((errors.length > 1) ? 'these' : 'this') + ' problem' + ((errors.length > 1) ? 's' : '') + ' and resubmit the form.';
	alert(errorMessage);
}