// JavaScript Document
$(document).ready(function(){
	var currentLink = document.location.href;
	
	if (currentLink.indexOf("/funds") > -1)
	{
		fundsOver();
	}
	else if (currentLink.indexOf("/tools") > -1)
	{
		toolsOver();
	}
	else if (currentLink.indexOf("/education") > -1)
	{
		educationOver();
	}
	else if (currentLink.indexOf("/reportsandapplications") > -1)
	{
		reportsOver();
	}
	else if (currentLink.indexOf("/about") > -1)
	{
		aboutOver();
	}
	else
	{
		homeOver();
	}
	
	if (currentLink.indexOf("/print.php") > -1)
		$("#actions").css("display", "none");
});

function bookmark(url)
{
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel("", url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, "");
	} else if(window.opera) { // Opera 7+
		return false; // do nothing - the rel="sidebar" should do the trick
	} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
		alert('Unfortunately, this browser does not support the requested action, please bookmark this page manually.');
	}
}

function homeOver()
{
	$("#home").removeClass("inactive");
	$("#home").addClass("active");
	
	$("#navLeft").removeClass("leftInactive");
	$("#navLeft").addClass("leftActive");
	
	/*if ($.browser.msie)
		$("#HomeNav").css("display", "block");
	else
		$("#HomeNav").css("display", "table-row");/**/
	
	fundsReset();
	toolsReset();
	advisorToolsReset();
	educationReset();
	reportsReset();
	aboutReset();
}

function homeReset()
{
	$("#home").removeClass("active");
	$("#home").addClass("inactive");
	
	//$("#HomeNav").css("display", "none");
	
	$("#navLeft").removeClass("leftActive");
	$("#navLeft").addClass("leftInactive");
}

function fundsOver()
{
	$("#funds").removeClass("inactive");
	$("#funds").addClass("active");
	
	if ($.browser.msie)
		$("#FundsNav").css("display", "block");
	else
		$("#FundsNav").css("display", "table-row");
	
	homeReset();
	toolsReset();
	advisorToolsReset();
	educationReset();
	reportsReset();
	aboutReset();
}

function fundsReset()
{
	$("#funds").removeClass("active");
	$("#funds").addClass("inactive");
	
	$("#FundsNav").css("display", "none");
}
	
function toolsOver()
{
	$("#tools").removeClass("inactive");
	$("#tools").addClass("active");
	
	if ($.browser.msie)
		$("#ToolsNav").css("display", "block");
	else
		$("#ToolsNav").css("display", "table-row");
	
	homeReset();
	fundsReset();
	advisorToolsReset();
	educationReset();
	reportsReset();
	aboutReset();
}

function toolsReset()
{
	$("#tools").removeClass("active");
	$("#tools").addClass("inactive");
	
	$("#ToolsNav").css("display", "none");
}

function advisorToolsOver()
{
	$("#advisorTools").removeClass("inactive");
	$("#advisorTools").addClass("active");
	
	if ($.browser.msie)
		$("#AdvisorToolsNav").css("display", "block");
	else
		$("#AdvisorToolsNav").css("display", "table-row");
	
	homeReset();
	fundsReset();
	toolsReset();
	educationReset();
	reportsReset();
	aboutReset();
}

function advisorToolsReset()
{
	$("#advisorTools").removeClass("active");
	$("#advisorTools").addClass("inactive");
	
	$("#AdvisorsToolsNav").css("display", "none");
}

function educationOver()
{
	$("#eduation").removeClass("inactive");
	$("#education").addClass("active");
	
	if ($.browser.msie)
		$("#EducationNav").css("display", "block");
	else
		$("#EducationNav").css("display", "table-row");
	
	homeReset();
	fundsReset();
	toolsReset();
	advisorToolsReset();
	reportsReset();
	aboutReset();
}

function educationReset()
{
	$("#education").removeClass("active");
	$("#education").addClass("inactive");
	
	$("#EducationNav").css("display", "none");
}

