//---------------------------------------------------------------
// This file has general purpose scripts for Web Course
//---------------------------------------------------------------
// This script should be included in all wNN.html files

 document.onclick=menuClick
 document.onmouseover=menuOver
 document.onmouseout=menuOut

if(top.location!=location)top.location.href=location.href

xbDetectBrowser();
//alert("Browser Sniffing Example" + "\n"+ "navigator.OS=" + navigator.OS + "\n" + "navigator.version=" + navigator.version + "\n" + "navigator.org=" + navigator.org + "\n" + "navigator.family=" + navigator.family)

/*
if(navigator.OS=="mac") {
    alert("This site requires Internet Explorer 5.5 or newer."+"\n\r"+ "Microsoft may not have upgraded the Macintosh Explorer yet.")
    document.styleSheets(0).href="../styles/web-mac.css"; // if mac use other css
    }

 */
 if(navigator.family.indexOf("nn") != -1){
    alert("This site requires Netscape 6 or newer." + "\n\r" + "The latest Netscape version may be downloaded free.")
    window.close()
}
var localhost = false;
//if(location.href.indexOf("file:") == -1 && location.href.indexOf("localhost") == true) { localhost = false; }
if(location.href.indexOf("localhost") == true) { localhost = true; }
if ( localhost ) { // works for local host or server host
	var hostAt = "http://localhost/ClassAnytime/mis373" }
else{
	var hostAt = "http://www.classanytime.com/mis373"
}
function localClick(to){
//document.write("<input type='button' value='&nbsp;Start&nbsp;' " + localClick("php/mx025.php") + "class='submit'  />")
    var href = "'" + hostAt + "/" + to
    href = "onclick=\"" + "location.href=" + href + "\'\""
    return href
}
function localHref(to){
// document.write("<a " + localHref('php/mx025.php?skipintro') + " title=' Join '>Join</a>")
    var href =  hostAt + "/" + to
    href = "href=\'" + href + "\'"
    //alert(href)
    return href
}
function checkMode(e){   // called from body onload to check event model
	if(window.event){alert("IE4+ event model")}else{if(e)alert("W3C/Netscape6+ event model")}
}
function wiggle(obj){
	obj.style.position = 'relative'
	obj.style.top = '-1px'
	obj.style.left = '-1px'
}
function unWiggle(obj){
	obj.style.position = 'relative'
	obj.style.top = '0px'
	obj.style.left = '0px'
}
function wOpen(f,h,w){
	var p="height=" + h + ",width=" + w + ",menubar=1,toolbar=0,scrollbars=1,resizable=1";
	window.open( f, "x", p )
}
function hrefClick(){
// <a href='javascript:hrefClick()'>example text</a>
	alert("You REALLY thought this was an active link?\n\nDoes this mean you will click anything?\n");
}
function printThis(o,title){
// creates a popup with only the contents of an object (for printing sections of pages)
    MyWindow = window.open("","MyWindow",
       "toolbar=yes,location=no,directories=no,status=no," +
       "menubar=yes,scrollbars=yes,resizable=yes,dependent=yes," +
       "width=500,height=400,hotkeys=no");
    var str = "<html><head>" +
    "<title>" + title + "</title><style type='text/css'>" +
    "body{margin:5%}@media print{input{display:none}}</style>" +
    "</head><body><input type='button' value=' Print ' style='margin-top:-12px' onClick='window.print();' />" + o.innerHTML + "<br clear='all' /><input type='button' value=' Close ' style='margin-top:-16px' onClick='self.close();' />&nbsp;&nbsp;</body></html>"
    self.MyWindow.document.open()
    self.MyWindow.document.write(str)
    self.MyWindow.document.close()
    MyWindow.focus()
}
/*--------------------------------------------------------------------------- */
var ns = (navigator.appName.indexOf('Netscape')>-1);
var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1);

function bg(e) {
    if (ns)  { var obj = e.target } else { var obj = e.srcElement }

    if( obj.tagName=="BODY" || obj.tagName=="TABLE") return              //alert(obj.previousSibling.tagName)

    if(obj.nodeType == 3)  obj = obj.parentNode    //  necessary for Netscape, not IE

    if(e.type=="mouseover" && obj.tagName=="A"){
        obj.style.backgroundColor="rgb(255,255,255)"  //"url(images/BGtestLeft.png) repeat-y" // //
        obj.style.cursor="hand"
    }
    if(e.type=="mouseout" && obj.tagName=="A"){
        obj.style.backgroundColor="transparent"
        // obj.style.background="url(images/BGtestRight.png) repeat-y"
    }
}

