$(document).ready(function(){

// Search field value (disappear and re-appear)
$('.search-field').each(function() {
    var default_value = this.value;
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
            $(this).toggleClass("search-color");
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
            $(this).toggleClass("search-color");
        }
    });
});


// Toggle personal and business radio buttons
$(".orange-bar li.checkbox").click(function(){
$(".orange-bar li.checkbox").toggleClass("checked");
});

// Initialize homepage slider
$('#slider').nivoSlider({
effect:'boxRain', // Specify sets like: 'fold,fade,sliceDown'
slices:5, // For slice animations
boxCols: 8, // For box animations
boxRows: 4, // For box animations
animSpeed:400, // Slide transition speed
pauseTime:7000, // How long each slide will show
startSlide:0, // Set starting Slide (0 index)
directionNav:true, // Next & Prev navigation
directionNavHide:false, // Only show on hover
controlNav:false, // 1,2,3... navigation
controlNavThumbs:false, // Use thumbnails for Control Nav
controlNavThumbsFromRel:false, // Use image rel for thumbs
controlNavThumbsSearch: '.jpg', // Replace this with...
controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
keyboardNav:true, // Use left & right arrows
pauseOnHover:true, // Stop animation while hovering
manualAdvance:false, // Force manual transitions
captionOpacity:1, // Universal caption opacity
prevText: 'Prev', // Prev directionNav text
nextText: 'Next', // Next directionNav text
beforeChange: function(){}, // Triggers before a slide transition
afterChange: function(){}, // Triggers after a slide transition
slideshowEnd: function(){}, // Triggers after all slides have been shown
lastSlide: function(){}, // Triggers when last slide is shown
afterLoad: function(){} // Triggers when slider has loaded
    });

// Sidebar Nav Rollovers
// Add icon to sidebar nav
//$("#sidebar-nav li").append("<span class='sidebar-icon'><span/>");
$("#sidebar-nav li").append("<img class='sidebar-icon' src='/images/general/icon-small.jpg' alt='small logo icon' />");

// Sidebar nav roll-over
$("#sidebar-nav li:not(.activelink)").mouseover(function(){
var navSelected = $(this).attr('id');
$("#" +navSelected+ " .sidebar-icon").stop(true, true).animate({ opacity: "show", 'filter': ''  }, "1");
});

// Sidebar nav roll-off
$("#sidebar-nav li:not(.activelink)").mouseleave(function(){
var navSelected = $(this).attr('id');
$("#" +navSelected+ " .sidebar-icon").stop(true, true).animate({ opacity: "hide", 'filter': ''  }, "1");
});

// Zebra stripe table rows
$('tbody tr:even').addClass('even');

// Display sidebar-quote
$("#sidebar-quote").css("display", "block")

// Online Banking box selection redirect
$('#btn-continue').click(function(){
if ($("#check-personal").hasClass("checked")) {
location.href = "https://server29.cey-ebanking.com/CLKPCB/053208192/login.asp?ID=828495628";
} else {
location.href = "https://server14.cey-ebanking.com/CLKCCM/053208192/login.asp?ID=780956301";
}
});

// Add class to checkboxes
$('input:checkbox, input:radio').addClass("checkbox");

// Add an asterisk to all required form labels
$('form label.required').append("<span class='ast'>*</span>");


// Creating custom :external selector (for external links)
$('a:not([href^="https://server29.cey-ebanking.com/CLKPCB/053208192/login.asp?ID=370173777"]):not([href^="https://server14.cey-ebanking.com/CLKCCM/053208192/login.asp?ID=780956301"]):not([href^="https://www.identitysecure.com/global/scripts/promo.asp?ref=CONSBROSPAG0001"]):not([href^="http://www.congareestatebank.com"]):not([href^="#"]):not([href^="/"]):not([href^="javascript"]):not([href^="mailto:"])').addClass('external')

// External links warning message
$('a.external').live('click', function() {
eLink = $(this).attr('href');
$('#external-warning span').html("<a href='" + eLink + "' target='_blank' onClick='javascript:parent.$.fancybox.close();'>Continue &raquo;</a>");
return false;
});
$('a.external').fancybox({
		'href'	:	'#external-warning',
		'hideOnContentClick' : false,
		'width' : 400,
		'height' : 270,
		'autoDimensions' : false
	});	

});
