
 function setImageLinks()
  {
   var loop;
   var iobj;
   var iid;
   var ilnk;
   if(typeof(imageLinks) !='undefined')
   for(loop=0;loop<imageLinks.length;loop++)
   {
    iid='i'+loop;
    ilnk=imageLinks[loop];
    iobj=document.getElementById(iid);
    //alert(ilnk);
   
    if(iobj!=null)
    iobj.src=ilnk;
   }
  }
  
  function imgPopup(obj)
  {
   if(obj==null) return;
   var imgsrc=''+obj.src;
   if(imgsrc==null || imgsrc=="") return;
   var sIdx=imgsrc.lastIndexOf('Image=');
   if(   sIdx>0 && (sIdx+6)<imgsrc.length )
    imgsrc=imgsrc.substr(sIdx+6);
   window.open(imgsrc,"ImgZoom","");
  }
  
  function imgPopup2(obj)
  {
   
   var imgURL=obj;
   if((String(imgURL)).indexOf('lfdb')<0) 
   {
    imgURL=obj.src;
    if(imgURL==undefined) {alert("undefined"); return;}
   }
   var imgNameIdx=imgURL.indexOf('Image=')+6;
   if(imgNameIdx==undefined) imgNameIdx=0;
   if(imgNameIdx<1) imgNameIdx=0;
   displayImage(imgURL.substr(imgNameIdx));
  }
  
  function setAdImages()
  {
   var loop;
   var iobj;
   var iid;
   var ilnk;
 //  alert(adImgs.length);
   for(loop=0;loop<adImgs.length; loop++)
   {
    iid='a'+loop;
    ilnk=adImgs[loop];
    iobj=document.getElementById(iid);
    //alert(ilnk);
  //  alert(iobj);
    ilnk="/img/blank.jpg";
    if(iobj!=null)
     iobj.src=ilnk;
   }
  }
  
  function gotoHref(link)
  {
   var hf=document.getElementById('hrefForm');
   hf.action=link;
   getWinSize();
   hf.winWidth.value=document.getElementById('winWidth').value;
   hf.winHeight.value=document.getElementById('winHeight').value;
   hf.submit();
  }
  
  function gotoParent(link)
  {
   var hf=document.getElementById('hrefForm');
   hf.Command.value="DisplayDetails";
   hf.PK.value=document.getElementById("FK_Parent").value;
   gotoHref(link);   
   hf.Command.value="";
   hf.PK.value="";
  }
  
  function gotoNavLink(topOrLeft,linkID)
  {
   if(topOrLeft=='t')
   {
    gotoHref(tNavLinks[linkID]);
   }
   if(topOrLeft=='l')
   {
    gotoHref(lNavLinks[linkID]);
   } 
   if(topOrLeft=='i')
   {
    gotoHref(iNavLinks[linkID]);
   }
  }
  
  function gotoRow(rId)
  {
   var gF=document.getElementById('gotoForm');
   gF.PK.value=rId;
   gF.winWidth.value=document.getElementById("winWidth").value;
   gF.winHeight.value=document.getElementById("winHeight").value;
   gF.submit();
   gF.PK.value="";
  }
  

  function getWinSize()
  {
   reduction=0.97;
   document.getElementById('winWidth').value=(document.body.clientWidth*reduction);
   document.getElementById('winHeight').value=(document.body.clientHeight*reduction);
  }
  
   function blinkSave()
  {
   if(buttonColor==1)   
    savebtn.style.background="#cccccc";  
   else
    savebtn.style.background="#ffff00";
    buttonColor=Math.abs(buttonColor-1);
   if(buttonColor==0)
    timerId=setTimeout("blinkSave();",200);
   else
    timerId=setTimeout("blinkSave();",600);
  }
  
  function fieldChanged()
  {
   if(notSaved==false)
   {
    blinkSave();
    savebtn.title="Data has been changed. Remember to save your work.";
   }
   notSaved=true;   
  }
  
  function checkSaved()
  {

   if(notSaved)
   {
    return('You have made changes to data on this page that have not been saved. '+
            'The action you are attempting will cause those changes to be lost. ' +
            'Are you sure you want to continue?')
   }
   
  }
  
  function gotoSearchPage(pageNum)
  {
   document.getElementById('curPage').value=pageNum;
   document.getElementById('SearchForm').submit();
  }
   
  function init_Search()
  {
   setImageLinks();
   setAdImages();
   document.getElementById('hrefForm').action="";
   document.getElementById("gotoPK").value="";
   if(initialField!=null && initialField!="")
    document.getElementById(initialField).focus();
   getWinSize();
  }
  
  function bak()
  {
   var destURL=bak_link;
   if(bak_Command!="") destURL+='?Command='+bak_Command;
   gotoHref(destURL);
  }
   
  function displayImage(url)
  {
   var cWidth=document.getElementById('winWidth').value;
   var cHeight=document.getElementById('winHeight').value;
   var newURL=curURL+"?Command=ObjectImg&Width="+cWidth+"&Height="+cHeight+"&Image="+url;
   document.location=newURL;
  }
   
  function displayImage2(url,backto)
  {
   var cWidth=document.getElementById('winWidth').value;
   var cHeight=document.getElementById('winHeight').value;
   var newURL=curURL+"?Command=ObjectImg&Width="+cWidth+"&Height="+cHeight+"&Image="+url+"&Back="+backto;
   document.location=newURL;
  } 
  function add()
  {
   var hrefForm=document.getElementById("hrefForm");
   hrefForm.Command.value="Add";   
   hrefForm.PK.value="";   
   gotoHref(curURL);
   hrefForm.Command.value="";   
  }
  
  function hideResults(obj)
  {
   if(obj) 
    document.getElementById("resultsTable").style.display="none";
   else
    document.getElementById("resultsTable").style.display="block";
  }
  function upload()
  {
   document.getElementById("uploadButton").style.display="none";
   document.getElementById("imageUpload").style.display="block";   
  }
  
  function gotoRelPage(pageNum)
  {   
   var assocForm=document.getElementById("AssociationsForm");
   assocForm.pk=document.getElementById("PK").value;
   assocForm.Command.value="DisplayDetails";
   assocForm.curPage.value=pageNum;
   assocForm.submit();   
  }
  
  function del()
  {   
   if(confirm("Are you sure you want to delete this "+delObj+"?"))
   {
    var pk=document.getElementById("PK").value;
    var hrefForm=document.getElementById("hrefForm");
    hrefForm.Command.value="Delete";
    hrefForm.PK.value=pk;
    gotoHref(curURL);
    hrefForm.PK.value="";
    hrefForm.Command.value="";        
   }
   else
   alert ("Aborted.");
  }
 
  
