



//Plug-in



jQuery.fn.getCheckboxVal = function(){ 

	var vals = []; 

	var i = 0; 

	this.each(function(){ 

		vals[i++] = jQuery(this).val(); 

	}); 

	return vals; 

}



//functions_________________________________________________________

	

$(document).ready(function(){

	//Select All

	$("#printChoice_all").click(function()				

			{

				var checked_status = this.checked;

				$("input[@name=printChoice]").each(function()

				{

					this.checked = checked_status;

				});

			});

	//Print Widget

	$("#printTables").click(function () {



		/*

		var defPrintArr = [ "yui-dt-mask" ];

		jQuery.each(defPrintArr, function() {

			$("." + this).addClass("print")

		});

		*/

		//Check to inlcude tech diagram

		if ($("input[name='techDiag']:checked")) {

			$('.techDiagram').addClass("print");

		}

		else {

			$('.techDiagram').addClass("noPrint");

		};

		//Get array of user-selected options

		var printArr = $("input[name='printChoice']:checked").getCheckboxVal();

		//Set class to "print"

		jQuery.each(printArr, function() {

			$("." + this).addClass("print");

			var $printTable = $("." + this).children();

			$printTable.find('div.yui-dt-liner').addClass("print");

			$printTable.addClass("print");

		});

		//Set everything else to no-print

		$('.dt-wrap').find('div:not(.print)').addClass("noPrint");

		//swap stylesheet and print

		window.print()

	});

});


