var gld = jQuery.noConflict();

gld(document).ready( function() {
	floatGLD();
});

function newGLDWindow(p_id) {
	// NOTE: MUST BE www.gldknowhow.com:8081 in prod... WWW is REQUIRED for cookie
	if (w) w.close();
	var w = window.open("http://www.gldknowhow.com:8081/gldmw/extensions/ownerprotect/login.php?profile_id=" + p_id +
		"&url=" + window.location,
		"ItemsToGLD", "menubar=no,width=660,height=570,toolbar=no,resizable=1");
	w.focus();
	}
function newPrintWindow(itemArray, action) {
	if (nw) nw.close();
	var nw = window.open("",
		"gldPrint", "menubar=yes,width=600,height=550,toolbar=no,resizable=1");
	nw.document.write( '<h3>' + gld('#profileName').html() + "</h3>" );
	for (var i=0; i<itemArray.length; i++) {
		nw.document.write( (i+1) + ") " + itemArray[i] + "<br/>" );
	}
	nw.document.write("<script>");
	if (action=='print') {
		nw.document.write("alert('To print, choose File, Print from the browser window (or right-click, Print).');");
	} else 
		nw.document.write("alert('To copy the contents of the window to your clipboard, choose Edit, Select All, and then Edit, Copy (or Ctrl-A to select, then Ctrl-C to copy).');");
	nw.document.write('</script>');	
	nw.document.write("<br/>To track and manage action items in GettingLegalDone, sign up for a 45-day free trial at <a target='_blank' href='http://www.gettinglegaldone.com'>www.GettingLegalDone.com</a>.");	

}

function floatGLD(){ // from gld / whiteboard code
    var name = '#gldlauncher';
    gld(window).scroll(function () {
	var p = gld(name).offset();
	var menuBottom = 235;
	gld('.accordionContent').each( function() {
		if (gld(this).css('display') == 'block') {
			var h = gld(this).height();	
			if (h + 50 > menuBottom)
				menuBottom = h + 50;
		}
	});


	if ((p.top > gld(document).scrollTop()) && (gld(document).scrollTop() < menuBottom))
		gld(name).css('position', 'static')
	else {
		gld(name).css('position', 'absolute');
    		offset = gld(document).scrollTop()+200;
        	gld(name).animate({top:offset},{duration:1000,queue:false}); 
	
	}

    });
}

