// JavaScript Document

document.getElementsByClassName=function(classname){
	var pattern=new RegExp("(^|\s*)"+classname+"(\s*|$)");
	var results=new Array();
	var d=document.getElementsByTagName('*'), l=d.length;
	for (var k=0; k<l; k++) if (pattern.test(d[k].className)) results.push(d[k]);
	return results;
}

function main()
{
	// create bookmark for site
	if (typeof(bookmark)=="function") bookmark("Accepted.co.uk - Compare Secured Loans", "http://www.accepted.co.uk/login");
	
	// launch errors function when form doesn't validate
	if (typeof(errors)=="function") errors();
	
	// life insurance form - show/hide second person details
	if (typeof(RegisterFormEvents)=="function") RegisterFormEvents();
	
	// max length on form inputs
	if (typeof(initMaxLength)=="function") initMaxLength();
	
	// gives focus to the first field in a form [if it's a textbox/area]
	if (typeof(formFocusFirst)=="function") formFocusFirst();
	
	// initialise the Leadbay form switcher
	if (typeof(initLeadbayForm)=="function") initLeadbayForm();
	
	// initialise the mortgages form switcher
	if (typeof(initMortgagesForm)=="function") initMortgagesForm();
	
	// set all links with rel="external" to window.open()
	hookExternalLinks();
	
	if( typeof( ieupdate ) == "function" ) ieupdate();
}

window.onload = main;