//added resetForPrint Function
function resetForPrint() {
  if (navigator.appName.indexOf("Netscape") != -1) {
  document.layers["layer1"].top = 0;
  } else {
  document.all["layer1"].style.top = 0;
  }
  window.print();
 }
//added placeIt function
function placeIt() {
  if (navigator.appName.indexOf("Netscape") != -1) {
  document.layers["layer1"].top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1))
  } else {
  document.all["layer1"].style.top = document.body.scrollTop + (document.body.clientHeight - (document.body.clientHeight-y1));
  }
  window.setTimeout("placeIt()", 10);
 }

function compareOptionValues(a, b) 
{ 

  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values

  var sA = parseInt( a.value, 10 );  
  var sB = parseInt( b.value, 10 );  
  return sA - sB;

}


function hasSpaces(s) {
    containsSpaces = false;
    for (i=0; i < s.length; i++){
        if (s.charAt(i) == " "){
            containsSpaces = true;
            break;
        }
    }
     return (containsSpaces);
}


// Compare two options within a list by TEXT

function compareOptionText(a, b) 
{ 

  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values

  var sA = parseInt( a.text, 36 );  
  var sB = parseInt( b.text, 36 );  
  return sA - sB;

}



// Dual list move function

function moveDualList(direction,moveAll ) 

{

  if (direction == "add")
  {
  	srcList  = form0.listLeft;
  	destList = form0.listRight;
  }
  else
  {
  	srcList  = form0.listRight;
  	destList = form0.listLeft;
  }


  // Do nothing if nothing is selected

  if (( srcList.selectedIndex == -1 ) && ( moveAll == false ))
  {
    return;
  }



  newDestList = new Array( destList.options.length );
  var len = 0;

  for( len = 0; len < destList.options.length; len++ ) 
  {
    if ( destList.options[ len ] != null )
    {
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
    }
  }



  for( var i = 0; i < srcList.options.length; i++ ) 
  { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Statements to perform if option is selected
       // Incorporate into new list
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       len++;
    }
  }



  // Sort out the new destination list
//  newDestList.sort( compareOptionValues );   // BY VALUES
newDestList.sort( compareOptionText );   // BY TEXT
  // Populate the destination with the items from the new array

  for ( var j = 0; j < newDestList.length; j++ ) 
  {
    if ( newDestList[ j ] != null )
    {
      destList.options[ j ] = newDestList[ j ];
    }
  }



  // Erase source list selected elements
  for( var i = srcList.options.length - 1; i >= 0; i-- ) 
  { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Erase Source
       //srcList.options[i].value = "";
       //srcList.options[i].text  = "";
       srcList.options[i]       = null;
    }
  }



} // End of moveDualList()
function DoInfo(infoid) 
{
	remote = window.open("","sub1","width=400,height=250,status=no,directories=no,location=no,menubar=no,resizable=no,scrollbars=auto,toolbar=no");
                remote.location.href = "http://www.generalmedical.co.uk/cgi-bin//info.cgi?infoid="+infoid;
		if (remote.opener == null) remote.opener = window;
		remote.opener.name = "opener";
	remote.focus();
}

function DoUnCheckedSubmit() 
{
    	document.form0.submit(); 
}

function imageChange(imageID1,FileName1) 
{
	document.images[imageID1].src = "http://www.generalmedical.co.uk/images/" + FileName1;
}

function isEmpty(s)
{   
   return ((s == null) || (s.length == 0))
}


function isNumeric(s)

{   
    var i;

    var reNumeric = /^[0-9]+$/

    if (isEmpty(s))
       if (isNumeric.arguments.length == 1) return false;
       else return (isNumeric.arguments[1] == true);

    else 
    {
       return reNumeric.test(s)
    }
} 



function DoReload() 
{
	document.form0.reset(); 
}

function DoCheckedSubmit() 
{
	if (formCheck())
	{
      		document.form0.submit(); 
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}