
var jsReady = false; // flag for synchronizing with ActionScript
function isReady() { return jsReady; }

function pageInit() {
	jsReady = true;
	//document.forms["form1"].output.value += "\n" + "JavaScript is ready.\n";
}

// ---------- save the selected room_id in the cookie
function previewClose() {
	window.close();
}

function saveRoom(index, value) {
	
	var expires1 = new Date( );
	expires1.setDate(expires1.getDate( ) + 90);	
	
	document.cookie = "room" + index + "=" + escape(value) + "; expires =" + expires1.toGMTString();
}

// ---------- delete the selected room_id in the cookie
function deleteRoom( index )
{
	var expires = new Date( );
	expires.setDate(expires.getDate( ) - 1);
	
	document.cookie = "room" + index + "=; expires=" + expires.toGMTString();
}

// ---------- get all the room_id in the cookie
function getRooms() {
	var rooms = new Array(20);
	var cookie = document.cookie;
		
	if( cookie.length == 0 )
		return null;

	for (i=0; i<20; i++) {
		search = "room" + i + "=";
		startIndex = cookie.indexOf( search );
		if( startIndex == -1 )
			continue;
		startIndex += search.length;
	
		endIndex = cookie.indexOf( ";", startIndex );
		if( endIndex == -1) 
			endIndex = cookie.length;
	 
		rooms[i] = unescape( cookie.substring( startIndex, endIndex ) );
	}
	
	return rooms;
}

