<!-- hide script from old browsers
function display_confirm(url,formName,screenName)
{
  
  var vialResult=confirm('Press OK to continue if you already printed the current '+screenName+' screen. Press Cancel in order to print the '+screenName+' screen before continuing.')
  			
  if (vialResult)
  {
    document.forms[formName].submit();
  }
}

function orderstatus_confirm($url,formName)
{
	var projectResult=confirm('Do you really want to manually change this order status?')
	if(projectResult)
	{
		document.forms[formName].submit();
	}
}

function qcproject_confirm(url,formName,qcProjectName)
{
  
  var projectResult=confirm('You are about to start a new '+qcProjectName+' QC project. Are you sure? Select OK or Cancel.')
  			
  if (projectResult)
  {
    document.forms[formName].submit();
  }

}

function orderFill_confirm(url,formName,fillOption)
{
  
  var projectResult=confirm('You are about to '+fillOption+' the current item. Are you sure? Select OK or Cancel.')
  			
  if (projectResult)
  {
    document.forms[formName].submit();
  }
}

function role_confirm(url,formName)
{
  
  var projectResult=confirm('You are about change user(s) privileges. Are you sure? Select OK or Cancel.')
  			
  if (projectResult==1)
  {
    document.forms[formName].submit();
  }
}


function litter_confirm(url,vial)
{
  var litterResult=confirm('You are about to start a new litter. Are you sure? Select OK or Cancel.')
  			
  if (litterResult)
  {
    self.location=url;
  }
}

function removeLitter_confirm(url,vial)
{
  var litterResult=confirm('You are about to remove a litter. Are you sure?')
  			
  if (litterResult)
  {
    self.location=url;
  }
}

function removeChimera_confirm(url,vial)
{
  var litterResult=confirm('You are about to remove a chimera and all of it\'s litters. Are you sure?')
  			
  if (litterResult)
  {
    self.location=url;
  }
}

function reopenGermline_confirm(url,vial)
{
  var litterResult=confirm('Really clear test result and reopen this germline testing?')
  			
  if (litterResult)
  {
    self.location=url;
  }
}

function batch_confirm(url,formName,batchOption)
{
  
  if(batchOption=="approveBatch"){
     var batchResult=confirm('Are you sure you want to release the entire batch for distribution.')
  }
  
  if(batchOption=="cancelBatch"){
     var batchResult=confirm('Are you sure you want to withdraw the entire batch from distribution.')
  }
  
  			
  if (batchResult)
  {
    document.forms[formName].submit();
  }

}


function displayQC_confirm(url,formName,projectStatus)
{
  
  if(projectStatus=="no")
  {
     alert("Error: All subprojects for QC must be completed before closing QC.");
  }
  else {
  	  
  	  var qcResult=confirm('Press OK if you are sure you want close entire QC project. Press Cancel to abort closing entire QC project')
  			
	  if (qcResult)
	  {
	    document.forms[formName].submit();
	  }
 }

}

		
function checkboxChecker(source,formName,chkBoxName) {
				
	var numElements = document.forms[formName].length-1;
				
	for (var i = 0; i <= numElements; i++){
					
		if (document.forms[formName][i].type == 'checkbox'){
						
				if (document.forms[formName][i].name == chkBoxName)
					document.forms[formName][i].checked = source.checked;
		}
    }    
}

//Special function for new bench page
//Toggles visibility of a select box
//when the checkbox is clicked.
function vialPosText(source,formName,textID){

	var myTextField = document.getElementById(textID);
if(myTextField)
{
	if (source.checked)
	{
		chooseVialSpot(source,formName,textID);
		myTextField.style.visibility= "visible";
		myTextField.focus();
	}

	if(!source.checked)
	{
		myTextField.style.visibility= "hidden";
		myTextField.value=-1;
	}
}


}



//Special function for new bench page
//Automatically picks the next available box spot for a vial

var lastVialSpot = 1;

function chooseVialSpot(source,formName,textID)
{
	var mySelect = document.getElementById(textID);
	var numElements = document.forms[formName].length-1;
	var takenValues = new Array();
	var j = 0;

	//drop out of the function if mySelect is null
	if(mySelect==null)
	{
		return false;
	}
		

	//loop over all select boxes and grab their values
	for (var i = 0; i <= numElements; i++){
		
		if (document.forms[formName][i].id.substring(0,2) == 'vt' && document.forms[formName][i].type == 'select-one' && document.forms[formName][i].value != -1 && document.forms[formName][i].name != mySelect.name)
		{
			takenValues[j] = document.forms[formName][i].value;
			j++;	
		}
	}

	
	var taken;
	//loop over possible values, see if one isn't taken
	for(var j=0; j < mySelect.options.length; j++)
	{
		taken=false;
		for (var i=0; i<takenValues.length; i++)
		{
			if(takenValues[i]==mySelect.options[j].value || parseInt(mySelect.options[j].value) < parseInt(lastVialSpot))
				taken=true;
		}

		if(taken==false)
		{
			mySelect.value = mySelect.options[j].value;
			lastVialSpot = mySelect.options[j].value;
			break;
		}
	}
	
	if(taken)
		mySelect.value=-1;
	return;	
}

function setLastVialSpot(source)
{
  lastVialSpot = source.value;
}

//Special function for new bench page
//Modified checkbox checker to suit needs of new bench page
//Also toggles the visiblity of select boxes associated with the check boxes
function vialChecker(source,formName,chkBoxName) {
				
	var numElements = document.forms[formName].length-1;

	for (var i = 0; i <= numElements; i++){
		if (document.forms[formName][i].type == 'checkbox'){
						
				if (document.forms[formName][i].name == chkBoxName){
					document.forms[formName][i].checked = source.checked;
					vialPosText(source,formName,'vt'+document.forms[formName][i].value);
				}
		}
    }    
}

function swapTableRows(tableID,rowID)
{
	var rows = document.getElementById(tableID).getElementsByTagName('tr');
	
	for (i=0; i<rows.length; i++)
	{
		if(rows[i].id==rowID)
		{
			if(rows[i].style.display == "none")
				rows[i].style.display = "";
			else
				rows[i].style.display = "none";
		}
			
	}

}

function swapDiv(id) {
 	if (document.getElementById){
		obj = document.getElementById(id);
		if (obj.style.display == "none"){
			obj.style.display = "";
		}
		else{
			obj.style.display = "none";
		} 
	}
}

function swapDisplay(){

//swap the display fields
	swapDiv('tNumberD');
	swapDiv('tNameD');
	swapDiv('tLocationD');
	swapDiv('tCommentD');
	swapDiv('tDisplay');
//swap the 	
	swapDiv('tNumberE');
	swapDiv('tNameE');
	swapDiv('tLocationE');
	swapDiv('tCommentE');
	swapDiv('tEdit');
	

}
		
function reloadTank(form)
{
	var val=form.tankNum.options[form.tankNum.options.selectedIndex].value;
	self.location='cryoarchiving.php?tankNum=' + val ;
}
		
function reloadRack(form)
{
	var val=form.rackNum.options[form.rackNum.options.selectedIndex].value;
	self.location='cryoarchiving.php?rackNum=' + val ;
}
		
function reloadBox(form)
{
	var val=form.boxNum.options[form.boxNum.options.selectedIndex].value;
	self.location='cryoarchiving.php?boxNum=' + val ;
}
		
function reloadPos(form)
{
	var val=form.posNum.options[form.posNum.options.selectedIndex].value;
	self.location='cryoarchiving.php?posNum=' + val ;
}
-->

