// Tools top menu related functions

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// Google Search form functions

function innerText(node) {
        if ((node.nodeType == Node.TEXT_NODE) ||
        (node.nodeType == Node.CDATA_SECTION)) {
          return node.data;
        }
        var childdata = '';
        if (node.hasChildNodes()) {
          for (i = 0; i < node.childNodes.length; i++) {
            childdata += innerText(node.childNodes.item(i));
          }
          return childdata;
        }
        return '';
      }
      function init() {
        finalinput = document.getElementById('finalinput');
        parts = new Object();
      }
      function applySample(e) {
        finalinput.value = innerText(e.currentTarget);
      }
      function updatepart(name, value) {
      }
      function updateform(e) {
        if (document.all)
        {
                //This is for IE
                e = window.event;
                var targ = e.srcElement;
        }
        else
        {
                //This is for Mozilla based or other browsers
                var targ = e.target;
        }
        if (targ.getAttribute) {
          tname = targ.getAttribute('id');
        } else {
          tname = targ.id;
        }
        tvalue = targ.value;
        if (!tvalue) {
          delete parts[tname];
        } else {
          switch (tname) {
            case 'or':
              parts[tname] = tvalue.split(/ +/).join(' OR ');
              break;
            case 'notextension':
              parts[tname] = '-filetype:' + tvalue;
              break;
            case 'extension':
              parts[tname] = 'filetype:' + tvalue;
              break;
            case 'notdomain':
              parts[tname] = '-site:' + tvalue;
              break;
            case 'domain':
              parts[tname] = 'site:' + tvalue;
              break;
            case 'linkop':
              parts[tname] = 'link:' + tvalue;
	      break;
            case 'defineop': 
              parts[tname] = 'define:' + tvalue;
              break;
            case 'excluded':
              items = tvalue.split(/ +/);
              for (i in items) {
                items[i] = '-' + items[i];
              }
              parts[tname] = items.join(' ');
              break;
            case 'phrase':
              parts[tname] = '"' + tvalue + '"';
              break;
            case 'synonym':
              items = tvalue.split(/ +/);
              for (i in items) {
                items[i] = '~' + items[i];
              }
              parts[tname] = items.join(' ');
              break;
            default:
              parts[tname] = tvalue;
              break;
          }
        }
        newvalue = [];
        for (part in parts) {
          newvalue.push(parts[part]);
        }

        finalinput.value = newvalue.join(' ');
        newvalue="";
      }

// Form Validation for link and define options
function checkform ( googlesearch )
{
 
  if (googlesearch.finalinput.length == 0) {
    alert( "Please enter your query" );
    googlesearch.required.focus();
    return false ;
  }
  return true ;
}


