/**
* functions.js - Comic Archive JavaScript functions
*
* Date Created: 7/07/05
* Last Update: 7/14/05
*
* History
*  7/19/05 (MH): - File creation
*	              - Initial content
*/

/*********************
* 
* Generic Functions
*
*/

/**
* loadImages - Preload images to be used
*/
function loadImages()
{
	curGame1= new Image()
	curGame1.src = "../images/curGame1.jpg"
	
	curGame2= new Image()
	curGame2.src = "../images/curGame2.jpg"
	
	curGame3= new Image()
	curGame3.src = "../images/curGame3.jpg"
		
	curRead1= new Image()
	curRead1.src = "../images/curRead1.jpg"
	
	curRead2= new Image()
	curRead2.src = "../images/curRead2.jpg"
	
	curRead3= new Image()
	curRead3.src = "../images/curRead3.jpg"
	
	prbLink= new Image()
	prbLink.src = "../images/prbLink.jpg"
	
	ethnos= new Image()
	ethnos.src = "../images/ethnos.gif"
	
	compassion= new Image()
	compassion.src = "../images/compassion.gif"
	
	xxxChurch= new Image()
	xxxChurch.src = "../images/xxxChurch.jpg"
	
	axium= new Image()
	axium.src = "../images/axium.gif"
}

/**
* validEmail - Checks valid email address
*
* Arguments
*  - address: The email address
*
* Returns
*  - True if valid
*/
function validEmail(address)
{
	var amp = address.indexOf("@");
	var period = address.indexOf(".");
	var result = true;

	if(amp == -1 || period == -1)
		result = false;

	return result;
}

/**
* validDate - Checks valid dates
* 
* Author: Matt Hartzell
* Last Update: 7/10/05
* 
* Arguments
*  - day: The day
*  - month: The month
*  - year: The year
*
* Returns
*  - True if valid
*/
function validDate(day, month, year)
{
	var result = true;
	
	if(day == 31 && (month == 2 || month == 4 || month == 6 || month == 9 || month == 11))
	{
		result = false;
	}
	
	if((day == 28 || day == 29) && (month != 2))
	{
		result = false;
	}

	return result;
}

/**
* checkAddComment - Check Add comment page
*/
function checkAddComment()
{
	with (document.addCommentForm)
	{
		if(name.value == "")
		{
			alert("Please enter your name!");
			name.focus();
		}
		/*else if(name.value == "Pmasta" || name.value == "PMasta" || name.value == "pmasta" || name.value == "PMASTA")
		{
			alert("There's only one PMasta, and you're not it!");
			name.focus();
		}*/
		else if(comment.value == "")
		{
			alert("Please write a comment!");
			comment.focus();
		}
		else
		{			
			submit();
		}
	}
}

/**
* checkAddBlog - Check Add blog page
*/
function checkAddBlog()
{
	with (document.addBlogForm)
	{
		if(title.value == "")
		{
			alert("Please enter a title.");
			title.focus();
		}
		else if(blog.value == "")
		{
			alert("Please write a blog.");
			blog.focus();
		}
		else
		{		
			submit();
		}
	}
}

/**
* preview - Goes to preview page
*/
function preview() 
{
	with (document.addBlogForm) {
		action = "../html/admin.php";
		
		submit();
	}
}

/**
* checkEmailSignup - Check email subscription
*/
function checkEmailSignup() 
{
	with(document.subscribeForm)
	{
		if(name.value == "")
		{
			alert("Please enter a name.");
			name.focus();
		}
		else if(email.value == "")
		{
			alert("Please enter an email.");
			email.focus();
		}
		else if(!validEmail(email.value))
		{
			alert("Please enter a valid email.");
			email.focus();
		}
		else
		{
			submit();
		}
	}
}