function menuClick(e){
    if (ns) { var obj = e.target } else { var obj = event.srcElement }

    if(obj.nodeType == 3)  obj = obj.parentNode        //  necessary for Netscape
	if(obj.id=="banner") nextPage(1) 						// nextPage(1) = forward, nextPage(0) = backward
    if(left(obj.tagName,1) == "H" || obj.className == "tof") {
        if(obj.className != 'check') looseMenuHome();
        return }

    if(obj.className.indexOf('menu')>-1){
       obj.className='menuClickBG'
       return }

    if(obj.id=="looseMenu") {return}

    if(obj.id=="leftColumn"){                      // move loose menu to point clicked in left col

         if (ie) { document.getElementById("looseMenu").style.top = window.event.offsetY + "px" }
           else { document.getElementById("looseMenu").style.top = e.clientY + "px" }

        //document.frmSearch.words.focus()    // see function searchMask() which sets focus also
        }
}
function looseMenuHome(){
    var targetTop= document.getElementById('looseMenu')
    targetTop.style.top = -20 +"px"                /* this MUST be coordinated with CSS */
    //document.frmSearch.words.focus()          // see function searchMask() which sets focus also
    window.scrollTo(0,0)
}
function looseOnClick(obj){    /* moves loose menu down to clicked topic */
    var h = obj.href
    var s = h.indexOf("#",0) +1
    if ( h==null || h.length<1 || s<2 ) return
    var eyeD = h.substring(s,9+s)
    var targetTop= document.getElementById(eyeD).offsetTop + 8
    if(ns) targetTop = targetTop +20
    var loose = document.getElementById('looseMenu')
    loose.style.top = 0 + targetTop  +"px"
    if (eyeD.indexOf("^",0) > -1) {
    	looseMenuHome()              // special id that has "^"
	}else{
		location.href =  h
	}
    return true
}
function menuOver(e){
    if (ns) { var obj = e.target } else { var obj = event.srcElement }
    if (obj.nodeType == 3)  obj = obj.parentNode        //  necessary for Netscape
    if (obj.className.indexOf('menu')>-1){
       obj.className='menuOverBG'
    }
}
function menuOut(e){
    if (ns) { var obj = e.target } else { var obj = event.srcElement  }
    if (obj.nodeType == 3)  obj = obj.parentNode        //  necessary for Netscape
    if (obj.className.indexOf('menu')>-1){
       obj.className='menuBG'
    }
}
function showMenus(x){
    document.getElementById('menuIntro').className="menuHide"
    document.getElementById('menuXHTML').className="menuHide"
    document.getElementById('menuCSS').className="menuHide"
    document.getElementById('menuXML').className="menuHide"
    document.getElementById('menuJS').className="menuHide"
    document.getElementById('menuDESIGN').className="menuHide"
    document.getElementById('menuGRAPHICS').className="menuHide"
    document.getElementById('menuSERVER').className="menuHide"
    if(x < 0 || x > 7) return
  switch (x){
    case 0:
        document.getElementById('menuIntro').className="menuDisplay";  break
    case 1:
        document.getElementById('menuXHTML').className="menuDisplay"; break
    case 2:
        document.getElementById('menuCSS').className="menuDisplay"; break
    case 3:
        document.getElementById('menuXML').className="menuDisplay"; break
    case 4:
        document.getElementById('menuJS').className="menuDisplay"; break
    case 5:
        document.getElementById('menuDESIGN').className="menuDisplay"; break
    case 6:
        document.getElementById('menuGRAPHICS').className="menuDisplay"; break
    case 7:
        document.getElementById('menuSERVER').className="menuDisplay"; break
    }
}
function searchMask(){
        document.write("<div style='font-size:8pt;width:100px;height:40px;position:relative; top:6px;left:40px; background:transparent; color:white' >")

        document.write("<img src='images/SiteMapButton.jpg' onclick='location.href=\"Web-SiteMap.html\"' alt='Site Map' /></div>")
}
function searchMaskOLD(){
        document.write("<div style='font-size:8pt;width:202px;height:80px;position:relative; top:6px;left:0px;zborder:1px blue solid;background:url(images/BGSearch1.png) no-repeat transparent;color:white' >")
        document.write("<span style='position:relative;left:55px;top:1px'>Search the site</span>")
        document.write("<div style='border-left:1px rgb(63,114,152) solid;border-right:1px rgb(80,136,136) solid;border-bottom:1px rgb(80,136,136) solid;'><img src='images/pixel.gif' width='198' height='71' /></div>")
        document.write("</div><div style='height:60px;width:190px;position:relative; top:-60px;left:10px;xborder:red 1px solid;margin-bottom:-55px'>  ")
        document.write("<form name='frmSearch'  style='margin-top:8px' method='get' action='http://www.utexas.edu/local/cgi-bin/htsearch'>  ")
        document.write("<input type='text' style='font-size:8pt;' size='24' name='words'  />  ")
        document.write("<input type='submit' style='font-size:8pt;background-color: rgb(63,114,152); color:rgb(255,255,255);' value=' Go ' /><br /><span style='padding-left:18px'>or show the&nbsp;</span>")
        document.write("<input type='button' style='font-size:8pt;margin-top:2px;background-color: rgb(63,114,152); color:rgb(255,255,255);' onclick='location.href=\"Web-SiteMap.html\"' value='Site Map' />")
        document.write("<input type='hidden' name='config' value='poynor' /><input type='hidden' name='restrict' value='' /><input type='hidden' name='exclude' value='' />")
        document.write("<input type='hidden'  name='format' value='builtin-long' /><input type='hidden' name='method' value='and' /><input type='hidden'  name='sort' value='score' /></form></div>")
        document.frmSearch.words.focus()   // see function menuClick() which sets focus also
}
function topWEBpage(){
document.write("<table id='topWEBpage' cols='8' align='left'  height='31' >")
document.write("<colgroup span='8' width='50' style='font-size:10pt; '></colgroup>")
document.write("<tr>")
//document.write("<span class='topMENUitems'>")
document.write("<td><a id='topIntro' href='#' title='Syllabus, assignments, tests, FAQs, your Web site, Internet history' onmouseover='showMenus(0)'>&nbsp;&nbsp;Home&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topXHTML' href='#' title='HTML and XHTML, references, tutorials, code examples' onmouseover='showMenus(1)'>&nbsp;&nbsp;XHTML&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topCSS'   href='#' title='cascading style sheet references, tutorials, code examples' onmouseover='showMenus(2)'>&nbsp;&nbsp;CSS&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topXML'   href='#' title='XML introduction, references, tutorials, code examples' onmouseover='showMenus(3)'>&nbsp;&nbsp;XML&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topJS'    href='#' title='JavaScript introduction, references, tutorials, code examples' onmouseover='showMenus(4)'>&nbsp;&nbsp;JScript&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topDESIGN' href='#' title='sites, pages, usability' onmouseover='showMenus(5)'>&nbsp;&nbsp;Design&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topGRAPHICS' href='#' title='introduction to graphics and art' onmouseover='showMenus(6)'>&nbsp;&nbsp;Graphics&nbsp;&nbsp;</a></td>")
document.write("<td><a id='topSERVER' href='#' title='introduction to server-side programming, ASP PHP references, tutorials, code examples' onmouseover='showMenus(7)'>&nbsp;&nbsp;Server&nbsp;&nbsp;</a></td>")
document.write("</tr></table>")

}
function topMenus(){
document.write("<table id='menuIntro' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web1.php") + " title='Topics covered, grading, assignments, tests, time and materials required, display setup, FAQ'>1 Course syllabus</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web2.php") + " title='Your Web site, URL, Web folders, uploading,mirror site, TextPad for editing Web pages'>2 Tools of the trade</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web3.php") + " title='Networking, TCP/IP, e-mail, Usenet, FTP, Telnet, Web census'>3 Internet history</td></tr>")
document.write("</table>")
document.write("<table id='menuXHTML' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web4.php") + " title='Introduction to markup, well-formed markup, XHTML defined, deprecation of HTML, examples'>4 Introduction to XHTML</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web5.php") + " title='Markup standards, purpose of markup, attributes, examples'>5 Basic markup</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web6.php") + " title='Page structure, block, inline, lists, people need structure to read, examples'>6 Element structure &amp; lists</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web7.php") + " title='Introduction to linking, design inportance of links, link attributes, automatic links, audio and video, examples'>7 Hyperlinks & multimedia</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web8.php") + " title='Introduction to Web images, folders, attributes, alignment, spacing, thumbnails, examples'>8 Images</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web9.php") + " title='Introduction to table markup, table and cell spacing, table and cell width, examples'>9 Table introduction</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web10.php") + " title='Alignment, width, size, borders, frames, styles, examples'>10 Advanced tables</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web11.php") + " title='Introduction to markup for areas of images, shape, coordinates, buttons, examples'>11 Image maps</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web12.php") + " title='Introduction to framesets markup, multiple pages, page to page communication, inline frames, examples'>12 Frames</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web13.php") + "title='Introduction to data gathering in XHTML, buttons, text boxes, examples'>13 Forms introduction</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web14.php") + " title='Pull-down lists, file uploads, multi-selection lists, verification of input, receiving forms on servers, examples'>14 Advanced forms</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web15.php") + " title='Source code for popular effects and techniques, links to references'>15 Samples and links</td></tr>")
document.write("</table>")
document.write("<table id='menuCSS' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web16.php") + " title='Cascading Style Sheets, terminology, syntax, principles of style markup'>16 CSS introduction</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web17.php") + " title='Fonts, text, the box model, borders, color chart, margins, padding'>17 Typeface and borders</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web18.php") + " title='Horizontal and vertical alignment, float, clear, hiding content, precise positioning'>18 Position and align</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web19.php") + " title='List styling, backgrounds, color chart, cursor, scrolling, print styles, using styles instead of tables for layout'>19 Advanced techniques</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web20.php") + " title='Source code for style effects and techniques, links to references'>20 Samples and links</td></tr>")
document.write("</table>")
document.write("<table id='menuXML' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web21.php") + " title='Introduction to XML, why we need XML, W3C, XHTML as XML, examples'>21 What is XML?</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web22.php") + " title='Schemas and DTDs defined, validating XML with Schemas and DTDs, industry examples of Schemas and DTDs'>22 A look inside XML</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web23.php") + " title='Using XML files as data sources for XHTML pages, data islands, CSS with XML, examples'>23 XML in action</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web24.php") + " title='Selecting and sorting with XSLT, introduction to nodes, examples'>24 XSLT</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web25.php") + " title='Source code for XML and XSLT techniques, links to references'>25 Samples and links</td></tr>")
document.write("</table>")
document.write("<table id='menuJS' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web26.php") + " title='Client- and server-side, when and where to script, DOM, syntax errors'>26 JavaScript introduction</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web27.php") + " title='Naming conventions, window, document, location, time, date, math, frames, child windows, events'>27 JavaScript objects</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web28.php") + " title='String methods, data typing, if, for, functions, scope and lifetime, arrays'>28 JavaScript methods</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web29.php") + " title='When and where to script, when errors occur, debugging, debugging, debugging'>29 Scripting and debugging</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web30.php") + " title='Styling and re-styling with JavaScript, examples of efficient scripting'>30 Dynamic XHTML</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web31.php") + " title='Hiding content, replacing content, rollovers, popups, resizing windows, validating form input, cookies'>31 JavaScript in action</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web32.php") + " title='Script source code for popular effects and techniques, links to references'>32 Samples and links</td></tr>")
document.write("</table>")
document.write("<table id='menuDESIGN' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web33.php") + " title='Audience, purpose, content, design goals, examples'>33 Web design defined</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web34.php") + " title='Pages must display essentials, types of sites, search engines, alliances with other sites, examples'>34 Business of Web design</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web35.php") + " title='Page objectives, points of view, writing style, printing, page size, site navigation, techniques for prettier pages, examples'>35 Page and site design</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web36.php") + " title='Design element examples, links to tutorials and references'>36 Samples and links</td></tr>")
document.write("</table>")
document.write("<table id='menuGRAPHICS' class='menuHide' border='1' cellspacing='0' cellpadding='0'>")
document.write("<tr><td class='menuBG' " + localClick("Web37.php") + " title='Planning, design, formats, resolution, PhotoImpact, examples'>37 Introduction to graphics</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web38.php") + " title='Tools, effects, anti-aliasing, line art, backgrounds, special effects, photos, examples'>38 Intermediate graphics</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web39.php") + " title='Icons, buttons, rollovers, banners, animation, slicing, free art, examples'>39 Advanced graphics</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web40.php") + " title='Graphics tutorials and references'>40 Samples and links</td></tr>")
document.write("</table>")
document.write("<table id='menuSERVER' class='menuHide' border='1' cellspacing='0' cellpadding='0' >")
document.write("<tr><td class='menuBG' " + localClick("Web41.php") + " title='Server- and client-side scripts, generating XHTML pages, HTTP headers, examples'>41 Server introduction</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web42.php") + " title='Steps to ASP programs, sessions, recordset maintenance, cookies, examples'>42 Introduction to ASP</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web43.php") + " title='Sending forms to servers, PHP syntax, strings, if, for, switch, e-mail, html e-mail, examples'>43 Introduction to PHP</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web44.php") + " title='Script source code and techniques, links to references'>44 Samples and links</td></tr>")
document.write("<tr><td class='menuBG' " + localClick("Web45.php") + " title='Web services explained with examples and exercises'>45 Web services</td></tr>")

