/*
Javascript creates header bar and search bar at top of all ipl2 pages

Script puts in different links, images, and/or HTML code, depending on 
which part of ipl2 you are in. Looks for text in URL to to do this.
*/

document.write('<script type="text/javascript" src="/scripts/SearchErrors.js"> </script>\n');
document.write('<script type="text/javascript" src="/scripts/jquery.js"> </script>\n');
document.write('<script type="text/javascript" src="/scripts/jquery-ui.js"> </script>\n');
document.write('<script type="text/javascript" src="/scripts/parseSearch.js"> </script>\n');
//declare array for selecting option on search drop-down menu
var searchOptMenu = new Array();
//set values in array initially to nothing
var j=0;
for (j=0; j<4; j++) {
    searchOptMenu[j] = '';
}

//REMOVE WHEN YOU CAN OFFER ALL SEARCH OPTIONS ON ALL PAGES WITHOUT SEARCH CODE ERRORS.
var searchOptions = '';

// if in For Kids
if (document.URL.search(/div\/ask\/|askauthor|cquest|hello|KidSearch|kidspace|kidsweb|orca|poisonsafe|projectguide|stateknow|storyhour/) > 0)
{ 
    ipl2Logoa = 'logo_kida.jpg';
    ipl2Logob = 'logo_kidb.jpg';
    ipl2LogobHt = '104';
    ipl2Logoc = 'askLogoBG_kids';
    logoLink = '/div/kidspace/';
    askaLink = '/div/ask/';
    searchOptMenu[1]='selected="selected"';
}
// if in For Teens
else if (document.URL.search(/aplus|faeq|graphicnovels|procrast|teen|teenpoet|TeenSearch/) > 0)
{ 
    ipl2Logoa = 'logo_teena.jpg';
    ipl2Logob = 'logo_teenb.jpg';
    ipl2LogobHt = '105';
    ipl2Logoc = 'askLogoBG_teens';
    logoLink = '/div/teen/';
    askaLink = '/div/askus/';
    searchOptMenu[2]='selected="selected"';
}
// if in Special Collections
else if (document.URL.search(/detjazz|dino|election|euphrates|exhibit|farq|germanref|gsteinccp|gsteinlaw|div\/io|isler|kelsey|labadie|light|litcrit|mushist|natam|div\/pf|pfarch|pottery|potus|quiltshow|special|trains/) > 0)
{ 
    ipl2Logoa = 'logo_speciala.jpg';
    ipl2Logob = 'logo_specialb.jpg';
    ipl2LogobHt = '104';
    ipl2Logoc = 'askLogoBG_spec';
    logoLink = '/div/special/';
    askaLink = '/div/askus/';
    searchOptMenu[0]='selected="selected"';
}
// if in (Resources by) Subject area
else if (document.URL.search(/Finding|subject/) > 0)
{ 
    ipl2Logoa = 'logo_subjecta.jpg';
    ipl2Logob = 'logo_subjectb.jpg';
    ipl2LogobHt = '104';
    ipl2Logoc = 'askLogoBG_RbS';
    logoLink = '/div/subject/';
    askaLink = '/div/askus/';
    searchOptMenu[0]='selected="selected"';
}
// if in Newspapers & Magazines area
else if (document.URL.search(/news/) > 0)
{ 
    ipl2Logoa = 'logo_newsa.jpg';
    ipl2Logob = 'logo_newsb.jpg';
    ipl2LogobHt = '104';
    ipl2Logoc = 'askLogoBG_news';
    logoLink = '/div/news/';
    askaLink = '/div/askus/';
    searchOptMenu[3]='selected="selected"';
}
// else, use default settings for ipl2 pages
else {
    ipl2Logoa = 'logo_ipl2a.jpg';
    ipl2Logob = 'logo_ipl2b.jpg';
    ipl2LogobHt = '105';
    ipl2Logoc = 'askLogoBG_main';
    logoLink = '';
    askaLink = '/div/askus/';
    searchOptMenu[0]='selected="selected"';
}
//Actual HTML output
//Javascript variables, usually between '+ and +', are defined above
document.write('<div id="tooltip">\n');
document.write('<div id="tooltip-header">&nbsp;</div>\n');
document.write('<div id="tooltip-body">\n');
document.write('<div align="left" style="font-weight: bold; font-size:8pt; padding:1px;">Description:</div>\n');
document.write('<div id="tooltip-desc" class="tooltipcontainer">DESCRIPTION</div>\n');
document.write('<div align="left" style="font-weight: bold; font-size:8pt; padding:1px; margin-top:4px; ">Solution:</div>\n');
document.write('<div id="tooltip-sol" class="tooltipcontainer">BODY</div>\n');
document.write('</div>\n');
document.write('</div>\n');
document.write('<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">\n');
document.write('<tr>\n');
document.write('<td width="176" rowspan="2" valign="top">\n');
document.write('<a href="/">\n');
document.write('<img src="/div/images/'+ipl2Logoa+'" alt="ipl2 Logo" width="176" height="152" border="0" align="absmiddle" />\n');
document.write('</a>\n');
document.write('</td>\n');
document.write('<td height="105" valign="top" class="'+ipl2Logoc+'">\n');
document.write('<a href="'+logoLink+'">\n');
document.write('<img src="/div/images/'+ipl2Logob+'" width="460" height="'+ipl2LogobHt+'" border="0" />\n');
document.write('</a>\n');
document.write('</td>\n');
document.write('<td width="164" rowspan="2" valign="top" class="'+ipl2Logoc+'">\n');
document.write('<div align="center" id="askButtonDiv">\n');
document.write('<a class="askButton" href="'+askaLink+'">Ask an ipl2 Librarian</a>\n');
document.write('</div>\n');
document.write('</td>\n');
document.write('</tr>\n');
document.write('<tr>\n');
document.write('<td>\n');