/***********************************************
* Switch Content script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated April 2nd, 2005.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="off" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

var contractsymbol='' //HTML for contract symbol. For image, use: <img src="whatever.gif">
var expandsymbol='' //HTML for expand symbol.


if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(rootobj, classname){
var temparray=new Array()
var inc=0
var rootlength=rootobj.length
for (i=0; i<rootlength; i++){
if (rootobj[i].className==classname)
temparray[inc++]=rootobj[i]
}
return temparray
}

function sweeptoggle(ec){
var thestate=(ec=="expand")? "block" : "none"
var inc=0
while (ccollect[inc]){
ccollect[inc].style.display=thestate
inc++
}
revivestatus()
}


function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(curobj, cid){
var spantags=curobj.getElementsByTagName("SPAN")
var showstateobj=getElementbyClass(spantags, "showstate")
if (ccollect.length>0){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
if (showstateobj.length>0){ //if "showstate" span exists in header
if (collapseprevious=="no")
showstateobj[0].innerHTML=(document.getElementById(cid).style.display=="block")? contractsymbol : expandsymbol
else
revivestatus()
}
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function revivestatus(){
var inc=0
while (statecollect[inc]){
if (ccollect[inc].style.display=="block")
statecollect[inc].innerHTML=contractsymbol
else
statecollect[inc].innerHTML=expandsymbol
inc++
}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
var alltags=document.all? document.all : document.getElementsByTagName("*")
ccollect=getElementbyClass(alltags, "switchcontent")
statecollect=getElementbyClass(alltags, "showstate")
if (enablepersist=="on" && ccollect.length>0){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0" 
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
if (ccollect.length>0 && statecollect.length>0)
revivestatus()
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate

/***********************************************
* Chromeless Window (v3.5)- By Gabriel Suchowolski (this credit MUST stay intact)
* Author site at http://www.microbians.com
* Visit http://www.dynamicdrive.com for this script
***********************************************/

//For paramater explanations, see accompanying faq.htm file
function openIT(u,W,H,X,Y,n,b,x,m,r) {
	var cU  ='close.gif'   //gif for close on normal state.
	var cO  ='close.gif'  //gif for close on mouseover.
	var cL  ='clock.gif'      //gif for loading indicator.
	var mU  ='minimize.gif'     //gif for minimize to taskbar on normal state.
	var mO  ='minimize.gif'    //gif for minimize to taskbar on mouseover.
	var xU  ='max.gif'     //gif for maximize normal state.
	var xO  ='max.gif'    //gif for maximize on mouseover.
	var rU  ='restore.gif'     //gif for minimize on normal state.
	var rO  ='restore.gif'    //gif for minimize on mouseover.
	var tH  ='<font face=verdana size=2>Chromeless Window</font>'   //title for the title bar in html format.
	var tW  ='Chromeless Window'   //title for the task bar of Windows.
	var wB  ='#D5D5FF'   //Border color.
	var wBs ='#D5D5FF'   //Border color on window drag.
	var wBG ='#D5D5FF'   //Background of the title bar.
	var wBGs='#D5D5FF'   //Background of the title bar on window drag.
	var wNS ='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0'  //Html parameters for Netscape.
	var fSO ='scrolling=auto noresize'   //Html parameters for main content frame.
	var brd =0;   //Extra border size.
	var max =x||false;   //Maxzimize option (true|false).
	var min =m||false;   //Minimize to taskbar option (true|false).
	var res =r||false;   //Resizable window (true|false).
	var tsz =0;   //Height of title bar.
	return chromeless(u,n,W,H,X,Y,cU,cO,cL,mU,mO,xU,xO,rU,rO,tH,tW,wB,wBs,wBG,wBGs,wNS,fSO,brd,max,min,res,tsz)
}

/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var defaultMenuWidth="100px" //set default menu width.

var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

// 
// Friend Blogs
//

