function open_window(sURL, iHeight, iWidth, iTop, iLeft, sWinName, sScrollbars, bResizable)
{
	window.open (sURL, sWinName,'height=' + iHeight + ',width=' + iWidth + ',scrollbars=' + sScrollbars + ',toolbar=no,location=no,directories=no,status=no,menubar=no,titlebar=yes,alwaysRaised=yes,fullscreen=no,resizable=' + bResizable + ',top=' + iTop + ',left=' + iLeft);
}

function set_booking_status(iBookingID, iBookingStatusID)
{
	if (confirm("Are you sure you wish to delete this booking?"))
		open_window("ManagerAmendBookingStatus.asp?BookingID=" + iBookingID + "&BookingStatusID=" + iBookingStatusID, 100, 200, 300, 300, "winBookingStatus", "no", "no") ;
}

function show_zoomzoomis()
{
	open_window("http://manager.zoomzoomis.co.uk", 500, 600, 50, 50, "winZoomZoomIS", "yes", "yes") ;
}

function show_prices_and_availability(iGiteID)
{
	open_window("La-Rose-Prices-And-Availabilty-Detail.asp?GiteID=" + iGiteID, 700, 700, 50, 50, "winPricesAvailability", "yes", "no") ;
}


function show_gallery(iGiteID)
{
	open_window("Gallery.asp?GiteID=" + iGiteID, 550, 545, 50, 50, "winGallery", "yes", "no") ;
}

function show_booking_request(iGiteID)
{
	open_window("La-Rose-Booking-Request.asp?GiteID=" + iGiteID, 600, 500, 75, 75, "winBookingRequest", "yes", "no") ;
}

function go_print()
{
	window.print() ;
}

function go_close()
{
	window.close() ;
}

function go_refresh()
{
	document.location.reload() ;
}

function change_image(oImage, sNewImagePath)
{
	if (oImage.src)
		oImage.src = sNewImagePath ;
}

function go_manager_logout()
{
	if (confirm("Are you sure you wish to logout?"))
		document.location = "ManagerLogout.asp" ;
}

function validate_numeric(oInput)
{
	if (is_not_empty(oInput.value))
		if (!is_numeric(oInput.value))
		{
			alert("Only Numberic whole number values allowed.") ; 
			oInput.value = "" ;
		}
}

function validate_numeric_float(oInput)
{
	if (is_not_empty(oInput.value))
		if (!is_numeric_float(oInput.value))
		{
			alert("Only Numeric number values allowed") ;
			oInput.value = "" ;
		}
}

function get_object_handle(iObjectID)
{
	return document.getElementById(iObjectID) ;
}

var aMenuStatus = [null, 0, null, 0, null, 0, null, 0] ; // 0:Closed, 1:About to Close, 2: Open

function show_menu(iMenuID)
{
	if (aMenuStatus[(2 * iMenuID) + 1] != 2)  // If not already open...
	{
		var oMenu = get_object_handle("divMenu" + iMenuID) ;
	
		if (oMenu != null)
		{
			if (oMenu.filters)
			{
				if ((oMenu.filters[0].status != 2)&&(oMenu.style.visibility != "visible")) // If the filter is not playing and is not already visible...
				{
					oMenu.filters[0].Apply() ;
					oMenu.style.visibility = "visible" ;
					oMenu.filters.revealTrans.transition = 5 ; // Wipe down... 5
					oMenu.filters[0].Play() ;
				}
			}
			else
				oMenu.style.visibility = "visible" ;
				
			aMenuStatus[(2 * iMenuID) + 1] = 2 ;
		}
	}
}

function go_hide_menu(iMenuID)
{
	var oMenu = get_object_handle("divMenu" + iMenuID) ;
	
	if ((oMenu != null)&&(aMenuStatus[(2 * iMenuID) + 1] == 1)) // Menu exists and it needs closing...
	{
		if (oMenu.filters)
		{
			if (oMenu.filters[0].status != 2) // If the filter is not playing...
			{
				oMenu.filters[0].Apply() ;
				oMenu.style.visibility = "hidden" ;
				oMenu.filters.revealTrans.transition = 4 ; // Wipe up... 4
				oMenu.filters[0].Play() ;
			}
		}
		else
			oMenu.style.visibility = "hidden" ;
			
		aMenuStatus[(2 * iMenuID) + 1] = 0 ;
	}
}

