/* ***********************************************************
* Popup Window Code
*********************************************************** */
function winpopup(url,wn,ht,wd,tb,st,sc,rz,tp,lf) 
{
	if (url == null) return(false);
	if (ht == null) ht = 400;  // Height
	if (wd == null) wd = 600;  // Width
	if (tb == null) tb = 0;    // Toolbar
	if (st == null) st = 0;    // Status bar
	if (sc == null) sc = 1;    // Scrollbars
	if (rz == null) rz = 1;    // Resizebale
	if (tp == null) tp = 0;    // Top
	if (lf == null) lf = 0;    // Left
	if (wn == null) lf = '';   // Window Name

	window.open(url,wn,"width="+wd+",height="+ht+",toolbar="+tb+",status="+st+",scrollbars="+sc+",resizable="+rz+",top="+tp+",left="+lf);
	return(false);
}

function tabswitch(yearon,monthon)
{
	var navtable = new Array('table1','table2','table3','table4','table5');
	var showyear=0;

	switch (yearon) 
	{
	case("mutual"):
		yearon = "1";
		break;
	case("income"):
		yearon = "2";
		break;
	case("resource"):
		yearon = "3";
		break;
	case("mbn"):
		yearon = "4";
		break;
	default:
		break;

	}

	// Display Selected Year
	showyear=eval(yearon)-1;
	document.tabindex.FundYear.selectedIndex = showyear;

	if (document.getElementById) 
	{
		for (i=0; i<5; i++) 
		{
			if (navtable[i] != null)
			{
				document.getElementById(navtable[i]).style.visibility = 'hidden';
				document.getElementById(navtable[i]).style.position = 'absolute';
			}
		}

		document.getElementById(navtable[showyear]).style.visibility = 'visible';
		document.getElementById(navtable[showyear]).style.position = 'relative';
	}
	else if (document.layers && document.layers[table1]) 
	{
		for (i=0; i<5; i++) 
		{
			if (navtable[i] != null)
			{
				document.layers[navtable[i]].visibility = 'hidden';
				document.layers[navtable[i]].position = 'absolute';
			}
		}

		document.layers(navtable[showyear]).visibility = 'visible';
		document.layers(navtable[showyear]).position = 'relative';
	}
	else if (document.all) 
	{
		for (i=0; i<5; i++) 
		{
			if (navtable[i] != null)
			{
				document.all[navtable[i]].style.visibility = 'hidden';
				document.all[navtable[i]].style.position = 'absolute';
			}
		}

		document.all(navtable[showyear]).style.visibility = 'show';
		document.all(navtable[showyear]).style.position = 'relative';
	}  

	// Display Selected Month
	if (monthon != null)
	{
		var shortmonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
		var navmonth = '';
		document.tabindex.FundMonth.selectedIndex = monthon;

		// Hide all months
		for (i=0; i<5; i++) 
		{
			for (j=0; j<12; j++)
			{
				navmonth = navtable[i] + shortmonth[j];
				if (document.getElementById) 
				{
					document.getElementById(navmonth).style.visibility = 'hidden';
					document.getElementById(navmonth).style.position = 'absolute';
				}
				else if (document.layers && document.layers[table1]) 
				{
					document.layers[navmonth].visibility = 'hidden';
					document.layers[navmonth].position = 'absolute';
				}
				else if (document.all) 
				{
					document.all[navmonth].style.visibility = 'hidden';
					document.all[navmonth].style.position = 'absolute';
				} 
			}
		}

		if (monthon == 0) 
		{
			for (j=0; j<12; j++)
			{
				// Show all months
				navmonth = navtable[showyear] + shortmonth[j];
				if (document.getElementById) 
				{
					document.getElementById(navmonth).style.visibility = 'visible';
					document.getElementById(navmonth).style.position = 'relative';
				}
				else if (document.layers && document.layers[table1]) 
				{
					document.layers[navmonth].visibility = 'visible';
					document.layers[navmonth].position = 'relative';
				}
				else if (document.all) 
				{
					document.all[navmonth].style.visibility = 'show';
					document.all[navmonth].style.position = 'relative';
				} 
			} 
		}
		else
		{
			// Show selected months
			navmonth = navtable[showyear] + shortmonth[monthon-1];
			if (document.getElementById) 
			{
					document.getElementById(navmonth).style.visibility = 'visible';
					document.getElementById(navmonth).style.position = 'relative';
			}
			else if (document.layers && document.layers[table1]) 
			{
				document.layers[navmonth].visibility = 'visible';
				document.layers[navmonth].position = 'relative';
			}
			else if (document.all) 
			{
				document.all[navmonth].style.visibility = 'show';
				document.all[navmonth].style.position = 'relative';
			} 
		} 
	}
}

function writedate(dTime) 
{
	if (dTime == null) dTime = 0;
	var today = new Date();
	var tdate = today.toLocaleDateString();
	if (dTime != 0) tdate = today;
	return tdate;
}

