//javascript include file - by Charlie Monroe
//written for the IAGLCWDC Web Site
//Copyright 1999-2009 by The International Association of Gay/Lesbian Country Western Dance Clubs
//All Rights Reserved

//change this date and resave the file to change the line "Last Updated on ..."
//it will be displayed on every page that calls the WriteContactInfo() function.
//Fri Jun 09 16:53:39 2000
var LastUpdate = 'UNUSED'

//local function called by WriteTextLinks
//writes one hyperlink, activating all but the link whose key is lock
function WriteLink(key,dir,lock,url,t,text)
{
	if (key!=lock) document.write('<a href="',dir,url,'"',t,'>');
	document.write(text);
	if (key!=lock) document.write('</a>');
}

//this functions writes the text links at the bottom of various web pages
//links will be active EXCEPT link with current key
function WriteTextLinks(key,dir)
//key is text string that deactivates the link
//dir is the relative location of the main directory (use '' if current directory is main directory)
//So, to use this on the Home page, use WriteTextLinks('home','')
//    to use this on the History page, use WriteTextLinks('history',''), etc.
//    to use this on a page that is one directory-level down, such as the By-Laws
//      page, use WriteTextLinks('bylaws','../')
//    to activate all links, use a key not in use, such as '' or 'none'
//    lesson: key!='home' means "key does NOT equal 'home'", etc.
{
	//set local variable t to appropriate target phrase
	var t;
	if (window.location.href==top.location.href)
		t = ' target = "_top"';
	else
		t = ' target= "frame_main"';

	document.write('<font size=-1>');
	WriteLink(key,dir,'home','main.php',t,'Home');
	document.write(' | ');
	WriteLink(key,dir,'bylaws','inside/bylaws/bylaws.php',t,'Charitable Status and By-Laws');
	document.write(' | ');
	WriteLink(key,dir,'history','history.html',t,'History');
	document.write(' | ');
	WriteLink(key,dir,'board','board.htm',t,'Board of Directors');
	document.write('<br>');

	
	WriteLink(key,dir,'events','events/events.php',t,'Event Calendar');
	document.write(' | ');
	WriteLink(key,dir,'conventions','events/conventions.php',t,'Conventions');
	document.write(' | ');
	WriteLink(key,dir,'dance','dance/dance.html',t,'Dance Competition');
	document.write(' | ');
	WriteLink(key,dir,'clubs','clubs.php',t,'Member Clubs');
	document.write(' | ');
	WriteLink(key,dir,'inside','inside/inside.htm',t,'Inside IAGLCWDC');
	document.write(' | ');
	WriteLink(key,dir,'maillist','maillist.htm',t,'Join Our Mail List');
	
	document.write('<br>');

	WriteLink(key,dir,'theysay','theysay/theysay.htm',t,'What They Say');
	document.write(' | ');
	WriteLink(key,dir,'join','join.htm',t,'Join Us');
	document.write(' | ');
	WriteLink(key,dir,'links','links/links.htm',t,'Related Sites');
	document.write(' | ');
	WriteLink(key,dir,'email','emailus.htm',t,'Contact Info');
	document.write(' | ');
	WriteLink(key,dir,'sitemap','sitemap.htm','target="_top"','Site Map');
	document.writeln('</font>');

	document.write('<p><font size=-1><a href="',dir,'webmaster.htm" ',t,'>See our Webmaster</a></font>');

}

//utility function used by WriteContactInfo()
//returns the name of the month given n, its number 0..11
function monthname(n)
{
var mname = "unknown month";
if (n==0) mname = "January";
if (n==1) mname = "February";
if (n==2) mname = "March";
if (n==3) mname = "April";
if (n==4) mname = "May";
if (n==5) mname = "June";
if (n==6) mname = "July";
if (n==7) mname = "August";
if (n==8) mname = "September";
if (n==9) mname = "October";
if (n==10) mname = "November";
if (n==11) mname = "December";
return mname;
}


function ToUnicode(st)
{
	var u,i,n;
	u = '';
	for (i=0; i<st.length; i++)
	{
		n = "&#"+st.charCodeAt(i).toString(10)+";";
		u += n;
	}
	return u;
}






function Contact(firstname)
{
	Contact(firstname,0,"");
}

function Contact(firstname,dirdepth)
{
	Contact(firstname,dirdepth,"");
}

// NOTE:  set abspath to "localhost" or "server", if blank, path is calculated using dirdepth
function Contact(firstname,dirdepth,abspath)
{
	var path;
	if (abspath=="localhost")
		path = "http://localhost/iaglcwdc/";
	else if (abspath!="")
		path = "http://iaglcwdc.org/";
	else
	{
		path = "";
		for (var i=0; i<dirdepth; i++)
			path += '../';
	}

	var t = '<html><head><title>Contact by E-mail</title></head>';
	t += '<body bgcolor="#F8C95A" text="#804000" link="#804000" vlink="#804000" alink="#804000" ';
	t += 'background="' + path +    'images/bg_logo_embossed50.jpg">';
	t += '<table border=0 width=100% height=100%><tr><td align=center valign=middle>';
	t += 'Contact<br>';
	t += '<img src="';
	t += path;
	t += 'phpapps/personemailname.php?key=' +firstname+ '">';
	t += '<br>at<br>';
	
	t += '<img src="';
	t += path;
	t += 'phpapps/personemailaddr.php?key=' +firstname+ '">';


	t += '<p><font size=2><tt>The e-mail address is shown above as a graphic.  Please ' +
		'retype it as needed.  We apologize for this inconvenience, but the ever-increasing ' +
		'problem of spam has given us no choice.  Thank you for your understanding.' +
		'</tt></font>';

	t += '</td></tr></table>';
	t += '</body></html>';
	var w = window.open('','msg','width=400,height=300,resizable=yes,scrollbars=yes');
	w.document.write(t);
	w.document.close();
	w.focus();


}