function hide_menu(iMenuID)
{
	if (aMenuStatus[(2 * iMenuID) + 1] == 2)
	{
		aMenuStatus[(2 * iMenuID) + 1] = 1 ; // Prepare to close...
		clearTimeout(aMenuStatus[(2 * iMenuID)]) ; // Clear any previous time out...
		aMenuStatus[(2 * iMenuID)] = setTimeout("go_hide_menu(" + iMenuID + ")", 400) ;
	}
}

/* Validation... */

var oNonEmptyRegex = new RegExp("^[\\w]") ;

function is_not_empty(sTheString)
{
	return (oNonEmptyRegex.test(sTheString)) ;
}

function validate_email(sEMailAddress)
{
	//var sEmailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]+[\.]+[\\w]+[\\w]$" ;
	var sEmailReg = "^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_\-])+[\.]+(\.[a-zA-Z0-9])+" ;
	var oRegex = new RegExp(sEmailReg) ;
     
	return (oRegex.test(sEMailAddress)) ;
}

function is_numeric(sNumericString)
{
	var iNumericValue = parseInt(sNumericString) ;
	
	var sStringValue = "" + iNumericValue ; // Make it a string...
	
	return (sStringValue == sNumericString) ;
}

function is_numeric_float(sNumericString)
{
	var cDecimalPoint = "." ;
	var cDeliminatorPoint = "," ;
	var iIndex ;
	var cChar ;
	var bFoundDecimal = false ;
	var bFoundDeliminator = false ;

	if (sNumericString == cDecimalPoint) 
		return false ;
	
	for (iIndex = 0 ; iIndex < sNumericString.length ; iIndex++)
	{
		cChar = sNumericString.charAt(iIndex) ;
	
		if ((cChar == cDecimalPoint) && !bFoundDecimal) 
			bFoundDecimal = true ;
		else if ((!is_numeric(cChar))&&(cChar != cDeliminatorPoint))
			return false ;
	}
	
	return true ;
}

function validate_date(sTheDate, sTodaysDate)
{
	if (sTheDate.indexOf("/") >= 0)
		var parsedDate = sTheDate.split ("/") ;
	else if (sTheDate.indexOf("-") >= 0)
		var parsedDate = sTheDate.split ("-") ;
	else
		return false ;
		
	if (parsedDate.length != 3) return false ;
   
	var day = parsedDate[0] ;
	var month = parsedDate[1] ;
	var year = parsedDate[2] ;

	var oDate = new Date (month + "/" + day + "/" + year) ;
	var oDateNow = new Date(sTodaysDate) ;
   
	if (day != oDate.getDate()) return false ;
	if (month - 1 != oDate.getMonth()) return false ;
	if (year != oDate.getFullYear()) return false ;
   
	if (oDate < oDateNow) return false ;

	return true ;
} 

function set_message_status(bShow)
{
	var oHelp = get_object_handle("divMessage") ;
	var sStatus = "hidden" ;
	var iTransitionNo = 0 ;
	
	if (oHelp)
	{
		if (bShow)
		{
			sStatus = "visible" ;
			iTransitionNo = 1 ; //19 ;
		}
		else
		{
			sStatus = "hidden" ;
			iTransitionNo = 0 ; //18 ;
		}
		
		if (oHelp.filters) // If browser supports filters and there is a valid transition...
		{
			oHelp.filters[0].Apply() ;
			oHelp.style.visibility = sStatus ;
			oHelp.filters.revealTrans.transition = iTransitionNo ;
			oHelp.filters[0].Play() ;
		}
		else
			oHelp.style.visibility = sStatus ;
	
	}
}