/* VERSION = $Rev: 21 $ $Date: 2008-12-30 21:05:46 -0800 (Tue, 30 Dec 2008) $ */
/* This function decodes the any string
 that's been encoded using URL encoding technique */
function URLDecode( sEncodeString )
{
    // Create a regular expression to search all +s in the string
    var lsRegExp = /\+/g;
    // Return the decoded string
    return unescape(String(sEncodeString).replace(lsRegExp, " "));
}
function changeCursor( elementID, cursorStyle )
{
     var sElement = document.getElementById(elementID);
     if( sElement )
     {
        sElement.style.cursor = cursorStyle;
     }
}
/**
 * Handles the event triggered when the user selected a new language
 * from the dropdown created by the <!--{mflanguage}--> token. 
 *
 * @param sContext explicitly set the context.
 */
function changeLanguage( sContext )
{
	var sLanguage = document.getElementById('language');
	var sCurrentPage = document.getElementById('currentpage');
	var sURL;
	if( sLanguage && sCurrentPage )
	{
		if( !sContext )
			sContext = '/iii/metafind';
		sURL = sContext + 
			'/changeLanguage.do?language=' + sLanguage.value +
			'&currentpage=' + sCurrentPage.value;
		replaceOrRedraw(sURL);
	}
}
function addInput( sType, sName, sValue )
{
   var inputRow = document.createElement('INPUT');
   inputRow.setAttribute('type', sType);
   inputRow.setAttribute('name', sName);
   inputRow.setAttribute('value', sValue);
   inputRow.setAttribute('id', sName);
   document.appendChild(inputRow);
   /* return inputRow */
}
function addButton(sValue,sName)
{
    var newButton = document.createElement("INPUT");
    newButton.setAttribute("type","button");
    newButton.setAttribute("value",sValue);
    newButton.setAttribute("name",sName);
    newButton.setAttribute("id",sName);
    document.appendChild(newButton);
    /*return newButton;*/
}
function isBrowserIE7()
{
var ie=0;
if( navigator.appName.indexOf('Explorer')>-1 )
{
  if( navigator.appVersion.indexOf('MSIE 7')>-1 )
  ie=1;
}
return ie;
}
function isBrowserIE()
{
    var ie=0;
    if( navigator.appName.indexOf('Explorer')>-1 )
         ie=1;
    return ie;
}
function escapeQuot( str )
{
    s = s.replace(/"/g,"&quot;");
    return s;
}
function trim( str ) 
{
   if( str.length > 0 ) 
   {
      if( str.charAt(0)==' ' ) 
      {
        str = str.substr(1,str.length-1);
        str = trim(str);
      }
      if( str.charAt(str.length-1)==' ' ) 
      {
        str = str.substr(0,str.length-1);
        str = trim(str);
      }
   }
   return str;
}
function suppressErrors() 
{ 
    return true; 
}
window.onerror= suppressErrors;
function replaceOrRedraw( new_URL )
{
    //var oBase = document.all.tags('base');
    //if(oBase && oBase.target) oBase.target = _self;
    if( navigator.appVersion.charAt( 0 ) < '3' )
    	location = new_URL;
    else
    	location.replace( new_URL );
    return false;
}
function replaceOrRedrawParent( new_URL )
{
    //var oBase = document.all.tags('base');
    //if(oBase && oBase.target) oBase.target = _self;
    if( navigator.appVersion.charAt( 0 ) < '3' )
    	parent.location = new_URL;
    else
    	parent.location.replace( new_URL );
    return false;
}
function openNewWindow (newURL, windowName, modal)
{
    var win;
    /* modal does not work in IE and does not keep you from checking a box in FF */
    if( modal == 'yes')
    {
        // not all browsers support model dialog
        if( window.showModalDialog )
            win = window.showModalDialog(newURL, windowName, "dialogWidth:750px;dialogHeight:650px;status:yes;scroll:yes;resizable:yes");
        else
            /* unfortunately it still doesn't actually make it modal it just forces it 
               to stay in front which is the best that you can do with these browsers */
            win = window.open(newURL, windowName,
                  "titlebar=yes,toolbar=no,width=750,height=650,status=yes,scrollbars=yes,resizable=yes,dependent=true,menubar=no,modal=yes");
    }
    else
        win = window.open(newURL, windowName,
              "titlebar=yes,toolbar=no,width=750,height=650,status=yes,scrollbars=yes,resizable=yes,dependent=true,menubar=no");

    win.focus();
    return false;
}
function popWindow ( url,name,options )
{
  var ContextWindow = window.open(url,name,options);
  ContextWindow.focus();
  return false;
}
//function controlling the collapsable portions of the menus
function toggleLayer(whichLayer)
{
    if( document.getElementById )
    {
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
    }
    else if( document.all )
    {
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
    else if( document.layers )
    {
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
}
function defaultMFPopUpSimShowMe(elemid)
{
    document.getElementById(elemid).style.display = 'block';
}
function defaultMFPopUpSimHideMe(elemid)
{
    document.getElementById(elemid).style.display = 'none';
}
function addBreaks (nbrBR)
{
var htmlString = "";
for( var i = 0; i < nbrBR; i++ )
    htmlString += "<br />"; 
document.writeln(htmlString);
}
function showFooter()
{
var htmlString = "";
htmlString += "<div style=\"clear:both;\"></div>";
htmlString += "<div id=\"footer\">";
htmlString += "<br />";
htmlString += "<p class=\"contact\"><a href=\"./contact.html\">Contact Molly</a></a>&nbsp;&nbsp;&nbsp;";
htmlString += "<a href=\"./privacy.html\">Privacy Statement</a></a></p>";
htmlString += "<p class=\"copyright\">Copyright &copy; 2006-2009 Molly Axtmann. All rights reserved.</p>";
htmlString += "</div>";
document.writeln(htmlString);
}
function showFooterWithBreaks (nbrBR)
{
var htmlString = "";
htmlString += "<div style=\"clear:both;\"></div>";
htmlString += "<div id=\"footer\">";
for( var i = 0; i < nbrBR; i++ )
    htmlString += "<br />"; 
htmlString += "<p class=\"contact\"><a href=\"./contact.html\">Contact Molly</a></a>&nbsp;&nbsp;&nbsp;";
htmlString += "<a href=\"./privacy.html\">Privacy Statement</a></a></p>";
htmlString += "<p class=\"copyright\">Copyright &copy; 2006-2009 Molly Axtmann. All rights reserved.</p>";
htmlString += "</div>";
document.writeln(htmlString);
}
function showFooterWithValue (sValue)
{
var htmlString = "";
htmlString += "<div style=\"clear:both;\"></div>";
htmlString += "<div id=\"footer\">";
htmlString += "<br />";
htmlString += sValue;
htmlString += "<p class=\"contact\"><a href=\"./contact.html\">Contact Molly</a></a>&nbsp;&nbsp;&nbsp;";
htmlString += "<a href=\"./privacy.html\">Privacy Statement</a></a></p>";
htmlString += "<p class=\"copyright\">Copyright &copy; 2006-2009 Molly Axtmann. All rights reserved.</p>";
htmlString += "</div>";
document.writeln(htmlString);
}
function showCopyrightFooterWithValue (sValue)
{
var htmlString = "";
htmlString += "<div style=\"clear:both;\"></div>";
htmlString += "<div id=\"footer\">";
htmlString += "<br />";
htmlString += sValue;
htmlString += "<p class=\"contact\"><a href=\"./privacy.html\">Privacy Statement</a></a></p>";
htmlString += "<p class=\"copyright\">Copyright &copy; 2006-2009 Molly Axtmann. All rights reserved.</p>";
htmlString += "</div>";
document.writeln(htmlString);
}
function showContactFooter ()
{
var htmlString = "";
htmlString += "<div style=\"clear:both;\"></div>";
htmlString += "<div id=\"footer\">";
htmlString += "<br />";
htmlString += "<p class=\"contact\"><a href=\"./privacy.html\">Privacy Statement</a></a></p>";
htmlString += "<p class=\"copyright\">Copyright &copy; 2006-2009 Molly Axtmann. All rights reserved.</p>";
htmlString += "</div>";
document.writeln(htmlString);
}
function showPrivacyFooter ()
{
var htmlString = "";
htmlString += "<div style=\"clear:both;\"></div>";
htmlString += "<div id=\"footer\">";
htmlString += "<br />";
htmlString += "<p class=\"contact\"><a href=\"./contact.html\">Contact Molly</a></a></p>";
htmlString += "<p class=\"copyright\">Copyright &copy; 2006-2009 Molly Axtmann. All rights reserved.</p>";
htmlString += "</div>";
document.writeln(htmlString);
}

