// 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');


 // comments are allowed but not required
    if (commenter_name) {
        hideDocumentElement('name-email');
    } else {
        showDocumentElement('name-email');
    }



    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) {

    if (commenter_name) {
        document.write('<p>Thanks for signing in, ' + commenter_name +
          '. Now you can comment. '+
          '(<a href="http://www.omarphillips.net/cgi-bin/mt/mt-comments.cgi?__mode=handle_sign_in&amp;static=1&amp;logout=1&entry_id=' + entry_id + '">sign out</a>)</p>');
    } else {

        document.write('<p>If you have a TypeKey identity, you can '+
          '<a href="https://www.typekey.com/t/typekey/login?&amp;lang=en_US&amp;t=m3t2BUzv9Kh9H35y6Enz&amp;v=1.1&amp;_return=http://www.omarphillips.net/cgi-bin/mt/mt-comments.cgi%3f__mode=handle_sign_in%26key=TypeKey%26static=1%26entry_id=' + entry_id + '">sign in</a> '+
          'to use it here.</p>');

    }

}


if ('www.omarphillips.net' != 'www.omarphillips.net') {
    document.write('<script src="http://www.omarphillips.net/cgi-bin/mt/mt-comments.cgi?__mode=cmtr_name_js"></script>');
} else {
    commenter_name = getCookie('commenter_name');
}



function likePapa() {
story = 
"<H3>The Boy and the Fox</H3>" +
"<P> One fine " +
document.fox.input1.value +
" morning, there was a young boy walking through the woods on his way to " + 
document.fox.input2.value + 
".  Suddenly, out of nowhere, a " +
document.fox.input3.value + 
" fox jumped out in front of him.  <p>'" +
document.fox.input4.value + 
"!!!' the boy exclaimed.  'I've never seen a " +
document.fox.input3.value + 
" fox in this part of " +
document.fox.input5.value + 
" before!'" +
"<p>'Actually " +
document.fox.input6.value +
", I'm looking for my " +
document.fox.input7.value +
" that I dropped when I was passing through last week.  Have you seen it?' asked the fox." +
"<p>'" +
document.fox.input6.value +
" is not my name, jackass,' said the boy.  " +
"<p>'Well, I don't often call myself " +
document.fox.input3.value + 
", but I let it go when you called me that.  I'm just looking for a little help here.  Couldn't you be a little " +
document.fox.input8.value +
" and help me out?' " +
"<p>'No, but I could spray some of this " +
document.fox.input9.value +  
" in your eyes if you don't get the hell out of my way,' said the boy." +
"<p>'Whoa!  Slow your roll, " +
document.fox.input6.value +
".  It doesn't have to come to that.  I'll move along,' said the fox.  " +
"<p>But the fox didn't move fast enough for the boy.  He reached in his backpack and grabbed the can of " +
document.fox.input9.value +
".  He underestimated the speed of the fox though.  The fox turned towards the boy and bit off his " +
document.fox.input10.value +
".  " +
"<p>'" +
document.fox.input4.value +
"!!! You bit off my " +
document.fox.input10.value +
",' cried the boy, as he fell to the ground wriggling in pain." +
"<p>Just then, the fox noticed his " +
document.fox.input7.value +
" fall out of the boy's backpack.  'Thanks, punk.  I'll have that back.  And I'll take the $" +
document.fox.input11.value +
" you have in your wallet too.'" +
"<p>The fox kicked the boy in the " +
document.fox.input12.value +
" as he walked happily away.";
libsWin = window.open("","","width=400,height=350,scrollbars=yes");
libsWin.document.write(story);
libsWin.document.close();
}

