function documentProche(ChunkID,DatabaseID) 
{
	var s = strip( "iFullTextQuery iStrategy iChunkId iDatabaseId iPageNumber" ) ;
	window.location = addparam( s, "iDatabaseId=" + DatabaseID + "&iChunkId=" + ChunkID + "&iStrategy=MeaningOnly" );
}

function write_answers_count (the_count, the_limit)
{
   if (the_count == 0)
   {
      document.write ("&nbsp;0&nbsp;r&eacute;ponse");
   }
   else if (the_count >= the_limit)
   {
      document.write ("&nbsp;plus de " + the_limit + " r&eacute;ponses");
   }
   else if (the_count == 1)
   {
      document.write ("&nbsp;" + the_count + "&nbsp; r&eacute;ponse");
   } else
   {
      document.write ("&nbsp;" + the_count + "&nbsp;r&eacute;ponses");
   }
}
function next_page (img, current_page, last_page)
{
   var p = current_page + 1;
   if ((p < 20) && (p < last_page))
      document.write("<a href=\"javascript:gotoPage('" + p + "')\"> " +  img + "</a> ")

}

function previous_page (img, current_page)
{
   var p = current_page - 1;

   if (p >= 0)
      document.write("<a href=\"javascript:gotoPage('" + p + "')\"> " +  img + "</a> ")

}

function write_pages (pagelimit, cur)
{	
   var panel_ = parseInt (cur) / 20;
   var panel  = Math.floor (panel_);
   var limit;
   if ((panel + 1) * 20 > pagelimit) limit = pagelimit;
   else limit = (panel + 1) * 20;
    
   if( pagelimit > 1 )
   {
      var pc;

      document.write( "Page " );                		
		
      if (panel > 0)
      {
          var p = (panel * 20) - 1;
          document.write ("<a href=\"javascript:gotoPage('" + p + "')\">" +"&lt&lt</a> ")
      }

      for (pc=(panel * 20); pc<limit; pc++)
      {
	  if (pc!=cur)
          {
	      document.write("<a href=\"javascript:gotoPage('" + pc + "')\">" + (pc+1) + "</a> ")
	  }
	  else
          {
	      document.write("<b>" + (pc+1) + "</b> ")
	  }

          if ((pc == limit - 1) && (pc != pagelimit - 1))
          {
             var p = pc + 1;
             document.write ("<a href=\"javascript:gotoPage('" + p + "')\">" + "&gt&gt</a> ");
          }
      }
   }
}
	
      function myescape (str)
      {
                  var t="";
		      for (var i=0; i<str.length; i++) {
			    var ch = str.substring (i, i+1);
                      if (ch != "+") { 
                        t += ch;
                       }
                       else
                       {
                         t += "%2B";
                       }
                  }
		return t;
      }
      function quotquot (str)
      {
                  var t="";
		      for (var i=0; i<str.length; i++) {
			    var ch = str.substring (i, i+1);
                      if (ch != "\"") { 
                        t += ch;
                       }
                       else
                       {
                         t += "&quot;";
                       }
                  }
		return t;
      }

      function myunescape (str)
      {
                  var t="";
		      for (var i=0; i<str.length; i++) {
			    var ch = str.substring (i, i+1);
                      if (ch == "+") { 
                        t += " ";
                       }
                       else
                       {
                         t += ch;
                       }
                  }
		return t;
      }

	function getText() {
		if (document.iIntranetForm.iQueryStr.value!="") {
			return document.iIntranetForm.iQueryStr.value;
		}
		else {
			return "";
		}
	}
	
	function getTypeRech() {
	    var t = valueof( "iStrategy" );
		if( t != "" ) return t;
		return "Default";
	}
	
	function strip(arg)
	{
		var s = String( self.location );
                var temp = self.location.search.split("&");
		var newURL;

		var u = String(arg).split(" ");
		if( temp[0].substr( 0, 1 ) == "?" )
			temp[0] = temp[0] .substr( 1, temp[0].length-1 ) ;

		var temp3 = "";
		for (var i=0; i<temp.length; i++)
		{
			var no = 0;
			for( var j = 0; (j < u.length) && !no; j++ )
 			{
                         //alert( temp[i], " VS ", u[j], "BR" );
			 if( temp[i].split("=")[0] == u[j] ) no = 1;
			}
			
			if( !no ) { temp3 += temp[i] + "&"; }
		}
		
		temp3 = temp3.substr( 0, temp3.length- 1 );
                //alert( "before : ", temp3 );
	
		if( temp3.substr( 0, 1 ) == "&" )
			temp3 = "?" + temp3 .substr( 1, temp3.length-1 ) ;
		else if ( temp3.substr( 0, 1 ) != "?" )
			temp3 = "?" + temp3;
                //alert( temp3 );
		return String(self.location).split("?")[0] + temp3;
	}

	function addparam( u, v )
	{
        	var t = u.substr( u.length-1,1 );
		if( t == "?" || t == "&" )
			return u + v;
		else if( u.split("?").length == 1 ) return u + "?" + v;
		else return u + "&" + v;

	}
	
	function gotoPage(number) {
		window.location = addparam(strip( "iPageNumber" ) , "iPageNumber=" + number );
	}
	
	

	function getDatabase() {
		var t=""; var i;
		for ( i=0; i<document.iIntranetForm.iDatabaseSelection.length; i++) {
			if (document.iIntranetForm.iDatabaseSelection.options[i].selected) {
				t += document.iIntranetForm.iDatabaseSelection.options[i].value + ",";
			}
		}
		if ( t == "" )
		{
			for ( i=0; i<document.iIntranetForm.iDatabaseSelection.length; i++) {
					t += document.iIntranetForm.iDatabaseSelection.options[i].value + ",";
					}
		}
		if( t.length>0)  t = t.substr(0,t.length-1); 
		return t;
	}
	
