$(function () {
    $('#search').formwatermark();
    $('.Doc2Form li').formwatermark({ label: 'p' });
    $('.accordian').accordian();
    $('.w_content table tbody').alt();
    fontface();
    $('#main_nav ul li').hover(function () {
        $(this).addClass('hover').children('ul').stop(true, true).slideDown(300, 'easeInOutCirc');
    }, function () {
        $(this).removeClass('hover').children('ul').stop(true, true).slideUp(0);
    }).find('ul').hide();
    $('a[href^="http"]').externallink({ url: url_frag });
    $('.eyebrow_function').eyebrow();
});

function fontface() {
    var special_font = [
            '.tout_content h3',
            '.toe h2',
            '.nocrazy',
            '.w_content h2'
      ];

    for (i in special_font) {
        $(special_font[i]).each(function () {
            $(this).hide().addClass('custom_font').addClass('typeface-js');
        });
    }

    var font_face = "titilliumtext22l_bold.typeface.js";
    $.getScript(url_frag + "/scripts/" + font_face, function () {
        _typeface_js.renderDocument();        
    });
    
    var special_font_bold = [
            '.crazy'
      ];
    for (i in special_font_bold) {
        $(special_font_bold[i]).each(function () {
            $(this).hide().addClass('custom_font_bold').addClass('typeface-js');
        });
    }
    var font_face_bold = "titilliumtext22l_xbold.typeface.js";
    $.getScript(url_frag + "/scripts/" + font_face_bold, function () {
        _typeface_js.renderDocument();
        $('.custom_font,.custom_font_bold').show();
    });
}
jQuery.fn.externallink = function () {
    var args = arguments[0] || {}; // It's your object of arguments
    var url = '/^' + args.url + '/i';

    return this.each(function () {
        var obj = jQuery(this);
       
        if (!obj.attr('href').match(url)) {
            obj.click(function () {
                var leave = confirm("You are about to leave Citizens Security Bank's website. Citizens Security Bank does not endorse or guarantee the products, information, or recommendations provided by linked sites and we are not liable for any failure of products or services advertised on these sites. In addition, the site may have a privacy and security policy different than that of Citizens Security Bank. ");
                if (leave) {
                    return true;
                } else {
                    return false;
                }
            });
        }
    });
};
jQuery.fn.eyebrow = function () {
    var args = arguments[0] || {}; // It's your object of arguments
    var obj = this;
    var target = jQuery(obj.attr('href'));
    var inital_height = target.height();

    var close = jQuery('<a id="eyebrow_top_close" href="#">Close</a>').appendTo(target)
        .click(function () {
            target.stop(true).animate({ height: inital_height }, 650, 'easeInOutExpo');
            return false;
        });
    obj.click(function () {
        target.stop(true).animate({ height: target.children().outerHeight() }, 650, 'easeInOutExpo');
        return false;
    });
};