function firstdate() {
story = 
"<H3>First (and last) Date</H3>" +
"<P> It was approaching 7:00, and " +
document.dinner.input1.value +
" was due any minute.  It was the first time " + 
document.dinner.input2.value + 
" had invited " +
document.dinner.input1.value + 
" over for dinner, and he wanted to make it a very special night.  He even made " +
document.dinner.input3.value + 
", his specialty.  As he heard a knock on the door, his heart skipped a beat.  ‘Showtime,’ he said. " +
"<p>" +
document.dinner.input1.value + 
" looked absolutely stunning.  She was wearing a " +
document.dinner.input4.value +
" " +
document.dinner.input5.value + 
", which made " +
document.dinner.input2.value +
" very happy.  'You look really " +
document.dinner.input6.value +
", " +
document.dinner.input11.value +
",' he said nervously." +
"<p>'Thanks... I think.  It smells good in here, did you make " +
document.dinner.input3.value +
" for me?' she asked." +
"<p>'I sure did.  I knew you'd like it,' he replied.  'Come on in and have a seat.  " +
"Mind if I put on some music?'  " +
document.dinner.input2.value +
" had a CD already picked out for the night." +
"<p>'Mmmm, " +
document.dinner.input7.value +
".  Good choice,' she said in an intentionally sexy voice.  Really, she didn't care much for " +
document.dinner.input7.value +
", but she was getting caught up in the moment." +
"<p>'I hope you're hungry,' he said as he brought dinner to the table.  He neatly put some of the " +
document.dinner.input3.value +
" on her plate, then his.  The conversation continued as they started to eat." +
"<p>Suddenly, " +
document.dinner.input1.value +
" noticed her throat start to itch, then she started to cough.  'Um, did you put " +
document.dinner.input8.value +
" in the " +
document.dinner.input3.value +
"?!' she asked between coughs." +
"<p>'Uh, uh, yeah, I think so.  Why?'" +
"<p>'I thought I told you, I'm <i>allergic</i> to " +
document.dinner.input8.value +
"!!!  Who puts " +
document.dinner.input8.value +
" in " +
document.dinner.input3.value +
" anyway?!?'  Her face was getting red and swollen.  She got up to make a run for the bathroom, but she didn't make it.  She threw up all over the " +
document.dinner.input9.value +
" in his living room.  'I... I think I had better go,' she gasped." +
"<p>As she walked towards the door, " +
document.dinner.input2.value +
" ran ahead to open it for her.  'I'm really sorry.  Maybe I could make it up to you, we could catch a movie next...'  " +
"Before he could finish, she threw up again, this time all over his " +
document.dinner.input10.value +
"." +
"<p>'I guess I won't ask for a goodnight kiss,' he uncomfortably quipped.  She glared " +
"at him as she ran to her car and drove off.";
libsWin = window.open("","","width=400,height=350,scrollbars=yes");
libsWin.document.write(story);
libsWin.document.close();
}

function girlscout() {
story = 
"<H3>The Monster at " +
document.scary.input3.value +
" Lane</H3>" +
"<P> The following is the " +
document.scary.input1.value +
"-chilling tale of a scary monster named " + 
document.scary.input2.value + 
".<p>" +
document.scary.input2.value + 
" lived alone atop a hill at the end of " +
document.scary.input3.value + 
" Lane.  The rumor in the neighborhood was that he had killed at least " +
document.scary.input4.value + 
" people, and that he kept the bodies preserved in his house, like trophies.  Even the police were too afraid to go investigate.  A few times per week, neighborhood residents claimed to have seen him " +
document.scary.input5.value +
" around the area.<p>One autumn day, a young girl scout named " +
document.scary.input6.value + 
" was walking through the neighborhood selling cookies.  The top seller in the area was going to win a free " +
document.scary.input7.value +
", and " +
document.scary.input6.value +
" really wanted it.  Even though she was scared, she walked up to " +
document.scary.input2.value +
"'s house and pressed the doorbell.<p>She waited a minute or so, nobody answered the door.  Before she turned around though, she thought she saw someone's " +
document.scary.input8.value +
" pass in front of the window.  She rang the doorbell again.<p>Thud.  Thud.  Thud.  Heavy steps moved closer towards the door.  The giant door opened with a loud creak.  Out from the shadows emerged a huge " +
document.scary.input9.value +
" figure with large " +
document.scary.input10.value +
" eyes.<p>" +
document.scary.input6.value +
" took a small step back, before hurriedly reciting, 'Hi, I'm from girl scout troop " +
document.scary.input11.value +
", would you like to buy some " +
document.scary.input12.value +
" -- I mean, cookies?'<p> " +
document.scary.input2.value +
" leaned in and groaned, 'Come closer, little one.'<p>As she inched forward, " +
document.scary.input2.value +
" grabbed her and pulled her in the house!  Neighbors heard " +
document.scary.input13.value +
" breaking and screams of terror coming from inside, but they were all too afraid to approach the house.  Several minutes later, " +
document.scary.input6.value +
" emerged from the house, cookie order sheet still in hand.<p>Years have passed, and " +
document.scary.input6.value +
" was never quite the same after that day.  Some are convinced that it wasn't her at all who left that house, but a look-alike created by the monster.  Nobody has had the guts to approach her to find out.<p>All they do know is that she won the " +
document.scary.input7.value +
", thanks to the " +
document.scary.input14.value +
" boxes of cookies she sold that day, to the <b>Monster of " +
document.scary.input3.value +
" Lane</b>.";
libsWin = window.open("","","width=400,height=350,scrollbars=yes");
libsWin.document.write(story);
libsWin.document.close();
}

