// JavaScript Document

function ShowHideFAQ(selected,total)
{
	var i;
	var selectedStatus = document.getElementById('A'+selected).style.display;

	for (i=1;i<=total;i++)
	{
		document.getElementById('A'+i).style.display = 'none';
		document.getElementById('Q'+i+'_Bullet').src = "/assets/elements/plus.gif";
	}
	
	if (selectedStatus == 'block')
	{
		document.getElementById('A'+selected).style.display = 'none';
		document.getElementById('Q'+selected+'_Bullet').src = "/assets/elements/plus.gif";
	}
	else
	{
		document.getElementById('A'+selected).style.display = 'block';
		document.getElementById('Q'+selected+'_Bullet').src = "/assets/elements/minus.gif";
	}

}

function ShowHideFAQ_original(e) {
	var answerBlock = document.getElementById('A'+e);
	var bulletImg = document.getElementById('Q'+e+'_Bullet');

	if (answerBlock.style.display == 'block') {
		answerBlock.style.display = 'none';
		bulletImg.src = "/assets/elements/plus.gif";
	}
	else {
		answerBlock.style.display = 'block';
		bulletImg.src = "/assets/elements/minus.gif";
	}
}

function CheckURL() {
	// Give selected status to the correct navigation bar tab
	var str = document.URL;
	if (str.match("/assetprotection") != null) {
		document.getElementById('nav_assetprotection').className='selected';
	}
	if (str.match("/casehistories") != null) {
		document.getElementById('nav_casehistories').className='selected';
	}
	if (str.match("/testimonials") != null) {
		document.getElementById('nav_testimonials').className='selected';
	}
	if (str.match("/publications") != null) {
		document.getElementById('nav_publications').className='selected';
	}
	if (str.match("/blog") != null) {
		document.getElementById('nav_blog').className='selected';
	}
	if (str.match("/podcasts") != null) {
		document.getElementById('nav_podcasts').className='selected';
	}
	if (str.match("/seminars") != null) {
		document.getElementById('nav_seminars').className='selected';
	}
	if (str.match("/company") != null) {
		document.getElementById('nav_company').className='selected';
	}
	if (str.match("/contact") != null) {
		document.getElementById('nav_contact').className='selected';
	}

	// Load the page with the correct section displayed open
	if (document.location.pathname === "/assetprotection/why-asset-protection.html")
	{
		switch(document.location.hash)
		{
			case "#Lawsuit":
				ShowHideFAQ('1','6');
				break;
			case "#Business":
		    	ShowHideFAQ('2','6');
				break;
			case "#Accident":
		    	ShowHideFAQ('3','6');
				break;
			case "#Divorce":
			    ShowHideFAQ('4','6');
				break;
			case "#Investigation":
			    ShowHideFAQ('5','6');
				break;
			case "#Debt":
		    	ShowHideFAQ('6','6');
				break;
			default:
			    break;
		}
	}
}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------
// Check required form fields
//
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 CheckForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=CheckForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain a valid e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Please complete all required fields:\n'+errors);
  document.MM_returnValue = (errors == '');
  if (errors.length==0) {
    document.getElementById('Submit').value='Processing...';
    document.getElementById('Submit').disabled='true'; }
}
