<!--

function bm_getcookie () {
var arr, x;
var oStr = retrieveCookie("hotelmark");
	if (!oStr) return 0;
	arr = oStr.split( "|" );
	for (x in arr) if (arr[x]) {
		arrx = arr[x].split( "=" );
		bm_add(arrx[0],arrx[1],0);
	}
}


function bm_setcookie () {
var o, i, oStr, nStr;
var p = getID("booktable"); 
	if (!p) return false;
	for (var i=1, oStr=''; i<p.rows.length; i++) if (p.rows[i].id) {
		o = p.rows[i].getElementsByTagName('img');
	    nStr = o[1].title;
	    oStr = oStr + "|" + p.rows[i].id.substr(2) + "=" + nStr;
	}
	setCookie("hotelmark",oStr,900,"/");
	// format:  Len|677000=Resort name|...
}


function bm_del (h,f) {
var p = getID("booktable"); 
	if (!p) return false;
	for (var i=1; i<p.rows.length; i++) {
		if (p.rows[i].id == 'bm' + h) {
		p.deleteRow(i);
		}
	}	
	bm_setcookie();
}


function bm_add (h,n,c) {
var p = getID("booktable"); 
	if (!p || !h) return false;
	for (var i=1; i<p.rows.length; i++) {
		if (p.rows[i].id == 'bm' + h) return false;
	}
var tblBody = p.tBodies[0];
var newRow = tblBody.insertRow(-1);
var newCel = newRow.insertCell(0);
var ss = n.substr(0,25);
var s1 = '<tr id="bm' + h + '" class="shown"><td nowrap><img src="' + homedir + 'images/iclose.gif" style="float: right; position:absolute" title="remove">';
var s2 = '<img src="http://' + ccode + '.th66.com/R24thumb.php?h=' + h + '&t=main.jpg&x=120&y=120" title="' + n + '"><br>' + ss.sub() + '</td></tr>';
	newCel.innerHTML = s1 + s2;
	newRow.id = 'bm' + h;
//	newRow.title = thishotel;
var	o = newCel.getElementsByTagName('img');
	o[0].onclick = function(){ bm_del(h,this); };
	o[1].onclick = function(){ location.href = homedir + "R24.php?h=" + h + "&pg=DETAIL"; };
	if (c) bm_setcookie();
	return false;
}


function bm_hideshow (onoff) {
var p = getID("booktable"); 
	if (!p) return false;
	for (var i=1; i<p.rows.length; i++) {
		o = p.rows[i].className = onoff ? "shown" : "hidden";
	}
}

function retrieveCookie( cookieName ) {
	/* retrieved in the format
	cookieName4=value; cookieName3=value; cookieName2=value; cookieName1=value
	only cookies for this domain and path will be retrieved */
	var cookieJar = document.cookie.split( "; " );
	for( var x = 0; x < cookieJar.length; x++ ) {
		var oneCookie = cookieJar[x].split( "=" );
		if( oneCookie[0] == escape( cookieName ) ) { return unescape( oneCookie[1] ); }
	}
	return null;
}

function setCookie( cookieName, cookieValue, lifeTime, path, domain, isSecure ) {
	if( !cookieName ) { return false; }
	if( lifeTime == "delete" ) { lifeTime = -10; } //this is in the past. Expires immediately.
	/* This next line sets the cookie but does not overwrite other cookies.
	syntax: cookieName=cookieValue[;expires=dataAsString[;path=pathAsString[;domain=domainAsString[;secure]]]]
	Because of the way that document.cookie behaves, writing this here is equivalent to writing
	document.cookie = whatIAmWritingNow + "; " + document.cookie; */
	document.cookie = escape( cookieName ) + "=" + escape( cookieValue ) +
		( lifeTime ? ";expires=" + ( new Date( ( new Date() ).getTime() + ( 1000 * lifeTime ) ) ).toGMTString() : "" ) +
		( path ? ";path=" + path : "") + ( domain ? ";domain=" + domain : "") + 
		( isSecure ? ";secure" : "");
	//check if the cookie has been set/deleted as required
	if( lifeTime < 0 ) { if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return false; } return true; }
	if( typeof( retrieveCookie( cookieName ) ) == "string" ) { return true; } return false;
}


function getID(divID) {
    if( document.getElementById ) { //DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID); }
    if( document.all ) { //Proprietary DOM; IE4
        return document.all[divID]; }
    if( document.layers ) { //Netscape layers
        return document.layers[divID]; }
    if( document[divID] ) { //Netscape alternative
        return document[divID]; }
    return false;
}

//-->