function shopping() {
story = 
"<H3>The Store Clerk</H3>" +
"<P> 'I don't know what I was thinking, coming to the mall today,' " +
document.shop.input1.value +
" thought to himself." + 
"<p>In front of him stood " +
document.shop.input2.value + 
" others waiting in the seemingly endless post-holiday checkout line.  All he wanted to do was return the " +
document.shop.input3.value + 
" that his aunt " +
document.shop.input4.value + 
" bought him for Christmas.  Unfortunately, the " +
document.shop.input2.value +
" other people all had similar stories.  Either that, or they were there to catch some of the great post-holiday sales.<p>After waiting " +
document.shop.input5.value + 
" " +
document.shop.input6.value +
", " +
document.shop.input1.value +
" finally made it to the checkout counter.<p>'Can I help you?' the clerk asked.<p>'Yes, I'd like to return these " +
document.shop.input3.value +
".  I don't have a receipt for them, but I'm pretty sure they were purchased here,' " +
document.shop.input1.value +
" said.<p>'No problem, that happens quite a bit around this time of year.  We'll be able to get you store credit.  Let me ring them up and see.. Hm, it looks like you'll get... $1.99 for this one, and $1.49 for this one.'<p>'WHAT?!' " +
document.shop.input1.value +
" exclaimed.  'That's it?'<p>'The items were on clearance,' she said.<p>'I waited forever in this line for three dollars and change?'<p>There was a brief grumbling noise, then suddenly, the clerk's skin began to turn " +
document.shop.input7.value +
", and her eyes a fiery shade of " +
document.shop.input8.value +
".  As she began to speak, flames and " +
document.shop.input13.value +
" shot from her mouth.  In a voice that can only be described as " +
document.shop.input9.value +
", she said, 'I HAVE BEEN WORKING TODAY SINCE 7 A.M.  I HAVE LISTENED TO " +
document.shop.input10.value +
" MILLION PEOPLE COMPLAIN TO ME BECAUSE THEIR RELATIVES ARE CHEAP, AND I AM NOT GOING TO TAKE IT ANYMORE.'  <P>By now, the fire shooting from her mouth had started several small fires in the store, and the sprinkler system began to turn on.<p>Scared, " +
document.shop.input1.value +
" said, 'I - um, I'm sorry!  I didn't -'<p>'SILENCE!' said the monster clerk.  She picked up the nearest " +
document.shop.input11.value +
" and threw it at him.  While he was down, she directed her fire breath towards him.  Within seconds, " +
document.shop.input1.value +
" was reduced to a pile of ashes.  The remaining customers stood by, soaked and horrified.<p>The monster clerk looked around briefly, then " +
document.shop.input12.value +
" asked, 'Can I help the next person in line?'";
libsWin = window.open("","","width=400,height=350,scrollbars=yes");
libsWin.document.write(story);
libsWin.document.close();
}

