   
   //*************************************
   
   function SubmitRegistation(Name, Mobile, Email, State, pwd) {
    var input_value = '';

    if (Name.trim() == '' || Mobile.trim() == '' || Email.trim() == '' || State.trim() == '' || pwd.trim() == '') {
           alert('all fields are required');
           return;
       }	   
       input_value = '{"Name": "' + Name.trim() + '","Mobile": "' + Mobile.trim() + '","Email": "' + Email.trim() + '","State": "' + State.trim() + '","Password": "' + pwd.trim() + '"}';
	   
	   $("#btnreg").hide();		
		$("#lblMsg").html("<span style='color:red'>Please wait...</span>");
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: URLRegistrationUser,
           data: input_value,
           dataType: "json",
           processData: false,
           success: function (data) {
               var v = data.RegistrationUserResult
               if (v.Title == 'Success') {				  
                   //window.location = "result.html?id=" + v.message;
				   alert("Registration Succesfully");
				    $("#btnreg").show();
					$("#lblMsg").html("");	
					
					
				   window.setTimeout(function(){
						  //window.location.href = "login.html";
						  window.location = "userdashboard.html?id=" + v.Email+"&UserName="+btoa(v.Name);
					}, 2000);
					
					
               }
               else {
                   alert(v.message);
				    $("#btnreg").show();
					$("#lblMsg").html("");
               }
           },
           error: function (result) {
               alert("Failed to connect Server,Please try again later.");
                $("#btnreg").show();
					$("#lblMsg").html("");
           }
       });
   }
   
    function LoginUser(Email,Pass) {
    var input_value = '';

    if (Email.trim() == '' || Pass.trim() == '') {
           alert('all fields are required');
           return;
       }	   
       input_value = '{"Email": "' + Email.trim() + '","Password": "' + Pass.trim() + '"}';
	   
	   $("#btnlg").hide();		
		$("#lblMsg").html("<span style='color:red'>Please wait...</span>");
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: URLLoginUser,
           data: input_value,
           dataType: "json",
           processData: false,
           success: function (data) {
               var v = data.LoginUserResult
               if (v.Title == 'Success') {
                    $("#btnlg").show();
					$("#lblMsg").html("");		
					if(v.message=="Admin")
						window.location = "admin.html?id=" + v.Email+"&UserName="+btoa(v.Name);
					else
                       window.location = "userdashboard.html?id=" + v.Email+"&UserName="+btoa(v.Name);	
                    				   
               }
               else {
                   alert("Invalid Email or Password !");
				    $("#btnlg").show();
					$("#lblMsg").html("");
               }
           },
           error: function (result) {
			                       $("#btnlg").show();
					$("#lblMsg").html("");				   
               alert("Failed to connect Server,Please try again later.");
           }
       });
   }
   
    function UserQAnswer(id,optiondetails) {
    var input_value = '';

    if (id.trim() == '' || optiondetails.trim() == '') {
           alert('server is down');
           return;
       }	   
       input_value = '{"userid": "' + id.trim() + '","OptionDetails": "' + optiondetails.trim() + '"}';
	   
	   $("#btnlg").hide();		
		$("#lblMsg").html("<span style='color:red'>Please wait...</span>");
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: URLQAnswer,
           data: input_value,
           dataType: "json",
           processData: false,
           success: function (data) {
               var v = data.QAnswerResult
               if (v.Title == 'Success') {				  
                  
					alert(v.message);
					document.getElementById('divstart').style.display = 'block';
                    document.getElementById('divquest').style.display = 'none';	
                    $("#btnlg").hide();
					$("#lblMsg").html("");	
                    StartQuestion(id);					
               }
               else {
                    alert(v.message);
				    $("#btnlg").show();
					$("#lblMsg").html("");
               }
           },
           error: function (result) {
			   $("#btnlg").show();
					$("#lblMsg").html("");
               alert("Failed to connect Server,Please try again later.");
           }
       });
   }
   
   function StartQuestion(id) {
    var input_value = '';
    var list="";
    if (id.trim() == '') {
           alert('insufficient input!');
           return;
       }	   
       input_value = '{"userid": "' + id.trim() + '"}';
	   
	   $("#btnst").hide();		
		$("#lblstMsg").html("<span style='color:red'>Please wait...</span>");
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: URLcheckuserAttemtOrNot,
           data: input_value,
           dataType: "json",
           processData: false,
           success: function (data) {
               var v = data.checkuserAttemtOrNotResult
               if (v.Title == 'Success') {	
                   
                    $("#btnst").show();
					$("#lblstMsg").html("");
					document.getElementById('divstart').style.display = 'none';
                    document.getElementById('divquest').style.display = 'block';			
					
               }
			   else if (v.Title == 'Result') {	
                    $("#btnst").hide();
					$("#lblstMsg").html("");
					document.getElementById('divstart').style.display = 'block';
                    document.getElementById('divquest').style.display = 'none';	
					var pecentage=(parseInt(v.message)/10)*100;
					
                    //
					 list += '<div class="contact-name">';
                    list += '<div class="col-md-12" style="border-radius:4px;margin-bottom:2px;padding:2px 5px;border:1px solid #BFC264;font-family:Verdana;line-height: 110%;">';					
					list += '<h3>Result</h3>';
                    list += '<ul style="list-style:none;padding:0px;margin-bottom:5px;">';                                  
                    list += '<li style="color:#615a5a;font-size:14px;" >Total Question <span style="color:#000;;font-size:14px">' + 10 + '</span>';
                    list += '<li style="color:#615a5a;font-size:14px;" >Correct Answer : <span style="color:#000;;font-size:14px">' + v.message + '</span></li>';
					
                    list += '<li style="color:#615a5a;font-size:14px;" >Result : <span style="color:#000;;font-size:14px">' + pecentage + ' %</span>';
                    list += '<br/><br/><li style="color:#615a5a;font-size:14px;" >';
                     //list += '<a href="certificate.html?id=' + urlParams["id"] + '" window.open(this.href);return false; style="color:blue">Click Here</a>';
					list += '<a href="certificate.html?id='+urlParams["id"]+'" class="btn_1" target="_blank">Download Certificate</a>';
                    list += '</li>';
                    
                    list += '</ul>';
                    list += '</div>';
                    list += '</div>';	
                      //	
               }
               else {
                   alert(v.message);
				    $("#btnst").show();
					$("#lblstMsg").html("");
					document.getElementById('divstart').style.display = 'block';
                    document.getElementById('divquest').style.display = 'none';						
               }
			   $("#tabresult").html(list);
           },
           error: function (result) {
			        $("#btnst").show();
					$("#lblstMsg").html("");
               alert("Failed to connect Server,Please try again later.");
           }
       });
   }
   
    function vwcert(id) {
    var input_value = '';
    var list="";
    if (id.trim() == '') {
           alert('insufficient input!');
           return;
       }	   
       input_value = '{"userid": "' + id.trim() + '"}';
	   
		$("#lblMsg").html("<span style='color:red'>Please wait...</span>");
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: URLCertifiateDetails,
           data: input_value,
           dataType: "json",
           processData: false,
           success: function (data) {
               var v = data.CertifiateDetailsResult
               if (v.Title == 'Success') {	                   
					$("#lblMsg").html("");					
                    document.getElementById('pnlPerson').style.display = 'block';
					document.getElementById('div2').style.display = 'block';
                    $("#lbl_firstname").html(v.Name);	
                    $("#lbl_certificatenumber").html(v.certid);		
                    $("#lbl_awardeddate").html(v.awddate);
                    $('#imgqrcode').attr("src",v.qrcode);					
					
               }			   
               else {
                   alert(v.message);
					$("#lblMsg").html("");
                    document.getElementById('pnlPerson').style.display = 'none';	
                    document.getElementById('div2').style.display = 'none';					
               }
			
           },
           error: function (result) {			       
					$("#lblMsg").html("");
               alert("Failed to connect Server,Please try again later.");
           }
       });
   }
   
   //admin
   function vwuserdetails(id) {
    var input_value = '';
    var list="";
    if (id.trim() == '') {
           alert('insufficient input!');
           return;
       }	   
       input_value = '{"userid": "' + id.trim() + '"}';
	   
		$("#lblstMsg").html("<span style='color:red'>Loading , Please wait...</span>");
       $.ajax({
           type: "POST",
           contentType: "application/json; charset=utf-8",
           url: URLGetVwUser,
           data: input_value,
           dataType: "json",
           processData: false,
           success: function (data) {
               var v = data.GetVwUserResult
			   $("#lblstMsg").html("");
                if (v.length > 0) {
				            
				            list += '<thead>';
				            list += '<tr><th>Sl No.</th> <th>Name</th> <th>Email</th> <th>Phone</th> <th>State</th><th>Regd. Date</th> <th>Certificate</th> </tr>';
				            list += '</thead>';
							list += '<tbody>';
				            for (var i = 0; i < v.length; i++) {
				                list += '<tr > ';
				                list += '<td align="center">' + (i + 1) + '</td>';
				                list += '<td align="left">' + v[i].Name + '</td>';
				                list += '<td align="left">' + v[i].Email + '</td>';
				                list += '<td align="left">' + v[i].Mobile + '</td>';
				                list += '<td align="left">' + v[i].State + '</td>';
				                list += '<td align="left">' + v[i].regdt + '</td>';
								if(v[i].awddate!="")
				                  list += '<td align="center"><a href="certificate.html?id='+v[i].userid+'" class="btn_1 flat green" target="_blank" style="padding: 5px 7px;">Download</a></td>';	
                                else
	                              list += '<td align="center"></td>';				               
				                list += '</tr>';
				            }
							list += '</tbody>';
				}
				else
				{
					$("#lblstMsg").html("<span style='color:red'>No Record Available</span>")
				}
			   $("#tabresult").html(list);
			   $('#tabresult').dataTable();
           },
           error: function (result) {			        
					$("#lblstMsg").html("");
               alert("Failed to connect Server,Please try again later.");
           }
       });
   }