$(document).ready(function(){ 

switchBackground();

hoverProducts();

barronsPopup();

// end of document.ready
});


// on page load generate a different background image
function switchBackground(){

//var backgrounds = ["url(dafiles/Internet/co/delaware/furniture/images/background/del-invest-home-01.jpg)","url(dafiles/Internet/co/delaware/furniture/images/background/del-invest-home-03.jpg)","url(dafiles/Internet/co/delaware/furniture/images/background/del-invest-home-04.jpg)","url(dafiles/Internet/co/delaware/furniture/images/background/del-invest-home-08.jpg)"];	

var backgrounds = ["01","03","04","08"];

// production full url path: /dafiles/Internet/co/delaware/furniture

var background = backgrounds[Math.floor(Math.random()*backgrounds.length)];
$('#VC-mainContent').css({backgroundImage:"url('/dafiles/Internet/co/delaware/furniture/images/background/del-invest-home-"+background+".jpg')"});
	
}; // end of switchBackground()


function hoverProducts(){

$('#products li div').css('opacity','0');

$("#products li").hover(
  	function () {
		$(this).children('a').addClass('hover');
		$(this).children('div').css({'display':'block','z-index':1}).stop().animate({opacity: 1}, 400);
  	}, 
  	function () {
		$(this).children('a').removeClass('hover');
		//$(this).children('div').stop().css({'opacity':'0','display':'none'});
		
		$(this).children('div').stop().css({'z-index':0});
		$(this).children('div').stop().animate({
			opacity: 0
			}, {
			duration: 400, 
			complete: function() {
				$(this).css('display','none');
			} 
		});
	});

}; // end of hoverProducts()

function barronsPopup(){
	$.fx.speeds._default = 1500;
	$('#delaware-barrons').dialog( {width: 520, height: 400, modal: true, show: 'fade', draggable: false, resizable: false, open: function(event, ui) {$('.ui-widget-header').hide();} });
	$('#delaware-barrons-close').css('opacity','0.5').click(function(){
		$('#delaware-barrons').dialog( "close" );
	});
	$('#delaware-barrons-close').hover(function(){
		$(this).stop().animate({opacity: 1}, 500);
		}, function(){
		$(this).stop().animate({opacity: 0.5}, 500);
		}	
	);		
}

