<!--
function js_load_photo(path_to_root, photo_ref) {
	if (document.images) {
		obj_main_photo = document.getElementById("main-photo");
		if (obj_main_photo.src.indexOf(encodeURI(photo_ref))<0) {
			obj_main_photo.src = encodeURI(path_to_root + photo_ref);
		} // end if
		return true;
	} // end if
} // end function
function js_load_photo_window(path_to_root) {
	if (document.images) {
		obj_main_photo = document.getElementById("main-photo");
		js_popup("photo_preview", obj_main_photo.src.toLowerCase().replace(".jpg","_l.jpg"));
		return true;
	} // end if
} // end function
function js_show_hide(str_mode, str_ident) {
	if (document.getElementById) {
		var obj_item = document.getElementById(str_ident);
		if (obj_item) {
			if (str_mode == "show") {
				obj_item.className = "page-item show";
			} else {
				obj_item.className = "page-item hide";
			} // end if
		} // end if
	} // end if
} // end function

function js_check_form(obj_form) {
	var str_message = "";
	var arr_fields = new Array();
	var arr_required = new Array();
	for (var int_i = 0; int_i < obj_form.length; int_i++) {
		if (obj_form[int_i].name) {
			if (obj_form[int_i].name.indexOf("frm_")==0) {
				arr_fields.push(obj_form[int_i].name);
				if (obj_form[int_i].attributes["class"].value != "") {
					if (obj_form[int_i].attributes["class"].value.indexOf("required") >= 0) {
						arr_required.push(obj_form[int_i].name);
						if (obj_form[int_i].value == "") {
							var str_label = get_label(obj_form, obj_form[int_i].name);
							if (str_label == "") { str_label = obj_form[int_i].name.replace("frm_",""); }
							str_message += str_label + "\n"; 
						} // end if
						// we could also check data types here plus form object types (select, radio etc)
					} // end if
				} // end if
			} // end if
		} // end if
	} // end for
	if (str_message != "") {  
		alert("Some details were missing, please complete the following:\n" + str_message);
		return false;
	} else {
		obj_form['fields'].value = arr_fields;
		obj_form['required'].value = arr_required;
		return true;
	} // end if
} // end function

function get_label(obj_form, str_ref) {
	var str_result = "";
	if (document.getElementsByTagName) {
		if (obj_form) {
			if (str_ref != "") {
				var obj_results = obj_form.getElementsByTagName("label");
				if (obj_results) {
					for (var int_i = 0; int_i < obj_results.length; int_i++) {
						if (obj_results[int_i].attributes["for"].value == str_ref) {
							str_result = obj_results[int_i].firstChild.data;
						} // end if
					} // end for
				} // end if
			} // end if
		} // end if
	} // end if
	return str_result;
} // end function


/*
	inputs = form.getElementsByTagName("input");
	buffer = "";
	for (i = 0; i < inputs.length; i++)
		buffer += inputs[i].name + "=" + inputs[i].value + "\n";
	
	alert(buffer);

var items = xml.getElementsByTagName('item')[0];//grab the first item node
var title = items.getElementsByTagName('title')[0].firstChild.data;//Gourmet gizmo
*/


/* W.Searle. Function to open popup */
function js_popup(name, link) {
	windowName = name;
	windowLeft = 400;
	windowTop  = 100;
	switch (windowName) {
		case 'join':	// join
			windowWidth = 400;
			windowHeight = 270;	
			windowScrollbars = 0;
			windowURL = link.href;
			break;
		case 'photo_preview':
			windowWidth = 476;
			windowHeight = 400;	
			windowScrollbars = 1;
			windowURL = "../../preview.htm?src=" + link;
			break;			
	} // end switch
	windowProps = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + windowScrollbars + ",resizable=0,copyhistory=0,width=" + windowWidth + ",height=" + windowHeight + ",left=" + windowLeft + ",top=" + windowTop;
	obj_new_window = window.open(windowURL,windowName,windowProps);	
	obj_new_window.focus();	
	return false;
} // end function
//-->