document.write("</table>")
}
function nextPage(direction){    	// nextPage(1) = forward, nextPage(0) = backward, called from menuClick()
	var lochref=location.href
	var strY = lochref.indexOf("/Web")+4
	var strX = "Web"
	var pageNo = parseInt(lochref.substr(strY))
	pageNo =(direction>=1)?parseInt(pageNo)+1:parseInt(pageNo)-1
	if( parseInt(pageNo) > 0 && parseInt(pageNo) < 46 ){
			location.href=lochref.substr(0,strY-3)+strX+pageNo+".php"
	}
}
function isNumber(x){             // returns true if arg is a number. Both "12" and 12 return true.
	return !isNaN(parseInt(x))
}
 function validIP(ipAddress){
	var ip = ipAddress.split(".")
	if (ip.length != 4) return false
	for( var i=0; i < 4; i++) {
	if(!isNumber(ip[i])) return false
	if(parseInt(ip[i]) < 0 || parseInt(ip[i]) > 255) return false
	}
	return true
}
function statusBar(){
window.status= "Current pixel width of content area = "+ document.body.offsetWidth + ", screen resolution (width) = " + screen.availWidth
}
function pixel(min){
var w=document.body.offsetWidth
if(w > min){document.write("<img src='../images/pixel.gif' width='"+parseInt(570+w-min-71)+"' height='1' />")}
}
function address(){
var a=new Date(document.lastModified);
    lm_year=a.getFullYear();
    lm_month=a.getMonth()+1;
    lm_day=a.getDate();
    m = new Array(12)
    m[0]='Jan'
    m[1]='Feb'
    m[2]='Mar'
    m[3]='Apr'
    m[4]='May'
    m[5]='Jun'
    m[6]='Jul'
    m[7]='Aug'
    m[8]='Sept'
    m[9]='Oct'
    m[10]='Nov'
    m[11]='Dec'

    document.write("<select style='margin-left:5px' id='pulldownMap' onchange='location.href=this.value'><option value='Web1.php'>1 Course syllabus</option><option value='Web2.php'>2 Tools of the trade</option><option value='Web3.php'>3 Internet history</option><option value='Web4.php'>4 Introduction to XHTML</option><option value='Web5.php'>5 Basic markup</option><option value='Web6.php'>6 Element structure & lists</option><option value='Web7.php'>7 Hyperlinks & multimedia</option><option value='Web8.php'>8 Images</option><option value='Web9.php'>9 Table introduction</option><option value='Web10.php'>10 Advanced tables</option><option value='Web11.php'>11 Image maps</option><option value='Web12.php'>12 Frames</option><option value='Web13.php'>13 Forms introduction</option><option value='Web14.php'>14 Advanced forms</option><option value='Web15.php'>15 Samples and links</option><option value='Web16.php'>16 CSS introduction</option><option value='Web17.php'>17 Typeface and borders</option><option value='Web18.php'>18 Position and align</option><option value='Web19.php'>19 Advanced techniques</option><option value='Web20.php'>20 Samples and links</option><option value='Web21.php'>21 What is XML?</option><option value='Web22.php'>22 A look inside XML</option><option value='Web23.php'>23 XML in action</option><option value='Web24.php'>24 XSLT</option><option value='Web25.php'>25 Samples and links</option><option value='Web26.php'>26 JavaScript introduction</option><option value='Web27.php'>27 JavaScript objects</option><option value='Web28.php'>28 JavaScript methods</option><option value='Web29.php'>29 Scripting and debugging</option><option value='Web30.php'>30 Dynamic XHTML</option><option value='Web31.php'>31 JavaScript in action</option><option value='Web32.php'>32 Samples and links</option><option value='Web33.php'>33 Web design defined</option><option value='Web34.php'>34 Business of Web design</option><option value='Web35.php'>35 Page and site design</option><option value='Web36.php'>36 Samples and links</option><option value='Web37.php'>37 Introduction to graphics</option><option value='Web38.php'>38 Intermediate graphics</option><option value='Web39.php'>39 Advanced graphics</option><option value='Web40.php'>40 Samples and links</option><option value='Web41.php'>41 Server introduction</option><option value='Web42.php'>42 Introduction to ASP</option><option value='Web43.php'>43 Introduction to PHP</option><option value='Web44.php'>44 Samples and links</option><option value='Web45.php'>45 Web services</option></select>")
    /* -----------------------------
    document.write("<!-- Begin Amazon Honor System Paybox --><div style='margin: 10px 10px'>")
	document.write("<img src='http://s1.amazon.com/exec/varzea/tipbox/A8VVZBC2WZ65I/T1JTVU2SU90FJK' usemap='#T1JTVU2SU90FJK' border='0' alt='Amazon Honor System'>")
	document.write("<map name='T1JTVU2SU90FJK'>")
	document.write("<area coords='20,60,130,115' href='http://s1.amazon.com/exec/varzea/pay/T1JTVU2SU90FJK' alt='Click here to support this site' target=_top>")
	document.write("<area coords='5,135,145,145' href='http://s1.amazon.com/exec/varzea/subst/fx/help/how-we-know.html' alt='Click here to learn about supporting this site' target=_top>")
	document.write("</map></div><!-- End Amazon Honor System Paybox -->")
	document.write("<div title='Phil Boyum' style='width:90px;margin: 10px 30px; padding:6px; font-size:9px;border:3px ridge steelblue;color:black;background-color:mintcream'>'the site...it's sure comforting knowing that its there.'</div>");
 --------------------------------------------- */
    var loc = right(location.href,10)
    var x = loc.indexOf("Web")     // find document number
    // alert(x + " " + loc)
    if(x >= 0) {
        var d = loc.indexOf(".")
        var n = loc.substring(x+3,d)
        //alert("doc n=" + n)
        //if(n > 0 && n < 45) pulldownMap.options[n-1].selected=true   // select document's list item
        if(n > 0 && n < 45) document.getElementById('pulldownMap').options[n-1].selected=true   // select list item (ie & nn)
        }
   // document.write("<address style='margin-left:15px'>Updated: " + m[lm_month-1]+' '+lm_day+', '+lm_year)
   // document.write("<br /><a href='mailto:Hugh@webPoynor.com?subject=WebSys site'>Comments to Hugh Poynor</a><br />")
    //document.write("</address>")
}
function checkPoint(eyeD){
    var objCheck = document.getElementById(eyeD)
    if(objCheck.style.display=="block"){
        objCheck.style.display="none"}
    else{
        objCheck.style.display="block"}
}
function insertReinforcement(text){
    document.write("<fieldset class='reinforce'><legend>Reinforcement</legend>")
    document.write( text + "</fieldset>")
}
//
// alternate row colors in tables
// requires a table ID to be sent in arg, and this html:
// <table id="xTable" onresize="rowShades(xTable)"> OR <table id="xTable" onmouseover="rowShades(xTable)">
//
function rowShades(oTable){
    for (var i=1; i < oTable.rows.length; i++){
    oTable.rows[i].bgColor= ((i % 2) == 0?"whitesmoke":"white")}
}

