

<script language="javascript">
    var asInitVals = new Array();
    
    $(document).ready(function() {
    	var prd = document.getElementById('val_prd_div');
        var iss = document.getElementById('val_iss_div');
        var dt = document.getElementById('val_dt_div');    
        
        $("#tabs").tabs( {
            "show": function(event, ui) {
                var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
                var tab1 = $("#tabs-1").is(":visible");
                var tab2 = $("#tabs-2").is(":visible");
                var tab3 = $("#tabs-3").is(":visible");

                if(tab1)
                    $("#tab_id").val("1");
                if(tab2)
                    $("#tab_id").val("2");
                if(tab3)
                    $("#tab_id").val("3");

                if ( oTable.length > 0 ) {
                    oTable.fnAdjustColumnSizing();
                }
            }
        } );
       //if($("#cupn").val == '' || $("#cupn").val == 0)
      
      	// added by Vidhya - 17-10-2017 - to hide coupon related fields when coupon count is not present
       if(document.getElementById('cupn').value == '' || parseInt(document.getElementById('cupn').value.trim()) <= 1 )
       {
        prd.style.display = 'none';
        iss.style.display = 'none';
        dt.style.display = 'none';
        
       }
       else
       {
           //document.getElementById('check_Coupons').style.display = 'none';
    	   prd.style.display = 'display';
           iss.style.display = 'display';
           dt.style.display = 'display';
       }
       
    } );
    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;
		}*/
    }

    // Added by Vidhya - on 12/12/2017
    var buttonclicked = false;
        
    function frm_validation()
    {
        if(navigator.appName != "Microsoft Internet Explorer")
            frmname = document.recuirtment;

        var tab1 = $("#tabs-1").is(":visible");
        var tab2 = $("#tabs-2").is(":visible");
        var tab3 = $("#tabs-3").is(":visible");

        if(tab1)
            $("#tab_id").val("1");
        if(tab2)
            $("#tab_id").val("2");
        if(tab3)
            $("#tab_id").val("3");

        if(tab1)
        {
            if(frmname.survey_id.value == "")
            {
                alert("Please Select Survey");
                frmname.survey_id.focus();
                return false;
            }
            if(frmname.location.value == "")
            {
                alert("Please Select Location");
                frmname.location.focus();
                return false;
            }
            if(frmname.location_type.value == "")
            {
                alert("Please Select Participant Type");
                frmname.location_type.focus();
                return false;
            }
            /*if(frmname.participant_id.value == "")
			{
				alert("Please Provide Participant ID");
				frmname.participant_id.focus();
				return false;
			}*/
            if(frmname.cupn_cde.value == "")
            {
                alert("Please Provide Coupon Code");
                frmname.cupn_cde.focus();
                return false;
            }
            else
            {
                var Pattern = /^[A-Z]{2}[0-9]{4}$/;
                if(!$("#cupn_cde").val().match(Pattern))
                {
                    alert("Please Provide Valid Coupon Code. Example: CH1001");
                    frmname.cupn_cde.focus();
                    return false;
                }
            }
            if(frmname.age.value == "")
            {
                alert("Please Provide Age");
                frmname.age.focus();
                return false;
            }
            else if(frmname.age.value != "" && isNaN(frmname.age.value))
            {
                alert("Please Provide Age in Numeric");
                frmname.age.focus();
                return false;
            }
            if(frmname.dob.value == "")
            {
                alert("Please Provide Date of Birth");
                frmname.dob.focus();
                return false;
            }
            if(frmname.sex.value == "")
            {
                alert("Please Provide Gender");
                frmname.sex.focus();
                return false;
            }
            /*if(frmname.ntwrk_sze.value == "")
            {
                alert("Please Provide Network Size");
                frmname.ntwrk_sze.focus();
                return false;
            }
            else if(frmname.ntwrk_sze.value != "" && isNaN(frmname.ntwrk_sze.value))
            {
                alert("Please Provide Network Size in Numeric");
                frmname.ntwrk_sze.focus();
                return false;
            }
            /*if(frmname.biometric_ref.value == "")
			{
				alert("Please Provide Biometric Reference");
				frmname.biometric_ref.focus();
				return false;
			}*/
        }

        if(tab2)
        {
            if(frmname.partcpnt_id2.value == "")
            {
                alert("Please Provide Participant ID");
                frmname.partcpnt_id2.focus();
                return false;
            }
            /*
			if(frmname.biometric_ref.value == "")
            {
                alert("Please Provide Biometric Reference");
                frmname.biometric_ref.focus();
                return false;
            }
			*/
        }

        if(tab3)
        {
            // Added by Vidhya - on 12/12/2017
            if(document.getElementById('cupn_stdarm').value == 'N' && document.getElementById('location_type').value == 'W')
            {
                if(buttonclicked == false)
                {
                    alert('Please Check the number of Coupons');
                	return false;
                }
            }
            
            sur_dt = $("#survey_comp_dt");
            sur_tbl = $("#survey_tbl");
            pcol = $("#pcolumn");
          
            if(sur_dt.val() == '')
            {
                alert("Survey needs to be completed for this Participant");
                return false;
            }

			lab_done = $("#lab_done");
			//alert('lab='+lab_done.val());
			if(lab_done.val() == 'failed')
			{
				alert("Lab Tests need to be completed for this Participant");
				return false;
			}
            
            if(frmname.partcpnt_id.value == "")
            {
                alert("Please Provide Participant ID");
                frmname.partcpnt_id.focus();
                return false;
            }
            if(frmname.cupn.value == "")
            {
                alert("Please Provide No of Coupons");
                frmname.cupn.focus();
                return false;
            }
            else
            {
                for(i=0; i<frmname.cupn.value; i++)
                {
                    cupn_lst = $("#cupn_lst_"+i);
                    if(cupn_lst.val() == "")
                    {
                        alert("Please Provide Coupon Code");
                        cupn_lst.focus();
                        return false;
                    }
                    else
                    {
                        if($("#coupn_fxd").val == "Y") {
                            var Pattern = /^[A-Z]{2}[0-9]{4}$/;
                            if(!$("#cupn_lst_"+i).val().match(Pattern))
                            {
                                // alert("Please Provide Valid Coupon Code");
    							alert("Please Provide Valid Coupon Code. Example: CH1001");
                                cupn_lst.focus();
                                return false;
                            }
    						else
    						{
    							loc = $("#partcpnt_id").val().substr(0, 2);
    							cupn_id = $("#cupn_lst_"+i).val();
    							cupn_loc = cupn_id.substr(0, 2);
    							
    							if(loc != cupn_loc)
    							{
    								alert("Please Provide Valid Coupon Code.");
    								cupn_lst.focus();
    								return false;
    							}
    						}
                        }
                    }
                    /*cupn_dt = $("#cupn_dt_"+i);
					if(cupn_dt.value == "")
					{
						alert("Please Provide Coupon Issue Date");
						cupn_dt.focus();
						return false;
					}
					cupn_prd = $("#cupn_prd_"+i);
					if(cupn_prd.value == "")
					{
						alert("Please Provide Coupon Valid Period");
						cupn_prd.focus();
						return false;
					}
					prd_type = $("#prd_type_"+i);
					if(prd_type.value == "")
					{
						alert("Please Provide Coupon Valid Period");
						prd_type.focus();
						return false;
					}
					cupn_vld_dt = $("#cupn_vld_dt_"+i);
					if(cupn_vld_dt.value == "")
					{
						alert("Please Provide Coupon Valid Date");
						cupn_vld_dt.focus();
						return false;
					}*/
                }
            }

            /*if(frmname.cupn_lst.value == "")
			{
				alert("Please Provide Coupon List");
				frmname.cupn_lst.focus();
				return false;
			}*/
            if(frmname.cupn_dt.value == "")
            {
                alert("Please Provide Coupon Issue Date");
                frmname.cupn_dt.focus();
                return false;
            }
            if(frmname.cupn_prd.value == "")
            {
                alert("Please Provide Coupon Valid Period");
                frmname.cupn_prd.focus();
                return false;
            }
            if(frmname.prd_type.value == "")
            {
                alert("Please Provide Coupon Valid Period");
                frmname.prd_type.focus();
                return false;
            }
            if(frmname.cupn_vld_dt.value == "")
            {
                alert("Please Provide Coupon Valid Date");
                frmname.cupn_vld_dt.focus();
                return false;
            }
        }
    }

    function val_age(bDay, dt_fmt)
    {
        bD = bDay.split('-');
        mnth = bD[1];
        days = bD[0];
        yrs = bD[2];
        
        if(dt_fmt == 'yyyy-mm-dd')
        {
            yrs = bD[0];
            mnth = bD[1];
            days = bD[2];
        }
        if(dt_fmt == 'dd-mm-yyyy')
        {
            yrs = bD[2];
            mnth = bD[1];
            days = bD[0];
        }
        if(dt_fmt == 'mm-dd-yyyy')
        {
            yrs = bD[2];
            mnth = bD[0];
            days = bD[1];
        }

        yr = CalAge(mnth, days, yrs);

        if(!isNaN(yr))
            $("#age").val(yr);
        // alert(yr);
    }

    function date_cal(bDay, intr, mode, i, dt_fmt)
    {
        bD = bDay.split('-');
        mnth = bD[1];
        days = bD[0];
        yrs = bD[2];
        
        if(dt_fmt == 'yyyy-mm-dd')
        {
            yrs = bD[0];
            mnth = bD[1];
            days = bD[2];
        }
        if(dt_fmt == 'dd-mm-yyyy')
        {
            yrs = bD[2];
            mnth = bD[1];
            days = bD[0];
        }
        if(dt_fmt == 'mm-dd-yyyy')
        {
            yrs = bD[2];
            mnth = bD[0];
            days = bD[1];
        }

        yr = date_interval(eval(mnth), eval(days), eval(yrs), eval(intr), eval(mode), dt_fmt);

        // $("#cupn_vld_dt_"+i).val(yr);
        $("#cupn_vld_dt").val(yr);
        // alert(yr);
    }

    function addRow_att(tableID, cnt, flag)
    {
    	// added by Vidhya - 17-10-2017
    	var prd = document.getElementById('val_prd_div');
        var iss = document.getElementById('val_iss_div');
        var dt = document.getElementById('val_dt_div');    
        
		len = eval($("#no_cupn").val());
		//alert($("#no_cupn").val()+" > "+cnt);
		
		if(cnt == 0)
		{
			alert("No of Coupons Should not be Zero");
			//$("#cupn").focus();
			$("#cupn").val(len);
			
			cnt = document.getElementsByName("cupn_lst[]").length;
			for(i=(len+1); i<=cnt; i++)
			{
				cpn_div = "cpn_div_"+i;
				$("#"+cpn_div).remove();
			}
			// added by Vidhya - 17-10-2017
		   prd.style.display = 'none';
	       iss.style.display = 'none';
	       dt.style.display = 'none';
		        
			return false;
		}
		else
		{
			prd.style.display = 'block';
	        iss.style.display = 'block';
	        dt.style.display = 'block';
		}
		if(eval($("#no_cupn").val()) > cnt && !flag)
		{
			len = document.getElementsByName("cupn_lst[]").length;
			for(i=len; i>cnt; i--)
			{
				cpn_div = "cpn_div_"+i;
				$("#"+cpn_div).remove();
			}
		}
		else if(!flag)
		{
			len = 0;
			for(i=1; i<=eval($("#no_cupn").val()); i++)
			{
				cpn_div = "cpn_div_"+i;
				if($("#"+cpn_div).length != 0 && $("#"+tableID+" #"+cpn_div).length == 0)
					len++;
			}
		}
		
		if(eval($("#no_cupn").val()) > eval(cnt) && flag)
		{
			alert("Please Enter The Value Greater Than Existing");
			$("#cupn").val(len);
			
			cnt = document.getElementsByName("cupn_lst[]").length;
			// for(i=len; i>cnt; i--)
			for(i=(len+1); i<=cnt; i++)
			{
				//cpn_div = "cpn_div_"+(i+1);
				cpn_div = "cpn_div_"+i;
				//alert(cpn_div);
				$("#"+cpn_div).remove();
			}
			return false;
			$("#no_cupn").val(cnt);
		}
		else if($("#no_cupn").val() == "")
			len = $("#no_cupn").val();
		
        var out = '';
        for(i=len; i<cnt; i++)
        {
            /*out = out+'<div class="questionrow" id="cpn_div_'+(i+1)+'"><div class="question">Coupons Code '+(i+1)+'</div><div class="answer"><input type="text" name="cupn_lst[]" id="cupn_lst_'+i+'" value="" maxlength="6" onKeydown="return keyRestricted(this, event, document.recuirtment.location.value.length, false);" onKeyup="return keyRestricted(this, event, document.recuirtment.location.value.length, true);" /></div></div>';*/
            out = out+'<div class="questionrow" id="cpn_div_'+(i+1)+'"><div class="question">Coupons Code '+(i+1)+'</div><div class="answer"><input type="text" name="cupn_lst[]" id="cupn_lst_'+i+'" value="" maxlength="6" /></div></div>';
        }
        $("#"+tableID).html(out);
		old_val();
    }

    function frm_val(formvars)
    {
        // alert(formvars);
        len = formvars.length;

        for(i=0; i<len; i++)
        {
            if(formvars[i].name == 'reg_id[]')
            {
                if(formvars[i].checked)
                {
                    survey = 'survey_'+i;
                    reg_location = 'reg_location'+i;
                    participant_type = 'participant_type_'+i;
                    cupn_code = 'cupn_code_'+i;
                    dor = 'dor_'+i;
                    ns = 'ns_'+i;
                    dob = 'dob_'+i;
                    age = 'age_'+i;
                    sex = 'sex_'+i;

                    alert(formvars[i].value+" "+$("#tab_id").val());
                }
            }
        }
    }

    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["participant_id"]+"&sur_id="+frmval["survey"],
            url: url+"index.php",
            error: function(msg){
				alert( msg.status );
            },
            success: function(msg){
                $("#content").html(msg);
                close_frame();
            }
        });
        return false;

        // alert(frmval.length);
        // $("#survey_id").find("option[value='"+frmval["survey"]+"']").attr("selected","selected");
        // $("#location").find("option[value='"+frmval["reg_location"]+"']").attr("selected","selected");
        // $("#location_type").find("option[value='"+frmval["participant_type"]+"']").attr("selected","selected");
        $("#id").val(frmval["reg_id"]);
        $("#survey_id").val(frmval["survey"]);
        $("#location").val(frmval["reg_location"]);
        $("#location_type").val(frmval["participant_type"]);
        $("#participant_div .questionrow .question").html("Participant ID");
        $("#participant_div .questionrow .answer").html(frmval["participant_id"]);
        // $("#participant_div .questionrow").css("margin-bottom", 10);
        $("#participant_div").show();
        $("#cupn_cde").val(frmval["cupn_code"]);
        $("#dor_span").html(frmval["dor"]);
        $("#dor").val(frmval["dor"]);
        $("#ntwrk_sze").val(frmval["ns"]);
        $("#dob").val(frmval["dob"]);
        $("#age").val(frmval["age"]);
        $("#sex").val(frmval["sex"]);
        $("#partcpnt_id2").val(frmval["participant_id"]);
        $("#biometric_ref").val(frmval["biometric_ref"]);
        $("#partcpnt_id").val(frmval["participant_id"]);
        $("#cupn").val(frmval["coupon_count"]);
        $("#cupn_dt").val(frmval["cupn_dt"]);
        $("#cupn_prd").val(frmval["cupn_prd"]);
        $("#prd_type").val(frmval["prd_type"]);
        $("#cupn_vld_dt").val(frmval["cupn_vld_dt"]);
        
        addRow_att('cpn_list', frmval["coupon_count"]);
        
        if(frmval["coupon_count"] != "" || frmval["coupon_count"] > 1)
        {
            for(i=0; i<frmval["coupon_count"]; i++)
            {
                t_id = "coupn_part_id_"+frmval["reg_id"]+"_"+i;
                $("#cupn_lst_"+i).val(frmval[t_id]);
            }
        }
        else
            $("#cupn_lst_0").val("");
        
        close_frame();
        $("#delete_img").show();
    }
	
	function enb_div(val)
	{ 
	  /*
		if(val != "")
		{
			$("#dob_div").show();
			$("#dob_clean_div").show();
		}
		else
		{
			$("#dob_div").hide();
			$("#dob_clean_div").hide();
			$("#dob").val("");
		}
	 */
	}

	// start - Added by Vidhya - Sep 2017
