siteVersion = '20060305';

// Copyright (c) 1996-1997 Athenia Associates.
// http://www.webreference.com/js/
// License is granted if and only if this entire
// copyright notice is included. By Tomer Shiran.
function setCookie (name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires : "") +
        (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : "");
    document.cookie = curCookie;
}

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

function deleteCookie (name, path, domain) {
    if (getCookie(name))
        document.cookie = name + "=" + ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
    var now = new Date();
    fixDate(now);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    now = now.toGMTString();
    if (f.author != undefined)
       setCookie('mtcmtauth', f.author.value, now, '/', '', '');
    if (f.email != undefined)
       setCookie('mtcmtmail', f.email.value, now, '/', '', '');
    if (f.url != undefined)
       setCookie('mtcmthome', f.url.value, now, '/', '', '');
}

function forgetMe (f) {
    deleteCookie('mtcmtmail', '/', '');
    deleteCookie('mtcmthome', '/', '');
    deleteCookie('mtcmtauth', '/', '');
    f.email.value = '';
    f.author.value = '';
    f.url.value = '';
}

function hideDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'none';
}

function showDocumentElement(id) {
    var el = document.getElementById(id);
    if (el) el.style.display = 'block';
}

var commenter_name;

function individualArchivesOnLoad(commenter_name) {

    hideDocumentElement('trackbacks-info');



    if (document.comments_form) {
        if (document.comments_form.email != undefined &&
            (mtcmtmail = getCookie("mtcmtmail")))
            document.comments_form.email.value = mtcmtmail;
        if (document.comments_form.author != undefined &&
            (mtcmtauth = getCookie("mtcmtauth")))
            document.comments_form.author.value = mtcmtauth;
        if (document.comments_form.url != undefined && 
            (mtcmthome = getCookie("mtcmthome")))
            document.comments_form.url.value = mtcmthome;
        if (mtcmtauth || mtcmthome) {
            document.comments_form.bakecookie.checked = true;
        } else {
            document.comments_form.bakecookie.checked = false;
        }
    }
}

function writeTypeKeyGreeting(commenter_name, entry_id) {

}




// Custom JavaScript for hackoff.com book site
function SetBlookmark (url, sendAlert) {
    if (getCookie('blookmark') != '') {
        deleteCookie('blookmark', '/', 'hackoff.com');
    }

    deleteCookie('blookmark', '/blook/', 'hackoff.com');

    var today = new Date();
    var one_year = 1000 * 60 * 60 * 24 * 365;
    var cookie_date = new Date (today.getTime() + one_year ); 

    setCookie('blookmark', url, cookie_date.toGMTString(), '/', 'hackoff.com');
    
    if (sendAlert) {
        alert('Your blookmark is set.  See you here soon.');
    }
}

function RestoreBlookmark () {
    deleteCookie('blookmark', '/blook/', 'hackoff.com');

    url = getCookie('blookmark');
    if (url == '') {
        window.open('http://www.hackoff.com/blook/pages/blookmark_none.html','blookmark',"toolbar=no,status=no,scrollbars=yes,resize=yes,menubar=no,width=450,height=300");
    } else {
        document.location=url;
    }
}

function AboutBlookmark () {
    window.open('http://www.hackoff.com/blook/pages/blookmark_about.html','blookmark',"toolbar=no,status=no,scrollbars=yes,resize=yes,menubar=no,width=450,height=300");
}

var quotes = new Array();

quotes[0] = '"Put him [Tom] on the short list of the people who made the internet the internet. When he headed up AT&T\'s internet services, he introduced flat-rate pricing and brought on the masses. He went on to see the power of VOIP before the industry did. And as you\'d expect, he\'s not publishing the old-fashioned way."<br><a href="http://www.buzzmachine.com">Jeff Jarvis</a> blogged <A HREF="http://www.buzzmachine.com/index.php/2005/08/16/who-shot-com/">here.</a>';

quotes[1] = '"I can\'t wait to watch this unfold... [The] story is really good and very entertaining.  If you lived through "the first Internet bubble and rubble", its your story too in many ways."<br><a href=" http://avc.blogs.com">Fred Wilson</a> blogged <A HREF=" http://avc.blogs.com/a_vc/2005/08/innovating_once.html">here.</a>';

quotes[2] = '"In addition to being awesome content (this is the book that every entrepreneur from 1997 - 2001 wanted to write), Tom is using (as well as inventing) lots of blog / Web 2.0 publishing technology into the experience."<br><a href="http://www.feld.com/blog/index.php">Brad Feld </a>  blogged <A HREF="http://www.feld.com/blog/archives/2005/09/hackoffcom_-_th.html">here.</a>';

quotes[3] = '"Very cool. Bravo Tom! As someone who worked in the crazed, sometimes plainly goofy, pre-ipo dotcom world I applaud Tom\'s endeavor and look forward to a good read..."<br><a href="http://davemartin.blogspot.com/">Dean Martin </a> blogged <A HREF="http://davemartin.blogspot.com/2005/09/learn-to-handle-rejection.html">here.</a>';


