
/***********************************************
*************  PRELOAD IMAGES  ****************
************************************************/

	$(document).ready(function(){
		$("<img>").attr("src", "/images/backgrounds/bg-footer.png");
		$("<img>").attr("src", "/images/navigation/bg-dropdowns.png");
	});
	
/***********************************************
************  HOMEPAGE BANNER   ****************
************************************************/

$(document).ready(function() {
		$('.slider').DDSlider({
			trans:'fading',
			waitTime: '6000',
			selector: '.slider_selector'
		});
		
		$('.footerSlider').DDSlider({
			trans:'fading',
			waitTime: '6000',
			selector: '.slider_selector'
		});
});

/***********************************************
***  BUTTON ROLLOVER & PRELOAD  ****************
************************************************/

$(document).ready(function() {
	// button rollover
	if ($('.imgBtn') != null) {
		$('.imgBtn').hover(function(){
				if(!$(this).is('.disabled'))
					$(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2'));
			},
			function(){
					if(!$(this).is('.disabled'))
						$(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2'));
				});
	}
	// preload image rollovers
	if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) {
	    $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			    $("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		    });
	}

/***********************************************
***  EXTERNAL LINKS  ***************************
************************************************/

	$("a[rel=external]").each(function() {
		$(this).addClass('external');
		$(this).attr({
			target: "_blank"
		});
	})
});

/***********************************************
********  ANIMATED SCROLLING   *****************
************************************************/

$(document).ready(function(){
		$('.goTop').click(function(){
				var id = $(this).attr('href');
				if(id.length === 1) return;
				var ele = $(id);
				if(ele.length) {
					var destination = ele.offset().top;
					$('html:not(:animated), body:not(:animated)').animate({
							scrollTop: destination -20
					}, 700, 'easeOutQuint');
				}
		});
});

/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(document).ready(function () {
    $('form.compact input').each(function () {
        if ($(this).val().length > 0 && $(this).attr('type') == 'text') {
            $('label[for=' + $(this).attr('id') + ']').stop().animate({ opacity: 0 }, 100);
        } else {
            $('label[for=' + $(this).attr('id') + ']').stop().animate({ opacity: 1 }, 200);
        }
    });
});

$(function(){
	$('form.compact input, form.compact select, form.compact textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').stop().animate({opacity:0.4},300);			
		});
	$('form.compact input, form.compact select, form.compact textarea').keypress(function(){
			if($(this).val().length >= 0)
				$('label[for=' + $(this).attr('id') + ']').stop().animate({opacity:0},100);
		});
	$('form.compact input, form.compact select, form.compact textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').stop().animate({opacity:1},200);
		});
	$('form.compact').removeClass('compact');
});



/***********************************************
******** SMALL ANIMATIONS AND EFFECTS **********
************************************************/  

$(document).ready(function(){
	
	
// Navigation
	 jQuery.each(jQuery.browser, function(i) {
		   if($.browser.msie){
				$('#navigation ul li').hover(function(){
						$(this).addClass('hover');
						$(this).find('ul').show();
					 },
					 function () {
						$(this).removeClass('hover');
						$(this).find('ul').hide();
					});
		   }else{}
	});
	
	$('#navigation ul li').hover(function(){
			$(this).addClass('hover');
			$(this).find('ul').stop(true, true).fadeIn(200);
		 },
		 function () {
			$(this).removeClass('hover');
			$(this).find('ul').stop(true, true).fadeOut(150);
		});
		
	
	$('.newsItem').hover(function(){
		$(this).find('a').css({
			color: '#fff',
			background: '#969d16'
			});
	 	 },
	 	 function () {
			$(this).find('a').css({
			color: '#555',
			background: '#eee'
			});
	 		}
		);
		
		$('.newsItem a').hover(function(){
		$(this).css({
			background: '#a7ae21'
			});
	 	 },
	 	 function () {
			$(this).css({
			background: '#969d16'
			});
	 		}
		);










});


