
function changeSearchArrow(type, speed) {
	var duration = speed || "slow";
	
	$("input[type='radio'][id='"+ type + "']").each(function(){
		this.checked = true;
	});
	
	switch (type) {
		case "thrift":
			$("#searchArrow").animate({"left": "77px"}, duration);
			break;
		default:
			$("#searchArrow").animate({"left": "40px"}, duration);
			break;
	}
}

$(document).ready(function(){
	// Search Scripts
	$("#thriftLabel").click(function(){
		changeSearchArrow("thrift");
		//$("#searchArrow").animate({"left": "77px"}, "slow");
	});
	$("#siteLabel").click(function(){
		changeSearchArrow("site");
		//$("#searchArrow").animate({"left": "40px"}, "slow");
	});
	
	$("#searchField").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	changeSearchArrow($("[name=searchOption]:checked").val(), 0);
	
/*
$(document).ready(function() {
	$("a").each( function(i, el) {
		//console.log(el.href);
		
		regex1 = new RegExp("(^http:\/\/((www|files|public|ww1|files1)\.)?ots)")<!-- added ww1 to stop js alert-->
		regex2 = new RegExp("(^http:\/\/76.12.198.99)")
		regex3 = new RegExp("(^http:\/\/localhost)")
		regex4 = new RegExp("(^mailto:)")
                regex5 = new RegExp("(^http:\/\/files.ots.treas.gov)")<!-- added to make documents load without error -->
		regex6 = new RegExp("(^http:\/\/76.12.198.104)")<!-- added to make documents load without error -->
		

		
		if( ! (regex1.test(el.href) || regex2.test(el.href) || regex3.test(el.href) || regex4.test(el.href) || regex5.test(el.href)) ) {
			$(el).click( function() {
				return confirm("You are now leaving the Office of Thrift Supervision website and being redirected to " + el.href + ".\n\nThe website you have selected is an external one located on another server. OTS has no responsibility for any external website. It neither endorses the information, content, presentation, or accuracy nor makes any warranty, express or implied, regarding any external site.\n\nThank you for visiting the OTS's website.");
			})
		}
	});
	
//	.click(function() { window.open($(this).href); return false; });
	});
*/

/*
	// Navigation Scripts
	$("#aboutArrow").click(function () {
        $("#navAboutSub").slideDown("normal");
		$("#navNewsSub,#navConsumersSub,#navSupervisionSub,#navPublicationsSub").hide();
		$("#navAboutSub").bind("mouseleave",function(){
			$("#navAboutSub").slideUp("slow");
		});
		return false;
    });

	$("#newsArrow").click(function () {
        $("#navNewsSub").slideDown("normal");
		$("#navAboutSub,#navConsumersSub,#navSupervisionSub,#navPublicationsSub").hide();
		$("#navNewsSub").bind("mouseleave",function(){
			$("#navNewsSub").slideUp("slow");
		});
		return false;
    });

	$("#consumersArrow").click(function () {
        $("#navConsumersSub").slideDown("normal");
		$("#navAboutSub,#navNewsSub,#navSupervisionSub,#navPublicationsSub").hide();
		$("#navConsumersSub").bind("mouseleave",function(){
			$("#navConsumersSub").slideUp("slow");
		});
		return false;
    });

	$("#supervisionArrow").click(function () {
        $("#navSupervisionSub").slideDown("normal");
		$("#navAboutSub,#navNewsSub,#navConsumersSub,#navConsumersSub,#navPublicationsSub").hide();
		$("#navSupervisionSub").bind("mouseleave",function(){
			$("#navSupervisionSub").slideUp("slow");
		});
		return false;
    });

	$("#publicationsArrow").click(function () {
        $("#navPublicationsSub").slideDown("normal");
		$("#navAboutSub,#navNewsSub,#navConsumersSub,#navConsumersSub,#navSupervisionSub").hide();
		$("#navPublicationsSub").bind("mouseleave",function(){
			$("#navPublicationsSub").slideUp("slow");
		});
		return false;
    });
*/



	$("#aboutArrow").click( function() {
	    $("#navAboutSub").animate({height:"show",opacity:"show"},"slow");
		$("#navNewsSub,#navConsumersSub,#navSupervisionSub,#navPublicationsSub").hide(); return false;
	  });
	$("#navAboutSub").hover( function() {},
	  function() { $("#navAboutSub").animate({opacity:1.0},1125).slideUp(375); return false;
	  });

	$("#newsArrow").click( function() {
	    $("#navNewsSub").animate({height:"show",opacity:"show"},"slow");
		$("#navAboutSub,#navConsumersSub,#navSupervisionSub,#navPublicationsSub").hide(); return false;
	  });
	$("#navNewsSub").hover( function() {},
	  function() { $("#navNewsSub").animate({opacity:1.0},1125).slideUp(375); return false;
	  });

	$("#consumersArrow").click( function() {
	    $("#navConsumersSub").animate({height:"show",opacity:"show"},"slow");
		$("#navAboutSub,#navNewsSub,#navSupervisionSub,#navPublicationsSub").hide(); return false;
	  });
	$("#navConsumersSub").hover( function() {},
	  function() { $("#navConsumersSub").animate({opacity:1.0},1125).slideUp(375); return false;
	  });

	$("#supervisionArrow").click( function() {
	    $("#navSupervisionSub").animate({height:"show",opacity:"show"},"slow");
		$("#navAboutSub,#navNewsSub,#navConsumersSub,#navConsumersSub,#navPublicationsSub").hide(); return false;
	  });
	$("#navSupervisionSub").hover( function() {},
	  function() { $("#navSupervisionSub").animate({opacity:1.0},1125).slideUp(375); return false;
	  });
	
	$("#publicationsArrow").click( function() {
	    $("#navPublicationsSub").animate({height:"show",opacity:"show"},"slow");
		$("#navAboutSub,#navNewsSub,#navConsumersSub,#navConsumersSub,#navSupervisionSub").hide(); return false;
	  });
	$("#navPublicationsSub").hover( function() {},
	  function() { $("#navPublicationsSub").animate({opacity:1.0},1125).slideUp(375); return false;
	  });
	
	// Tab Scripts
	$("#news .tab").click(function(){
		$("#newsContent").show();
		$("#news .tab").removeClass("on off alt");
		$("#news .tab").addClass("on");
		$("#eventsContent").hide();
		$("#events .tab").removeClass("on off alt");
		$("#events .tab").addClass("off");
		$("#updatesContent").hide();
		$("#updates .tab").removeClass("on off alt");
		$("#updates .tab").addClass("off");
		return false;
	});
	$("#events .tab").click(function(){
		$("#eventsContent").show();
		$("#events .tab").removeClass("on off alt");
		$("#events .tab").addClass("on");
		$("#newsContent").hide();
		$("#news .tab").removeClass("on off alt");
		$("#news .tab").addClass("alt");
		$("#updatesContent").hide();
		$("#updates .tab").removeClass("on off alt");
		$("#updates .tab").addClass("alt");
		$("#eventsWrapper").jScrollPane();
		
		return false;
	});
	$("#updates .tab").click(function(){
		$("#updatesContent").show();
		$("#updates .tab").removeClass("on off alt");
		$("#updates .tab").addClass("on");
		$("#newsContent").hide();
		$("#news .tab").removeClass("on off alt");
		$("#news .tab").addClass("off");
		$("#eventsContent").hide();
		$("#events .tab").removeClass("on off alt");
		$("#events .tab").addClass("alt");
		$("#updatesWrapper").jScrollPane();
		
		return false;
	});
	
	// Rounded Corners
	//$("#disclosure").corner("10px");
	//$("#contact").corner("10px");
	//$("#disclosureSub").corner("10px");
	//$("#contactSub").corner("10px");
	
	$(".scroll-pane").jScrollPane();
	
	
	// Pagination Scripts
	
	$(".firstPagination a.first").each(function () {
		$(this).mouseover(function () {
			$(this).parent().css({ backgroundPosition:"bottom right" });
		});
		$(this).mouseout(function () {
			$(this).parent().css({ backgroundPosition:"top left" });
		});
	});
	$(".firstPagination a.previous").each(function () {
		$(this).mouseover(function () {
			$(this).parent().css({ backgroundPosition:"bottom left" });
		});
		$(this).mouseout(function () {
			$(this).parent().css({ backgroundPosition:"top left" });
		});
	});
	$(".lastPagination a.next").each(function () {
		$(this).mouseover(function () {
			$(this).parent().css({ backgroundPosition:"bottom right" });
		});
		$(this).mouseout(function () {
			$(this).parent().css({ backgroundPosition:"top left" });
		});
	});
	$(".lastPagination a.last").each(function () {
		$(this).mouseover(function () {
			$(this).parent().css({ backgroundPosition:"bottom left" });
		});
		$(this).mouseout(function () {
			$(this).parent().css({ backgroundPosition:"top left" });
		});
	});
	
	
	// MiniCal ToolTip
	
	
	
	
	
	

});