function checkCoupons(id,pid)
{
	 // Added by Vidhya - on 12/12/2017	
	buttonclicked = true;
	
	var loc = window.location;
    var pathName = loc.pathname.substring(0, loc.pathname.lastIndexOf('/') + 1);
	var url = loc.href.substring(0, loc.href.length - ((loc.pathname + loc.search + loc.hash).length - pathName.length));
	var msg,msg1;
	  $.ajax({
        type: "POST",
         url: url+"index.php?page=recuirtment&action=ajaxfunction&id="+id+"&pid="+pid,
         error: function(msg){
            alert('There has been an internal problem');
			alert( msg.status );
        }, 
        success: function(msg){
        	msg1 = msg;
            if(document.getElementById('cupn_showvar').value == 'Y')
            {
            	if(msg.substring(0,1) == 'S')
            	{
            		alert('This participant belongs to Standard Arm');
            	}
            	else if(msg.substring(0,1) == 'A')
                	alert('This participant belongs to Altered Arm');
            }
            msg = msg1.slice(1);
          
            if(msg == '222')
            {
                alert('Survey not completed for this Participant');
                $("#cupn").val(0);
                prd.style.display = 'none';
                iss.style.display = 'none';
                dt.style.display = 'none';
            }
            else if(msg == '111')
            {
                alert('Lab test/result not completed for this Participant');
                $("#cupn").val(0);
                prd.style.display = 'none';
                iss.style.display = 'none';
                dt.style.display = 'none';
            }
            else
            {
                if(msg1.substring(0,1) == 'A')
                {
	                var arr = msg1.split(',');
	                document.getElementById('equations').style.border = '1px';
	                
	                document.getElementById('equations').innerHTML = '[ SexPartners6 = <strong>'+arr[1]+'</strong>,PharmDrugs =<strong>'+arr[2]+'</strong>,PharmDrugs_Cat =<strong>'+arr[3]+'</strong>, NumDrugs =<strong>'+arr[4]+'</strong>, ln(nw2) = <strong>'+arr[5]+'</strong>, Sum of Coeffs =<strong>'+arr[6]+'</strong>, Prob =<strong>'+arr[7]+'</strong>, cf_su5c='+arr[8]+', cf_su8c='+arr[9]+', cf_su4c='+arr[10]+', cf_sv1='+arr[11]+', cf_su38d='+arr[12]+', cf_su39b='+arr[13]+', cf_su39f='+arr[14]+', cf_su39h='+arr[15]+', cf_su39e='+arr[16]+', cf_su38b='+arr[17]+', cf_sv22='+arr[18]+']'; 
	                
	                $("#cupn").val(arr[19]);
					
	                if(document.getElementById('cupn_showvar').value == 'N')
		                document.getElementById('equations').style.display = 'none';
	               
	           		//$("#cupn").val(msg);
	           		//addRow_att('cpn_list',msg,true);
	           		addRow_att('cpn_list',arr[19],true);
                }
                else if(msg1.substring(0,1) == 'S')
                {
                	$("#cupn").val(2);
                	addRow_att('cpn_list',2,true);
                }
            }
        },
    });  
    return false;
}
//end - Added by Vidhya - Sep 2017