function bookFooter(){  // foot of course textbook
document.write("<div class='footer'><a href='#' onclick='looseMenuHome()'>top</a> | <a href='index.html' target='_self'>homepage</a>&nbsp;&nbsp;<br /><table border=0 align='left' style='font-size:8pt;text-align:left;padding:6px'><tr><td><img src='images/madewithcss.gif' width='88' height='31' valign='top' align='left' alt='Made with CSS' border='0' /></td><td><a href='index.html' target='_top'>Web Systems Development (WebSys)</a><br /><a href='mailto:professor@classanytime.com'>Contact:</a> professor@classanytime.com<br /></td></tr></table><br clear='all' /><br clear='all' /></div>")
}

function simpleFooter(){  // foot of course pages that are not textbook pages
document.write("<div class='footer'><a href='#tof'>top</a> | <a href='index.html' target='_self'>homepage</a>&nbsp;&nbsp;<div style='font-size:8pt;text-align:left'><br /><img src='images/madewithcss.gif' width='88' height='31' valign='top' align='left' alt='Made with CSS'  style='margin-top:4px;margin-right:12px' border='0' /><a href='index.html' target='_top'>Web Systems Development (WebSys)</a><br /><a href='mailto:professor@classanytime.com'>Contact:</a> professor@classanytime.com<br /></div></div>")
}

