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




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)
{
	// FOR HOEDOWN2009.COM -- CHANGE HERE AND IN Email FUNCTION BELOW
	abspath = "server";

	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 w = window.open(path+'phpapps/conv2009_email/conv2009_email.php?key='+firstname,'msg','width=600,height=650,resizable=yes,scrollbars=yes,menubar=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)
{
	// FOR HOEDOWN2009.COM -- CHANGE HERE AND IN Contact FUNCTION ABOVE
	abspath = "server";

	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-2006 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; 
} 


// cookies

function setCookie(name,value,mseconds)
{
	var exp = new Date();
	exp.setTime(exp.getTime() + mseconds);
	document.cookie = name + "=" + escape(value) + ";path=/" +
		((exp==null) ? "":";expires=" +
		exp.toGMTString());
}

function getCookie(name)
{
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0)
	{
		begin = dc.indexOf(cname);
		if (begin!= -1)
		{
			begin += cname.length;
			end = dc.indexOf(";",begin);
			if (end== -1) end = dc.length;
			return unescape(dc.substring(begin,end));
		}
	}
	return null;
}