
function z() {}



function firstOf2variables(text) {  // eg alert(firstOf2variables("two,three"))
var arrayString = new Array(2)
arrayString = text
Length1 =arrayString.indexOf(",",1)
if (Length1 <1) return text
else {
Length2 =arrayString.length - Length1 -1 
String1 = arrayString.substring(0,Length1)
return String1
}
}

function secondOf2variables(text) {  // eg alert(secondOf2variables("two,three"))
var arrayString = new Array(2)
arrayString = text
Length1 =arrayString.indexOf(",",1)
Length2 =arrayString.length - Length1 -1 
String2 = arrayString.substring(Length2-1,Length1+Length2+1)
return String2
}



function NthChar(vLookin,vNum) {
// returns the char vNum in vLookin
   	//if (vLookin.length<vNum) vNum = vLookin.length
	vLookfor = "(\.\)"
	for (var i = 1; i<=vNum-1; i++) {
	vLookfor = vLookfor + "(\.\)";} 
	myRe = new RegExp(vLookfor, "ig")
	if (vLookin != null) {
		myArray = myRe.exec(vLookin);
		return myArray[vNum] ;}
	else return ""
}


function extractFrom(vLookin,vLookfor) {
// returns the vLookin without any occurances of vLookfor
   	vReg = "(\.\*)" + vLookfor + "(\.\*)"
	myRe = new RegExp(vReg, "ig")
	myArray = myRe.exec(vLookin);
	while (myArray != null) {
		vLookin = myArray[1]+myArray[2] 
		myArray = myRe.exec(vLookin)
		}
	return vLookin 
}

function loadThumbs() {
	filename=getFilename()
//	filenam =""
//	for(var i = 0; i < filename.length-2; i++) {
//	filenam += filename.charAt(i); }
	filename = filename + "-t.htm"
	parent.thumbs.location.href = filename
}

function test() {
alert()
}

function loadPic(filename) {
	parent.big.location.href = filename+".htm"
}


function showNextPic(ImageNum,tot) { // show next in series file1.gif, file2.gif, file3.gif etc as high as 9
	filename = document.images[ImageNum].src
	n=filename.length - 5
//	alert(filename.length)
//	alert((filename.charAt(n)*1)+1)
	vN=(filename.charAt(n)*1)+1
	if (vN=tot+1) vN=1
	vA = "text"
	vAN = vA+vN
	vN = vAN.charAt(4)
	vRel =""
	for(var i = 0; i < n; i++) {
	vRel += filename.charAt(i); }
//	alert(vRel)
	filename = vRel + vN + ".gif"
//	alert(filename)
	document.images[ImageNum].src = filename
	}

function WinMembership(filename) {
  var winX =0;
  var winY = 0;
  // only set new values if 4.0 browser
  if (parseInt(navigator.appVersion) >= 4) {
  winX = 620
  winY = 440 
  //winX = (screen.availWidth - 30);
 winY = (screen.availHeight - 60) 
  if (winY > 580) winY=580
  
  }
     strFeatures='minimize=no,maximize=no,resizable=yes,dependent=yes,menubar=no,directories=no,location=0,status=0,scrollbars=yes,toolbar=no,left=0,top=0,height='+winY+',width=625';
     content=window.open('','Membership',strFeatures)
     window.content.focus()
	 content.location.href = filename
}

function memberOpen(vURL) {
	vMemb= parent.getMembership()
	if (vMemb == "BPG member") {
		location.href = vURL
		return vMemb
	}
}