function showHTML(txtText){
    newHTML=txtText.replace("<body>","")
    newHTML=newHTML.replace("</body>","")
    newHTML=newHTML.replace("<html>","")
    newHTML=newHTML.replace("</html>","")
    newHTML=newHTML.replace("<BODY>","")
    newHTML=newHTML.replace("</BODY>","")
    newHTML=newHTML.replace("<HTML>","")
    newHTML=newHTML.replace("</HTML>","")

    MyWindow = window.open("","MyWindow",
       "toolbar=no,location=no,directories=no,status=no," +
       "menubar=no,scrollbars=yes,resizable=yes,dependent=yes," +
       "width=400,height=300,hotkeys=no")
    str = "<html><head>" +
    "<title>Try-out</title><style type='text/css'>" +
    "body{margin:5%}</style>" +
    "</head><body>" + newHTML + "<br clear='all' /><input type='button' value=' Close ' style='margin-top:1em' onClick='self.close();' /></body></html>"
    self.MyWindow.document.open()
    self.MyWindow.document.write(str)
    self.MyWindow.document.close()
    MyWindow.focus()
}
function showJavascript(){
    var newJS=inputJavascript.innerText
    newJS=newJS.replace("<body>","")
    newJS=newJS.replace("</body>","")
    newJS=newJS.replace("<html>","")
    newJS=newJS.replace("</html>","")
    newJS=newJS.replace("<BODY>","")
    newJS=newJS.replace("</BODY>","")
    newJS=newJS.replace("<HTML>","")
    newJS=newJS.replace("</HTML>","")

    MyWindow = window.open("","MyWindow",
       "toolbar=no,location=no,directories=no,status=no," +
       "menubar=no,scrollbars=yes,resizable=yes,dependent=yes," +
       "width=400,height=300,hotkeys=no")
    str = "<html><head>" +
    "<title>Javascript Practice</title><style type='text/css'>" +
    "body{margin:5%}</style>" +
    "</head><body>" + newJS + "<br clear='all' /><input type='button' value=' Close ' style='margin-top:3em' onClick='self.close();' /></body></html>"
    self.MyWindow.document.open()
    self.MyWindow.document.write(str)
    self.MyWindow.document.close()
}
// trims leading & trailing spaces
function trim(str){
    var x="", y="";
    for (var i=0; i<str.length; i++){
    	y=str.substring(i,i+1);
    	if( y!=" " && y!="\n" && y!="\t" ){x = x + y}
	}
    return x
}
function rtrim(str){
	var x=""
	for (var i=str.length-1; i >-1; i--){
		var x = str.charAt(i)
		alert(i+"="+x)
		if( x!=" " && x!="\n" && x!="\t" ) return str.substr(0,i+1)
	}
	return ""
}
function ltrim(str){
    for (var i = 0; i < str.length; i++){
		var x = str.charAt(i)
		alert(i+"="+x)
		if( x!=" " && x!="\n" && x!="\t" ) return str.substr(i)
    }
return ""
}
function right(string, many){
    var l = string.length
    if(l<=0 || many<=0) return string;
    return string.substr(l-many)
}
function left(string, many){
    var l = string.length
    if(l<=0 || many<=0) return string;
    return string.substr(0,many)
}
//writeCookie("Age","56")
//readCookie("Age")
//writeCookie("Visitor","Jane")
//readCookie("Visitor")
function readCookie(tag){
    var c = unescape(document.cookie) + ";"
    if( c == ";" ) return false
    var x = c.indexOf(tag)
    if( x == -1 ) return false
    var y = c.indexOf(";", x)
	value = c.substring(x+tag.length+1, y)
    //alert("This is " + tag + "= "+ value)
    return value
}
function writeCookie(tag,value){
    var threeDays = 3 * 24 * 60 * 60 * 1000      	// date/time in milliseconds
	var fiveMinutes = 1 * 1 *   5 * 60 * 1000      	// date/time in milliseconds
    var today = new Date()                      			 // today's date
    today.setTime(today.getTime() + fiveMinutes)   	// add lifetime to cookie
    ExpiresWhen = today.toGMTString()            		// convert to GMT
    document.cookie = tag + "=" + escape(value) + '; expires=' + ExpiresWhen
}
function isEmailString(e){
     if(howMany("@",e) != 1 || howMany(".",e) == 0) { return false }else{ return true }
}
function isDateString(d){
    // validates date strings ( e.g. input text boxes)
    // requires a 4-digit year
        if (howMany("/",d) != 2) return false;
        var s1 = d.indexOf("/")
        var mm = left(d,s1)
        var s2 = d.indexOf("/",s1+1)
        var dd = mid(d,s1+1,s2-s1-1)
        var yy = mid(d,s2+1)
        return goodDate(dd,mm,yy)
}
function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function isDate (day,month,year) {
	// checks if date passed is valid
	// will accept dates in following format:
	// isDate(dd,mm,ccyy), or
	// isDate(dd,mm) - which defaults to the current year, or
	// isDate(dd) - which defaults to the current month and year.
	// Note, if passed the month must be between 1 and 12, and the
	// year in ccyy format.
    var today = new Date();
    year = ((!year) ? y2k(today.getFullYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getFullYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false
}
function howMany(needles, haystack){
    var n = 0
    var loc = 0
    for(var i=0; i < haystack.length; i++){
            loc = haystack.indexOf(needles,loc)
            if ( loc == -1 ) return n;
            n++
            loc++
            }
    return n
}
function minimum(a,b){if(a<b){return a}else{return b}}
function openExample(aFile) {
window.open(aFile,'winExample','height=500,width=570,toolbar=no,scrollbars=yes,menubar=no,resizable=yes,location=no,directories=no');
}
//
//  openColorChart used to open up color names and hex values
//
function openColorChart() {
window.open('Web-Colorchart.html','winColor','height=500,width=520,toolbar=no,scrollbars=yes,menubar=no,resizable=yes,location=no,directories=no');
}
/*
 * $Log: ua.js,v $
 * Revision 1.7  2002/05/14 16:52:52  bc6ix
 * use CVS Log for revision history
 *
 *
 */

/* ***** BEGIN LICENSE BLOCK *****
 * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
 * Full Terms at /evangelism/lib/js/license/mpl-tri-license.txt
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Netscape code.
 *
 * The Initial Developer of the Original Code is
 * Netscape Corporation.
 * Portions created by the Initial Developer are Copyright (C) 2001
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s): Bob Clary <bclary@netscape.com>
 *
 * ***** END LICENSE BLOCK ***** */

 /* **** Basic Example *****

 alert("Browser Sniffing Example" + "\n"+ "navigator.OS=" + navigator.OS + "\n" + "navigator.version=" + navigator.version + "\n" + "navigator.org=" + navigator.org + "\n" + "navigator.family=" + navigator.family)

 navigator.OS
     "win" for all Windows platforms
     "mac" for all Macintosh platforms
     "nix" for all Unix like platforms
     "" if platform is not one of the above

 navigator.org
     "opera" for Opera based browsers
     "netscape" for Netscape browsers
     "microsoft" for Microsoft browsers
     "compuserve" for Compuserve browsers
     "sun" for HotJava
     "" if organization is not one of the above

 navigator.version
     If the browser organization is one of the above, then the version will be reported in navigator.version as a floating point number. Otherwise, the version will be 0. Note that Gecko based browser will report the Release Version from the UserAgent string and not actual version reported by the vendor.

 navigator.family
 navigator.family contains a string that groups browsers into families that can be reasonably treated in a similar fashion. Different versions of a browser within a family can be distinguished by the navigator.version property. Current families that are detected are:
     "hotjava" HotJava browsers from Sun
     "opera" Opera Browsers
     "ie3" Internet Explorer versions before 4
     "ie4" Internet Explorer versions 4 and later
     "gecko" browsers based upon the Mozilla Open Source browser such as Netscape 6
     "nn3" Netscape Navigator 3.x browsers
     "nn4" Netscape Navigator 4.x browsers
     "aol" AOL browsers
******* */
function xbDetectBrowser()
{
  var oldOnError = window.onerror;
  var element = null;

  window.onerror = null;

  // work around bug in xpcdom Mozilla 0.9.1
  window.saveNavigator = window.navigator;

  navigator.OS    = '';
  navigator.version  = parseFloat(navigator.appVersion);
  navigator.org    = '';
  navigator.family  = '';

  var platform;
  if (typeof(window.navigator.platform) != 'undefined')
  {
    platform = window.navigator.platform.toLowerCase();
    if (platform.indexOf('win') != -1)
      navigator.OS = 'win';
    else if (platform.indexOf('mac') != -1)
      navigator.OS = 'mac';
    else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
      navigator.OS = 'nix';
  }

  var i = 0;
  var ua = window.navigator.userAgent.toLowerCase();

  if (ua.indexOf('opera') != -1)
  {
    i = ua.indexOf('opera');
    navigator.family  = 'opera';
    navigator.org    = 'opera';
    navigator.version  = parseFloat('0' + ua.substr(i+6), 10);
  }
  else if ((i = ua.indexOf('msie')) != -1)
  {
    navigator.org    = 'microsoft';
    navigator.version  = parseFloat('0' + ua.substr(i+5), 10);

    if (navigator.version < 4)
      navigator.family = 'ie3';
    else
      navigator.family = 'ie4'
  }
  else if (ua.indexOf('gecko') != -1)
  {
    navigator.family = 'gecko';
    var rvStart = navigator.userAgent.indexOf('rv:') + 3;
    var rvEnd = navigator.userAgent.indexOf(')', rvStart);
    var rv = navigator.userAgent.substring(rvStart, rvEnd);
    var decIndex = rv.indexOf('.');
    if (decIndex != -1)
    {
      rv = rv.replace(/\./g, '')
      rv = rv.substring(0, decIndex) + '.' + rv.substr(decIndex)
    }
    navigator.version = parseFloat(rv);

    if (ua.indexOf('netscape') != -1)
      navigator.org = 'netscape';
    else if (ua.indexOf('compuserve') != -1)
      navigator.org = 'compuserve';
    else
      navigator.org = 'mozilla';
  }
  else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
  {
    var is_major = parseFloat(navigator.appVersion);

    if (is_major < 4)
      navigator.version = is_major;
    else
    {
      i = ua.lastIndexOf('/')
      navigator.version = parseFloat('0' + ua.substr(i+1), 10);
    }
    navigator.org = 'netscape';
    navigator.family = 'nn' + parseInt(navigator.appVersion);
  }
  else if ((i = ua.indexOf('aol')) != -1 )
  {
    // aol
    navigator.family  = 'aol';
    navigator.org    = 'aol';
    navigator.version  = parseFloat('0' + ua.substr(i+4), 10);
  }
  else if ((i = ua.indexOf('hotjava')) != -1 )
  {
    // hotjava
    navigator.family  = 'hotjava';
    navigator.org    = 'sun';
    navigator.version  = parseFloat(navigator.appVersion);
  }

  window.onerror = oldOnError;
}