<?php echo '
<link rel="stylesheet" href="includes/media/css/TableTools_JUI.css" type="text/css" />
<script type="text/javascript" language="javascript" src="includes/media/js/ZeroClipboard.js"></script>
<script type="text/javascript" language="javascript" src="includes/media/js/TableTools.js"></script>
'; ?>
<script language="javascript">
	var asInitVals = new Array();
	
	$(document).ready(function() {
		$("#tabs").tabs( {
			"show": function(event, ui) {
				var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
				var tab3 = $("#tabs-3").is(":visible");
				
				if(tab3)
					$("#tab_id").val("3");
				
				if ( oTable.length > 0 ) {
					oTable.fnAdjustColumnSizing();
				}
			}
		} );
	} );
	
	function assign_partid(val)
	{
		$("#partcpnt_id").val(val["reg_id"]);
		close_frame();
		partcpnt_id_old = $("#partcpnt_id_old").val();
		
		if(partcpnt_id_old != "" && partcpnt_id_old != $("#partcpnt_id").val())
		{
			$("#dataTable").hide();
			$("#submit_div").hide();
			$("#partcpnt_id_old").val($("#partcpnt_id").val());
		}
		else
			$("#partcpnt_id_old").val($("#partcpnt_id").val());
	}
        
	function specimen_data()
	{
		if(!$("#partcpnt_id_all").is(":checked"))
		{
			if($("#partcpnt_id").val() == "")
			{
				alert('Please Specify Participant ID');
				$("#partcpnt_id").focus();
				return false;
			}
			else
				part_id = $("#partcpnt_id").val();
		}
		else
			part_id = "";
		
		prd_frm = $("#prd_frm").val();
		prd_to = $("#prd_to").val();
		var url = "";
		var loc = window.location;
		var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
		url = loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
		
		$.ajax({
			type: "POST",
			data: "page="+getUrlVars()["page"]+"&mode=edit&attr=print&partcpnt_id="+part_id+"&prd_frm="+prd_frm+"&prd_to="+prd_to,
			url: url+"index.php",
			error: function(msg){
				alert( msg.status );
			},
			success: function(msg){
				//alert(msg);
				$('#dataTable').show();
				$('#dataTable').html(msg);
				n = msg.indexOf("No menu items to display");
				if(msg != '' && n < 1)
					$("#submit_div").show();
				else
					$("#submit_div").hide();
			}
		});
	}
	function open_search(chk)
	{
		if(chk)
		{
			$("#srch_img").hide();
			//$("#partcpnt_id").val('');
		}
		else
		{
			$("#srch_img").show();
		}
		$('#dataTable').hide();
		$("#submit_div").hide();
	}
</script>
<style>
	#dataTable table, #dataTable{
		line-height: 15px !important
	}
</style>
<?php
	$dt_fmt = str_replace("mm", "m", DT_FMT);
	$dt_fmt = str_replace("dd", "d", $dt_fmt);
	$dt_fmt = str_replace("yyyy", "Y", $dt_fmt);
	
	$dt = date($dt_fmt);
?>
<div style="width: 95%; margin: 0 auto; padding: 10px;">
	<div id="frm_display">
        <div id="tabs">
            <ul>
                <li class="active"><a href="#tabs-3">&nbsp;Participant Reference Number&nbsp;</a></li>
            </ul>
            <form class="form" name="recuirtment" id="recuirtment" method="post" action="<?php echo $action; ?>" style="width: 85%;">
                <div id="tabs-3">
                    <div class="questionrow" style="width: 60%; margin: 0 auto;">
                        <div class="question"><strong>Date</strong></div>
                        <div class="answer">
                            <input type="hidden" name="dt_fmt" id="dt_fmt" value="<?php echo DT_FMT; ?>" />
                            <input type="hidden" name="prd_to_old" id="prd_to_old" value="" />
                        	<input type="text" name="prd_to" id="prd_to" value="<?php echo $dt; ?>" readonly="readonly" />
                            <script>
                                $(function() {
                                    $('#prd_to').datepick({pickerClass: 'datepick-jumps', 
                                            renderer: $.extend({}, $.datepick.defaultRenderer, 
                                            {picker: $.datepick.defaultRenderer.picker. 
                                                replace(/\{link:prev\}/, '{link:prevJump}{link:prev}'). 
                                                replace(/\{link:next\}/, '{link:nextJump}{link:next}')
                                            }), 
                                            dateFormat: '<?php echo DT_FMT; ?>', 
                                            yearRange: '1900:<?php echo date('Y'); ?>',
                                            showTrigger: '#calImg',
											onClose: showDate
                                    });
                                });
								function showDate(date) {
									// alert('The date chosen is ' + date);
									prd_to_old = $("#prd_to_old").val();
									
									if(prd_to_old != "" && prd_to_old != $("#prd_to").val())
									{
										$("#dataTable").hide();
										$("#submit_div").hide();
										$("#prd_to_old").val($("#prd_to").val());
									}
									else
										$("#prd_to_old").val($("#prd_to").val());
								}
                            </script>
                        </div>
                        <div class="question"><strong>Particpant ID</strong></div>
                        <div class="answer">
                            <input type="hidden" name="partcpnt_id_old" id="partcpnt_id_old" value="" />
                        	<input type="text" name="partcpnt_id" id="partcpnt_id" value="" readonly />
							<img src="includes/images/search_img.png" style="vertical-align: middle; display: none;" id="srch_img" onclick="open_frame('autocomplete.php');">
							<span style="float:right;">
								<input type="checkbox" name="partcpnt_id_all" id="partcpnt_id_all" value="1" onclick="open_search(this.checked);" checked /> All
							</span>
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow" align="center">
						<br/><input type="button" name="print" value="Go" onclick="return specimen_data();" /><br/><br/>
                    </div>
					<div class="questionrow" id="dataTable" style="display: none; overflow: auto; width: 60%; max-height: 350px; margin: 0px auto;">
					</div>
					<div class="clear_form">
					</div>
                    <div class="questionrow">
                        <div style="padding: 5px; display: none;" align="center" id="submit_div">
                            <input type="submit" name="excel" value="Excel" />
                            <input type="submit" name="pdf" value="Pdf" />
                        </div>
                    </div>
                </div>
            </form>
		</div>
	</div>
</div>