function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function goto_URL(object) {
    window.location.href = object.options[object.selectedIndex].value;
}

function doNothing(){ }


function loginTest(form) {
	if(isEmpty(form.UserName)) {
		alert('You must enter your email address') ;
		form.UserName.focus();
		return false;
		}

   if (isValidEmail(form.UserName.value) == false) {
		alert('You must enter a valid e-mail address') ;
		form.UserName.focus();
		return false;
		}

	if(isEmpty(form.Password)) {
		alert('You must enter a password') ;
		form.Password.focus(); 
		return false;
		}

	if(form.agree.checked == false){
	  alert('To proceed Please click the "I have read and accepted the Terms and Conditions" checkbox') ;
	  form.agree.focus();
	  return false;
    }

	return true;
	}


function emailTest(form) {
	if(isEmptyWhenTrimmed(form.fname)) {
		alert('You must enter your first name') ;
		form.fname.focus();
		return false;
		}
   if(isEmptyWhenTrimmed(form.lname)) {
        alert('You must enter a surname') ;
        form.lname.focus(); 
        return false;
        }
	if(isEmptyWhenTrimmed(form.email)) {
		alert('You must enter your email address') ;
		form.email.focus();
		return false;
		}
   if (isValidEmail(form.email.value) == false) {
		alert('You must enter a valid e-mail address') ;
		form.email.focus();
		return false;
		}
	if (form.email.value == 'a@a.com' || form.email.value == 'a@b.com') {
		alert('You must verify your email address, so please enter a real address.') ;
		form.email.focus();
		return false;
		}
	if ( form.email.value.indexOf(',') != -1 ) {
		alert("Your email address contains a comma. Please enter one single email address.");
		form.email.focus();
		return false;
	}
   if(isEmptyWhenTrimmed(form.Password)) {
        alert('You must enter a password') ;
        form.Password.focus(); 
        return false;
        }
   if( (form.Password.value != form.ConfirmPassword.value) == true) {
		alert('The password and confirmation password must match') ;
		form.ConfirmPassword.focus();
		return false;
		}
   if(isEmptyWhenTrimmed(form.myCompany)) {
        alert('You must enter a Company Name') ;
        form.myCompany.focus(); 
        return false;
        }
	if ( form.myCompany.value.indexOf('http://') != -1 || form.myCompany.value.indexOf('www') != -1 ) {
		alert("Please enter your company's name, not the web address.");
		form.myCompany.focus();
		return false;
	}
	if ( form.terms == null || form.terms.checked == false ) {
		alert('You must agree to the terms and conditions to sign up.') ;
		form.terms.focus();
		return false;
		}
	if ( form.email.value.indexOf( "yahoo" ) != -1 || form.email.value.indexOf( "hotmail" ) != -1 ) {
		alert ( "Make sure you add support@solocheck.ie to your Address book, otherwise this mail may not get through." ) ;
		}
   if (form.email.value.indexOf( ',' ) > -1) {
		form.email.focus();
		return confirm('Ooops, should your email address contain a comma ?') ;
		}
   if (form.email.value.indexOf( '@hotmial.' ) > -1) {
		form.email.focus();
		return confirm('Ooops, did you spell hotmail incorrectly ?') ;
		}
   if (form.email.value.indexOf( 'goglemail.' ) > -1) {
		form.email.focus();
		return confirm('Ooops, did you spell googlemail incorrectly ?') ;
		}
   if (form.email.value.indexOf( 'www' ) > -1) {
		form.email.focus();
		return confirm('Email addresses do not usually contain www. Are you sure this is correct ?') ;
		}

	return true;
	}


function emailTestNonUser(form) {
	if(isEmptyWhenTrimmed(form.fname)) {
		alert('You must enter your first name') ;
		form.fname.focus();
		return false;
		}
   if(isEmptyWhenTrimmed(form.lname)) {
        alert('You must enter a surname') ;
        form.lname.focus(); 
        return false;
        }
	if(isEmptyWhenTrimmed(form.email)) {
		alert('You must enter your email address') ;
		form.email.focus();
		return false;
		}
   if (isValidEmail(form.email.value) == false) {
		alert('You must enter a valid e-mail address') ;
		form.email.focus();
		return false;
		}
   if(isEmptyWhenTrimmed(form.Password)) {
        alert('You must enter a password') ;
        form.Password.focus(); 
        return false;
        }
   if( (form.Password.value != form.ConfirmPassword.value) == true) {
		alert('The password and confirmation password must match') ;
		form.ConfirmPassword.focus();
		return false;
		}
  
	if ( form.terms == null || form.terms.checked == false ) {
		alert('You must agree to the terms and conditions to sign up.') ;
		form.terms.focus();
		return false;
		}

	if ( form.email.value.indexOf( "yahoo" ) != -1 || form.email.value.indexOf( "hotmail" ) != -1 ) {
		alert ( "Make sure you add support@solocheck.ie to your Address book, otherwise this mail may not get through." ) ;
		}

	return true;
	}

function EnhancedListingRegTest(form) {

	if ( !isEmpty(form.url) && !isValidURL(form.url.value) ) {
		alert('Please enter a valid URL for the Website') ;
		form.url.focus();
		return false;
	}

	if ( !isEmpty(form.logo) && !isValidLogo(form.logo.value) ) {
		alert('Cannot upload file\n' + form.logo.value
			  + '\n\nWe can only support files with these extensions:'
			  + '\n\t.jpg\t.jpeg\t.gif\t.png');
		form.logo.focus();
		return false;
	}

	return true;
}


function coSearchTest(form) {
	if(isEmpty(form.irishCompanyName) && isEmpty(form.irishCompanyNumber)) {
		alert('You must enter either a Company Name or Company Number') ;
		form.irishCompanyName.focus();
		return false;
		}
	return true;
	}

function dirSearchTest(form) {
	if(isEmpty(form.dirName) ) {
		alert('You must enter a Director Name') ;
		form.dirName.focus();
		return false;
		}
	return true;
	}

function showMe (it, box) {
var vis = (box.checked) ? "block" : "none";
document.getElementById(it).style.display = vis;
}


function ukCompanySearchTest(form)
{
 
if (isEmpty(form.companyNameUK) && isEmpty(form.companyNumberUK))
   {
      alert('To search for a UK company you can enter a company name OR a company number') ;
	  form.companyNameUK.focus();
      return false;
   }

if (!isEmpty(form.companyNameUK) && !isEmpty(form.companyNumberUK))
   {
      alert('To search for a UK Company you can enter a company name OR a company number') ;
  	  form.companyNameUK.focus();
      return false;
   }
   return true;
}


function ukDirectorSearchTest(form)
{
 
if (isEmpty(form.surnameUK) )
   {
      alert('To search for a UK director you must enter their surname') ;
      return false;
   }
   return true;
}