//////////////////////////////////////////////////////////////
//           HELPER MODULE FOR THE CDWEB
//
// Functions:
//     cdwHitList(query, dbname, view, limit, sortorder, template, starthit)
//     cdwDocList(selectquery, dbname, view, limit, sortorder, hquery)
//     cdwSearchScreen(tmpl_file, err_file)
//     cdwDoc(docid, dbname, view, hquery, rank)
//     cdwDict(query, dbname, view, limit, template)
//
//  Ver:
//      1.0 Beta
//  HISTORY
//     2002.10.07  wywolanie cdweb:?  zamieniono na /taweb-cgi/ w celach kompatybilnosci z tawebem
//     12.2000 crteated by the jbo
//
//----------------------------------------------
// how to include the cdweb.js : example
//
// <script language="JavaScript" src=cdweb.js>
// alert("Can not load cdweb.js!") ;
// </script>
//////////////////////////////////////////////////////////////


//-----------------------------------
// cdwHitList(query, dbname, view, limit[, sortorder, template, starthit])
// make link to the hitlist
//-----------------------------------
function cdwHitList(query, dbname, view, limit, sortorder, template, starthit)
{
 var ss = "/karta-cgi/taweb.exe?x=r&v=" + view + "&d=" + dbname + "&l=" + limit + "&q=" + query ;
 if (sortorder && (sortorder != "")) ss += "&so=" + sortorder ;
 if (template && (template!="")) ss += "&t=" + template ;
 if (starthit) ss += "&h=" + starthit ;

 //alert ("cdweb.cdwHitList:.." + ss + "..") ;
 return ss ;
} // cdwHitList


//---------------------------------------------------------
//  cdwDocList(selectquery, dbname, view, limit[, sortorder[, highquery]])
//   (by search)
//
// if highquery is undefined then use select query,
// if highquery is empty string then do not highlight at all
//---------------------------------------------------------
function cdwDocList(selectquery, dbname, view, limit, sortorder, hquery)
{
 var sq = dbname ;
 var ret= "" ;

 if (sortorder && sortorder != "") sq += String.fromCharCode(7) + sortorder ;
 sq += String.fromCharCode(7) + selectquery ;

 ret = "/karta-cgi/taweb.exe?x=d&o=l&v=" + view + "&d=" + dbname + "&s=" + sq ;
 
 if (!hquery) ret += "&q=" +  selectquery ;   // if not set then use select query
 else if (hquery != "") ret += "&q=" + hquery ; // if not empty string then use it
 
//alert ("cdweb.cdwDocList:.." + ret + "..") ;
 return ret ;
} // cdwDocList



//---------------------------------------------------------
// cdwSearchScreen(tmpl_file [, view [, err_file]])
//---------------------------------------------------------
function cdwSearchScreen(tmpl_file, view, err_file)
{
 var ss = "/karta-cgi/taweb.exe?x=s&t=" + tmpl_file ;
 if (view && view != "") ss += "&v=" + view ;
 if (err_file && err_file != "") ss += "&et=" + err_file ;
 //alert ("cdweb.cdwSearchScreen:.." + ss + "..") ;
 return ss ;
} // cdwSearchScreen


//---------------------------------------------------------
//   cdwDoc(docid, dbname[, view][, hquery][, rank])
//  link do dokumentu wg id
//---------------------------------------------------------
function cdwDoc(docid, dbname, view, hquery, rank)
{
 var ss = "/karta-cgi/taweb.exe?x=d&o=d" ;

 ss += "&i=" + docid + "&d=" + dbname ;
 if (view && view != "") ss += "&v=" + view ;
 if (hquery && hquery != "") ss += "&q=" + hquery ;
 if (rank && rank != "") ss += "&p=" + rank ;
 //alert ("cdweb.cdwDoc:.." + ss + "..") ;
 return ss ;
} // cdwDoc()


//----------------------------------------------------------
function cdwDict(query, dbname, view, limit, template)
{
 var ss = "/karta-cgi/taweb.exe?x=r&o=d&d=" + dbname + "&v=" + view + "&l=" + limit + "&q=" + query ;
 if (template && template != "") ss += "&t=" + template ;
 //alert ("cdweb.cdwDict:.." + ss + "..") ;
 return ss ;
} //cdwDict(docid, dbname, view, query, rank)