function thankyou() {
story = 
"<P>Dear " +
document.thanks.input1.value +
",<p>I would like to sincerely thank you, from the bottom of my " + 
document.thanks.input2.value + 
", for the role you have played in keeping omarphillips.net alive for a full year.  StatCounter shows me that you visit about " +
document.thanks.input3.value + 
" times daily, and let me tell you, I very much appreciate each of those " +
document.thanks.input3.value + 
" visits.<p>Writing for this blog has always been fun for me, and has not often felt like a burden in spite of all that I've had going on in my life over the past year.  While parenting, trying to be a good husband, working, and " +
document.thanks.input4.value + 
", I'm actually surprised I've found any time to write at all!  Really though, I think that doing so much writing over the past year has kept me mentally sharp, and I hope to keep it up for at least " +
document.thanks.input5.value + 
" years. <p>Your comments have been simultaneously humorous, insightful, and " +
document.thanks.input6.value +
".  The posts on this site only make up " +
document.thanks.input7.value +
"% of the site's collective humor, in my opinion.  The rest comes from the comment threads.  I'll deny it if anyone asks me, but between you and me, I think your comments are the funniest, " +
document.thanks.input1.value +
".  The next funniest comments come from " +
document.thanks.input8.value + 
", but they come in a distant second to yours.<p>It's not just your comments that inspire me, but the writing over at '" +
document.thanks.input9.value +
"' as well.  Seriously, that post about " +
document.thanks.input10.value +  
" was the funniest thing I ever read!  <p>So thanks again for being a loyal reader.  I really like you and think you're great, in a 'don't really know you, wouldn't know if I walked right by you on the street, wouldn't testify in court on your behalf' kind of way." +
"<p>Sincerely,<br>Omar " +
"<p>P.S. Oh, and I received the " +
document.thanks.input11.value +
"  you sent in the mail as a blog birthday gift, and I love it.  You really went above and beyond.";
libsWin = window.open("","","width=400,height=350,scrollbars=yes");
libsWin.document.write(story);
libsWin.document.close();
}

function fight() {
story =
"<h3>Misunderstanding</h3>" +
"<p>'We need to talk,' " +
document.breakup.input1.value +
" said.</p><p>Knowing that this couldn't be good, " +
document.breakup.input2.value +
" paused the game of " +
document.breakup.input3.value +
" he was playing, then sat up.  'Sure " +
document.breakup.input4.value +
", what's up?'</p><p>'Well first of all, you know I don't like it when you call me " +
document.breakup.input4.value +
",' she snapped.</p><p>'Sorry.'</p><p>'Anyway,' she continued, 'we need to talk about this.'  She pulled a " +
document.breakup.input5.value +
" out from behind her back.  'I found it in your car when I borrowed it to go to the store.  Care to explain what this is about?'</p><p>'What?  It's just a " +
document.breakup.input5.value +
"!!  I can't believe you're freaking out about that.'</p><p>'I wouldn't freak out about it, if it didn't say 'To " +
document.breakup.input2.value +
", Love " +
document.breakup.input6.value +
"' written on the bottom.'</p><p>'So what?  She's --'</p><p><i>'So what?!?</i>'" +
document.breakup.input1.value +
" interrupted.  She was starting to turn red with anger.  'I can't believe you have the nerve to act like this is no big deal!  I've spent the last " +
document.breakup.input7.value +
" months loving and supporting you while you work that dead-end " +
document.breakup.input11.value +
" job, and this is how you repay me?  The "+
document.breakup.input8.value +
" and " +
document.breakup.input9.value +
" I bought you are sitting on the floor in your closet, but this " +
document.breakup.input5.value +
" is important enough to stay with you in your car?  I'm tired of this.  We're <b>done</b>.  I'm getting my things, " +
document.breakup.input10.value +
", and never coming back!  Good luck finding someone else as " +
document.breakup.input12.value +
" as me, or someone who will put up with this crap!'</p><p>As she started to storm off, " +
document.breakup.input2.value +
" said, 'I hate to interrupt the " +
document.breakup.input10.value +
", but do you even know who " +
document.breakup.input6.value +
" is?'</p><p>'Don't even try that just-a-friend crap, because --'</p><p>'You remember when we went to my birthday party a few months ago, and you met my uncle Jerry and his daughter, <b>" +
document.breakup.input6.value +
"</b>?'</p><p>'You mean this is your <i>cousin</i> " +
document.breakup.input6.value +
"?'</p><p>'Feel free to continue " +
document.breakup.input10.value +
", I'm going back to " +
document.breakup.input3.value +
".'";
libsWin = window.open("","","width=400,height=350,scrollbars=yes");
libsWin.document.write(story);
libsWin.document.close();
}