</script>
    <div id="frm_display">
        <div id="tabs">
            <ul>
                <li class="active"><a href="#tabs-1">&nbsp;Registration&nbsp;</a></li>
                <li><a href="#tabs-2">&nbsp;Biometric Reference&nbsp;</a></li>
                <li><a href="#tabs-3">&nbsp;Coupon 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-1">
                    <div class="questionrow">
                        <div class="question">Survey</div>
                        <div class="answer">
                            <input type="hidden" name="id" id="id" value="<?php echo $id; ?>" />
                            <input type="hidden" name="tab_id" id="tab_id" value="" />
                            <input type="hidden" name="dt_fmt" id="dt_fmt" value="<?php echo DT_FMT; ?>" />
                            <input type="hidden" name="coupn_fxd" id="coupn_fxd" value="<?php echo COUPONFXD; ?>" />
                            <input type="hidden" name="survey_id" id="survey_id" value="<?php echo $survey_id; ?>" />
                           
                            <?php
                            date_default_timezone_set('Asia/Calcutta');
							echo $sur_title;
                            // $common->dropdown('sur_code', 'sur_title', 'custom_survey_master', '', 'sur_title', 'survey_id', $survey_id, 'class="required"');
                            ?>
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Location</div>
                        <div class="answer">
                            <input type="hidden" name="location" id="location" value="<?php echo $location; ?>" />
                            <?php
							echo $loc_title;
                            // $common->dropdown('loc_code', 'loc_name', 'custom_location', '', 'loc_name', 'location_sel', $location, 'disabled');
                            ?>
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow" id="participant_div">
                        <div class="question">Participant ID</div>
                        <div class="answer">
                  <?php echo $participant_id; ?>

			

                            <input type="hidden" name="participant_id" id="participant_id" value="<?php echo $participant_id; ?>" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Coupon Code</div>
                        <div class="answer">
                            <?php echo $cupn_cde; ?>
                            <input type="hidden" name="cupn_cde" id="cupn_cde" value="<?php echo $cupn_cde; ?>" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Recruitment Date</div>
                        <div class="answer">
                            <?php
                            echo '<span id="dor_span">' . $dor . '</span>';
                            ?>
                            <input type="hidden" name="dor" id="dor" value="<?php echo $dor; ?>" readonly="readonly" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Participant Type</div>
                        <div class="answer">
                            <select name="location_type" id="location_type">
                                <option value="">Select</option>
                                <option value="S">Seed</option>
                                <option value="W">Recruit</option>
                            </select>
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Age</div>
                        <div class="answer">
                            <input type="text" name="age" id="age" value="<?php echo $age; ?>" onblur="return CalYearfrmAge(this.value, '#dob'), enb_div(this.value);" maxlength="3" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow" id="dob_div" style="display: none;">
                        <div class="question">Date of Birth</div>
                        <div class="answer">
                            <input type="text" name="dob" id="dob" value="<?php echo $dob; ?>" readonly="readonly" />
                            <script>
                                $(function() {
                                    $('#dob').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'
                                    });
                                });
                            </script>
                            <!--<a style="cursor: pointer;" onclick="return showCalendar(this,'dob', '<?php echo DT_FRMT; ?>');"><img src="includes/images/cal.gif" border="0"/></a>-->
                        </div>
                    </div>
                    <div class="clear_form" id="dob_clean_div" style="display: none;">
                    </div>
                    <div class="questionrow">
                        <div class="question">Gender</div>
                        <div class="answer">
							<?php $common->dropdown('gen_code', 'gen_name', 'custom_gender_master', '', 'gen_name', 'sex', $sex, ''); ?>
                            <!--<select name="sex" id="sex">
                                <option value="">Select</option>
                                <option value="1">Male</option>
                                <option value="2">Female</option>
                                <option value="3">Hijrah / Transgender</option>
                            </select>-->
                        </div>
                    </div>
                    <div class="clear_form" style="display: none;">
                    </div>
                    <div class="questionrow" style="display: none;">
                        <div class="question">Network size</div>
                        <div class="answer">
                            <input type="text" name="ntwrk_sze" id="ntwrk_sze" value="<?php echo $ntwrk_sze; ?>" onkeyup="return acceptDigits(this);" />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div style="padding: 5px;" align="center">
                            <?php
                                if($mode == 'edit')
                                    echo '<input type="submit" name="Submit" value="Submit" />';
                                else
                                    echo '<input type="submit" name="Submit" value="Next" />';
                            ?>
                        </div>
                    </div>
                </div>
                <div id="tabs-2">
                    <div class="questionrow">
                        <div class="question">Particpant ID</div>
                        <div class="answer">
							<?php echo $participant_id; ?>
                            <input type="hidden" name="partcpnt_id2" id="partcpnt_id2" value="<?php echo $participant_id; ?>" readonly />
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">Biometric Reference</div>
                        <div class="answer">
                            <input type="text" name="biometric_ref" id="biometric_ref" value="<?php echo $biometric_ref; ?>" />
                            <!--<textarea name="biometric_ref" id="biometric_ref"><?php //echo $biometric_ref; ?></textarea>
                            <select name="biometric_ref" id="biometric_ref">
                                <option value="">Select</option>
                                <option value="1">Yes</option>
                                <option value="0">No</option>
                            </select>-->
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div style="padding: 5px;" align="center">
                            <?php
                                if($mode == 'edit')
                                    echo '<input type="submit" name="Submit" value="Submit" />';
                                else
                                    echo '<input type="submit" name="Submit" value="Next" />';
                            ?>
                        </div>
                    </div>
                </div>
                <div id="tabs-3">
                <input type="hidden" name="survey_comp_dt" id="survey_comp_dt" value="<?php echo $survey_comp_dt ?>" />
                <input type="hidden" name="survey_tbl" id="survey_tbl" value="<?php echo $surveytable1 ?>" />
                <input type="hidden" name="pcolumn" id="pcolumn" value="<?php echo $p_column1 ?>" />
                <input type="hidden" name="lab_done" id="lab_done" value="<?php echo $lab_done ?>" />
                    <div class="questionrow">
                        <div class="question">Participant ID</div>
                        <div class="answer">