function vLogin(frmOn)
{

	switch (frmOn) 
	{

	case("frmLogin"):
	if (document.frmLogin.txtadvisor.value == "")
	{
		window.alert("You must enter your email address.");
		return;
	}

	if (document.frmLogin.txtpwd.value == "")
	{
		window.alert("You must enter your password.");
		return;
	}
	document.frmLogin.submit();
	break;

	case ("frmUpdPwd"):
	if (document.frmUpdPwd.OldPwd.value == "")
	{
		window.alert("You must enter your Current Password.");
		return;
	}
	if (document.frmUpdPwd.NewPwd.value == "")
	{
		window.alert("You must enter a New Password.");
		return;
	}
	if (document.frmUpdPwd.NewPwd.value.length <5)
	{
		window.alert("Passwords should be 5 or more characters long.");
		return;
	}
	if (document.frmUpdPwd.confNewPwd.value == "")
	{
		window.alert("You must confirm your New Password.");
		return;
	}
	if (document.frmUpdPwd.confNewPwd.value != document.frmUpdPwd.NewPwd.value)
	{
		window.alert("Password confirmation does not match your New Password.");
		return;
	}
	document.frmUpdPwd.submit();
	break;

	case("frmSendpwd"):
	if (document.frmSendpwd.txtadvisor.value == "")
	{
		window.alert("You must enter your email address.");
		return;
	}
	document.frmSendpwd.submit();
	break;

	case("frmReps"):
	if (document.frmReps.FirstName.value == "")
	{
		window.alert("You must enter your First Name.");
		return;
	}
	if (document.frmReps.Surname.value == "")
	{
		window.alert("You must enter your Last Name.");
		return;
	}
	if (document.frmReps.Email.value == "")
	{
		window.alert("You must enter your Email Address.");
		return;
	}
	if (document.frmReps.confEmail.value == "")
	{
		window.alert("You must confirm your Email Address.");
		return;
	}
	if (document.frmReps.confEmail.value != document.frmReps.Email.value)
	{
		window.alert("Email confirmation does not match your Email Address.");
		return;
	}
	if (document.frmReps.RepCode.value == "")
	{
		window.alert("You must enter your Rep Code Number.");
		return;
	}
	if (document.frmReps.DealerCode.value == "")
	{
		window.alert("You must enter your Dealer Code.");
		return;
	}
	if (document.frmReps.Telephone.value == "")
	{
		window.alert("You must enter your Telephone number.");
		return;
	}
	document.frmReps.submit();
	break;
	default:
		break;

	}

}

function LmOver(elem,bg)
{
	elem.style.backgroundColor = bg;
}

function LmOut(elem)
{
	elem.style.backgroundColor = '';
}

function nospam(rep,web,dom)
{
	if (rep == null) return(false);
	if (web == null || web == '') web = "middlefield";
	if (dom == null || dom == '') dom = ".com";
	var sym = new Array('@','lto',':','mai');
	var retval = sym[3] + sym[1] + sym[2] + rep + sym[0] + web + dom;
	location.href = retval.toString();
	return true;
}

function getshow(showID,winName,fwidth,fheight) 
 {
	fwidth = fwidth + 40
	fheight = fheight + 40
	window.open(showID,winName,"width="+fwidth+",height="+fheight+",resizable=yes,scrollbars=yes")
 }

/* ***********************************************************
* Request Form Data Validation
*********************************************************** */
function checkrequest()
{
	if (document.askus.FirstName.value == "")
	{
		window.alert("You must enter your First Name.");
		return;
	}
	if (document.askus.Surname.value == "")
	{
		window.alert("You must enter your Last Name.");
		return;
	}
	if (document.askus.Address1.value == "")
	{
		window.alert("You must enter your Address.");
		return;
	}
	if (document.askus.City.value == "")
	{
			window.alert("You must enter your City.");
			return;
	}
	if (document.askus.State.value == "")
	{
		window.alert("You must enter your State.");
		return;
	}
	if (document.askus.PostalCode.value == "")
	{
		window.alert("You must enter your Zip / Postal Code.");
		return;
	}
	if ((document.askus.Country.selectedIndex == "") || (document.askus.Country.selectedIndex == 3))
	{
		window.alert("You must select your Country.");
		return;
	}
	if (document.askus.Email.value != "" && (document.askus.Email.value.match("@") == null || document.getElementById("Email").value.indexOf(".") == -1))
	{
		window.alert("Not a valid email.");
		return;
	}
		
	if (checkfileds())
	{
		document.askus.submit();
	}
	else
	{
		window.open("thanks.htm","_top");
		return;
	}
		
}

function checkfileds()
{
	var reqfld = new Array("FirstName","Surname","Address1","Address2","City","State","PostalCode","Email","Telephone","Fax","Other","Comments");
	var strValue = "";
	var fndCount = 0;
		
	for (k=0; k<12; k++)
	{
		strValue = document.getElementById(reqfld[k]).value;
		strValue = strValue.toLowerCase();
		if ((strValue.match("http") != null) || (strValue.match("href") != null))  fndCount++;
	}

	if (fndCount == 0) 
	{
		return(true);
	}
	else
	{
		return(false);
	}

}