// Window opener functions  v1.0.6
// documentation: http://www.dithered.com/javascript/window/index.html
// license: http://creativecommons.org/licenses/by/1.0/
// code by Chris Nott (chris[at]dithered[dot]com)


/*******************************************************************************
	Popup Window openers
*******************************************************************************/

var winReference = null;


// Open a window at a given position on the screen
function openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName) {
	
	// ie 4.5 and 5.0 mac - windows are 2 pixels too short; if a statusbar is used, the window will be an additional 15 pixels short
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("mac") != -1 && agent.indexOf("msie") != -1 && (agent.indexOf("msie 4") != -1 || agent.indexOf("msie 5.0") != -1) ) {
		height += (status) ? 17 : 2;
	}

	// Adjust width if scrollbars are used (pc places scrollbars inside the content area; mac outside) 
	width += (scrollbars != '' && scrollbars != null && agent.indexOf("mac") == -1) ? 16 : 0;

	var properties = 'width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y + ((status) ? ',status' : '') + ',scrollbars' + ((scrollbars) ? '' : '=no') + ((moreProperties) ? ',' + moreProperties : '');
	var reference = openWindow(url, name, properties, openerName);
	
	// resize window in ie if we can resize in ns; very messy
	// commented out because openPositionedWindow() doesn't set the resizable attribute
	// left in for reference
	/*if (resizable && agent.indexOf("msie") != -1) {
		if (agent.indexOf("mac") != -1) {
			height += (status) ? 15 : 2;
			if (parseFloat(navigator.appVersion) > 5) width -= 11;
		}
		else {
			height += (status) ? 49 : 31;
			width += 13;
		}
		setTimeout('if (reference != null && !reference.closed) reference.resizeTo(' + width + ',' + height + ');', 150);
	}*/

	return reference;
}


// Open a window at the center of the screen
function openCenteredWindow(url, name, width, height, status, scrollbars, moreProperties, openerName) {
	var x, y = 0;
	if (screen) {
      x = (screen.availWidth - width) / 2;
	   y = (screen.availHeight - height) / 2;
   }
	if (!status) status = '';
	if (!openerName) openerName = '';
	var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName);
	return reference;
}	


// Open a window at the center of the parent window
function openCenteredOnOpenerWindow(url, name, width, height, status, scrollbars, moreProperties, openerName) {
	var centerX = 0;
   var centerY = 0;
   if (window.screenX != null && window.outerWidth) {
      centerX = window.screenX + (window.outerWidth / 2);
      centerY = window.screenY + (window.outerHeight / 2);
   }
   else if (window.screenLeft) {
      if (document.documentElement) {
         centerX = window.screenLeft + (document.documentElement.offsetWidth / 2);
         centerY = window.screenTop + (document.documentElement.offsetHeight / 2);
      }
      else if (document.body && document.body.offsetWidth) {
         centerX = window.screenLeft + (document.body.offsetWidth / 2);
         centerY = window.screenTop + (document.body.offsetHeight / 2);
      }
   }
   
   if (centerX == 0) {
      openCenteredWindow(url, name, width, height, status, scrollbars, moreProperties, openerName);
   }
   var x = parseInt(centerX - (width / 2));
   var y = parseInt(centerY - (height / 2));
	if (!status) status = '';
	if (!openerName) openerName = '';
	var reference = openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName);
	return reference;
}	


// Open a full-screen window (different from IE's fullscreen option)
function openMaxedWindow(url, name, scrollbars, openerName) {
	var x, y = 0;
	var width  = 600;
	var height = 800;
	if (screen) {
      if (screen.availLeft) {
         x = screen.availLeft;
         y = screen.availTop;
      }
      width  = screen.availWidth - 6;
	   height = screen.availHeight - 29;
   }
	var reference = openPositionedWindow(url, name, width, height, x, y, false, scrollbars, openerName);
	return reference;
}


// Open a full-chrome (all GUI elements) window
// This is like using a target="_blank" in a normal link but allows focussing the window
function openFullChromeWindow(url, name, openerName) {
	return openWindow(url, name, 'directories,location,menubar,resizable,scrollbars,status,toolbar');
}