<span><?php echo $participant_id; ?></span>
		<?php 
		if($cupn_stdarm == 'N')
		{
		if(trim($location_type) == 'W') { 
                            ?>
			<span>
<input type="button" name="check coupon" value="Check Coupons" id="check_Coupons" onclick="javascript:checkCoupons('<?php echo $survey_id; ?>','<?php echo $participant_id ?>')" />
			</span>
			<?php }
		}
                ?>
                <input type="hidden" name="partcpnt_id" id="partcpnt_id" value="<?php echo $participant_id; ?>" readonly />
                 <input type="hidden" name="cupn_showvar" id="cupn_showvar" value="<?php echo $cupn_showvar ?>" />
                 <input type="hidden" name="cupn_stdarm" id="cupn_stdarm" value="<?php echo $cupn_stdarm ?>" />
                 
                        </div>
                    </div>
                    <div id="equations"></div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow">
                        <div class="question">No of Coupons</div>
						<?php
							if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "")
							{
								?>
								<div class="answer">
									<input type="hidden" name="no_cupn" id="no_cupn" value="<?php echo $cupn; ?>" readonly />
									<!--<input type="text" name="cupn" id="cupn" value="<?php //echo $cupn; ?>" onkeyup="return acceptDigits(this), addRow_att('cpn_list', this.value, true);" onblur="return addRow_att('cpn_list', this.value, false);" />-->
									<input type="text"  name="cupn" id="cupn" readonly value="<?php echo $cupn; ?>" onkeyup="return acceptDigits(this);"  onblur="return addRow_att('cpn_list', this.value, false);" />
								</div>
								<?php
							}
							else
							{
								?>
								<div class="answer">
									<input type="hidden" name="no_cupn" id="no_cupn" value="<?php echo $cupn; ?>" readonly />
									<!--<input type="text" name="cupn" id="cupn" value="<?php //echo $cupn; ?>" onkeyup="return acceptDigits(this), addRow_att('cpn_list', this.value, true);" onblur="return addRow_att('cpn_list', this.value, false);" />-->
									<input type="text"  name="cupn" id="cupn" readonly value="<?php echo $cupn; ?>" onkeyup="return acceptDigits(this);" onblur="return addRow_att('cpn_list', this.value, true);" />
								</div>
								<?php
							}
						?>
                    </div>
                    <div class="clear_form">
                    </div>
                    <?php
                        if(count($rec) != 0)
						{
							for($i=0; $i<$cupn; $i++)
							{
								$coupn_part_id = $rec[$i]['coupn_participant_id'];
								
								if($coupn_part_id == "")
									$coupn_part_id = "";
									// $coupn_part_id = $location;
								?>
								<div class="questionrow" id="cpn_div_<?php echo ($i+1); ?>">
									<div class="question">Coupons Code <?php echo ($i+1); ?></div>
									<div class="answer">
										<!--<input type="text" name="cupn_lst[]" id="cupn_lst_<?php // echo $i; ?>" value="<?php // echo $coupn_part_id; ?>" maxlength="6" onKeydown="return keyRestricted(this, event, document.recuirtment.location.value.length, false);" onKeyup="return keyRestricted(this, event, document.recuirtment.location.value.length, true);" />-->
										<input type="text" name="cupn_lst[]" id="cupn_lst_<?php echo $i; ?>" value="<?php echo $coupn_part_id; ?>" maxlength="6" />
									</div>
								</div>
								<div class="clear_form">
								</div>
								<?php
							}
						}
                        else
                        {
							for($i=0; $i<$cupn; $i++)
							{
								// $coupn_part_id = $location;
								?>
								<div class="questionrow" id="cpn_div_<?php echo ($i+1); ?>">
									<div class="question">Coupons Code <?php echo ($i+1); ?></div>
									<div class="answer">
										<!--<input type="text" name="cupn_lst[]" id="cupn_lst_<?php // echo $i; ?>" value="<?php // echo $coupn_part_id; ?>" maxlength="6" onKeydown="return keyRestricted(this, event, document.recuirtment.location.value.length, false);" onKeyup="return keyRestricted(this, event, document.recuirtment.location.value.length, true);" />-->
										<input type="text" name="cupn_lst[]" id="cupn_lst_<?php echo $i; ?>" value="<?php echo $coupn_part_id; ?>" maxlength="6" />
									</div>
								</div>
								<div class="clear_form">
								</div>
								<?php
							}
                        }
                    ?>
                    <div id="cpn_list">
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow" id="val_iss_div" >
                        <div class="question">Coupon Issue Date</div>
                        <div class="answer">
							<?php
								if($cupn_dt == "")
									$cupn_dt = str_replace("%", "", date(DT_FRMT));
							?>
                            <input type="text" name="cupn_dt" id="cupn_dt" value="<?php echo $cupn_dt; ?>" readonly="readonly" />
                            <script>
                                /*$(function() {
                                    $('#cupn_dt').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'
                                    });
                                });*/
                            </script>
                            <!--<a style="cursor: pointer;" onclick="return showCalendar(this,'cupn_dt', '<?php echo DT_FRMT; ?>');"><img src="includes/images/cal.gif" border="0"/></a>-->
                        </div>
                    </div>
                    <div class="clear_form">
                    </div>
                    <div class="questionrow" id="val_prd_div">
                        <div class="question">Coupon Validity Period</div>
                        <div class="answer">
                            <input type="text" name="cupn_prd" id="cupn_prd" value="<?php echo $cupn_prd; ?>" size="7" onkeyup="return date_cal($('#cupn_dt').val(), $('#cupn_prd').val(), $('#prd_type').val(), 0, '<?php echo DT_FMT; ?>');" />
                            <select name="prd_type" id="prd_type" onchange="return date_cal($('#cupn_dt').val(), $('#cupn_prd').val(), $('#prd_type').val(), 0, '<?php echo DT_FMT; ?>');">
                                <option value="">Select</option>
                                <option value="1">Days</option>
                                <option value="2">Weeks</option>
                                <option value="3">Month</option>
                                <option value="4">Year</option>
                            </select>
                        </div>
                    </div>
                    <div class="clear_form" id="val_prd_clear">
                    </div>
                    <div class="questionrow" id="val_dt_div">
                        <div class="question">Coupon Validity Date</div>
                        <div class="answer">
                            <input type="text" name="cupn_vld_dt" id="cupn_vld_dt" value="<?php echo $cupn_vld_dt; ?>" readonly="readonly" onfocus="return date_cal($('#cupn_dt').val(), $('#cupn_prd').val(), $('#prd_type').val(), 0, '<?php echo DT_FMT; ?>');" />
                        </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>