// Open new window for tool help
function helpWindow(page,width,height) {
    helpwindow = window.open(page,"helpwindow","width=" + width + ",height=" + height+",left=550,top=50,screenX=550,screenY=50,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
    helpwindow.focus();
 
    if (!helpwindow.opener) 
       helpwindow.opener = self;
}

function moreWindow(page,width,height) {
    morewindow = window.open(page,"morewindow","width=" + width + ",height=" + height+",left=650,top=80,screenX=650,screenY=80,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
    morewindow.focus();
 
    if (!morewindow.opener) 
       morewindow.opener = self;
}

// Open new window for search result
function openResultWindow(googlesearch) {
// Form validate
  var query_str=googlesearch.finalinput.value
  if (query_str.indexOf("link:") ==-1 || query_str.indexOf("define:") ==-1  ) {
   // alert( "You do not have Link Option" );
   // return false ;
    searchresult = window.open('http://www.google.com/search','searchresult','width=800,height=600,left=250,top=100,screenX=250,screenY=100,menubar=yes, status=yes, location=yes, toolbar=yes, scrollbars=yes, resizable=yes');
searchresult.focus();
return true ;
  }
  else {
    if (query_str.indexOf("link:") !=0 || query_str.indexOf("define:") !=0  ) {
      alert( "You can use only one Special Feature Option" );
      return false;
    }
  }
    

}

//Reset the one form. this basically reloads the page from history 0=current page
function clearForm() {
        history.go(0);
}

//Reset all Forms in a page
function resetAllForms (windowOrLayer) {
  if (!windowOrLayer)
    windowOrLayer = window;
  if (document.forms.length>0){
  for (var f = 0; f < document.forms.length; f++)
        windowOrLayer.document.forms[f].reset();
  }
  if (document.layers){
    for (var l = 0; l < windowOrLayer.document.layers.length;l++ )
       resetAllForms(windowOrLayer.document.layers[l]);
  }

  history.go(0);
}

// Tool Tips Text for Locate Google Search

var allofthewords_tip=	"The AND operator includes ALL keywords in your search. Results must have ALL words, in any order, in any position, within the document.";

var noneofthewords_tip=	"The (minus) - operator excludes any page with this word from the results. Ex: spaghetti -meatballs only returns documents containing spaghetti without the word meatballs.";
var oneofthewords_tip=	"Using the OR operator between keywords returns documents containing ANY of the words. Ex: rhino OR rhinoceros OR unicorn returns results containing any one of these words.";
var exactphrase_tip=	"A phase within double quotation marks will appear in results exactly as you write it. Ex: 'to be, or not to be.' Remember, Google is not case sensitive; capitalization is ignored.";
var usingdomain_tip=	"Focuses search on all sites within a single domain. Ex: site:edu searches all .edu websites. Also used to search within a specific site. Ex: site:nasa.gov returns results from just NASA's website.";
var usingfileext_tip=	"Narrows search to one file type. The most common file type is Hypertext Markup Language (html); others include, Adobe (pdf) and Microsoft (.doc, .xls, .ppt). Ex: filetype:doc returns Word documents.";
var usingnyms_tip=	"The tilde ~ operator in front of a keyword retrieves documents with that word and the word's 'nyms'. Nyms are types of words that focus or expand a search. Ex: ~cat returns results for cat, kitty, pet, and animal.";
var notusingdomain_tip=	"Eliminates one domain from your search. Ex: -site:com removes all .com sites from your results.";
var notusingfileext_tip="Eliminates one file type from your search. The most common file type extensions are html, pdf, doc, and ppt. Ex: -filetype:html removes all files ending in .html from your results.";

var link_tip=		"This special feature lets you find other websites that link to the website you are evaluating. Ex: link:21cif.imsa.edu will return a list of all sites that link to the 21st Century Information Portal.";
var define_tip=		"This special feature lets you check meaning and find additional keywords for your queries. The definition is based on the exact phrase you enter.";

var searchboxstrategy_tip= "Do a search. Scan the results. Revise the query, and try again!";

var search_tip=		"Learn how advanced queries improve search results. Use this tool to develop skills with your Search Box Strategy. Enter keywords and watch the magic as your query is built below. Then do the search. See the results. Revise the query, and try again!";
var spelling_tip=	"Spelling of your keywords makes a difference � use the online spell check tab";
var thesaurus_tip=	"Choosing the right keywords is critical, use the online thesaurus tab to find alternative keyword candidates";
var evaluation_tip=	"Use the online Evaluation Tool Tab to see the 10 questions to evaluate a site and tips on how to find the answers";
var citation_tip=	"Use the online citation tab to copy  required  information from the site  and create your  ready to use citation";
var browser_tip=	"Supported browsers are: IE6.0, Firefox1.0, Netscape7.1, Mozilla1.4.1, and Safari1.2.4(Mac OSX)."; 

var CarlH_tip=	"<a href=\'\'><span onClick=\"helpWindow(\'/aboutus/team/ch-profile\',600,400);return false;\"><img src=\'/aboutus/team/images/ch-picture\' width=\'106\'><br>Carl Heine, Ph.D</a>";
var DanB_tip=	"<a href=\'\'><span onClick=\"helpWindow(\'/aboutus/team/dbalzer-profile\',600,400);return false;\"><img src=\'/aboutus/team/images/dbalzer-picture\' width=\'100\'><br>Dan Balzer</a>";


// End Tool tips

function mmVoid() {;}
