//handle auto-focus on login inputs
var hasFocus = false;
$(function(){
	$("input[name='j_username']").focus(function(){
		hasFocus = true;
	});
	$("input[name='j_password']").focus(function(){
		hasFocus = true;
	});	
	var usernameValue = $("input[name='j_username']").attr("value");
	var passwordValue = $("input[name='j_password']").attr("value");
	if(usernameValue == "" && passwordValue == "" && !hasFocus){
		$("input[name='j_username']").focus();
	} 
	else if(!hasFocus){
		$("input[name='submit']").focus();
	}
});


//handle bookmark link
$(function(){
	$("a.bookmark-link").click(function(){
		var title = "Educated Investor Financial Success Suite";
		var url = "https://www.educatedinvestor.com/fss/admin/login.xml";
		if (window.sidebar){
			//mozilla
			window.sidebar.addPanel(title, url, "");
		}
		else if(window.opera && window.print){ 
			//opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();
		} 
		else if(document.all){
			//ie
			window.external.AddFavorite(url, title);
		}
		return false;
	});
});
