function delOffer(id, act)
{
	var okToDelete = confirm('Are you sure you want to delete this offer?');
	if(okToDelete)
	{
		$currentURL=  "../admin/process/book_u.php?act=deloff&id=" + id;
		location.href = $currentURL;
	}
}

function addOffer(id, act)
{
	var okToAdd = confirm('Are you sure you want to add this offer?');
	

	if(okToAdd)
	{
		$currentURL=  "../admin/process/book_u.php?act=addoff&id=" + id;
		location.href = $currentURL;
	}
}

function addOffer2(id)
{
//	var okToAdd = confirm('Are you sure you want to add this offer?');

	var id2;
	id2=id.value;
	
//	if(okToAdd)
//	{
		$currentURL=  "../admin/process/book_u.php?act=addoff&id=" + id2;
		location.href = $currentURL;
//	}
}



function changeImages() {
			for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}

function OpenWindow($im, $name)
{
$features="";
$features+="width=530, ";
$features+="height=530, ";
$features+="toolbars=no, ";
$features+="resizable=no, ";
$features+="location=no, ";
$features+="directories=no, ";
$features+="status=no, ";
$features+="menubar=no, ";
$features+="scrollbars=no, ";
$features+="left=30, ";
$features+="top=30";

win=window.open($im, $name, $features);
win.focus();

}

function validate_registration(item)
{
	var $e_mail;
	var $username;
	var $password1;
	var $password2;
	var $response;
	var $errors;

	$e_mail=item.email.value;
	$username=item.username.value;
	$password1=item.password1.value;
	$password2=item.password2.value;

	$response="There are errors on the form: \n";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="\n- Return e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\n- Return e-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($username) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Username not entered";
		$errors+=1;
	}

	if (isEmpty($password1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password not entered";
		$errors+=1;
	}

	if (isEmpty($password2) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Repeated Password not entered";
		$errors+=1;
	}

	if ($password1.length <6 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password to short";
		$errors+=1;
	}

	
	if ($password1!=$password2)
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password and Repeated Password are not the same";
		$errors+=1;
	}

	
	
	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}


function validate_password_change(item)
{
	var $password1;
	var $password2;
	var $response;
	var $errors;

	$password1=item.newpassword1.value;
	$password2=item.newpassword2.value;

	$response="There are errors on the form: \n";
	$errors=0;


	if (isEmpty($password1) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password not entered";
		$errors+=1;
	}

	if (isEmpty($password2) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Repeated Password not entered";
		$errors+=1;
	}

	if ($password1.length <6 )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password to short";
		$errors+=1;
	}

	
	if ($password1!=$password2)
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\n- Password and Repeated Password are not the same";
		$errors+=1;
	}


	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}
}



function validate_mail_form(item)
{
	var $e_mail;
	var $title;
	var $message;
	var $response;
	var $errors;

	$e_mail=item.messagefrom.value;
	$title=item.messagetitle.value;
	$message=item.message.value;

	$response="Errors:- ";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="\nReturn e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="\nReturn e-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($title) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\nMessage title not entered";
		$errors+=1;
	}

	if (isEmpty($message) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="\nBody of message not entered";
		$errors+=1;
	}

	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}

}


function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

function isEmail (s)
{   
   
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)

    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the .
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;

    else 

return true;
}


function PopupLand(url)
{
// This function is used to display the bedroom images in Landscape in a named window.
// If the window is already open then it will just update the existing contents
//
// Expected to be used in hypertext links, e.g.:
// <A HREF=DisplayItem.asp?ObjID=CIV:1021 onClick="OpenTaskWindow('xyz.htm');return false;\>

//  windowName = "_blank";
  windowName = "PopupLand";
  params  = "";
  params += "toolbar=0,";
  params += "location=0,";
  params += "directories=0,";
  params += "status=0,";
  params += "menubar=0,";
  params += "scrollbars=0,";
  params += "resizable=0,";
  params += "width=360,";
  params += "height=320,";
  params += "left=50,";
  params += "top=75,";

    win = window.open(url, windowName, params);
    win.focus();

}

function PopupPort(url)
{
// This function is used to display the bedroom images in Portrait in a named window.
// If the window is already open then it will just update the existing contents
//
// Expected to be used in hypertext links, e.g.:
// <A HREF=DisplayItem.asp?ObjID=CIV:1021 onClick="OpenTaskWindow('xyz.htm');return false;\>

//  windowName = "_blank";
  windowName = "PopupPort";
  params  = "";
  params += "toolbar=0,";
  params += "location=0,";
  params += "directories=0,";
  params += "status=0,";
  params += "menubar=0,";
  params += "scrollbars=0,";
  params += "resizable=0,";
  params += "width=400,";
  params += "height=400,";
  params += "left=50,";
  params += "top=75,";

    win = window.open(url, windowName, params);
    win.focus();

}

function ChangeMonth(item)
{
document.getElementById('current_month').style.display="none";
document.getElementById('month1').style.display="none";
document.getElementById('month2').style.display="none";
document.getElementById('month0').style.display="none";

document.getElementById(item).style.display="block";
	
	}
	