linkset[0]='<table cellspacing=5><tr><td width=75>'
linkset[0]+='<a href="http://riedl.blogspot.com/" target="_blank">Aaron</a>'
linkset[0]+='<a href="http://angiesphotoblog.blogspot.com/" target="_blank">Angie</a>'
linkset[0]+='<a href="http://anriedl.blogspot.com/" target="_blank">Anna</a>'
linkset[0]+='<a href="http://ashbyduck.livejournal.com/" target="_blank">Ashby</a>'
linkset[0]+='<a href="http://www.strandys.com" target="_blank">Brent</a>'
linkset[0]+='<a href="http://killinggoliath.blogspot.com" target="_blank">Brian</a>'
linkset[0]+='<a href="http://ifellfirst.blogspot.com/" target="_blank">Chris</a>'
linkset[0]+='<a href="http://beatlesxforxsale.blogspot.com/" target="_blank">Ciara</a>'
linkset[0]+='<a href="http://canazndan.blogspot.com/" target="_blank">Dan L</a>'
linkset[0]+='<a href="http://danzollner.blogspot.com" target="_blank">Dan Z</a>'
linkset[0]+='<a href="http://escapedthekushtaka.blogspot.com/" target="_blank">Dave</a>'
linkset[0]+='<a href="http://gorgeoussleep.blogspot.com/" target="_blank">Jacey</a>'
linkset[0]+='<a href="http://jaderose1987.blogspot.com/" target="_blank">Jade</a>'
linkset[0]+='<a href="http://www.creasonfamily.com/" target="_blank">Jarett</a>'
linkset[0]+='<a href="http://hairlady29.blogspot.com/" target="_blank">Jenn</a>'
linkset[0]+='<a href="http://www.seekjen.blogspot.com/" target="_blank">Jennifer</a>'
linkset[0]+='<a href="http://iamjabbott.blogspot.com/" target="_blank">Jeremy</a>'
linkset[0]+='<a href="http://www.amplifiedworship.net/" target="_blank">Joel</a>'
linkset[0]+='<a href="http://jonnysmall.blogspot.com/" target="_blank">Jon</a>'
linkset[0]+='</td><td width=75 valign="top">'
linkset[0]+='<a href="http://web.mac.com/justinwolverton/iWeb/Jdub/Blog/Blog.html" target="_blank">Justin</a>'
linkset[0]+='<a href="http://justvisitinghere.blogspot.com/" target="_blank">Kathi</a>'
linkset[0]+='<a href="http://kenbussellblog.blogspot.com/" target="_blank">Ken</a>'
linkset[0]+='<a href="http://kristingoestoaustralia.blogspot.com/" target="_blank">Kristin</a>'
linkset[0]+='<a href="http://lauralindgren25.blogspot.com/" target="_blank">Laura</a>'
linkset[0]+='<a href="http://50-and-focused.blogspot.com/" target="_blank">Mom</a>'
linkset[0]+='<a href="http://rabbittrailthoughts.blogspot.com/" target="_blank">Natalie</a>'
linkset[0]+='<a href="http://wellijusthadtolaugh.blogspot.com/" target="_blank">Nate</a>'
linkset[0]+='<a href="http://www.paulramey.com" target="_blank">Paul</a>'
linkset[0]+='<a href="http://melchizedek077.blogspot.com/" target="_blank">Paulos</a>'
linkset[0]+='<a href="http://rachelwolverton.blogspot.com/" target="_blank">Rachel</a>'
linkset[0]+='<a href="http://wasmachstdugern.blogspot.com/" target="_blank">Terry</a>'
linkset[0]+='<a href="http://tradmacher.blogspot.com/" target="_blank">Tiffany</a>'
linkset[0]+='<a href="http://toddly13.blogspot.com/" target="_blank">Todd</a>'
linkset[0]+='<a href="http://impministries.blogspot.com/" target="_blank">Tom</a>'
linkset[0]+='<a href="http://seektroy.blogspot.com/" target="_blank">Troy H</a>'
linkset[0]+='<a href="http://www.artifexcc.typepad.com/the_claptrap/" target="_blank">Troy S</a>'
linkset[0]+='<a href="http://weslysmith.blogspot.com/" target="_blank">Wes</a>'
linkset[0]+='</td></tr></table>'
// 
// Cool Blogs
//