function ImageWin(vTitle,vFilePath) {

  var winX =0;
  var winY = 0;
  // only set new values if 4.0 browser
  if (parseInt(navigator.appVersion) >= 4) {
  winX = (screen.availWidth - 650);
  winY = (screen.availHeight - 500) 
  }
     strFeatures='minimize=no,maximize=no,resizable=a,dependent=yes,menubar=no,directories=no,location=0,status=0,scrollbars=yes,toolbar=no,left='+winX+',top='+winY+' ,height=480,width=640';
     content=window.open('','',strFeatures)
	 content.document.open()
	 content.document.write('<html><head>')
//	 content.document.write('<SCRIPT type=text/javascript>function mouseDown(e) { if (parseInt(navigator.appVersion)>3) {')  
//	 content.document.write('var clickType=1;    if (navigator.appName=="Netscape") clickType=e.which;    else clickType=event.button;  if (clickType!=1) {')
//	 content.document.write('alert("Please do not copy - use the Download button. ");} } return true;} if (parseInt(navigator.appVersion)>3) { document.onmousedown = mouseDown;  if (navigator.appName=="Netscape")    document.captureEvents(Event.MOUSEDOWN); } </SCR')
//	 content.document.write('IPT>')
	 content.document.write('</head><body><IMG alt='+vTitle+' src="'+vFilePath+'")>')
	 content.document.write('</body></html>')
}


//======================== Filename functions ========================

function getFilePath() { // returns path+filename+extension eg "http://C:/filename.htm"
	return location.href 
	}
 
function getFilenameHtm() { // returns filename+extension eg "filename.htm"
	vFilePath=getFilePath()
	return getEnd(vFilePath,"/") 
	}

function getFilename() { // returns Filename without extension
	vFilenameHtm = getFilenameHtm()
	return getBeg(vFilenameHtm,".")  
}

function getEnd(lookin,lookfor) { // returns end of lookin after last instance of lookfor
	vNum = lookin.lastIndexOf(lookfor)
	vRel =""
	for(var i = vNum+1; i < lookin.length; i++) {
	vRel += lookin.charAt(i); }
	return vRel  
}

function getBeg(lookin,lookfor) { // returns start of lookin before last instance of lookfor
	vNum = lookin.lastIndexOf(lookfor)
	vRel =""
	for(var i = 0; i < vNum; i++) {
	vRel += lookin.charAt(i); }
	return vRel  
}

//======================== URL variables ===========================

function URLvariable(URLvar) {
  var query = location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0].toLowerCase() == URLvar.toLowerCase()) {
	  value= replaceChars(pair[1],"+"," ")
//alert('URLvar ' + URLvar + ' = '+ value);
      return value;
    }
  } 
//  alert('URLvar ' + URLvar + ' not found in the URL');
    return ""; 
}

function replaceChars(string,oldChars,newChars) {// eg replaceChars("ABC","BC","ef") => "Aef"
// Replaces oldChars with newChars in string
    var strLength = string.length, txtLength = oldChars.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(oldChars);
    if ((!i) && (oldChars != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + newChars;
    if (i+txtLength < strLength)
        newstr += replaceChars(string.substring(i+txtLength,strLength),oldChars,newChars);
    return newstr;
}

function AddToField(name,value) { // eg to add to a text area or button name
var t
      
t= name.value;
      
name.value = t + value
     
return true;
    
}



//======================== Cookie functions ========================
function writeTodayCookie(name,value) {
   //alert("WriteCookie")
   today = new Date()
   expires = new Date()
   //expires.setTime(today.getTime() + 1000*30) // today + 1/2 min
   expires.setTime(today.getTime() + 1000*60*60*24) // today + 1 day
   setCookie(name, value, expires)  
}

function writeExpireCookie(name,value) {
   setCookie(name, value)  
}

function writeCookie(name,value) {
   today = new Date()
   expires = new Date()
   expires.setTime(today.getTime() + 1000*60*60*24*365) // today + 1 yr
   setCookie(name, value, expires)  
}

function readCookie(name) {
	vRead = getCookie(name)
	return vRead  
}

function promptCookie(vPrompt, vName)  {
	vNote = readCookie(vName)
	vNote = prompt(vPrompt, vNote)
	writeCookie(vName, vNote)
	return vNote 
}

// Sets cookie values. Expiration date is optional (default expires with session)


function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))   
}

function getCookie(Name) {
   search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { // if cookie exists 
         offset += search.length 
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset) 
         // set index of end of cookie value
         if (end == -1) // should there be an "{" here?
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end)) 
		 } 	
		 else {
			// alert("Cookie " +Name+ " is not yet recorded.")
			ThisCookies = false 
			return "";}
	   }
	   else {
		//	alert("No Cookies have yet recorded.")
			NewCookies = false  
			return "";}
}

	
//========================  functions ========================

