today = new Date();
now = today.getHours();
				
if(now < 6 || now >= 18) {
	//$('html').css('background', '#08182f url(../uploads/d5_template/p16_night_bkgd_pattern.gif) repeat');
	$('html').css('background', '#142135 url(../uploads/d5_template/p16_night_bkgd_pattern.gif) repeat');	
}
 

function daynight(){ 
				
// Roger Daynight.js
// =============================================

today = new Date(); // set today's date
now = today.getHours();
			
if(now >= 6 && now < 18) {		
	$('#main_nav').addClass('nav_day');
	$('#main_nav_promo').addClass('nav_promo_day');	
}	
	
if(now < 6 || now >= 18) {
	$('#main_nav').addClass('nav_night');
	$('#main_nav_promo').addClass('nav_promo_night');
	// $('html').css('background', '#333333');
}

$('.daynight').each(function(index) {	
	filename = $(this).attr("src");	

	if(now >= 6 && now < 18) {
		$(this).attr("src","/uploads/d5_template/main_nav_day/" + filename);
	}	

	if(now < 6 || now >= 18) {
		$(this).attr("src","/uploads/d5_template/main_nav_night/" + filename);
	}	

});

$('.daynight_swap').each(function(index) {	
	filename = $(this).attr("src");	
	currentid = $(this).attr("id");

	if(now >= 6 && now < 18) {

    $(this).attr("src","/uploads/d5_template/main_nav_day/" + filename);
	
	$(this).mouseover(function() {
		currentid = $(this).attr("id");							   
		$(this).attr("src","/uploads/d5_template/main_nav_day/"+currentid+"_over.png");
	});

	$(this).mouseout(function() {
		currentid = $(this).attr("id");							   
		$(this).attr("src","/uploads/d5_template/main_nav_day/"+currentid+".png");
	});
	
	newonload="MM_preloadImages('/uploads/d5_template/main_nav_day/"+currentid+"_over.png')";
	$(this).attr("onload",newonload);

	}	

	if(now < 6 || now >= 18) {
		
    $(this).attr("src","/uploads/d5_template/main_nav_night/" + filename);
	
	$(this).mouseover(function() {
		currentid = $(this).attr("id");							   
		$(this).attr("src","/uploads/d5_template/main_nav_night/"+currentid+"_over.png");
	});

	$(this).mouseout(function() {
		currentid = $(this).attr("id");
		$(this).attr("src","/uploads/d5_template/main_nav_night/"+currentid+".png");
	});
	
	newonload="MM_preloadImages('/uploads/d5_template/main_nav_night/"+currentid+"_over.png')";
	$(this).attr("onload",newonload);
		
	}	

});

$('.daynight_bkgd').each(function(index) {								  
	filename = $(this).attr("src");	

	if(now >= 6 && now < 18) {
        $(this).attr("src","/uploads/d5_template/bkgd_image/day_" + filename);
	}	

	if(now < 6 || now >= 18) {	
		$(this).attr("src","/uploads/d5_template/bkgd_image/night_" + filename);	
	}	

});

// =============================================
// Roger Daynight.js

};
