//
// COPYRIGHT (C) 2009 - APOISLANDRESORT.COM
//
// Developed by: 
// intago
// web@intago.net
//

function startUpload(form){
	if (form.elements['realmomentName'].value == "") {
		alert('Please enter your name');
		return false;
	}
	if (form.elements['realmomentLocation'].value == "") {
		alert('Please enter your geographical location or N/A if you do not wish to share this information');
		return false;
	}
	if (form.elements['realmomentEmail'].value == "") {
		alert('Please enter your email address or N/A if you do not wish to be contacted');
		return false;
	}
	if (form.elements['realmomentAboutMsg'].value == "") {
		alert('Please enter a explaination about your Real Moment');
		return false;
	}
	if (form.elements['upload'].value == "") {
		alert('Please select a photo to upload');
		return false;
	}
	
	document.getElementById('errorMsg').style.visibility = 'hidden';
	document.getElementById('uploadProgress').style.visibility = 'visible'; 
	return true;
}

function stopUpload(result,id,file){
	var msg = '';
	if (result == 0) {
		msg = 'The file is not a valid image type';
	}
	else if (result == 2) {
		msg = 'The file was unable to upload to server';
	}
	else if ((result == 4) || (result == 5) || (result == 8)) {
		msg = 'Unable to update database. Please contact the web administrator.';
	}
	else if (result == 9) {
		alert("The image you uploaded is smaller than 990px in width. You will not be able to use this image as a website header image");
		window.location = "crop.php?rlmid="+id+"&file="+file;
	}
	else if (result == 10) {
		window.location = "crop.php?rlmid="+id+"&file="+file;
	}
	else {
		 msg = 'An unexpected error occurred (x'+result+')';
	}
	document.getElementById('errorMsg').style.visibility = 'visible';
	document.getElementById('errorMsg').innerHTML = msg;
	document.getElementById('uploadProgress').style.visibility = 'hidden';
	return true;   
}
