function BlankFieldsCheck(CheckFields)
{
	// paramerters are in pairs first is the field, second is the span to turn red. 
	var MasterSw = true;  //master switch 
	for (i=0; i<arguments.length; i=i+2)  //loop thru the parameters 
	{
		

		var sw = BlankFieldCheck(arguments[i], arguments[i+1]);
		MasterSw = MasterSw && sw;
		
	}

	return MasterSw;

}

function CheckedFieldsCheck(CheckFields)
{
// paramerters are in tres  first is the checkbox, second is the field to check and the last is span to turn red. 
	var MasterSw = true;  //master switch 
	for (i=0; i<arguments.length; i=i+3) //loop thru the parameters 	
	{

		var acheckbox = document.getElementById(arguments[i]); 
		if (!acheckbox.checked)
			{return true}
		var sw = BlankFieldCheck(arguments[i+1], arguments[i+2]);
		MasterSw = MasterSw && sw;
		
	}

	return MasterSw;

}

function BlankFieldCheck(object,subject)
//object is the input item
//subject is the text that will be made visiable 

{

  var ThisObject =  document.getElementById(object);  	// input item 
  var ThisSubject = document.getElementById(subject);   // hidden message
  
  
  ThisSubject.style.visibility='hidden';
  
  if ( leftTrim(ThisObject.value) == "" )
  	{
		ThisSubject.style.visibility='visible';
		return false;
		
	}
	else
	{
		return true;
	}

	
}

function checkallinputs(form)

{
	
	var ThisForm =  document.getElementById(form);
	var sw = true;
	elements = ThisForm.elements;
	for (x in elements)
	{
		if (elements[x].type == 'text')	
			{
				sw = sw && !leftTrim(elements[x].value) == "" 
				
			}
	}
	
	return sw;
}

function leftTrim(sString)
{
	if(sString.length == 0)
		{return ""}
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	return sString;
}


function rightTrim(sString)
{
	if(sString.length == 0)
		{return ""}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}


function trimAll(sString)
{
	while (sString.substring(0,1) == ' ')
	{
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ')
	{
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}