//TexPoint javascript

var comingfrom; // Store here which texpoint page we are coming from

function TPsearch(sform,isframe)
{
 var str=sform.searchstr.value;
 var defstr=sform.defsearch.value;
  
 //sform.searchstr.value="";
 if(str=="") return;
 str=str.replace(/\s/,"+");
 if(defstr!="") str=defstr+"+"+str; 
 
 var siteID="a";
 if(isframe)
  {
  	if(sform.searchloc[0].checked) siteID="m";
  	else if(sform.searchloc[1].checked) siteID="f";
  }
 else
 	siteID=sform.searchloc.value;
 	
 var site="site%3Atexpoint.necula.org";
 if(siteID=="m") site="cache:texpoint.necula.org/manual.html";
 else if(siteID=="f") site="cache:texpoint.necula.org/faq.html";
 
 str="http://www.google.com/search?hl=en&q="+site+"+"+str;

 // Save where we are coming from
 if(isframe) {
     try {
         top.comingfrom = top.frames['content'].location.href;
     } catch(e) {
     }
     top.frames['content'].location.href=str;
 } else {
     try {
         top.comingfrom = window.location.href;
     } catch(e) {
     }
     window.location.href=str;
 }
}

function activateTPsearch(pagename)
{
    if(pagename=="")
        {
            pagename=document.URL;
            var p=pagename.lastIndexOf("/");
            pagename=pagename.substr(p+1);
        }	
    top.location.href="search.html?"+pagename;
}

function closeTPsearch()
{
    // If the content frame now show Google results we cannot get its href
    try {
        top.location.href = top.frames['content'].location.href;
    } catch(e) {
        if(top.comingfrom) {
            top.location.href = top.comingfrom;
        } else {
            top.localtion.href = "index.html";
        }
    }
}