<script>
    // select_checked('sex', '<?php //echo $sex; ?>', "");
    select_checked('location_type', '<?php echo $location_type; ?>', "");
    // select_checked('biometric_ref', '<?php echo $biometric_ref; ?>', "");
    select_checked('prd_type', '<?php echo $prd_type; ?>', "");
	<?php if($coupon == "Y") { ?>
		<?php if($no_of_coupon_fxd == "Y") { ?>
			$('#cupn').attr("readonly", true);
		<?php } ?>
		<?php if($cupn_prd_fxd == "Y") { ?>
			$("#val_prd_div").hide();
			$("#val_prd_clear").hide();
			date_cal($('#cupn_dt').val(), $('#cupn_prd').val(), $('#prd_type').val(), 0, '<?php echo DT_FMT; ?>');
		<?php } ?>
	<?php } else { ?>
        $("#tabs").tabs({disabled: [2]});
	<?php } ?>
</script>
<?php
	echo '<script>
				function old_val()
				{
					';
					if(count($rec) != 0)
					{
						for($i=0; $i<$cupn; $i++)
						{
							$coupn_part_id = $rec[$i]["coupn_participant_id"];
							
							if($coupn_part_id == "")
								$coupn_part_id = "";
								// $coupn_part_id = $location;
							
							//echo 'alert("'.$coupn_part_id.'");';
							echo '$("#cupn_lst_'.$i.'").val("'.$coupn_part_id.'");';
						}
					}
				echo '}
		  </script>';
?>