function reportsOver()
{
	$("#reports").removeClass("inactive");
	$("#reports").addClass("active");
	
	$("#navRight").removeClass("rightInactive");
	$("#navRight").addClass("rightActive");
	
	if ($.browser.msie)
		$("#ReportsNav").css("display", "block");
	else
		$("#ReportsNav").css("display", "table-row");
	
	homeReset();
	fundsReset();
	toolsReset();
	advisorToolsReset();
	educationReset();
	aboutReset();
}

function reportsReset()
{
	$("#reports").removeClass("active");
	$("#reports").addClass("inactive");
	
	$("#navRight").removeClass("rightActive");
	$("#navRight").addClass("rightInactive");
	
	$("#ReportsNav").css("display", "none");
}


function aboutOver()
{
	$("#about").removeClass("inactive");
	$("#about").addClass("active");
	
	
	
	homeReset();
	fundsReset();
	toolsReset();
	advisorToolsReset();
	reportsReset();
	educationReset();
	
	if ($.browser.msie)
		$("#AboutNav").css("display", "block");
	else
		$("#AboutNav").css("display", "table-row");
	
	$("#navRight").removeClass("rightInactive");
	$("#navRight").addClass("rightActive");
}

function aboutReset()
{
	$("#about").removeClass("active");
	$("#about").addClass("inactive");
	
	$("#navRight").removeClass("rightActive");
	$("#navRight").addClass("rightInactive");
	
	$("#AboutNav").css("display", "none");
}

function showSnapshot(section)
{
	switch (section)
	{
		case "overview":
			$("#SnapshotOverview").css("display", "inline");
			$("#SnapshotManagement").css("display", "none");
			$("#SnapshotCommentary").css("display", "none");
			
			if ($.browser.msie)
				$("#SnapshotOverviewHeading").css("display", "block");
			else
				$("#SnapshotOverviewHeading").css("display", "table-row");
			
			$("#SnapshotManagementHeading").css("display", "none");
			$("#SnapshotCommentaryHeading").css("display", "none");
			
			$("#SnapshotOverviewButton").css("background-image", "url(../images/ss_overview.jpg)");
			$("#SnapshotManagementButton").css("background-image", "url(../images/ss_management.jpg)");
			$("#SnapshotManagementButton2").css("background-image", "url(../images/ss_management2.jpg)");
			$("#SnapshotCommentaryButton").css("background-image", "url(../images/ss_commentary.jpg)");
			break;
		
		case "management":
			$("#SnapshotOverview").css("display", "none");
			$("#SnapshotManagement").css("display", "inline");
			$("#SnapshotCommentary").css("display", "none");
			
			if ($.browser.msie)
				$("#SnapshotManagementHeading").css("display", "block");
			else
				$("#SnapshotManagementHeading").css("display", "table-row");
			
			$("#SnapshotOverviewHeading").css("display", "none");
			$("#SnapshotCommentaryHeading").css("display", "none");
			
			$("#SnapshotOverviewButton").css("background-image", "url(../images/ss_overview_f2.jpg)");
			$("#SnapshotManagementButton").css("background-image", "url(../images/ss_management_f2.jpg)");
			$("#SnapshotCommentaryButton").css("background-image", "url(../images/ss_commentary_f2.jpg)");
			break;
		
		case "commentary":
			$("#SnapshotOverview").css("display", "none");
			$("#SnapshotManagement").css("display", "none");
			$("#SnapshotCommentary").css("display", "inline");
			
			if ($.browser.msie)
				$("#SnapshotCommentaryHeading").css("display", "block");
			else
				$("#SnapshotCommentaryHeading").css("display", "table-row");
			
			$("#SnapshotManagementHeading").css("display", "none");
			$("#SnapshotOverviewHeading").css("display", "none");
			
			$("#SnapshotOverviewButton").css("background-image", "url(../images/ss_overview_f3.jpg)");
			$("#SnapshotManagementButton").css("background-image", "url(../images/ss_management_f3.jpg)");
			$("#SnapshotCommentaryButton").css("background-image", "url(../images/ss_commentary_f3.jpg)");
			break;
	}
}