linkset[1]='<a href="http://bobhyatt.typepad.com/" target="_blank">Bob Hyatt</a>'
linkset[1]+='<p class="grey">Senior Pastor at Evergreen Community</p><br>'

linkset[1]+='<a href="http://blogs.ign.com/Hyrule-Times/" target="_blank">Hyrule Times</a>'
linkset[1]+='<p class="grey">Blogs about Zelda Games</p><br>'

linkset[1]+='<a href="http://www.johnjohnson.typepad.com/" target="_blank">John Johnson</a>'
linkset[1]+='<p class="grey">Senior Pastor at Village Baptist</p><br>'

linkset[1]+='<a href="http://theresurgence.com/md_blog" target="_blank">Mark Driscoll</a>'
linkset[1]+='<p class="grey">Senior Pastor at Mars Hill in Seattle</p><br>'

linkset[1]+='<a href="http://occasionalsuperheroine.blogspot.com/" target="_blank">Occasional Superheroine</a>'
linkset[1]+='<p class="grey">True Confessions of a former DC Editor</p><br>'

linkset[1]+='<a href="http://www.gamematters.com" target="_blank">Scott Miller</a>'
linkset[1]+='<p class="grey">CEO of 3D Realms</p><br>'

linkset[1]+='<a href="http://gelatometti2.blogspot.com/" target="_blank">Sun of Gelatometti</a>'
linkset[1]+='<p class="grey">A number of professional illustrators</p><br>'

linkset[1]+='<a href="http://xxxchurch.com/07/blog_home.php?b=x3" target="_blank">xxxChurch Blog</a>'
linkset[1]+='<p class="grey">Updates on the xxxChurch ministry</p>'

// 
// Marvel Blogs
//

linkset[2]='<a href="http://www.marvel.com/blogs/tom%20brevoort" target="_blank">Blah Blah Blog</a>'
linkset[2]+='<p class="grey">Tom Brevoort (Executive Editor)</p><br>'

linkset[2]+='<a href="http://www.marvel.com/blogs/marvelknights" target="_blank">Blog By Knight</a>'
linkset[2]+='<p class="grey">Various Editors (Marvel Knights)</p><br>'

linkset[2]+='<a href="http://www.marvel.com/blogs/joe%20quesada" target="_blank">Cup of Blog</a>'
linkset[2]+='<p class="grey">Joe Quesada (Editor-in-Chief)</p><br>'

linkset[2]+='<a href="http://www.marvel.com/blogs/spideyoffice" target="_blank">Spidey\'s Web Log</a>'
linkset[2]+='<p class="grey">Various Editors (Spider-Man Office)</p><br>'

linkset[2]+='<a href="http://www.marvel.com/blogs/john%20barber" target="_blank">Ultimate Blog</a>'
linkset[2]+='<p class="grey">John Barber (Ultimate Universe)</p><br>'

linkset[2]+='<a href="http://www.marvel.com/blogs/the%20x-office" target="_blank">The X-Blog</a>'
linkset[2]+='<p class="grey">Various Editors (The X-Office)</p>'

//
// Quick Links
//

linkset[3]='<p>Paul Ramey Band</p>'
linkset[3]+='<a href="http://www.paulrameyband.com" target="_blank"><img src="../images/prbLink.jpg"></a><hr>'

linkset[3]+='<p>Ethnos Church</p>'
linkset[3]+='<a href="http://www.ethnoschurch.org" target="_blank"><img src="../images/ethnos.gif" width=100 height=35></a><hr>'

linkset[3]+='<p>Compassion International</p>'
linkset[3]+='<a href="http://www.compassion.com" target="_blank"><img src="../images/compassion.gif" width=40 height=42></a><hr>'

linkset[3]+='<p>xxxChurch<br></p>'
linkset[3]+='<a href="http://www.xxxchurch.com" target="_blank"><img src="../images/xxxChurch.jpg" width=50 height=66></a><hr>'

linkset[3]+='<p>Axium (My job)</p>'
linkset[3]+='<a href="http://www.axiumae.com" target="_blank"><img src="../images/axium.gif" width=50 height=19></a><hr>'

