function go()
{
location=document.George.example.
options[document.George.example.selectedIndex].value
}
/* Code from chapter 2 */
function showText(inputdata){ 
	window.alert(inputdata); 
}

function buildPage(){
	var pagecontent = "<html><head><title>";
	pagecontent += document.pageform.pagetitle.value;
	pagecontent += "</title></head>\n"
	pagecontent += "<body bgcolor='white'>\n"
	pagecontent += document.pageform.bodytext.value;
	pagecontent += "\n</body>\n</html>";

	document.pageform.mycode.value=pagecontent;
}
/* End of code from chapter 2 */


/* Code from chapter 3 */
/* Code to manipulate values from form objects */
function getRadioValue(formname,radioname){
    var theRadioButtons = document[formname][radioname];
    for (i=0;i<theRadioButtons.length;i++){
        if (theRadioButtons[i].checked){
            return theRadioButtons[i].value;
        }
    }
}

function showRadioValue(formname,radioname,thevalue){
    var theRadioButtons = document[formname][radioname];
    for (i=0;i<theRadioButtons.length;i++){
        var temp = theRadioButtons[i].value;
        if (temp == thevalue){
            theRadioButtons[i].checked = true;
        }
    }   
}

function getSelectValue(formname,selectname){
    var theMenu = document[formname][selectname];
    var selecteditem = theMenu.selectedIndex;
    return theMenu.options[selecteditem].value;
}

function showSelectValue(formname,selectname,thevalue){
    var theMenu = document[formname][selectname];
    for (i=0;i<theMenu.options.length;i++){
        var temp = theMenu.options[i].value;
        if (temp == thevalue){
            theMenu.selectedIndex = i;
        }
    }   
}

/* End of code to manipulate values from form objects */
/* End of code from chapter 3 */

/* Code from chapter 6 */
/* Essential Arrays for pages with calendars */
var theDays = new Array();
theDays[0]="Sunday";
theDays[1]="Monday";
theDays[2]="Tuesday";
theDays[3]="Wednesday";
theDays[4]="Thursday";
theDays[5]="Friday";
theDays[6]="Saturday";

var theMonths = new Array();
theMonths[0]="January";
theMonths[1]="February";
theMonths[2]="March";
theMonths[3]="April";
theMonths[4]="May";
theMonths[5]="June";
theMonths[6]="July";
theMonths[7]="August";
theMonths[8]="September";
theMonths[9]="October";
theMonths[10]="November";
theMonths[11]="December";
/* End of code from chapter 6 */

/* Code from chapter 7 */
/* Beginning of Cookie Code Based on code by Bill Dortch
   of hidaho designs who has generously placed it in the public domain.*/
function SetCookie(name,value,expires,path,domain,secure){
	var temp = name + "=" + escape(value);
	if (expires){
		temp += "; expires=" + expires.toGMTString();
	}
	if (path){
		temp += "; path=" + path;
	}
	if (domain){
		temp += "; domain=" + domain;
	}
	if (secure){
		temp += "; secure";
	}
	document.cookie = temp;
}
function GetCookie(name){
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i,j) == arg){
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function getCookieVal(offset){
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1){
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset,endstr));
}
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    var temp = name + "=";
    temp += ((path) ? "; path=" + path : "");
    temp += ((domain) ? "; domain=" + domain : "");
    temp += "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    document.cookie = temp;
  }
}
/* End of Cookie Code */

/* converts days to milliseconds */
function daysToMS(days){
	return days * 24 * 60 * 60 * 1000;
}

/* converts weeks to milliseconds */
function weeksToMS(weeks){
	return weeks * 7 * 24 * 60 * 60 * 1000;
}

/* converts years to milliseconds */
function yearsToMS(years){
	return years * 365.25 * 24 * 60 * 60 * 1000;
}
/* End of code from chapter 7 */


