function popmeebo()
{
helpwindow= window.open ("http://library.ndsu.edu/help/im/", "im",
    "location=1,status=1,scrollbars=1,width=600,height=400");
helpwindow.moveTo(0,0);
}


function irsdonation()
{
helpwindow= window.open ("https://epayment.ndus.nodak.edu/C22800_ustores/web/product_detail.jsp?PRODUCTID=3150&SINGLESTORE=true", "donate",
    "location=1,status=1,scrollbars=1,width=800,height=700");
helpwindow.moveTo(0,0);
}



function clearFunction(input) {
	if (input.defaultValue==input.value) {
		input.value = "";
	}
}

 var catMessage = "Search for books, ebooks, journals, movies, & more";
 var odinMessage = "Click to search regional libraries";
 var triMessage = "Click to search the Tri-College";


 var catalog = '<p>Example: Freakonomics</p><form action="http://catalog.library.ndsu.edu/search/" method="get" name="search" id="search"><p><input type="hidden" value="X" name="searchtype" id="searchtype" value="X"/><input name="searcharg" value="'+catMessage+'" size="30" maxlength="75" id="searcharg" type="text" onclick="clearFunction(this);" onkeypress="clearFunction(this);"/><input type="hidden" name="SORT" value="D" /><input type="hidden" value="1" name="searchscope" id="searchscope" /> <input class="buttons" type="SUBMIT" name="cmdSearchSubmit" value="Search"/></form><div style="clear:both;"><input type="radio" id="catalog" name="searchTarget" value="catalog" checked onClick="javascript:changeCatalogTarget(this)"> <label for ="catalog">NDSU Catalog</label> <input type="radio" id="odin" name="searchTarget" value="odin" onClick="javascript:changeCatalogTarget(this)"> <label for ="odin">Regional Libraries</label> <input type="radio" id="triCollege" name="searchTarget" value="triCollege" onClick="javascript:changeCatalogTarget(this)"> <label for ="triCollege">Tri-college</label></div>'; 
 
  function multiSearch(search) {
  	var message = "";
  	switch(search){
  		case "odin":
  			message = odinMessage;
  			break;
  		case "triCollege":
  			message = triMessage;
  			break;
  		default:
  			break;
  	}
  	return '<p>Example: Freakonomics</p><form id="searchForm" name="search" method="post" action=""><p><input name="searcharg" value="'+message+'" size="30" maxlength="75" id="searcharg" type="text" onclick="javascript:clearFunction(this);" onkeypress="javascript:clearFunction(this);"/> <input class="buttons" type="SUBMIT" name="cmdSearchSubmit" value="Search"/></p></form><div style="clear:both;"><input type="radio" id="catalog" name="searchTarget" value="catalog"  onClick="javascript:changeCatalogTarget(this)"> <label for ="catalog">NDSU Catalog</label> <input type="radio" id="odin" name="searchTarget" value="odin" onClick="javascript:changeCatalogTarget(this)"> <label for ="odin">Regional Libraries</label> <input type="radio" id="triCollege" name="searchTarget" value="triCollege" onClick="javascript:changeCatalogTarget(this)"> <label for ="triCollege">Tri-college</label></div>';
 }
 
  var articles ='<p>Search for journal articles in multiple databases</p><form id="searchForm" name="search" method="post" action="/multi-db/"><p><input name="searcharg" value="Search selected library databases" size="30" maxlength="75" id="searcharg" type="text" onclick="javascript:clearFunction(this);" onkeypress="javascript:clearFunction(this);"/><input class="buttons" type="SUBMIT" name="cmdSearchSubmit" value="Search"/></p></form>';
  var printJournals = '<p>Browse journals</p><form action="http://catalog.library.ndsu.edu/search" method="post" name="search" id="search"><input type="hidden" name="searchtype" id="searchtype" value="h"/><input name="searcharg" value="Enter Journal title" size="30" maxlength="75" id="searcharg" type="text" onclick="clearFunction(this);" onkeypress="clearFunction(this);"/><input type="hidden" name="SORT" value="D" /><input type="hidden" value="1" name="searchscope" id="searchscope" /> <input class="buttons" type="SUBMIT" name="cmdSearchSubmit" value="Search"/></form><p style="clear: both;"><input type="radio" name="journal" value="ejournal" id="ejournal" onClick="javascript:switchJournals(this,ejournals);"> <label for="ejournal" checked>Electronic Journals</label> <input type="radio" name="journal" value="ejournal" id="ejournal" checked> <label for="paper">Print Journals</label></p>';
  
  var ejournals = '<p>Browse journals</p><form action="http://atoz.ebsco.com/titles.asp" method="get"><input name="txtKeyword" value="Enter Journal title" size="30" onclick="clearFunction(this);" onkeypress="clearFunction(this);"/> <input type="HIDDEN" name="SF" value="Titles"/><input type="hidden" name="id" value="8829"/><input type="hidden" name="sid" value="95023143" ID="Hidden1"/><input type="hidden" name="LH" value="" ID="Hidden2"/><input type="hidden" name="lang.subject" value="" ID="Hidden3"/><input type="hidden" name="lang.menu" value="" ID="Hidden4"/><input type="hidden" name="lang" value=""/><input class="buttons" type="SUBMIT" name="cmdSearchSubmit" value="Search"/></form><p style="clear:both;"><input type="radio" name="journal" checked value="ejournal" id="ejournal"> <label for="ejournal" >Electronic Journals</label> <input type="radio" name="journal" value="ejournal" id="paper" onClick="javascript:switchJournals(this,printJournals);"> <label for="paper">Print Journals</label></p>  Browse: <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=65&lang=en">A</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=66&lang=en">B</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=67&lang=en">C</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=68&lang=en">D</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=69&lang=en">E</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=70&lang=en">F</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=71&lang=en">G</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=72&lang=en">H</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=73&lang=en">I</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=74&lang=en">J</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=75&lang=en">K</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=76&lang=en">L</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=77&lang=en">M</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=78&lang=en">N</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=79&lang=en">O</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=80&lang=en">P</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=81&lang=en">Q</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=82&lang=en">R<a/> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=83&lang=en">S</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=84&lang=en">T</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=85&lang=en">U</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=86&lang=en">V</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=87&lang=en">W</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=88&lang=en">X</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=89&lang=en">Y</a> <a href="http://atoz.ebsco.com/titles.asp?Id=NDST1372&menuid=90&lang=en">Z</a>';
  
	var searchsite = '<p>Look for information on the library site</p><form action="http://library.ndsu.edu/search/?" method="get" name="headersearchform" id="headersearchform"><input name="term" value="Click to search" size="15" id="term" type="text" onclick="clearFunction(this);" onkeypress="clearFunction(this);"/>	<input name="num" id="num" type="hidden" value="25"/><input name="omit" id="omit" type="hidden" value=""/><input name="advsearch" value="yes" type="hidden"/><input name="exactphrase" value="" type="hidden"/><input type="submit" value="Search" name="submit" alt="Submit Search" /></form>'; 
	