quotes[4] = '"The first chapter of hackoff.com is a daring experiment. Instead of any sort of traditional narrative, we are presented with a hodgepodge of press releases, news clips and forum posts all concerned with the murder of the ex-hacker chairman and CEO of an internet security company."<br><a href="http://www.fiddleandburn.com/blog/">Jason Pomerantz</a> blogged <A HREF="http://www.blogfic.com/2005/09/19/and-there-will-come-a-blook/">here.</a>';


quotes[5] = '"Tom\'s a great writer and had front row seats/was a lead actor in the bubble.  The first episode has me hooked.  This is going to be fun!"<br><a href="http://onlyonce.blogs.com/">Matt Blumberg</a> blogged <A HREF="http://onlyonce.blogs.com/onlyonce/2005/09/hackoff_the_blo.html">here.</a>';

quotes[6] = '"Speaking of the Internet revolution -- check my friend, Tom Evslin\'s, "blook" (blog on book -- an online novel). I\'m only a couple chapters in, and it\'s a good read. "<br><a href="http://thecodyblog.blogspot.com/">Cody Willard</a> ';

quotes[7] = '"Additionally, his passages regarding how the investment banks made money "coming and going" off of clients illustrates a sophistication that I haven\'t seen even in good financial journalism. His portrayal is so accurate that I think the book may only play well to former dot-commers and tech bankers. Regardless, Hackoff.com should be required reading for all financial journalism training programs." <br><a href="http://techtrader.blogspot.com/2005/12/hackoffcom-hybrid-blog-and-book.html">TechTrader</a> ';

quotes[8] = '"The book satisfied a lot of my curiosity about what an IPO is like.  Tom is a very good writer and tells an interesting yarn,”<br><a href="http://www.800ceoread.coml">Jack Covert, President 800ceoread</a> ';

quotes[9] = '"Lots of folks got killed by the Internet bubble, but nothing like this. Tom Evslin provides a ring side seat to the fast paced battles and intrigue when entrepreneurs cross Wall Street. Like a chart of NASDAQ, it\'s a wild ride."<br><a href="http://www.andykessler.com/">Andy Kessler - Author of Running Money and Wall Street Meat</a> ';

quotes[10] = '"Vividly captures the spirit of online chatter and was well suited to serialization on a blog – the form combined with the geeky subject matter and a cracking whodunnit make this book an excellent read for blook-fans."<BR><a href="http://pdfserver.prweb.com/pdfdownload/367086/pr.pdf"> Judges awarding Runner-up in the Fiction Blooker Prize</a>';

quotes[11] = '“…solidly plotted, entertaining thriller. Its USP (unique selling point), as some of its characters would say, is that the author, Tom Evslin, was in at the centre of the dotcom boom…”<BR><a href="http://blogcritics.org/archives/2006/05/07/134629.php"> BlogCritics</a>';



var images = new Array();
var imageSets = new Array();

imageSets['front'] = new Array();
imageSets['front'][0] = 'http://www.hackoff.com/blook/images/author/author01f.gif';
imageSets['front'][1] = 'http://www.hackoff.com/blook/images/author/author02f.gif';
imageSets['front'][2] = 'http://www.hackoff.com/blook/images/author/author03f.gif';
imageSets['front'][3] = 'http://www.hackoff.com/blook/images/author/author04f.gif';
imageSets['front'][4] = 'http://www.hackoff.com/blook/images/author/author05f.jpg';
imageSets['front'][4] = 'http://www.hackoff.com/blook/images/author/author06f.jpg';
imageSets['front'][5] = 'http://www.hackoff.com/blook/images/author/author00f.gif';

imageSets['tom'] = new Array();
imageSets['tom'][0] = 'http://www.hackoff.com/blook/images/author/author01.gif';
imageSets['tom'][1] = 'http://www.hackoff.com/blook/images/author/author02.gif';
imageSets['tom'][2] = 'http://www.hackoff.com/blook/images/author/author03.gif';
imageSets['tom'][3] = 'http://www.hackoff.com/blook/images/author/author04.gif';
imageSets['tom'][4] = 'http://www.hackoff.com/blook/images/author/author05.gif';
imageSets['tom'][4] = 'http://www.hackoff.com/blook/images/author/author06.jpg';

imageSets['mary'] = new Array();
imageSets['mary'][0] = 'http://www.hackoff.com/blook/images/mary/mary01.gif';
imageSets['mary'][1] = 'http://www.hackoff.com/blook/images/mary/mary02.gif';
imageSets['mary'][2] = 'http://www.hackoff.com/blook/images/mary/mary03.gif';
imageSets['mary'][3] = 'http://www.hackoff.com/blook/images/mary/mary04.gif';






