function popitup(url)
{
	newwindow=window.open(url,'name','height=550,width=700,scrollbars=yes,resizeable=no');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popitup2(url)
{
	newwindow=window.open(url,'name','height=550,width=500,scrollbars=no,resizeable=no');
	if (window.focus) {newwindow.focus()}
	return false;
}

function see_map()
{
	newMapWindow = window.open('/popup/see_map.php','Map to Hotel','width=500,height=500,scrollbars=yes,resizeable=no');
	if (window.focus) {newMapWindow.focus()}
	return false;
}

function error_HighlightField(thisOne)
{
	thisOne.style.background 	= "#F8BC84";
	thisOne.style.color 		= "#000";
}
function error_RemoveHighlight(thisOne)
{
	thisOne.style.background 	= "#fffeee";
}

function checkForm_Email()
{
	var errors 		= '';
	var forename	= document.contactUs.forename.value;
	var surname		= document.contactUs.surname.value;
	var email		= document.contactUs.email.value;

	// DELETE ////////////////////////////////////////////////////////////////////////
	if (button == 'DELETE') {
		return delete_check();
	}

	// SAVE ////////////////////////////////////////////////////////////////////////
	
	if ( button == 'SEND' ) {

		// FORENAME
		if (forename == '') {
			errors = errors + "Personal Details: Please give us a name.\n";
			error_HighlightField(document.getElementById("forename"));
		}
		// SURNAME
		if (surname == '') {
			errors = errors + "Personal Details: Please give us a surname.\n";
			error_HighlightField(document.getElementById("surname"));
		}
		
		// FROM EMAIL
		if (email == '') {
			errors = errors + "Personal Details: Please give us an email address.\n";
			error_HighlightField(document.getElementById("email"));
		} else {
			if ( !isEmail(email) ) {
				errors = errors + "Personal Details: Please make sure our email address is valid.\n";
				error_HighlightField(document.getElementById("email"));
			}
		}
	}

	if (errors != '') {
		alert(errors);
		return(false);
	} else {
		return(true);
	}
	
	if ( button == 'CANCEL' ) {
		return(true);
	}

	return false;
}
function delete_check()
{
	var agree=confirm("This item will be deleted!\nClick OK, if you want to continue. Otherwise click Cancel.");
	if (agree)
		return true ;
	else
		return false ;
}

function setButtonValue(val) {
    button = val;
}

function isEmail(str)
{
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
