/**
 * 
 *  code for management of image references
 *
 */

// move to the next logical field when the current field
// has ln or more chars in it
function fieldcheck( theField, ln, nxt ) 
{ 
  var theForm = theField.form;
  if( theField.value.length >= ln )
  { 
    eval( 'theForm.'+nxt+'.focus()' ); 
  } 
}

// Check the references and if it a web gallery ref (a letter on the end) go 
// to the appropriate web gallery
// note if it is an X on the end then it is a test order not a gallery order and
// so process as normal
function checkReferences(theForm)
{ 
	var thirteenthChar = theForm.referencenumber4.value;
	if (thirteenthChar != '' && isALetter(thirteenthChar) && thirteenthChar != 'x' && thirteenthChar != 'X')	// a letter in the last part indicates a web gallery reference
	{
		var eventNum = theForm.referencenumber.value + theForm.referencenumber2.value + theForm.referencenumber3.value;
		var webGallery;
		if (thirteenthChar == 'A' || thirteenthChar == 'a')		// A is for normal web gallery
		{
			eventNum += 'A';
	 		webGallery = "http://" + location.host + "/jalbum/" + eventNum + "/index.html";
		}
		else // if (thirteenthChar == 'B' || thirteenthChar == 'b')	// B is for free web gallery
		{
			eventNum += 'B';
		 	webGallery = "http://" + location.host + "/jalbum_free/" + eventNum + "/index.html";
		}
		location.href = webGallery; 
		return false;
	}
	else
	{
		return true;
	}
}

function isALetter(c)
{
	var retVal = false;
	
	retVal = c == '0' || c == '1' || c == '2' ||
			 c == '3' || c == '4' || c == '5' ||
			 c == '6' || c == '7' || c == '8' ||
			 c == '9';
	return !retVal;
}

