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




function fixPosting() {
	
	
	if ( detectIE() == false ) {
		return true;
	}
	
	
	var a = document.getElementById('cityUpdateArea').innerHTML;
	var x = a.length;
	
	var s = '';
	if ( x < 10 ) {
		s = '0px';
	}
	else if ( x < 200 ) {
		s = '250px';
	}
	else if ( x < 400 ) {
		s = '300px';
	}
	else {
		s = '375px';
	}
	
	document.getElementById('cityUpdateArea').style.height = s;
	
}





function detectIE()
{
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	if ( browser=="Microsoft Internet Explorer") 
	{
		return true;
	}
	else
	{
		return false;
	}
}