function addToCookie(strVillaName, strVillaID)
{
	var strCompare = strVillaName + "|" + strVillaID + "|";
	var strCookie = document.cookie;
	var intStart = strCookie.indexOf("Villas=");
	if (intStart != -1)
	{
		// Cookie exists - check whether this Villa is already in it
		var intEnd = strCookie.substr(intStart).indexOf(";");
		if (intEnd == -1)
			intEnd = strCookie.length;
		var strValue = strCookie.substring(intStart, intEnd);
		if (strValue.indexOf(strCompare) == -1)
		{
			// This Villa is not in the cookie - add it in
			//alert("Villas=" + strValue.substr(7) + strCompare);
			document.cookie = "Villas=" + strValue.substr(7) + strCompare + ";path=/";
			//alert("New Value: " + document.cookie);
		} else {
			// This Villa is in the cookie - leave it there
			//alert("Already there: " + document.cookie);
			//alert("strCompare: " + strCompare);
		}
	} else {
	// Villas cookie does not exist at all - add it in
		document.cookie = "Villas=" + strCompare + ";path=/";
		//alert("Newly added");
	}
}

function getCookie()
{
	var strCookie = document.cookie;
	var intStart = strCookie.indexOf("Villas=");
	var intEnd = strCookie.substr(intStart).indexOf(";");
	//alert(intStart + " - " + intEnd);
	if (intEnd == - 1)
		intEnd = strCookie.length;
	else
		intEnd += intStart;
	var strValue = strCookie.substring(intStart, intEnd);
	//alert("COOKIE: " + strValue);
	return(strValue);	
}

function removeFromCookie(strVilla, strVillaID)
{
	var strCookie = getCookie();
	var strFind = strVilla + "|" + strVillaID + "|";
	var intStart = strCookie.indexOf(strFind);
	var strNewCookie = strCookie.substr(0, intStart) + strCookie.substr(intStart + strFind.length);
	document.cookie = strNewCookie;
	window.location.href="book_form.asp?id=" + strVillaID;
}