// Open a sized full-chrome (all GUI elements) window 
function openSizedFullChromeWindow(url, name, width, height, openerName) {
	return openCenteredWindow(url, name, width, height, true, true, 'directories,location,menubar,resizable,toolbar', openerName)
}


// Core utility function that actually creates the window and gives focus to it
function openWindow(url, name, properties, openerName) {

	// ie4.x pc can't give focus to windows containing documents from a different domain
	// in this case, initially load a local interstisial page to allow focussing before loading final url
	var agent = navigator.userAgent.toLowerCase();
	if (agent.indexOf("msie") != -1 && parseInt(navigator.appVersion) == 4 && agent.indexOf("msie 5") == -1 && agent.indexOf("msie5") == -1 && agent.indexOf("win") != -1 && url.indexOf('http://') == 0) {
		winReference = window.open('about:blank', name, properties);
		
		setTimeout('if (winReference && !winReference.closed) winReference.location.replace("' + url + '")', 300);
	}
	else {
		winReference = window.open(url, name, properties);
	}

	// ie doesn't like giving focus immediately (to new window in 4.5 on mac; to existing ones in 5 on pc)
	setTimeout('if (winReference && !winReference.closed) winReference.focus()', 200);
	
	if (openerName) self.name = openerName;
	return winReference;
}


/*******************************************************************************
	Modal Dialog controls
*******************************************************************************/

// Close a dialog
// Call from onunload event handler of any page that can create a dialog
function closeDialog(dialog) {
	if (dialog && dialog.closed != true) dialog.close();
}


// Close parent popup
// Call from onload event handler of any page that could be created from a dialog
function closeParentDialog() {
	if (top.opener && isWindowPopup(top.opener)) {
		root = top.opener.top.opener;
		top.opener.close();
		top.opener = root;
	}
}


// Check if a window is a popup
function isWindowPopup(win) {
	return ((win.opener) ? true : false);
}

/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Original script by Corneliu Lucian Rusu | http://www.anet.ro/zen/
Portions modified by Lee Underwood | http://javascript.internet.com/ */

function showhide(s){
  while(s.nodeType!=1 && s.nodeName.toLowerCase()!='span'){s=s.nextSibling};
  s.className=(s.className=='show2')?'hide':'show2';
  return false;
}

// Borrowed from Jeremy Keith | http://www.domscripting.com/
window.onload=getReady;
function getReady() {
  var links = document.getElementsByTagName("a");
  for (var i=0; i<links.length; i++) {
    if (links[i].className == "show") {
      links[i].onclick = function() {
      return showhide(this.nextSibling);
     }
    }
  }
}

// Random encryption key feature by Andrew Moulden, Site Engineering Ltd
// This code is freeware provided these four comment lines remain intact
// A wizard to generate this code is at http://www.jottings.com/obfuscator/

var __MTTBLINK__;
var __MTTBID__;
function obfuscator(coded, key, mode, path, hidden) {
	shift = coded.length;
	link = "";
	
	for(i=0;i<coded.length;i++) {
		if (key.indexOf(coded.charAt(i))==-1) {
			ltr = coded.charAt(i);link+=(ltr);
		} else {
			ltr = (key.indexOf(coded.charAt(i)) - shift + key.length) % key.length;
			link += (key.charAt(ltr));
		}
	}
	if(mode == 'hidden_input') {
		document.write('<input type="hidden" name="CCode" value="' + link + '" />');
	} else if(mode == '__MTTBLINK__') {
		__MTTBLINK__ = path + link;
		if(hidden) return;
		document.write(link);
	} else if(mode == '__MTTBID__') {
		__MTTBID__ = link;
		if(hidden) return;
		document.write(link);
	}
}

// Dynamic Comment Preview - Kudos to Mike Industries for the inspiration!
// D.C.P. - Comment Text
function ReloadTextDiv() {
document.getElementById('TextDisplay').innerHTML = '<p>'+document.getElementById('comment-text').value.replace(/(\r\n|\n)/g,'<br />').replace(/(<br \/>){2,}/gi,'<'+'/p><p>')+'<'+'/p>';
}
// D.C.P. - Comment Author
function ReloadNameDiv() {
document.getElementById('NameDisplay').innerHTML = document.comments_form.comment-author.value;
}
// End Dynamic Comment Preview
