// JavaScript Document

// This function make an element visible with id 'picture'.
function show_des(des_item,item_amount) {
	
	var item_name=des_item.substring(0,des_item.length-1);	// remove one trailing char

	// main function 
	for (i=1; i<=item_amount; i++) 
		document.getElementById(item_name+i).style.visibility="hidden";
	document.getElementById(des_item).style.visibility="visible";
	return;
}



// Put cursor on the first field
function focusOnFirst() {
	// Check if a form existed in a page
	if (document.forms.length > 0) {
		// Find the first field that isn't hidden
		for (var i=0; i < document.forms[0].elements.length; i++) {
			var oField = document.forms[0].elements[i];
			if (oField.type == "text") {
				oField.focus();
				return;
			}
		}
	}
}


// Show warning message if required field is missing
function showMissingFieldMessage() {
	var str=window.location;
	var text=str.toString();

	if(text.match("missing")) document.getElementById("missing_field").style.display="block";
	if(text.match("sent")) document.getElementById("sent_confirmed").style.display="block";
}
