var nav_away_message = "NOTICE: You are now leaving SFCUs website. The link you have chosen will take you to a website outside of the control of Sidney Federal Credit Union. SFCU has partnered with this site in order to provide you with additional services, and therefore an SFCU logo may be displayed along with the logo of the outside service. SFCU is not responsible for any products you purchase or services you use. Please be aware that the privacy policies of the site you are linking to may differ from that of Sidney Federal Credit Union.";

$(function()
{
	$(".js-enabled").show();
	$("ul#nav li").hover(function()
	{
		$("ul:first", $(this)).show();
		$(this).addClass("active");
	}, function()
	{
		$("ul", $(this)).hide();
		$(this).removeClass("active");
	});
	
	$("form.subscribe input").data("value", $("form.subscribe input").val());
	$("form.subscribe input").focus(function()
	{
		($(this).val() == $(this).data("value")) ? $(this).val("") : null;
	}).blur(function()
	{
		($(this).val() == "") ? $(this).val($(this).data("value")) : null;
	});
	/*$("a.btn_register").click(function()
	{
		$("body").append('<div id="modal-layer"></div>');
		$("#sitewrapper").append('<div id="modal"></div>');
		$("#modal").load($(this).attr("href"), function() { $("#modal-layer, #modal").fadeIn(300); });
		scrollTo(0, 0);
		return false;
	});*/
	$("#modal-layer, #modal button").live("click", function()
	{
		$("#modal-layer, #modal").fadeOut(300, function() { $(this).remove(); } );
		return false;
	});
	$("#translate select").change(function()
	{
		($("option:selected", $(this)).val() == "") ? null : window.location = "http://www.google.com/translate_c?hl=en" + $("option:selected", $(this)).val() + "&u=" + window.location.href;
	});
	
	$('#slide_show').after('<div id="slide_nav">').cycle({ 
	    fx:     'fade', 
	    speed:  1000, 
		timeout: 3000,
	    pager:  '#slide_nav'
	});
	
	$('#slide_nav a').click(function()
	{
		$('#slide_show').cycle('pause');
	});
	$('#play_slide').click(function()
	{
		$('#slide_show').cycle('resume', true);
	});
	
	var zIndexNumber = 1000;
	$('ul#nav li').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
	
	$(".leaving-site").click(function()
	{
		dest = $(this).attr("href");
		$("#dialog").attr("title", "Continue to external site?")
		$("#dialog").html(nav_away_message);
		$("#dialog").dialog({
			bgiframe: true,
			resizable: false,
			width:400,
			height:280,
			modal: true,
			autoOpen: false,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				'Continue': function() {
					$(this).dialog('close');
					window.open(dest);
				},
				Cancel: function() {
					$(this).dialog('close');
				}
			}
		});
		$("#dialog").dialog('open');
		return false;
	});
});