var ask = '<p>Ask a reference librarian</p> <p style="margin-top: 1em;"> <a href="/ask-librarian/">Phone</a>| <a href="http://library.ndsu.edu/ask-librarian/">IM/Chat Service</a>| <a href="/research-help/">How do I...</a></p>';
 
  
 //returnXMLDoc("http://library.ndsu.edu/tools/user-tags/selectBox.php/?user=char.myhre&topic=frequent-databases");
 
 	function changeCatalogTarget(target){
		// We want to preserve user input
		text = $("searcharg").value;
		switch(target.value){
			case "odin":
				target.parentNode.parentNode.innerHTML = multiSearch("odin");
				$("searchForm").action = "http://library.ndsu.edu/multi-cat/";
				$("odin").checked = true;
				getSearchBoxText(text,target.value);
				break;
			case "triCollege":
				target.parentNode.parentNode.innerHTML = multiSearch("triCollege");
				$("searchForm").action = "http://library.ndsu.edu/tri-college/";
				$("triCollege").checked = true;
				getSearchBoxText(text,target.value);
				break;
			default:
				target.parentNode.parentNode.innerHTML = catalog;
				getSearchBoxText(text,target.value);
				break;
		}
	}
	function getSearchBoxText(text,target){
 		if (
 			text == "Click to search the Library Catalog" ||
 			text == "Click to search regional libraries" ||
 			text == "Click to search the Tri-College" || 
 			text == "") {
 				
 				switch(target){
 					case "odin":
 						text = odinMessage;
 						break;
 					case "triCollege":
 						text = triMessage;
 						break;
 					default:
 						text = catMessage;
 						break;
				}
 		}
		document.getElementById("searcharg").value = text;
 	}

  function setText(text,theElement){
  	if ($("content2").visible() == false){
	  	$("content2").update(text);
	  	Effect.Fade('content1', {duration:0.25 });
	  	Effect.Appear('content2',{duration:0.25,queue:'end'});
		} else {
			$("content1").update(text);
			Effect.Fade('content2',{duration:0.25});
			Effect.Appear('content1',{duration:0.25,queue:'end'});
		}
		
    if (theElement != undefined){
      id = Element.identify(theElement);

      Element.setStyle($(theElement).up(),"background:#002119 none repeat scroll 0 0;border-style: solid;border-width: 1px;border-color: white;border-bottom-style:none;padding-bottom: 0em;padding-top: 0em;");
      Try.these(
        function(){Element.setOpacity($(theElement).up(),1.0)},
        function(){Element.setOpacity(theElement,1.0)}
      );
      Element.setStyle(theElement,"font-weight:bold;");
      //Effect.Pulsate(id,{pulses: 5, duration: 0.75});
      theElement.blur();
      resetTabs(Element.siblings($(theElement).up()));
    }
  }
  function resetTabs(tabs){
    for (var i in tabs){
      Element.setStyle(tabs[i],"background:##009900 none repeat scroll 0 0;border-width: 0px;font-weight:normal;padding: 0.5em;padding-bottom: 0em;padding-top: 0em;");
      Try.these(function(){Element.setOpacity(tabs[i],0.80)});

      descendants = Element.childElements(tabs[i]);
     // Element.setStyle(descendants[0],"font-weight:normal;");
     if (descendants[0]!= undefined){
       //alert(descendants[0].innerHTML);
       Element.setStyle(descendants[0],"font-weight:normal;");
     }
    }
  }
  function switchJournals(object, target){
  	object.parentNode.parentNode.innerHTML = target;
  }