function Email(firstname)
{
	Email(firstname,0,"");
}

function Email(firstname,dirdepth)
{
	Email(firstname,dirdepth,"");
}

function getPath(dirdepth,abspath)
{
	var path = "";
	if (abspath=="localhost")
		path = "http://localhost/iaglcwdc/";
	else if (abspath!="")
		path = "http://iaglcwdc.org/";
	else
	{
		path = "";
		for (var i=0; i<dirdepth; i++)
			path += '../';
	}
	return path;
}

function Email(firstname,dirdepth,abspath)
{
	if (abspath==undefined) abspath = "";
	if (dirdepth==undefined) dirdepth = 0;
	var path = getPath(dirdepth,abspath);

	document.write('<a href="javascript:Contact(\'', firstname, '\',', dirdepth, ',\'', abspath, '\')" title="Click to view this e-mail address in a popup window.">');
	document.write('<img style="border-bottom-width : 1px;border-bottom-style : inset;border-bottom-color : black;" src="');
	document.write(path);
	document.write('phpapps/personemailname.php?key=' +firstname+ '" align=absmiddle border=0>', '</a>');
}



function Addr(firstname,dirdepth)
{
	Addr(firstname,dirdepth,"");
}

function Addr(firstname,dirdepth,abspath)
{
	if (abspath==undefined) abspath = "";
	if (dirdepth==undefined) dirdepth = 0;
	var path = getPath(dirdepth,abspath);
	
	document.write('<img src="');
	document.write(path);
	document.write('phpapps/personemailaddr.php?key=' +firstname+ '" align=absmiddle border=0>');	
}

function WriteContactInfo()
{
	WriteContactInfo(0,"");
}

function WriteContactInfo(dirdepth)
{
	WriteContactInfo(dirdepth,"");
}

function WriteContactInfo(dirdepth,abspath)
{
	if (abspath==undefined) abspath = "";
	if (dirdepth==undefined) dirdepth = 0;
	with (document)
	{
	write('<table width=100% border=0><tr valign=top><td width=85%>');
	write('<font size=2><i>');
	write('&copy; 1996-2009 IAGLCWDC.  All rights reserved.<br>');
	write('This site hosted by <a href="http://www.dreamhost.com/" target="_top">DreamHost</a><br>');	
	write('Questions about IAGLCWDC: <a href="javascript:Contact(\'info\',',dirdepth, ',\'', abspath, '\')">IAGLCWDC Information</a>');
	write('<br>Web Page Questions Contact: <a href="javascript:Contact(\'webmaster\',',dirdepth, ',\'', abspath, '\')">IAGLCWDC Webmaster</a>');
	write('<br>Webmaster <a href="javascript:Contact(\'dave\',',dirdepth, ',\'', abspath, '\')">Dave Hayes</a>');
	write(' - Assistant Webmaster <a href="javascript:Contact(\'charlie\',',dirdepth, ',\'', abspath, '\')">Charlie Monroe</a>');
	write('</i></font>');
	write('</td>');
	write('<td width=15% nowrap>');
	write('<font size=2><i>');
	write('IAGLCWDC<br>');
	write('5543 Edmondson Pike<br>');
	write('P.M.B. 107<br>');
	write('Nashville, TN 37211<br>');
	write('USA');
	write('</i></font>');
	write('</td></tr></table>');
	}
}




function PDFinfo(dir)
{
	var w = window.open(dir+'pdfinfo.htm','pdfinof',
		'width=500,height=400,scrollbars=yes,resizable=yes,menubar=yes');
	w.focus();
}

//utility function to compute the number of days until a given date
//if date is today or past, returns -1
function daysUntil(targetdate) 
{ 
	//format of targetdate:  'Feb 25 2001'
	var now = new Date(); //get today's date
	var lastday = new Date(targetdate); 
	var left = lastday.getTime() - now.getTime();  //milliseconds 
	left = Math.floor(left/(1000*60*60*24)); 
	left++;
	return left;
}

function WriteUntilWeHoedown(size,lastdate) 
{ 
	left = daysUntil(lastdate);
	var daysinhoedown = 5;
	if (left > 1) 
	{ 
		document.write("<font size=+",size,">Only " + left + " more day"); 
		if (left!=1) 
		{  
			document.write("s"); 
		} 
		document.write(" until we hoedown!</font>"); 
	}
	else if (left==1)
	{ 
		document.write('<font size=+',size+1,'>TOMORROW WE HOEDOWN!</font>'); 
	} 
	else if (left<=0 && Math.abs(left)<daysinhoedown) 
	{ 
		document.write('<font size=+',size+1,'>JOIN US TODAY AT THE HOEDOWN!</font>'); 
	} 
	return true; 
} 