function showSnapshotPerformance(section)
{
	switch (section)
	{
		case "monthly":
			if ($.browser.msie)
				$("#SnapshotMonthlyPerformance").css("display", "block");
			else
				$("#SnapshotMonthlyPerformance").css("display", "table-row");
			
			$("#SnapshotQuarterlyPerformance").css("display", "none");
			
			$("#SnapshotMonthlyPerformanceButton").css("background-image", "url(../images/ss_monthly.jpg)");
			$("#SnapshotQuarterlyPerformanceButton").css("background-image", "url(../images/ss_quarterly.jpg)");
			break;
		
		case "quarterly":
			if ($.browser.msie)
				$("#SnapshotQuarterlyPerformance").css("display", "block");
			else
				$("#SnapshotQuarterlyPerformance").css("display", "table-row");
			
			$("#SnapshotMonthlyPerformance").css("display", "none");
			
			$("#SnapshotMonthlyPerformanceButton").css("background-image", "url(../images/ss_monthly_f2.jpg)");
			$("#SnapshotQuarterlyPerformanceButton").css("background-image", "url(../images/ss_quarterly_f2.jpg)");
			break;
	}
}

function showFundTracker()
{
	$("#FundTracker").css("display", "block");
	$("#RiskReturn").css("display", "none");
	$("#TrackerTop").attr("src", "/newsite/images/66_33_tracker_top.gif");
}

function showRiskReturn()
{
	$("#RiskReturn").css("display", "block");
	$("#FundTracker").css("display", "none");
	$("#TrackerTop").attr("src", "/newsite/images/66_33_riskreturn_top.gif");
}
function LeaveSite(url) {
	var result = window.showModalDialog("/exit.php", "", "dialogHeight:200px; dialogWidth:390px;");
	if (result == 1) {
		window.open(url);
	}
}
function LeaveSiteAlps(url) {
	var result = window.showModalDialog("/exitalps.php", "", "dialogHeight:293px; dialogWidth:458px;");
	if (result == 1) {
		window.open(url);
	}
}
function LeaveSiteDirectors(url) {
	var result = window.showModalDialog("/exitdirectors.php", "", "dialogHeight:293px; dialogWidth:458px;");
	if (result == 1) {
		window.open(url);
	}
}
function LeaveSiteArticle(url) {
	var result = window.showModalDialog("/articledisclosure.php", "", "dialogHeight:580px; dialogWidth:510px;");
	if (result == 1) {
		window.open(url);
	}
}
function LeaveSiteWholesalers(url) {
	var result = window.showModalDialog("/exitwholesalers.php", "", "dialogHeight:293px; dialogWidth:458px;");
	if (result == 1) {
		window.open(url);
	}
}
function validEmail(email)
{
	var invalidChars = "/:,;";
	
	if (email == "") {
		return false;
	}
	
	for (i=0; i<invalidChars.length; i++) {
		badChar = invalidChars.charAt(i);
		if (email.indexOf(badChar,0) > -1) {
			return false;
		}
	}
	
	var atPos = email.indexOf("@", 1);
	if (atPos == -1) { 
		return false;
	}
	
	if (email.indexOf("@", atPos+1) > -1) {
		return false;
	}
	
	var periodPos = email.indexOf(".", atPos);
	if (periodPos == -1) {
		return false;
	}
	
	if (periodPos+3 > email.length) {
		return false;
	}
	
	return true;
}

function fontSize(size)
{
	if (size == 1)
	{
		$("body").css("font-size", "10px");
		$("td").css("font-size", "10px");
		$("p").css("font-size", "10px");
	}
	else if (size == 2)
	{
		$("body").css("font-size", "12px");
		$("td").css("font-size", "12px");
		$("p").css("font-size", "12px");
	}
	else if (size == 3)
	{
		$("body").css("font-size", "14px");
		$("td").css("font-size", "14px");
		$("p").css("font-size", "14px");
	}
	
	
}
