// expires is a time in minutes
function SetCookie( name, value, expires, path)
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires )
	{
		expires = expires * 1000 * 60;
	}
	var expires_date = new Date(today.getTime() + (expires));

	document.cookie = name + "=" + escape(value) +
		((expires) ? ";expires=" + expires_date.toGMTString() : "" ) +
		((path) ? ";path=" + path : "" );
}

// this function gets the cookie, if it exists
function GetCookie(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 deletes the cookie when called
function DeleteCookie( name, path)
{
// alert("delete cookie");  // debug
	if(GetCookie(name))
		document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function wopen(url, name, w, h)
{
	// Fudge factors for window decoration space.
	w += 32;
	h += 96;
	var win = window.open(url,
		name,
		'width=' + w + ', height=' + h + ', ' +
		'location=no, menubar=no, ' +
		'status=no, toolbar=no, scrollbars=yes, resizable=yes');
	win.resizeTo(w, h);
	win.focus();
}

function popupplayercheck(w,h)
{
	if(!GetCookie('playerwindow'))		// if player cookie does not exist then open player
	{
		popupplayer(w,h);			// open the player window
	}
	else
	{
// alert("cookie="+GetCookie('playerwindow'));  // debug
		SetPopUpCookie();				// refresh timeout on the cookie
	}
}

function popupplayer(w,h)
{
	var PopWin;
	
	var PopWin = window.open("http://www.vorbic.com/player/popup.php",
		"_vorbicplayer",
		'width=' + w + ', height=' + h + ', ' +
		'location=no, menubar=no, ');
	PopWin.resizeTo(w, h);
	PopWin.focus();
}

function SetPopUpCookie()
{
	SetCookie('playerwindow','open',60,'/');
}

function DeletePopUpCookie()
{
	DeleteCookie('playerwindow','/');
}