var qDelaySeconds = 010;
var pDelaySeconds = 010;
var qDelay    = 10000; // The delay between changes
var pDelay    = 10000; // The delay between changes
var imageCounter = Math.floor(Math.random() * images.length);
var quoteCounter = Math.floor(Math.random() * quotes.length);
var newsCounter = Math.floor(Math.random() * quotes.length);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function initImages(imageSet) {
    images = imageSets[imageSet];
    for (i = 0; i < images.length; i++) {
        MM_preloadImages(images[i]);
    }

    if (pDelaySeconds > 0) {
        pDelay = pDelaySeconds * 1000;
    }

    switchImage();
}

function switchImage() {
	if (imageCounter >= images.length) {
		imageCounter = 0;
	}

	var object = document.getElementById('rotatingImage');
	object.src = images[imageCounter];
	imageCounter++;
	window.setTimeout('switchImage();', pDelay);
}


function initQuotes() {
    if (qDelaySeconds > 0) {
        qDelay = qDelaySeconds * 1000;
    }

    switchQuote();
}

function switchQuote() {
	if (quoteCounter >= quotes.length) {
		quoteCounter = 0;
	}

	var object = document.getElementById('rotatingQuote');
	object.innerHTML = '<i>' + quotes[quoteCounter] + '</i>';
	quoteCounter++;
	window.setTimeout('switchQuote();', pDelay);
}

function initNews() {
    if (qDelaySeconds > 0) {
        qDelay = qDelaySeconds * 1000;
    }

    switchNews();
}

function switchNews() {
	if (newsCounter >= newsItems.length) {
		newsCounter = 0;
	}

	var object = document.getElementById('rotatingNews');
	object.innerHTML = quotes[newsCounter];
	newsCounter++;
	window.setTimeout('switchNews();', pDelay);
}

function printQuotes() {
    for (i = 0; i < quotes.length; i++) {
        document.write(quotes[i] + '<br><br>');
    }
}

function printNews() {
    for (i = 0; i < newsItems.length; i++) {
        document.write(newsItems[i] + '<br><br>');
    }
}

function setQuotes() {
	var object = document.getElementById('quoteList');

    for (i = 0; i < quotes.length; i++) {
		object.innerHTML = object.innerHTML + quotes[i] + '<br><br>';
    }
}

function setNews() {
	var object = document.getElementById('newsList');

    for (i = 0; i < newsItems.length; i++) {
		object.innerHTML = object.innerHTML + newsItems[i] + '<br><br>';
    }
}


function updateLastVisit() {
    var today = new Date();
    var one_year = 1000 * 60 * 60 * 24 * 365;
    var cookie_date = new Date (today.getTime() + one_year ); 

    if (getCookie('thisVisit') == '') {
        setCookie('lastVisit', today.getTime(), cookie_date.toGMTString(), '/', 'hackoff.com');
    } else {
        setCookie('lastVisit', getCookie('thisVisit'), cookie_date.toGMTString(), '/', 'hackoff.com');
    }

    setCookie('thisVisit', today.getTime(), cookie_date.toGMTString(), '/', 'hackoff.com');
    
    url = getCookie('blookmark');
    version = '0' + getCookie('version');
    if (parseInt(version, 10) < 20060305 && url != '') {
    	window.setTimeout('alert("We’ve made a change.  Blookmarking is now partially automated.  Reading will always resume wherever you left off as long as you’re using the same computer you were before and cookies are enabled.  If you mean to stop reading for a while, you can mark the an episode “read” at the bottom of the episode so that you will be automatically taken to the next episode on your next visit.")', 500);
	}

    setCookie('version', siteVersion, cookie_date.toGMTString(), '/', 'hackoff.com');
}

updateLastVisit();

var forceNews = 0;

chapterTree = new Array();
chCounter = 0;
imgShowing = 'http://www.hackoff.com/blook/images/showing-mac.gif';
imgHiding = 'http://www.hackoff.com/blook/images/hiding-mac.gif';

function toggleView(objSuffix) {
    objLst = document.getElementById('cat_' + objSuffix);
    objTab = document.getElementById('tab_' + objSuffix);

    if (objLst.style.display == 'none') {
        hideAllChapters();
        objLst.style.display = 'inline';
        objTab.src = imgShowing;
    } else {
        objLst.style.display = 'none';
        objTab.src = imgHiding;
    }
}

function initChapterTree() {
	if (navigator.appVersion.indexOf('Macintosh') == -1) {
		imgShowing = 'http://www.hackoff.com/blook/images/showing-win.gif';
		imgHiding = 'http://www.hackoff.com/blook/images/hiding-win.gif';
	}

	hideAllChapters();
}

function hideAllChapters() {
	for (i = 0; i < chapterTree.length; i++) {
		objImg = document.getElementById('tab_' + chapterTree[i]);
		objLnk = document.getElementById('cat_' + chapterTree[i]);
		objImg.src = imgHiding;
		objLnk.style.display = 'none';
	}
}