/* code from chapter 8 */
var myWindow = null;
function openWin(url,targetname,W,H,L,T,thefeatures) {
    var params = "";
    var nofeatures = "toolbar=0,location=0,directories=0,status=0,";
    nofeatures += "menubar=0,scrollbars=0,resizable=0,copyhistory=0";
    var basicfeatures = "scrollbars=1,resizable=1,menubar=1 ";
    var morefeatures = "toolbar=1,location=1,directories=1,";
	morefeatures += "status=1,copyhistory=1";
    var dimensions = "width=" + W + ",height=" + H;
    /* Callout: The placement variable contains values for left/top and screenX/screenY. Use both to ensure compatibility with all browsers. */
    var placement = "left="  + L + ",top=" + T;
    placement += ",screenX="  + L + ",screenY=" + T;
    
    /* Callout: The switch control structure makes decisions that depend on the value of a variable. In this case the value of the parameter variable thefeatures determines the value of the variable params. */
    switch (thefeatures){
        case "none":
            params += nofeatures;
            break;
        case "basic":
            params += basicfeatures;
            break;
        case "full":
            params += basicfeatures + "," + morefeatures;
            break;
        default:
            params += thefeatures;
    }
    /* Adds the dimensions and placement info to the params variable. */
    params += "," + dimensions + "," + placement;
    /* The window.open()method  creates myWindow. */
    myWindow = window.open(url,targetname,params);
}

function closeWin(){
    if (myWindow != null){
        myWindow.close();
        myWindow = null;    
    }
}
/* End of openWin() and closeWin() functions for mylibrary.js file */
/* End of code from chapter 8 */

/* code from chapter 9 */
/* Add this browser detection code to mylibrary.js */
/* Callout: theApp will contain the browser name */
var theApp = navigator.appName.toLowerCase();

/* Callout: UA for user agent will contain more detailed browser info. For example, UA for Internet Explorer on Mac would be 'mozilla/4.0 (compatible; msie 5.0; mac_powerpc)' */
var UA = navigator.userAgent.toLowerCase();

/* variables for the two major browsers in existence today. */
var isIE = (UA.indexOf('msie') >= 0) ? true : false;
var isNS = (UA.indexOf('mozilla') >= 0) ? true : false;

// 'compatible' text string exists only in non-Netscape browsers
if (UA.indexOf('compatible')>0){
	isNS = false;
}

// platform
var thePlatform = navigator.platform.toLowerCase();
var isMAC = (UA.indexOf('mac') >= 0) ? true : false;
var isWIN = (UA.indexOf('win') >= 0) ? true : false;

/* Most UNIX users use X-Windows so this detects UNIX most of the time.*/
var isUNIX = (UA.indexOf('x11') >= 0) ? true : false;

// browser version
var version = navigator.appVersion;
var isMajor = parseInt( version );
// Internet Explorer version 5 on the Mac reports itself as version 4
if(isIE && isMAC) {
	if(UA.indexOf("msie 5")) {
		isMajor = 5;
		var stringLoc = UA.indexOf("msie 5");
		version = UA.substring(stringLoc + 5, stringLoc + 8);
	}
}

// Netscape 6 reports itself as version 5
if(isNS && isMajor>4) {
	if(UA.indexOf("netscape6")) {
		isMajor = 6;
		var stringLoc = UA.indexOf("netscape6");
		version = UA.substring(stringLoc + 10, stringLoc + 14);
	}
}
var isMinor = parseFloat( version );

var obsolete = (document.getElementById) ? false : true;
/* End of browser detection code */
/* End of code from chapter 9 */

function page() {
 
  document.location = "http://bobbinsandthreads.co.uk/index.asp";
}
function exhibitions_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_mill_exhibition_news.asp";
}
function memories_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_our_memories.asp";
}
function add_story() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_send_mill_stories.asp";
}
function photo_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_photo_gallery.asp";
}
function mill_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_mill.asp";
}
function events_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_events_guide.asp";
}
function clubs_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_clubs_guide.asp";
}

function quiz_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_monthly_quiz.asp";
}
function sponsors_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_sponsors.asp";
}

function club_news_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/club_news.asp";
}

function forum_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_forum.asp";
}

function guest_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_guest_book.asp";
}

