$(document).ready(function(){


	/* !Show alert messages */
	$('div.alert').slideDown('fast',function(){
		$(this).children('.close').click(function(){
			$(this).parents('div.alert').eq(0).slideUp('fast');
		});
	});

	$('.card-template label').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		}
	);

	$('.card-template label').click(function(){
		$('.card-template label').removeClass('radio_checked');
		$(this).addClass('radio_checked');
	});
	
	/* !Style elements that have children with focus */
	//$("input:not(.dontHighlight)").focus(function(){
	//	if($(this).attr('type') != 'submit') {
	//		$(this).parent().addClass("notice");
	//	}
	//});
	//$("input:not(.dontHighlight)").blur(function(){
	//	if($(this).attr('type') != 'submit') {
	//		$(this).parent().removeClass("notice");
	//	}
	//});


	/* !Toggle the CodeIgniter profiler */
	$('div#profiler-control a').toggle(
		function() {
			$('div#codeigniter_profiler').slideDown();
			$(this).html('Hide');
			return false;
		},
		function() {
			$('div#codeigniter_profiler').slideUp();
			$(this).html('Show');
			return false;
		}
	);


	/* !Focus first input in content area */
	$('div#content input:first').focus();


	/* !Open specified links in new windows */
	$('a.newWindow').attr('target','_blank');
	$("a[href*='http://']:not([href*='"+location.hostname+"'])").attr('target','_blank');

        $('.bubbleInfo').each(function () {
            var distance = 30;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        top: -150,
                        left: -110,
                        display: 'block'
                    }).animate({
                        top: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        top: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
        
			
});

// Site Specific non-Jquery Javascript
function confirmRedirect(url, desciption) {
	if (confirmWindow(desciption)) {
		 window.location = url;
	}
}


function checkDefaultName(id) {
	var input = document.getElementById(id);
	
	if(input.value == 'First Name' || input.value == 'Last Name') {
		input.value = '';
	}
}
