function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_openBrWindow(theURL) { //v2.0
	options = "status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=500,height=450";
	window.open(theURL, "", options);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore) { //v3.0
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

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_jumpMenuGo(selName,targ,restore){ //v3.0
 var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
function limitText(limitField, limitCount, limitNum) {
        if (limitField.value.length > limitNum) {
                limitField.value = limitField.value.substring(0, limitNum);
        } else {
                limitCount.value = limitNum - limitField.value.length;
        }
}

// Exclamation point tells yuicompressor to leave comment intact
// Note that this comment must also appear within script tag in HTML that includes this JS file
/*!**********************************************
* Bookmark site script - Copyright Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use.
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code.
***********************************************/
function bookmarksite(title, url)
{
	if (document.all)
	{
		window.external.AddFavorite(url, title);
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel(title, url, "");
	}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function selectFormat(dropdown, baseURL) {
        var myindex  = dropdown.selectedIndex;
        var selValue = dropdown.options[myindex].value;
        var newurl = baseURL+"&format="+selValue+"#tabs";

        top.location.href = newurl;

        return true;
}

function selectProximity(dropdown, baseURL) {
        var myindex  = dropdown.selectedIndex;
        var selValue = dropdown.options[myindex].value;
        var newurl = baseURL+"&caseType="+selValue+"#tabs";

        top.location.href = newurl;

        return true;
}

function selectLoc(dropdown, baseURL) {
        var myindex  = dropdown.selectedIndex;
        var selValue = dropdown.options[myindex].value;
        var newurl = baseURL+"&loc="+selValue+"#tabs";

        top.location.href = newurl;

        return true;
}

function selectSort(dropdown, baseURL) {
        var myindex  = dropdown.selectedIndex;
        var selValue = dropdown.options[myindex].value;
        var sortElement = selValue.substring(0, selValue.indexOf("_"));
        var sortDir = selValue.substring(selValue.indexOf("_")+1);      

        var newurl = baseURL+"&se="+sortElement+"&sd="+sortDir+"&qt=sort_"+sortElement+"_"+sortDir;

        try {
            top.location.href = newurl;
        } catch (err) {
            // do nothing
        }
        return true;
}

function selectStyle(dropdown, baseURL) {
        var myindex  = dropdown.selectedIndex;
        var selValue = dropdown.options[myindex].value;

        var newurl = baseURL+"&style=" + selValue;
        top.location.href = newurl;
        return true;
}


function showhide(div_id) {
  NS4 = (document.layers) ? 1 : 0;
  IE4 = (document.all) ? 1 : 0;
  W3C = (document.getElementById) ? 1 : 0;
  if (W3C) {
    if (document.getElementById(div_id).style.display != 'none') {
      document.getElementById(div_id).style.display = 'none';
    } else {
      document.getElementById(div_id).style.display = '';
    }
  } else if (NS4) {
    if (document.layers[div_id].display != 'none') {
      document.layers[div_id].display = 'none';
    } else {
      document.layers[div_id].display = 'block';
    }
  } else {
    if (document.all[div_id].display != 'none') {
      document.all[div_id].display = 'none';
    } else {
      document.all[div_id].display = 'block';
    }
  }
}

function $()
{
    var elements = new Array();
    for (var i = 0; i < arguments.length; i++)
    {
        var element = arguments[i];
        if (typeof element == 'string')
            element = document.getElementById(element);
        if (arguments.length == 1)
            return element;
        elements.push(element);
    }
    return elements;
}
function listCheckAll()
{
    for (var i = 0; i < $("resultsform").length; i++)
    {
        if ($("resultsform")[i].type == "checkbox")
        {
            $("resultsform")[i].checked = true;
        }
    }
}
function listClearAll()
{
    for (var i = 0; i < $("resultsform").length; i++)
    {
        if ($("resultsform")[i].type == "checkbox")
        {
            $("resultsform")[i].checked = false;
        }
    }
}


/*! This script came from Uncle Jim's Javascript Examples at JDStiles.com */
function selectAll(theField)
{
        var tempval = eval("document." + theField)
        tempval.focus();
        tempval.select();
}

/* Show/Hide DIV */
function showMe (it, box)
{
        var vis = (box.checked) ? "block" : "none";
        document.getElementById(it).style.display = vis;
}



/* Select all checkboxes */
function mvcToggleChecked ()
{
        var curVal = document.listEntryForm.checkToggle.checked;
        if (curVal)
        mvcCheckAll ();
        else
        mvcClearAll ();
}
function mvcCheckAll()
{
        var lef = document.listEntryForm;
        var len = lef.elements.length;
        for (var i = 0; i < len; i++)
        {
                var e = lef.elements[i];
                if (e.name == "ed[]")
                        e.checked = true;
        }
}
function mvcClearAll()
{
        var lef = document.listEntryForm;
        var len = lef.elements.length;
        for (var i = 0; i < len; i++)
        {
                var e = lef.elements[i];
                if (e.name == "ed[]")
                        e.checked = false;
        }
}
function mvcVerifyChecked()
{
        var lef = document.listEntryForm;
        var len = lef.elements.length;
        var sel = false ;
        for (var i = 0; i < len; i++)
        {
                var e = lef.elements[i];
                if ((e.name == "ed[]") && e.checked)
                        return (true);
        }
        alert ("Bitte zuerst einen Titel aus der Liste auswählen.");
        return (false);
}
/* END Select all checkboxes */

/* Display hidden "added to list" message on search results pages. */
function addToList()
{
        var value = document.getElementById('theMenu').options[document.getElementById('theMenu').selectedIndex].value;
        var html = document.getElementById('theMenu').options[document.getElementById('theMenu').selectedIndex].innerHTML;

        if (value == "account-list-new.shtml")
        {
                window.location.href = "account-list-new.shtml";
        }
        else if (value != "#")
        {
                document.getElementById('list_name').innerHTML = html;
                document.getElementById('list_message').style.display = "inline";
        }
        else
        {
                document.getElementById('list_message').style.display = "none";
        }
        return false;
}

/* Toggle display of DIV when link is clicked */
/* Example: <a href="#" onclick="toggleDisplay('div-action-view-fulltext');return false;">show/hide</a> */
function toggleDisplay(divId)
{
        var div = document.getElementById(divId);
        div.style.display = (div.style.display=="inline" ? "none" : "inline");
}

/* THIS IS FOR THE MOUSEOVER TOOLTIP IN WCL AVAILABILITY AREA*/
// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety =  8;

function newelement(newid)
{ 
    if(document.createElement)
    { 
        var el = document.createElement('div'); 
        el.id = newid;     
        with(el.style)
        { 
            display = 'none';
            position = 'absolute';
        } 
        el.innerHTML = '&nbsp;'; 
        document.body.appendChild(el); 
    } 
} 
var ie5 = (document.getElementById && document.all); 
var ns6 = (document.getElementById && !document.all); 
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
    if(document.getElementById)
    {
        var iebody=(document.compatMode && 
        	document.compatMode != 'BackCompat') ? 
        		document.documentElement : document.body;
        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

        var lixlpixel_tooltip = document.getElementById('tooltip');
        lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + 'px';
        lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + 'px';
    }
}
function tooltip(tip)
{
 if(!document.getElementById('tooltip')) newelement('tooltip');
 var lixlpixel_tooltip = document.getElementById('tooltip');
 lixlpixel_tooltip.innerHTML = tip;
 myTimer = setTimeout('showTooltip()', 1100);
 document.onmousemove = getmouseposition;
}
function showTooltip()
{
 document.getElementById('tooltip').style.display = 'block';
}
function exit()
{
    document.getElementById('tooltip').style.display = 'none';
}

/*END TOOLTIP JS*/

function getGroupAvl(id, url) {
 var link = document.getElementById("linkgroupavl-"+id);
 link.style.display = 'none';

 var inp = document.getElementById("inpgroupavl-"+id);
 inp.style.display = 'inline';

 commLoadDocId(url, "groupavl-"+id);
}

//if a DB other than WorldCat is selected, and a scope other than "worldwide" is selected, show a warning
function showLimitWarning(nonWCDBSelected, msg) {
        var show=false;

        var scopeVal = document.getElementById("scope").value.toString();
        var scopeIndex = document.getElementById("scope").selectedIndex;
        var scopeText = document.getElementById("scope").options[scopeIndex].text;

        if (nonWCDBSelected && scopeVal != "0") {
                show = true;
        }
        
        if (show) {
		if (document.getElementById("dbalert_top_text"))
	                document.getElementById("dbalert_top_text").innerHTML = msg;

		if (document.getElementById("dbalert_bottom_text"))
	                document.getElementById("dbalert_bottom_text").innerHTML = msg;

		if (document.getElementById("dbalert_text"))
			document.getElementById("dbalert_text").innerHTML = msg;

		if (document.getElementById("dbalert_top"))
	                document.getElementById("dbalert_top").style.display = 'block';

		if (document.getElementById("dbalert_image"))
	                document.getElementById("dbalert_image").style.display = 'block';

		if (document.getElementById("dbalert_bottom"))
	                document.getElementById("dbalert_bottom").style.display = 'block';

		if (document.getElementById("dbalert"))
	                document.getElementById("dbalert").style.display = 'block';
        } else {
		if (document.getElementById("dbalert_top"))	
	                document.getElementById("dbalert_top").style.display = 'none';

		if (document.getElementById("dbalert_image"))
	                document.getElementById("dbalert_image").style.display = 'none';

		if (document.getElementById("dbalert_bottom"))
	                document.getElementById("dbalert_bottom").style.display = 'none';

		if (document.getElementById("dbalert"))
	                document.getElementById("dbalert").style.display = 'none';
        }
}
