 alerta='<B>To Extract the Items That you Wish To Analyze, please<BR>' 
 alerta+='Enter Key Words or Key Sentences Separated by commas(,)<BR>'	
 alerta+='Example:<font color="white">fisk ashtray, goodyear sign, michelin english guide'
 alerta+='</font></B>'
//-----------------------------------------------------------------------------------------  
                                                                                      //-------------------------------------------------------------------------------------
function writeHtm(colr,txt)
{

html='<html><BODY BGCOLOR="'+colr+'"><H1>'+txt+'</H1>'
html+='</BODY></HTML>'
parent.right.document.open();
parent.right.document.write(html);

}

//-------------------------------------------------------------------------------------
function writeErase()
{
 window.open("rolodex.gif",Target="left")
//parent.right.location="blank.html"
parent.right.document.close();

}



//---------------------------------------------------------------------------------------------------------------                                                                                       
function allWordsMatch(sentence,target)  // make sure all words in sentence are in target		
  {                                      // regardless of order	
  words=sentence.split(' ');             // split words by blanks
  yesAll=words.length;                   // if all words in sentence are in target they must match yesAll 
  yesAllOk=0                             // yesAllOK must match yesAll 
      for(Iword=0;Iword<yesAll;Iword++)        //look all words in sentence            
       { 
        if (target.indexOf(words[Iword])>-1)    //if a word matches the target add 1 to yesAllOk
          { yesAllOk++             } 
       }
  //alert("yesAll "+yesAll+" yesAllOk "+yesAllOk+" "+target);  
  return (yesAll == yesAllOk)?1:0               //if all words match return 1
  
    

  } 
 
//---------------------------------------------------------------------------------------------------------------       

function ExtractValue(thumbs)                        //Extract selected values from database
{
  parent.left.document.open();
  parent.left.document.src="Rolodex.gif"                      //displays running 
  var listkeys=document.forms[0].KEYsel.value; //pick all words entered in textarea
     if(0 == listkeys.length){writeHtm('red',alerta)} 
     if(0 == listkeys.length){alert('Nothing Selected')} 
  if(0 != listkeys.length)
 {
  writeErase()                                 //erase prior report 
  var xkeysX=listkeys.split(',');              //split the key words by commas
  DataSel=new Array();                         //create DataSel array to hold all selected items
    var iDataSel=0;                            //iDataSel will control placement of selected items
    Inext=0;                                   //once all elements are found Inext will control next, prior items
    for(i=0;i<Dataitems.length;i++)            //loop throug all the data base named Dataitems
        {
         for(iKey=0;iKey<xkeysX.length;iKey++)     // loop through all the key words(sentences)    
           {
            key=xkeysX[iKey].toUpperCase()         // capture one key sentence and make it uppercase
             if (1== allWordsMatch(key,Dataitems[i]))  // if all words in key are in database line
             { DataSel[iDataSel]=Dataitems[i];       // add selected item to DataSel
               iDataSel++;
             } 
            
           } 

        }

if (iDataSel==0){alert("No items found");}
//if (iDataSel>0){CaptureValues();}
DoReport(thumbs)
}
} //end ExtractValue()

//---------------------------------------------------------------------------------------------------------------       


//---------------------------------------------------------------------------------------------------------------       
function CaptureValues()
{
    button1=DataSel[Inext].split(';')[2]; 
    button2=DataSel[Inext].split(';')[3];
    button3=DataSel[Inext].split(';')[4];
    button4=DataSel[Inext].split(';')[0];

}
//---------------------------------------------------------------------------------------------------------------       
function DoReport(thumbs)
{
    //MICHELIN GUIDE BRITISH ISLES 1911 1ST EDIT;339141040-11.jpg;102500;6    ;11      ;1", 
    //alert('reporting')
    // example syntax parent.right.document.open(); 
     
     swtch=0   //set switch to 0
     htmlx='<HTML><HEAD><TITLE></TITLE></HEAD><BODY>'
     htmlx+='<table border=0><TR><TH>Image</TH><TH>Description</TH><TH>$ CLOSE</TH><TH>Bids</TH><TH>$ OPEN</TH></TR>'
     for (irow=0;irow<DataSel.length;irow++)
      {        
               rowRep=DataSel[irow].split(';')
               htmlx+='<TR>'
               largeIMG=rowRep[1];origBidx=largeIMG.split("-");
               origBidy=origBidx[1].split(".")
              // htmlx+='<TD><A HREF="'+largeIMG+'"'+',target="left">'
                htmlx+='<TD><A href="'+largeIMG+'"'+' target="left">'
               if (thumbs==1){ 
               htmlx+='<IMG SRC="'+largeIMG+'" width=80 height=60></A></TD>';}
               if (thumbs==0){ 
               htmlx+='<IMG SRC="whitebullet.gif" width=10 height=10></A></TD>';}

               htmlx=htmlx+'<TD><B>'+rowRep[0]+'</B></TD>';
               htmlx=htmlx+'<TD><B>$'+rowRep[2]/100+'</B></TD>' ;
               htmlx=htmlx+'<TD><B>'+rowRep[3]+'</B></TD>' ;
               if(origBidy[0].indexOf("r")>-1)
               {htmlx=htmlx+'<TD BGCOLOR="red"><B><font color="white">$'+origBidy[0]+'</font></B></TD></TR>';swtch=1}
               else
               {htmlx=htmlx+'<TD><font color="blue"><B>$'+origBidy[0]+'</font></B></TD></TR>';} 
            
      }
if(swtch==1){
htmlx+='<TR><TH colspan=5><SUB>Items in red may not have sold because reserve was not met</SUB></TH></TR>'}

htmlx+='</TABLE>'
htmlx+='</BODY></HTML>'
writeHtm("white",htmlx);
//document.write(htmlx);

}




