function addDays(myDate,days) 
{
    return new Date(myDate.getTime() + days*24*60*60*1000);
}

function setCookie(name, value, days)
{
	if(value == "")
	{
		var the_value = "true";
	}
	else
	{
		var the_value = value;
	}
	var the_date = addDays(new Date(), days);
	var the_cookie_date = the_date.toGMTString();
	var the_cookie = name + " = " + the_value;
	the_cookie = the_cookie + ";path=/;expires=" + the_cookie_date;
	//alert(the_cookie);
	document.cookie = the_cookie;
}

function getCookie(cookiename)
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function Set_Cookie( name, value, expires, path, domain, secure ) 
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct 
expires time, the current script below will set 
it for x number of days, to make it for hours, 
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
( ( path ) ? ";path=" + path : "" ) + 
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
        
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}



// THIS SCRIPT DOES THE DOUBLE SWAP (CLOSES THE POP-UP, CHANGES THE PARENT)
// USAGE: <A HREF="#" onClick="DoubleSwap('http://www.domain.com')">text link</A>
function DoubleSwap(URL)
{
	window.opener.location = URL;
	window.close();
}

// THIS SCRIPT RUNS THE POPUP WINDOWS
// USAGE: <a href="javascript:NewWindow('page.html', 'nameOfWindow', 500, 300, 1, 1)">Text Link</a>
function NewWindow(url, myname, w, h, scroll, resize) 
{
	winprops = 'height='+h+',width='+w+',top=10,left=10,scrollbars='+scroll+',resizable='+resize+',toolbar=0'
	win = window.open(url, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// THIS SCRIPT RUNS THE DROPDOWN MENUS
// USAGE: <DIV CLASS="navBlock" onMouseOver="this.className='navBlockHover'; change('subs1', 'subNavHover'); change('flash', 'flashHide'); change('flash2', 'flashHide')" onMouseOut="this.className='navBlock'; change('subs1', 'subNavHide'); change('flash', 'flashShow'); change('flash2', 'flashShow')" onClick="this.className='navBlock'; change('subs1', 'subNavHide'); change('flash', 'flashShow'); change('flash2', 'flashShow')" STYLE="margin-left: 10px; width: 130px;">
function change(id, newClass)
{
	if(document.getElementById(id) != null)
	{
		var identity = document.getElementById(id);
		identity.className = newClass;
	}
}



// THIS SCRIPT GRADUALLY EXPANDS A DIV LAYER TO IT'S CONTENTS' HEIGHT
/* 
USAGE: <DIV ID="test" onClick="expandIt('test', 7);">
<div id = "innertest"> // this must have the id of "inner" + the outter id's name
text or images goes here
</DIV>
</DIV>
*/

function expandIt(id, millisecs) {
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		millisecs = Math.round(millisecs / 10);
		millisecs = 1;
	}
	var x = 1;

	if(document.getElementById(id) == null)
	{
		//do nothing
	}
	else
	{
		// set variables based on 'id'
		var innerid			= "inner" + id;
		var identity		= document.getElementById(id);
		var inneridentity	= document.getElementById(innerid);
		
		function expandMe() {
			//get heights of id & innerid:
			var idHeight 		= identity.offsetHeight;
			var inneridHeight	= inneridentity.offsetHeight;

			if(idHeight > inneridHeight)
			{
				clearInterval(intervalId);
				return;
			}
			
			x=x+10;
			identity.style.height = x + 'px';
		}
		var intervalId = setInterval(expandMe, millisecs);
	}
}


// THIS SCRIPT GRADUALLY COLLAPSES A DIV LAYER TO IT'S CONTENTS' HEIGHT
/* 
USAGE: <DIV ID="test" onClick="collapseIt('test', 7);">
<div id = "innertest"> // this must have the id of "inner" + the outter id's name
text or images goes here
</DIV>
</DIV>


function collapseIt(id, millisecs) {
	if (navigator.appVersion.indexOf("MSIE")!=-1)
	{
		millisecs = Math.round(millisecs / 10);
		millisecs = 1;
	}

	if(document.getElementById(id) == null)
	{
		//do nothing
	}
	else
	{
		// set variables based on 'id'
		var innerid			= "inner" + id;
		var identity		= document.getElementById(id);
		var inneridentity	= document.getElementById(innerid);
		var x				= identity.offsetHeight;
		
		function collapseMe() {
			//get heights of id & innerid:
			var idHeight 		= identity.offsetHeight;

			if(idHeight <= 0)
			{
				clearInterval(intervalId);
				return;
			}
			
			x = x - 1;
			identity.style.height = x + 'px';
		}
		var intervalId = setInterval(collapseMe, millisecs);
	}
}
*/


function collapseIt(id) {
	if(document.getElementById(id) == null)
	{
		//do nothing
	}
	else
	{
		var identity			= document.getElementById(id);
		identity.style.height	= 1 + 'px';
	}
}