
// jquery popupwindow profiles
/* 
height:600, // sets the height in pixels of the window.
width:600, // sets the width in pixels of the window.
toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
left:0, // left position when the window appears.
top:0, // top position when the window appears.
center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
createnew:1 // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
 */
var profiles = { 
	mini: {
		height:200,width:200,status:1,resizable:0
	}, 
	miniCenter: {
		height:200,width:400,center:1,resizable:1,scrollbars:1 
	},		
	mediumCenter: {
		height:400,width:800,center:1,resizable:1,scrollbars:1
	},		
	largeCenter: {
		height:600,width:1000,center:1,resizable:1,scrollbars:1
	},		
	miniPopCenter: {
		height:200,width:400,center:1,resizable:1,toolbar:0,scrollbars:1
	},		
	mediumPopCenter: {
		height:400,width:800,center:1,resizable:1,toolbar:0,scrollbars:1
	},		
	largePopCenter: {
		height:600,width:1000,center:1,resizable:1,toolbar:0,scrollbars:1
	},		
	fullPopCenter: {
		height:screen.height,width:screen.width,center:1,resizable:1,toolbar:0,scrollbars:1
	},		
	smDemoPopCenter: {
		height:659,width:808,center:1,resizable:0,toolbar:0,scrollbars:0
	},
	fullReportConsole: {
		height:screen.height,width:screen.width,center:1,resizable:1,toolbar:1,scrollbars:1
	},		
	largeNewWindow: {
		height:600,width:1000,center:1,resizable:1,toolbar:1,scrollbars:1,status:1,createnew:1,location:1,menubar:1  
	},	
	windowNotNew: {
		height:300,width:400,center:1,createnew:0
	}
};

$(function() { 
	$('.popupwindow').live('click',function(event) { 
		event.preventDefault();
		// this is a mod of jquery.popupwindow.js
		var settings, parameters, mysettings, b, a, winname;
		
		// overrides default settings
		mysettings = ($(this).attr("rel") || "").split(",");
		
		// default profile
		settings = { 
			height:600, // sets the height in pixels of the window.
			width:600, // sets the width in pixels of the window.
			toolbar:0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
			scrollbars:0, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
			status:0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
			resizable:1, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
			left:0, // left position when the window appears.
			top:0, // top position when the window appears.
			center:0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
			createnew:1, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
			location:0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
			menubar:0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
		};

		// if mysettings length is 1 and not a value pair then assume it is a profile declaration
		// and see if the profile settings exists

		if(mysettings.length == 1 && mysettings[0].split(":").length == 1) {
			a = mysettings[0];
			// see if a profile has been defined
			if(typeof profiles[a] != "undefined") {
				settings = jQuery.extend(settings, profiles[a]);
			}
		}
		else {
			// if the first position is a profile, load it; additional values may exist which override the specific profile (kjm 2/5/2010)
			var startpos = 0; // starting position of loop
			
			if(mysettings[0].split(":").length == 1) {
				a = mysettings[0];
				// see if a profile has been defined
				if(typeof profiles[a] != "undefined") {
					settings = jQuery.extend(settings, profiles[a]);
					startpos = 1;
				}
			}		
		
			// overrides the settings with parameter passed in using the rel tag.
			for(var i=startpos; i < mysettings.length; i++) {
				b = mysettings[i].split(":");
				if(typeof settings[b[0]] != "undefined" && b.length == 2) {
					settings[b[0]] = b[1];
				}
			}
		}

		// center the window
		if (settings.center == 1) {
			settings.top = (screen.height-(settings.height + 110))/2;
			settings.left = (screen.width-settings.width)/2;
		}
		
		parameters = "location=" + settings.location + ",menubar=" + settings.menubar + ",height=" + settings.height + ",width=" + settings.width + ",toolbar=" + settings.toolbar + ",scrollbars=" + settings.scrollbars  + ",status=" + settings.status + ",resizable=" + settings.resizable + ",left=" + settings.left  + ",screenX=" + settings.left + ",top=" + settings.top  + ",screenY=" + settings.top;
		
		winname = settings.createnew ? 'PopUpWindow' + Math.random().toString() : 'PopUpWindow'; 
		if(!$(this).attr("suppress")) { // added by kjm 1/1/2009 as a way of suppressing the event if the result of a confirm dialog
			window.open($(this).attr('href'),name,parameters).focus();
		}
		return false; 
	});

});

$(function() {
	$("tr.trselector") 
		.live("mouseover",function() { $(this).addClass("trselector-hover"); }) 
		.live("mouseout",function() { $(this).removeClass("trselector-hover"); }) 
		.live("click",function() { 
			var thetd = $('td:first',this);
			var thehref = $('a:first',thetd).attr('href');
			if(thehref != null) { 
				location.href = thehref; 
			} 
		})
}); 

$(function() { 
	$("tr.trhighlighter")
		.live("mouseover",function() { $(this).addClass("trhighlighter-hover"); }) 
		.live("mouseout",function() { $(this).removeClass("trhighlighter-hover"); })
}); 

function checkboxCheckAll(id) { 
	var id = (id != null) ? id : ''; // parent element within which to check checkboxes
	if(id.length) { 
		$('#' + id + ' input:checkbox').attr('checked',true);
	}
	return false;
}

function checkboxUncheckAll(id) { 
	var id = (id != null) ? id : ''; // parent element within which to check checkboxes
	if(id.length) { 
		$('#' + id + ' input:checkbox').removeAttr('checked');
	}
	return false;
}