// searchbox
document.write('<div class="center">\n');
document.write('<form name="frmSearch" id="frm" method="get" action="">\n');
document.write('<table width="498" height="71" border="0" cellpadding="0" cellspacing="0">\n');
document.write('<tr>\n');
document.write('<td width="25" id="search_left">&nbsp;</td>\n');
document.write('<td id="search_center">\n');
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0">\n');
document.write('<tr height="35px">\n');
document.write('<td>\n');
document.write('<input value="" name="Key" type="text" id="key_input" onKeyPress="return keyPress(event.keyCode)" onKeyUp="return charcheck(event.keyCode,this.id)" />\n');
document.write('</td>\n');
document.write('<td class="btnSearch">\n');
document.write('<div align="right" class="btnSearch">\n');
document.write('<button type="submit" id="btnSearch" onclick="return search();"><img border="0" align="right" alt="Search!" src="/div/images/btn_searchipl2main.gif" /> </button>\n');
document.write('</div>\n');
document.write('</td>\n');
document.write('</tr>\n');
document.write('<tr>\n');
document.write('<td><div style="text-align: center;">\n');
document.write('<table width="100%" border="0" cellspacing="0" cellpadding="0" style="padding-top:5px;">\n');
document.write('<tr>\n');
document.write('<td>\n');
document.write('<div align="left" id="choices"><strong>Search:\n');
document.write('<select name="collection" id="collOptions" class="dropdown" style="clear:none;">\n');
document.write('<option '+searchOptMenu[0]+' value="gen">All of ipl2</option>\n');
document.write('<option '+searchOptMenu[1]+' value="youth">For Kids</option>\n');
document.write('<option '+searchOptMenu[2]+' value="teen">For Teens</option>\n');
document.write('<option '+searchOptMenu[3]+' value="news">Newspapers &amp; Magazines</option>\n');
document.write('</select>\n');
document.write('</strong></div>\n');
document.write('</td>\n');
document.write('</table>\n');
document.write('</div>\n');
document.write('</td>\n');
document.write('<td><div align="center" id="choices"><strong><a href="/IPL/searchHelp.jsp" style="text-decoration: none;">Search Help</a></strong></div></td>\n');
document.write('</tr>\n');
document.write('</table>\n');
document.write('</td>\n');
document.write('<td width="25" id="search_right">&nbsp;</td>\n');
document.write('</tr>\n');
document.write('</table>\n');
document.write('</form>\n');
document.write('<div align="center"><div id="serror-1" align="center">&nbsp;</div></div>\n');
document.write('</div>\n');
document.write('</td>\n');
document.write('</tr>\n');
document.write('</table>\n');

// add padding to sides of main content area on all ipl2 pages
document.write('<div id="maincontainer">\n');


