<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 tab2 = $("#tabs-2").is(":visible");
				
				if(tab2)
					$("#tab_id").val("2");
				
				if ( oTable.length > 0 ) {
					oTable.fnAdjustColumnSizing();
				}
			}
		} );
	} );
	function part_id()
	{
		if(navigator.appName != "Microsoft Internet Explorer")
			frmname = document.recuirtment;
		
		lcn = frmname.location.value;
		lcn_typ = frmname.location_type.value;
		frmname.participant_id.value = lcn+lcn_typ;
		
		/*if(frmname.location.value == "")
		{
			alert("Please Provide Report Type");
			frmname.location.focus();
			return false;
		}*/
	}
	
	function div_enb(ctrl)
	{
		if(ctrl.value != "")
			$("#pp_div").show();
		else
			$("#pp_div").hide();
	}
	
	function frm_validation()
	{
		if(navigator.appName != "Microsoft Internet Explorer")
			frmname = document.recuirtment;
		
		var tab2 = $("#tabs-2").is(":visible");
		
		if(tab2)
			$("#tab_id").val("2");
		
		if(tab2)
		{
			if(frmname.partcpnt_id.value == "")
			{
				alert("Please Provide Participant ID");
				frmname.partcpnt_id.focus();
				return false;
			}
			if(frmname.name.value == "")
			{
				alert("Please Provide Name");
				frmname.name.focus();
				return false;
			}
			if(frmname.addrs.value == "")
			{
				alert("Please Provide Address");
				frmname.addrs.focus();
				return false;
			}
			if(frmname.city.value == "")
			{
				alert("Please Provide City");
				frmname.city.focus();
				return false;
			}
			if(frmname.pin_code.value == "")
			{
				alert("Please Provide Pin Code");
				frmname.pin_code.focus();
				return false;
			}
			else
			{
				if(frmname.pin_code.value.length != 6)
				{
					alert("Please Provide Pin Code in 6 Digits");
					frmname.pin_code.focus();
					return false;
				}
			}
			/*if(frmname.phne.value == "")
			{
				alert("Please Provide Phone");
				frmname.phne.focus();
				return false;
			}
			else if(frmname.phne.value != "")
			{
				var Pattern = /^[0-9]\d{3,5}-\d{6,8}$/
				var Pattern = /\b\d{3,5}\-\d{6,8}\b/
				phne = frmname.phne.value;
				
				if(!phne.match(Pattern))
				{
					alert("Please Provide Valid Phone Number");
					frmname.phne.focus();
					return false;
				}
			}*/
			if(frmname.mble.value == "")
			{
				alert("Please Provide Mobile");
				frmname.mble.focus();
				return false;
			}
			/*if(frmname.email.value == "")
			{
				alert("Please Provide E-Mail");
				frmname.email.focus();
				return false;
			}
			else
			{
				if(!checkEmail(frmname.email.value))
				{
					alert("Please Provide Valid E-Mail");
					frmname.email.focus();
					return false;
				}
			}*/
		}
	}
	
	function val_age(bDay)
	{
		bD = bDay.split('-');
		mnth = bD[1];
		days = bD[0];
		yrs = bD[2];
		
		yr = CalAge(mnth, days, yrs);
		
		if(!isNaN(yr))
			$("#age").val(yr);
		// alert(yr);
	}
	
	function date_cal(bDay, intr, mode, i)
	{
		bD = bDay.split('-');
		mnth = bD[1];
		days = bD[0];
		yrs = bD[2];
		
		yr = date_interval(eval(mnth), eval(days), eval(yrs), eval(intr), eval(mode));
		
		// $("#cupn_vld_dt_"+i).val(yr);
		$("#cupn_vld_dt").val(yr);
		// alert(yr);
	}
	
	function addRow_att(tableID, cnt)
	{
		var out = '';
		for(i=1; i<cnt; i++)
		{
			out = out+'<div class="questionrow"><div class="question">Coupons '+(i+1)+'</div><div class="answer"><input type="text" name="cupn_lst[]" id="cupn_lst_'+i+'" value="" /></div></div>';
		}
		$("#"+tableID).html(out);
	}
	
	function assign_partid(val)
	{
		// alert(val);
		$("#survey_id").val(val["sur_id"]);
		$("#partcpnt_id").val(val["reg_id"]);
		close_frame();
	}
	
	function frm_edit_val(frmval)
	{
		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&id="+frmval,
				url: url+"index.php?page="+getUrlVars()["page"],
				error: function(msg){
					alert( msg.status );
				},
				success: function(msg){
					// alert(msg);
					close_frame();
					$('#tabs-2').html(msg);
					$("#delete_img").show();
				}
		});
	}
</script>
<div style="width: 95%; margin: 0 auto; padding: 10px;">
	<div id="frm_display">
        <div id="tabs">
            <ul>
                <li class="active"><a href="#tabs-2">&nbsp;Locator Information&nbsp;</a></li>
            </ul>
            
            <form class="form" name="recuirtment" id="recuirtment" method="post" action="<?php echo $action; ?>" onsubmit="return frm_validation();">
                <div id="tabs-2">
                    <div class="questionrow">
                        <div class="question">Particpant ID</div>
                        <div class="answer">
                        	<input type="hidden" name="survey_id" id="survey_id" value="" readonly />
                        	<input type="text" name="partcpnt_id" id="partcpnt_id" value="" readonly />
							<img src="includes/images/search_img.png" style="vertical-align: middle;" onclick="open_frame('autocomplete.php?from=loc');">
                        	<?php // echo $common->dropdown('reg_id', 'reg_participant_id', 'custom_participant_registration', '', 'reg_participant_id', 'partcpnt_id', $partcpnt_id, 'class="required"'); ?>
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Name</div>
                        <div class="answer">
                            <input type="text" name="name" id="name" value="" style="text-transform: uppercase;" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Address</div>
                        <div class="answer">
                            <textarea name="addrs" id="addrs"></textarea>
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">City</div>
                        <div class="answer">
                            <input type="text" name="city" id="city" value="" style="text-transform: uppercase;" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Pincode</div>
                        <div class="answer">
                            <input type="text" name="pin_code" id="pin_code" value="" onkeyup="return acceptDigits(this);" maxlength="6" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Mobile No.</div>
                        <div class="answer">
                            <input type="text" name="mble" id="mble" value="" onkeyup="return acceptDigits(this);" maxlength="11" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Alternate Mobile No.</div>
                        <div class="answer">
                            <input type="text" name="phne" id="phne" value="" onkeyup="return acceptPhone(this);" maxlength="12" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div style="padding: 5px;" align="center">
                            <input type="submit" name="Submit" value="Submit" />
                        </div>
                    </div>
		</div>
            </form>
		</div>
	</div>
</div>