function amenities_page() {
 
  document.location = "http://bobbinsandthreads.co.uk/neilston_amenities.asp";
}
var correctAnswers = new Array();
correctAnswers[1] = "1792";
correctAnswers[2] = "1883";
correctAnswers[3] = "5 weeks";
correctAnswers[4] = "low station";
correctAnswers[5] = "1500";
correctAnswers[6] = "Calculation Machine";
//correctAnswers[6] = "1827";
//correctAnswers[7] = "1827";
//correctAnswers[8] = "1827";
//correctAnswers[9] = "1827";
//correctAnswers[10] = "1827";
function checkAnswers(){
    var score = 0;
    for (i=1; i<7; i++){
        deathDate = getSelectValue("quiz","q" + i);
        if (deathDate == correctAnswers[i]){
            score++;
        }
    }
    document.quiz.scorefield.value = score;
}
function popimage(imagesrc,winwidth,winheight){
var look='width='+winwidth+',height='+winheight+','
popwin=window.open("","",look)
popwin.document.open()
popwin.document.write('<title>Bobbins And Threads Photographs </title><head><style type="text/css">.formbutton {color: #FFFFFF; text-transform: capitalize; cursor: hand; background-color: #006666;	font-weight: bold; font-size: x-small;}</style></head><body bgcolor="#FFFFFF"><img src="'+imagesrc+'">')
popwin.document.write('<center>')
popwin.document.write('<br>')
popwin.document.write('<b><font face="Arial, Helvetica, sans-serif", color="#006666">Bobbins and Threads Neilston </font></b>')


popwin.document.write('<FORM NAME="FORM1">\n');

popwin.document.write('<INPUT TYPE="BUTTON" VALUE="Close Window" class="formbutton" ONCLICK="window.close();">\n');

popwin.document.write('</FORM>\n');
popwin.document.write('</center>')
popwin.document.write('</body>')
popwin.document.close()
}

function popimage2(imagesrc,winwidth,winheight){
var look='width='+winwidth+',height='+winheight+','
popwin=window.open("","",look)
popwin.document.open()
popwin.document.write('<title>Bobbins And Threads Exhibition of Neilston Mill </title><head><style type="text/css">.formbutton {color: #FFFFFF; text-transform: capitalize; cursor: hand; background-color: #006666;	font-weight: bold; font-size: x-small;}</style></head><body bgcolor="#FFFFFF"><img src="'+imagesrc+'">')
popwin.document.write('<center>')
popwin.document.write('<br>')
popwin.document.write('<b><font face="Arial, Helvetica, sans-serif", color="#006666">Bobbins and Threads Exhibition </font></b><br><br>')
popwin.document.write('<b><font face="Arial, Helvetica, sans-serif", color="#006666">October 2003 </font></b>')

popwin.document.write('<FORM NAME="FORM1">\n');

popwin.document.write('<INPUT TYPE="BUTTON" VALUE="Close Window" class="formbutton" ONCLICK="window.close();">\n');

popwin.document.write('</FORM>\n');
popwin.document.write('</center>')
popwin.document.write('</body>')
popwin.document.close()
}

function checkform()
{
var message="";
//tests that the guest name has been entered

if (document.cardform.realname.value.length ==0)
{
message=message + "please enter a contact name on the request form\n";
document.cardform.realname.value=""
document.cardform.email.setfocus
}
//====================================================================
//checks that it is a valid e-mail

if (document.cardform.email.value.indexOf("@")==-1 || (document.cardform.email.value.length ==0))
{
message=message + "please enter a valid e-mail address\n";
document.cardform.email.value=""
document.cardform.email.setfocus
}
//====================================================================================================================
// test for a subject description being added

if (document.cardform.subject.value.length ==0)
{
message=message + "please enter a a subject description for your reply email this is so we can notify you when your story has been added or answer any questions you may have\n";
document.cardform.subject.value=""
document.cardform.subject.setfocus
}
//======================================================================





if (message.length>0)
{
alert(message);
return false;
}
else
{
return true;
}
}// end of function checkform

function email() {
   var add = document.swtForm.To.value
   var msg = document.swtForm.Message.value
   var from = document.swtForm.Name.value
   document.swtForm.action="mailto:"+add+"?subject=Check out this site"+"&body="+msg+" %0A%0A- "+from;
}

function PopOpen()
  {    
    var popup = window.open('cgi-bin/cSurvey.cgi','popup',config='height=420,width =300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=no');
      return true;
  } 

function go()
{
location=document.George.example.
options[document.George.example.selectedIndex].value
}




// Don't edit below!



