function roll_over(pic_name,pic_src) {
	if(document.images){
		document[pic_name].src=pic_src.src;
	}
}
      
function findInCookie(LookFor, Place) {
var lookIn = getCookie(Place)
if (lookIn == null) lookIn = ""
var searchFor = "|" + LookFor + "|"
var lookStartIndex = lookIn.indexOf(searchFor)
if (lookStartIndex == -1) return null
return 1
}

function getCookie(name) {
var prefix = name + "="
var cookieStartIndex = document.cookie.indexOf(prefix)
if (cookieStartIndex == -1)
return null
var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
if (cookieEndIndex == -1)
cookieEndIndex = document.cookie.length
return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
}

function setCookie(name, value, expires, path, domain, secure) {
var theCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "")
if ((name + "=" + escape(value)).length <= 4000)
document.cookie = theCookie
}

function addToCookie(theRef, Place){
if (findInCookie(theRef, Place)==null){
var now = new Date()
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
var lastCookie = getCookie(Place)
if (lastCookie == null) lastCookie = "|"
var newCookie = lastCookie + theRef + "|"
setCookie(Place, newCookie, now, "/")
}
if (Place == 'Aut'){
	alert ("Author marked - press refresh/reload to view change")
}else{
	alert ("Story marked - press refresh/reload to view change")
}
}

function cutCookie(theRef, name){
var wholeCookie = getCookie(name)
var searchFor = "|" + theRef + "|"
var startIndex = wholeCookie.indexOf(searchFor)
var endIndex = wholeCookie.indexOf("|", startIndex+1)
var now = new Date()
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
newCookie = wholeCookie.substring(0, startIndex) + wholeCookie.substring(endIndex, wholeCookie.length)
setCookie(name, newCookie, now, "/")
if (name == 'Aut'){
	alert ("Author un-marked - press refresh/reload to view change")
}else{
	alert ("Story un-marked - press refresh/reload to view change")
}
}
      
var newWindow
var oldStuff = parseInt(navigator.appverson) < 3			
			
function makeNewWindow(new_URL,new_TITLE){
		newWindow = window.open (new_URL, new_TITLE, "scrollbars,STATUS,resizable,HEIGHT=510,WIDTH=500")
		if (!newWindow.opener){
				newWindow.opener = window
		}
		if (!oldStuff) {
			newWindow.focus()
		}
}

function makeBigWindow(new_URL){
	newWindow = window.open (new_URL, "", "location,scrollbars,STATUS,resizable,HEIGHT=440,WIDTH=400")
	if (!newWindow.opener){
		newWindow.opener = window
	}
	if (!oldStuff) {
		newWindow.focus()
	}
}
		
function lookUpWord() {

    if (navigator.appName!='Microsoft Internet Explorer') {
	    var theWord = document.getSelection();
	    outputWord(theWord);
    } else {
	var theWord = document.selection.createRange();
	if(document.selection.type == 'Text' && theWord.text>'') {
	    document.selection.empty();
	    outputWord(theWord.text);
	}
    }

    function outputWord(theWord) {
	while (theWord.substr(theWord.length-1,1)==' ') theWord=theWord.substr(0,theWord.length-1);
	while (theWord.substr(0,1)==' ') theWord=theWord.substr(1);
	if (theWord) window.open('http://www.m-w.com/dictionary/'+escape(theWord), 'online_dictionary');
    }
     
}

document.ondblclick=lookUpWord
