/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// On Load of Page

// on load of document
$(document).ready( function() {

		// make all links with 'rel="friend"' link in a new window.
		// needed as XHTML strict doesn't allow target="_blank"
		$('A[rel="friend"]').click( function() {
			window.open( $(this).attr('href') );
			return false;
		});

		// resize wrapper with background image
		resize_wrapper();
});


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Function - resize wrapper to fit view size
// necessary to cause background to wrap entire wrapper div
function resize_wrapper() {
	
	$middle_h 	= $("#content-column").height() + $("#footer").height(); 	// middle column height
	$window_h	= $(document).height();										// window height
	
	if ($middle_h > $window_h) {
		$("#wrapper").height($middle_h);
	} else {
		$("#wrapper").height($window_h);
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Resize the wrapper with background image when page adjusted

var resizeTimer = null;
$(window).bind('resize', 
	function() {
		if (resizeTimer) clearTimeout(resizeTimer);
		resizeTimer = setTimeout(resize_wrapper, 100);
	}
);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Javascript Drop Down Menu Script

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open)
   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;