linkset[3]+='<p>Encyclopedia of Life</p>'
linkset[3]+='<a href="http://www.eol.org" target="_blank"><img src="../images/eol.jpg" width=100 height=56></a>'

//
// Current Media
//

linkset[4]='<p class="orange">Games</p><hr>'
linkset[4]+='<table cellspacing=5><tr><td>'
linkset[4]+='<p>Final Fantasy XII<br></p>'
linkset[4]+='<p class="grey">Square-Enix</p>'
linkset[4]+='<a href="http://ps2.ign.com/objects/488/488222.html" target="_blank"><img src="../images/curGame1.jpg" width=87 height=125></a>'
linkset[4]+='</td>'

linkset[4]+='<td>'
linkset[4]+='<p>Half-Life 2: Episode 1</p>'
linkset[4]+='<p class="grey">Valve</p>'
linkset[4]+='<a href="http://pc.ign.com/articles/710/710967p1.html" target="_blank"><img src="../images/curGame2.jpg" width=87 height=125></a>'
linkset[4]+='</td>'

linkset[4]+='<td>'
linkset[4]+='<p>Dragon Quest VIII</p>'
linkset[4]+='<p class="grey">Square-Enix</p>'
linkset[4]+='<a href="http://ps2.ign.com/articles/666/666876p1.html" target="_blank"><img src="../images/curGame3.jpg" width=87 height=125></a>'
linkset[4]+='</td></tr></table>'

linkset[4]+='<p class="orange">Books</p><hr>'
linkset[4]+='<table cellspacing=5><tr><td>'
linkset[4]+='<p>Introduction to Biblical Interpretation<br></p>'
linkset[4]+='<p class="grey">Klein, Blomberg, and Hubbard Jr.</p>'
linkset[4]+='<a href="http://www.amazon.com/Introduction-Biblical-Interpretation-Revised-Expanded/dp/0785252258/ref=sr_1_2/002-4806637-0126414?ie=UTF8&s=books&qid=1175534281&sr=8-2" target="_blank"><img src="../images/curRead1.jpg" width=75 height=108></a>'
linkset[4]+='</td>'

linkset[4]+='<td>'
linkset[4]+='<p>Spiritual Disciplines for the Christian Life<br></p>'
linkset[4]+='<p class="grey">Donald S. Whitney</p>'
linkset[4]+='<a href="http://www.amazon.com/Spiritual-Disciplines-Christian-Donald-Whitney/dp/1576830276/sr=1-1/qid=1168803602/ref=pd_bbs_sr_1/105-7655221-4796412?ie=UTF8&s=books" target="_blank"><img src="../images/curRead2.jpg" width=75 height=112></a>'
linkset[4]+='</td>'

linkset[4]+='<td>'
linkset[4]+='<p>Star Wars: The Joiner King - Dark Nest<br></p>'
linkset[4]+='<p class="grey">Troy Denning</p>'
linkset[4]+='<a href="http://www.amazon.com/gp/product/0345463048/qid=1140633840/sr=2-1/ref=pd_bbs_b_2_1/002-7062876-0439207?s=books&amp;v=glance&amp;n=283155" target="_blank"><img src="../images/curRead3.jpg" width=75 height=117></a>'
linkset[4]+='</td></tr></table>'

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// No need to edit beyond here
//

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function showmenu(e, which, optWidth){
if (!document.all&&!document.getElementById)
return
clearhidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
eventX=ie5? event.clientX : e.clientX
eventY=ie5? event.clientY : e.clientY
//Find out how close the mouse is to the corner of the window
var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<menuobj.contentwidth)
//move the horizontal position of the menu to the left by it's width
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
else
//position the horizontal position of the menu where the mouse was clicked
menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
//same concept with the vertical position
if (bottomedge<menuobj.contentheight)
menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
else
menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
menuobj.style.visibility="visible"
return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(){
delayhide=setTimeout("hidemenu()",500)
}

function clearhidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

// Preload images
window.onload=loadImages