/*
The following 'New Window' Javascript is used by hyperlinks in the footer of this page to open the requested page in a separate browser window at a controlled size without toolbars, in effect a pop up window.

It is required for this to work so please ensure the following link is put the head tag of any pages that have
pop up page links on them

<script language='javascript' type='text/javascript' src='Resources/js/newWindow.js'>
<!-- new window script -->
</script>

Note this assumes that the page is contained within the top folder of the website, if it contained in a sub folder
then change the src link accordingly.

*/
/****************************************************
     AUTHOR: WWW.CGISCRIPT.NET, LLC
     URL: http://www.cgiscript.net
     Use the code for FREE but leave this message intact.
     Download your FREE CGI/Perl Scripts today!
     ( http://www.cgiscript.net/scripts.htm )
****************************************************/
var win=null;
function NewWindow(mypage, myname, w, h, pos, infocus){
if(pos=='random'){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=='center'){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!='random') || pos==null){myleft=0;mytop=20}
settings='width=' + w + ',height=' + h + ',top=' + mytop + ',left=' + myleft + ',scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';win=window.open(mypage,myname,settings);
win.focus();}
// end of NewWindow script

// version of NewWindow script with scroll bars enabled
var win=null;
function NewWindowScroll(mypage, myname, w, h, pos, infocus){
if(pos=='random'){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=='center'){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!='random') || pos==null){myleft=0;mytop=20}
settings='width=' + w + ',height=' + h + ',top=' + mytop + ',left=' + myleft + ',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';win=window.open(mypage,myname,settings);
win.focus();}
// end of NewWindow script


/*
The following 'Close Me' Javascript is used in pop up window to present the website user with an 'in page' otpion for closing the pop up page.

It is required for this to work so please ensure the following link is put the head tag of any pop pages that have
a close button on them

<script language='JavaScript' type='text/javascript' src='../js/newWindow.js'>
<!-- new window script -->
</script>

Note this assumes that the page is contained within /Resources/html folder of the website, if it contained in a different
folder then change the src link accordingly.

*/
function closeme(){self.close();}
// end of closeme script

/*
Login Script
*/
function Login(){
var done=0;
var username=document.login.username.value;
username=username.toLowerCase();
var password=document.login.password.value;
password=password.toLowerCase();
if (username=="test" && password=="test") { window.location="homeRegistered.htm"; done=1; }
if (username=="member2" && password=="password2") { window.location="page2.html"; done=1; }
if (username=="member3" && password=="password3") { window.location="page3.html"; done=1; }
if (done==0) { alert("Sorry your have entered your details incorrectly, please try again."); }
}

/*
Script to clear a form
*/
function clearForm(formIdent) 
{ 
  var form, elements, i, elm; 
  form = document.getElementById 
    ? document.getElementById(formIdent) 
    : document.forms[formIdent]; 

	if (document.getElementsByTagName)
	{
		elements = form.getElementsByTagName('input');
		for( i=0, elm; elm=elements.item(i++); )
		{
			if (elm.getAttribute('type') == "text")
			{
				elm.value = '';
			}
		}
	}

	// Actually looking through more elements here
	// but the result is the same.
	else
	{
		elements = form.elements;
		for( i=0, elm; elm=elements[i++]; )
		{
			if (elm.type == "text")
			{
				elm.value ='';
			}
		}
	}
}
/*
This was on the same page - not sure what is used for but have added it in here in case it used by teh above script
*/
function addEvent(elm, strEvent, fnHandler)
{
	return ( elm.addEventListener
	? elm.addEventListener( strEvent, fnHandler, false)
	: elm.attachEvent( 'on'+strEvent, fnHandler)
	);
}