var speedToggling = 8000;
var speedHiding = 1000;

function makeGreen() {
	$(".tips").css("border", "0.1em solid #c4e9ae");
	$(".tips").css("background", "#fff");
	$(".tips span").css("color", "#3b4f14");
};
function makeBlue() {
	$(".tips").css("border", "0.1em solid #cbe2f0");
	$(".tips").css("background", "#cbe2f0");
	$(".tips span").css("color", "#012252");
};
function showLeaf() {
	$(".quote1").css("width", "2.3em");
	$(".quote1").css("height", "2em");
	$(".quote1 img").css("width", "2.3em");
	$(".quote1 img").css("height", "2em");
	$(".quote1 img").attr("src", "img/leaf1.jpg");
	$(".randomText span").css("line-height", "1.6em");
}
function showQuote() {
	$(".quote1").css("width", "1.9em");
	$(".quote1").css("height", "1.4em");
	$(".quote1 img").css("width", "1.9em");
	$(".quote1 img").css("height", "1.4em");
	$(".quote1 img").attr("src", "img/quote1.jpg");
	$(".randomText span").css("line-height", "1.4em");
}
function setRandomGreenText() {
	var grTipsLength = greenTipsArray.length - 1;
	var grTipRNumb = Math.round(Math.random()*grTipsLength);
	$(".randomText span").html('');
	if ((greenTipsArray[grTipRNumb].text) != 'none') {
		$(".randomText span").append(greenTipsArray[grTipRNumb].text);
	}
	//Signature
	var signSpans = $(".randomSign span");
	$(signSpans[0]).html('');
	$(signSpans[1]).html('');
	if ((greenTipsArray[grTipRNumb].signature) != 'none') {
		$(signSpans[0]).append("&mdash;&nbsp;&nbsp;");
		$(signSpans[1]).append(greenTipsArray[grTipRNumb].signature);
	}
}
function setRandomBlueText() {
	var blueTipsLength = blueTipsArray.length - 1;
	var blueTipRNumb = Math.round(Math.random()*blueTipsLength);
	$(".randomText span").html('');
	if ((blueTipsArray[blueTipRNumb].text) != 'none') {
		$(".randomText span").append(blueTipsArray[blueTipRNumb].text);
	}
	//Signature
	var signSpans = $(".randomSign span");
	$(signSpans[0]).html('');
	$(signSpans[1]).html('');
	if ((blueTipsArray[blueTipRNumb].signature) != 'none') {
		$(signSpans[0]).append("&mdash;&nbsp;&nbsp;");
		$(signSpans[1]).append(blueTipsArray[blueTipRNumb].signature);
	}
}
function changeBoxes() {
	$(".opacityDiv").animate( { opacity: "show" }, speedHiding, function() {
		if (startingBox == "blue") {
			makeGreen();
			showLeaf();
			setRandomGreenText();
			startingBox = "green";
		} else {
			makeBlue();
			showQuote();
			setRandomBlueText();
			startingBox = "blue";
		}
		$(".opacityDiv").animate( { opacity: "hide" }, speedHiding);
	});
};
function repeatFunctions() {
	changeBoxes();
	setTimeout('repeatFunctions();', speedToggling + 2*speedHiding);
};	
$(document).ready(function() {
var citeBox = $("div#citeBox").length;
//alert($("div#citeBox"));
	if (citeBox != 0 ) {
		if (startingBox == "blue") {
			setRandomBlueText();
		} else {
			setRandomGreenText();
		}
		var indexdelay = $("#menu-line li a.tips-delay").length;
		if (indexdelay == 1) {
			window.setTimeout(repeatFunctions, 40000);
		} else {
			window.setTimeout(repeatFunctions, speedToggling);
		}
	}	
	//IE HOVER

		$(".one-call a").hover(
		  function () {
			$(".one-call a img.dark").hide();
			$(".one-call a img.light").show();
		  }, 
		  function () {
			$(".one-call a img.dark").show();
			$(".one-call a img.light").hide();
		  }
		);
		
 		$("#fee-schedule").hover(
		  function () {
			$("#fee-schedule a img.fee-schedule-off").hide();
			$("#fee-schedule a img.fee-schedule-on").show();
		  }, 
		  function () {
			$("#fee-schedule a img.fee-schedule-off").show();
			$("#fee-schedule a img.fee-schedule-on").hide();
		  }
		); 
		
		$(".main-menu li a").hover(
		  function () {
			$(this).find("img").hide();
			$(this).find("img.active").show();
		  }, 
		  function () {
			if (!$(this).hasClass("current")) {
				$(this).find("img").show();
				$(this).find("img.active").hide();
			}
		  }
		);
		
		$("#menu-line li").hover(
		  function () {
			$(this).find("img.normal").hide();
			$(this).find("img.hover").show();
			$(this).find("div.drop_down").show();
		  }, 
		  function () {
			$(this).find("img.normal").show();
			$(this).find("img.hover").hide();
			$(this).find("div.drop_down").hide();
		  }
		);
		
	/* window.setTimeout("alert(document.documentElement.scrollTop)",3000);
	window.setTimeout("alert(document.body.)",5000); */
});
