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=620, ";
$features+="height=620, ";
$features+="toolbars=no, ";
$features+="resizable=no, ";
$features+="location=no, ";
$features+="directories=no, ";
$features+="status=no, ";
$features+="menubar=no, ";
$features+="scrollbars=no, ";
$features+="left=50, ";
$features+="top=50";

win=window.open($im, $name, $features);
win.focus();

}

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+="Return e-mail address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="Return e-mail address invalid";
		$errors+=1;
	}

	if (isEmpty($title) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="Message title not entered";
		$errors+=1;
	}

	if (isEmpty($message) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="Body of message not entered";
		$errors+=1;
	}
	
	if ($errors==0)
	{
//		alert ("OK");
		return true;
	}
	else
	{
		alert ($response);
		return false;
	}

}


function validate_caption_form(item)
{
	var $e_mail;
	var $name;
	var $caption;
	var $response;
	var $errors;

	$e_mail=item.email_address.value;
	$name=item.name.value;
	$caption=item.caption.value;

	$response="Errors:- ";
	$errors=0;

	if (isEmpty($e_mail) )
	{
		$response+="Email address not entered";
		$errors+=1;
	}

	if (! isEmail($e_mail) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}
		$response+="Email address invalid";
		$errors+=1;
	}

	if (isEmpty($name) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="Name not entered";
		$errors+=1;
	}

	if (isEmpty($caption) )
	{

		if ($errors!=0)
		{
			$response+=", ";
		}

		$response+="Caption 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 checkLength(form, maxlength)
{
	var twitlength;

	twitlength=form.value.length;
	charsleft=maxlength-twitlength;
	
	if(charsleft>0)
	{
		charstext="<font color='#660033'>"+charsleft+" characters left</font>";
	}
	else
	{
		charstext="<font color='#CC0000'>"+charsleft+" characters left</font>";
	}
	

	document.getElementById('twitcount').innerHTML = charstext;	
	
}
