var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}

function SimpleSwap(el,which)
{
        el.src=el.getAttribute(which||"origsrc");
}

function SimpleSwapSetup(){
  var x = document.getElementsByTagName("img");
  for (var i=0;i<x.length;i++){
    var oversrc = x[i].getAttribute("oversrc");
    if (!oversrc) continue;
    // preload image
    // comment the next two lines to disable image pre-loading
    x[i].oversrc_img = new Image();
    x[i].oversrc_img.src=oversrc;
    // set event handlers
    x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
    x[i].onmouseout = new Function("SimpleSwap(this);");
    // save original src
    x[i].setAttribute("origsrc",x[i].src);
  }
}

function resetForm()
{
	document.logon.caseID.value ="";
	document.logon.initial.value ="";
	document.logon.surname.value ="";
	document.logon.postcode1.value ="";
	document.logon.postcode2.value ="";
	document.logon.password.value ="";
}
function resetpasswordForm()
{
	document.change_password.password.value ="";
	document.change_password.new_password.value ="";
	document.change_password.confirm_password.value ="";
}

function get_password()
{

	//Change action of form to get password
	document.logon.action = "act_get_password.cfm";
	//alert(document.logon.action);
	document.logon.submit();
}
function login_TMH()
{
	//Validate the login form
	var strErrMessage = '';
	
	//Validate Case Number id numeric only
	if (document.all.caseID.value != '')
	{
		if (!/^[0-9]{0,20}$/i.test(document.all.caseID.value))
		{
			strErrMessage = strErrMessage + " The Case Number must be numeric\n";
		}
	}
	
	//Validate initial for illegal chars
	if (document.all.initial.value != '')
	{
		if (!/^[a-z]{0,64}$/i.test(document.all.initial.value))
		{
			strErrMessage = strErrMessage + " The initial contains illegal characters\n";
		}
	}		
	
	//Validate surname for illegal chars
	if (document.all.surname.value != '')
	{
		if (!/^[-&a-z0-9_' ]{0,64}$/i.test(document.all.surname.value))
		{
			strErrMessage = strErrMessage + " The surname contains illegal characters\n";
		}
	}
			
	//Validate outer postcode for illegal chars
	if (document.all.postcode1.value != '')
	{
		if (!/^[-&a-z0-9]{0,6}$/i.test(document.all.postcode1.value))
		{
			strErrMessage = strErrMessage + " The outer postcode contains illegal characters\n";
		}
	}
			
	//Validate inner postcode for illegal chars
	if (document.all.postcode2.value != '')
	{
		if (!/^[-&a-z0-9]{0,6}$/i.test(document.all.postcode2.value))
		{
			strErrMessage = strErrMessage + " The inner postcode contains illegal characters\n";
		}
	}
			
	if (strErrMessage == "")
	{
	//Keep action of form to login
	document.logon.action = "act_login.cfm";
	//alert(document.logon.action);
	document.logon.submit();
	}
	else
	{
		alert(strErrMessage);
	}


}




