var URL = window.location.href;
function LoadingMessage(msg1, msg2)
{
    $('.loader').show();
	//$('#dvLoadingmsg').show();
	$('#spn1msg').html(msg1);
	$('#spn2msg').html(msg2);
	$('.hls-bg').show();
}
function CloseHlsPopup()
{
	$('.hls-bg').hide();
	$('.hls-wrap').hide();
	$('.loader').hide();
	//$('#dvLoadingmsg').hide();
}
function OpenProductTab(_this, tab) {	
	$('a[group=ProductTab]').each(function () {
		$(this).removeClass('active');
	});
	$(_this).addClass('active');
	$('div[group=ProudctTabDiv]').each(function () {
		$(this).css('display', 'none');
	});
	$('#div' + tab + 'Tab').css('display', '');	
}
function BindDropDowns()
{
	$.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt)
		{
			if(dt.d > 0)
			{
				$.ajax({
					type: "POST",
					url: URL + "/BindDropDowns",
					data: '{}',
					contentType: "application/json;charset=utf-8",
					dataType: "json",
					success: function (data)
					{
						var dt = $.parseJSON(data.d);
						$('#drpDepartment').html(dt.DepartmentRes);
						$('#drpClass').html(dt.ClassRes);
						$('#drpStudentBatchStatus').html(dt.EnrollStatusRes);
						$('#drpStatus').html(dt.StatusRes);
						$('#drpDivision').html(dt.DivisionRes);
						$('#drpExam').html(dt.ExamRes);
						$('#castecategorychkdropdown').html(dt.castcategorychklist);
						$("#castecategorychkdropdown").multiSelect();
						//$('#drpAvailableFields').html(dt.GeneralExamAvailRes);
					    //$('#drpAvailableFieldsO').html(dt.GeneralExamAvailRes);
						$('#drpAvailableFields').html(dt.GeneralExamAvailRes.replace('<option value="GR No">GR No</option>', ""));
						$('#drpAvailableFieldsO').html(dt.GeneralExamAvailRes.replace('<option value="GR No">GR No</option>', ""));
						$('#drpSavedReport').html(dt.SavedReportList1);
						if(dt.ExamReportList != '')						
							$('#tblReportList').html(dt.ExamReportList);
						else
							$('#tblReportList').html('<tr><td colspan="5">No Records Available</td></tr>');
						window.setTimeout(function() { CloseHlsPopup(); },500);
					},
					error: function (xhr, status, error)
					{
						var err = eval("(" + xhr.responseText + ")");
						console.log(err.Message);
					}
				});
			}
			else
			{
				CloseHlsPopup();
				LoadingMessage('Your session has expired, we are redirecting to login page','<b>Please Wait ...</b>');
				window.setTimeout(function(){ window.location = '/Pages/BaseFramework/Security/Login.aspx'; },2000);
			}
        },
		error: function (xhr, status, error)
		{
			var err = eval("(" + xhr.responseText + ")");
			console.log(err.Message);
		}
    });
}
function LoadDivision(cobj)
{
    $('#chkIssubject').prop('checked', false);
	$.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt)
		{
			if(dt.d > 0)
			{
				var obj = {
					"ClassId": $(cobj).val()
				};
				$.ajax({
					type: "POST",
					url: URL + "/LoadDivision",
					data: JSON.stringify(obj),
					contentType: "application/json;charset=utf-8",
					dataType: "json",
					success: function (data)
					{
						var dt = $.parseJSON(data.d);
						$('#drpDivision').html(dt.DivisionRes);
					},
					error: function (xhr, status, error)
					{
						var err = eval("(" + xhr.responseText + ")");
						console.log(err.Message);
					}
				});
                $.ajax({
			        type: "POST",
			        url: URL + "/BindDropDowns",
			        data: '{}',
			        contentType: "application/json;charset=utf-8",
			        dataType: "json",
			            success: function (data)
			            {
                            var dt = $.parseJSON(data.d);
						
                            $('#drpAvailableFields').html(dt.GeneralExamAvailRes.replace('<option value="GR No">GR No</option>', ""));
                            $('#drpAvailableFieldsO').html(dt.GeneralExamAvailRes.replace('<option value="GR No">GR No</option>', ""));
                           
						window.setTimeout(function () {
                            CloseHlsPopup(); }, 500);
						},
						error: function (xhr, status, error)
						{
                                var err = eval("(" +xhr.responseText + ")");
						console.log(err.Message);
						}
			    });

			}
			else
			{
				CloseHlsPopup();
				LoadingMessage('Your session has expired, we are redirecting to login page','<b>Please Wait ...</b>');
				window.setTimeout(function(){ window.location = '/Pages/BaseFramework/Security/Login.aspx'; },2000);
			}
        },
		error: function (xhr, status, error)
		{
			var err = eval("(" + xhr.responseText + ")");
			console.log(err.Message);
		}
    });
}

function OnExamChange(cobj) {
    $('#chkIssubject').prop('checked', false);

    $.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt) {
			if(dt.d > 0)
            {
				$.ajax({
                type: "POST",
                url: URL + "/BindDropDowns",
                data: '{}',
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                success: function(data)
                {
                    var dt = $.parseJSON(data.d);
               
				    $('#drpAvailableFields').html(dt.GeneralExamAvailRes.replace('<option value="GR No">GR No</option>', ""));
				    $('#drpAvailableFieldsO').html(dt.GeneralExamAvailRes.replace('<option value="GR No">GR No</option>', ""));
						
			        window.setTimeout(function() { CloseHlsPopup(); }, 500);
			    },
				error: function (xhr, status, error)
				{
                    var err = eval("(" +xhr.responseText + ")");
                    console.log(err.Message);
			    }
			    });
			 }
            else
			{
				CloseHlsPopup();
				LoadingMessage('Your session has expired, we are redirecting to login page', '<b>Please Wait ...</b>');
				window.setTimeout(function() {
                    window.location = '/Pages/BaseFramework/Security/Login.aspx';
				}, 2000);
			}
        },
        error: function (xhr, status, error)
            {
            var err = eval("(" +xhr.responseText + ")");
            console.log(err.Message);
            }
    });
}
function ShowHideAndBind(cobj, flag)
{
	if($(cobj).is(':checked'))
	{
		$(cobj).parent().next('div').show();
		$(cobj).parent().next('div').html('&nbsp;<img src="../../../Images/loading-ajax.gif" />' + '&nbsp; Loading....');
		BindValues(cobj, flag);
	}
	else
	{
		$(cobj).parent().next('div').hide();
		$(cobj).parent().next('div').html('');
	}
}
function BindValues(cobj, flag)
{
	$.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt)
		{
			if(dt.d > 0)
			{
				var ClassStr = '';
				if($('#chkClass').is(':checked'))
				{
					$('#dvClass').children('input[type=checkbox]').each(function(index, element) {
                        if($(this).is(':checked'))
						{
							ClassStr = ClassStr + $(this).attr('attrid') + ',';
						}
                    });
				}
				var obj = {
					"flag": flag,
					"ClassStr": ClassStr
				};
				$.ajax({
					type: "POST",
					url: URL + "/BindValues",
					data: JSON.stringify(obj),
					contentType: "application/json;charset=utf-8",
					dataType: "json",
					success: function (data)
					{
						var datas = $.parseJSON(data.d);
						if(datas.Result != '')
						{
							$(cobj).parent().next('div').html(datas.Result);
							$(cobj).parent().next('div').css('border','1px solid Silver');
							$(cobj).parent().next('div').slimScroll({ height: '100px' });
						}
						else
						{
							$(cobj).parent().next('div').html('&nbsp;No Data');
						}
					},
					error: function (xhr, status, error)
					{
						var err = eval("(" + xhr.responseText + ")");
						console.log(err.Message);
					}
				});
			}
			else
			{
				CloseHlsPopup();
				LoadingMessage('Your session has expired, we are redirecting to login page','<b>Please Wait ...</b>');
				window.setTimeout(function(){ window.location = '/Pages/BaseFramework/Security/Login.aspx'; },2000);
			}
        },
		error: function (xhr, status, error)
		{
			var err = eval("(" + xhr.responseText + ")");
			console.log(err.Message);
		}
    });
}
function ShowHideSaveReport(obj)
{
	if($(obj).is(':checked'))
	{
		$('div[group=dvreportgroup]').show();
	}
	else
	{
		$('div[group=dvreportgroup]').hide();
	}
}
function AppendSelected(flag)
{
	if(flag == 1)
	{
		if ($("#drpAvailableFields option:selected").length > 0){
			if($("#drpAvailableFields option:selected").length == 1)
			{
				var option = new Option($('#drpAvailableFields').val(), "value");				
				var dup = false;			
				$('#drpSelectedFields option').each(function(i, selected){				
					if($(selected).text() == $('#drpAvailableFields').val())
					{
						dup = true;
					}				
				});
				if(dup == false)
				{
					$('#drpSelectedFields').append(option);				
				}
			}
			else
			{
				$("#drpAvailableFields option:selected").each(function(index, element) {
					var dup = false;
					var sTexts = $(this).val();			
					$('#drpSelectedFields option').each(function(i, selected){				
						if($(selected).text() == sTexts)
						{
							dup = true;
						}				
					});
					if(dup == false)
					{
						 var option = new Option(sTexts, "value");
						 $('#drpSelectedFields').append(option);
					}	
                });
			}
		}
		else
		{
			alert('Please select at least one value from list box');
		}
	}
	else
	{
		if ($("#drpSelectedFields option:selected").length > 0){			
			$("#drpSelectedFields option:selected").remove();
		}
		else
		{
			alert('Please select at least one value from list box');
		}
	}
	if ($("#drpSelectedFields option").length > 0){
		$('#btnGenerateReport').attr('onclick','GenerateReport();');
	}
	else
	{
		$('#btnGenerateReport').removeAttr('onclick');
	}
}
function UpDownSelected(flag)
{
	if ($("#drpSelectedFields option:selected").length > 0){
		var $op = $('#drpSelectedFields option:selected');
		if($op.length){
			(flag == '1') ? $op.first().prev().before($op) : $op.last().next().after($op);
		}
	}
}
function AppendSelectedO(flag)
{
	if(flag == 1)
	{
		if ($("#drpAvailableFieldsO option:selected").length > 0){
			if($("#drpAvailableFieldsO option:selected").length == 1)
			{
				var option = new Option($('#drpAvailableFieldsO').val(), "value");				
				var dup = false;			
				$('#drpSelectedFieldsO option').each(function(i, selected){				
					if($(selected).text() == $('#drpAvailableFields').val())
					{
						dup = true;
					}				
				});
				if(dup == false)
				{
					$('#drpSelectedFieldsO').append(option);				
				}
			}
			else
			{
				$("#drpAvailableFieldsO option:selected").each(function(index, element) {
					var dup = false;
					var sTexts = $(this).val();			
					$('#drpSelectedFieldsO option').each(function(i, selected){				
						if($(selected).text() == sTexts)
						{
							dup = true;
						}				
					});
					if(dup == false)
					{
						 var option = new Option(sTexts, "value");
						 $('#drpSelectedFieldsO').append(option);
					}	
                });
			}
		}
		else
		{
			alert('Please select at least one value from list box');
		}
	}
	else
	{
		if ($("#drpSelectedFieldsO option:selected").length > 0){			
			$("#drpSelectedFieldsO option:selected").remove();
		}
		else
		{
			alert('Please select at least one value from list box');
		}
	}
}
function UpDownSelectedO(flag)
{
	if ($("#drpSelectedFieldsO option:selected").length > 0){
		var $op = $('#drpSelectedFieldsO option:selected');
		if($op.length){
			(flag == '1') ? $op.first().prev().before($op) : $op.last().next().after($op);
		}
	}
}
function SearchExams()
{
    
	$.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt)
		{
			if(dt.d > 0)
			{
			    //debugger;
				LoadingMessage('Loading Details','<b>Please Wait ...</b>');
				var OrderByStr = '', ClassStr = '', ExamStr = '', CastCatStr = '';
				$("#drpSelectedFieldsO option").each(function(index, element) {
					OrderByStr = OrderByStr + $(this).text() + ',';
				});
				$('#castecategorychkdropdown option:selected').each(function (i, sel) {
				    CastCatStr = CastCatStr + $(sel).val() + ',';
				});
				if($('#chkClass').is(':checked'))
				{
					$('#dvClass').children('input[type=checkbox]').each(function(index, element) {
                        if($(this).is(':checked'))
						{
							ClassStr = ClassStr + $(this).attr('attrid') + ',';
						}
                    });
				}
				if($('#chkExam').is(':checked'))
				{
					$('#dvExam').children('input[type=checkbox]').each(function(index, element) {
                        if($(this).is(':checked'))
						{
							ExamStr = ExamStr + $(this).attr('attrid') + ',';
						}
                    });
				}
				if ($('#chkCastCategory').is(':checked')) {
				    $('#dvCastCategory').children('input[type=checkbox]').each(function (index, element) {
				        if ($(this).is(':checked')) {
				            CastCatStr = CastCatStr + $(this).attr('attrid') + ',';
				        }
				    });
				}
				var isSaveReport = $('#chkSaveReport').is(':checked') ? 1 : 0;
				var isCommon = $('#chkIsCommon').is(':checked') ? 1 : 0;
				var isCommonForOrg = $('#chkIsCommonForOrg').is(':checked') ? 1 : 0;
				var obj = {
					"DepartmentId": $('#drpDepartment').val(),
					"ClassId": $('#drpClass').val(),
					"DivisionId": $('#drpDivision').val(),
					"ExamId": $('#drpExam').val(),
					"IdNumber": $('#txtIdNo').val(),
					"FirstName": $('#txtFirstName').val(),
					"LastName": $('#txtLastName').val(),
					"StatusId": $('#drpStatus').val(),
					"FromMark": $('#txtFMark').val(),
					"ToMark": $('#txtTMark').val(),
					"FromGrade": $('#txtFGradePoint').val(),
					"ToGrade": $('#txtTGradePoint').val(),
					"FromRank": $('#txtFRankNumber').val(),
					"ToRank": $('#txtTRankNumber').val(),
					"FromPercentage": $('#txtFPercentage').val(),
					"ToPercentage": $('#txtTPercentage').val(),
					"FromPercentile": $('#txtFPercentile').val(),
					"ToPercentile": $('#txtTPercentile').val(),
					"Grade": $('#txtGrade').val(),										
					"OrderByStr": OrderByStr,
					"ClassStr": ClassStr,
					"ExamStr": ExamStr,
					"isSaveReport": isSaveReport,					
					"isCommon": isCommon,
					"isCommonForOrg": isCommonForOrg,
					"ReportName": $('#txtReportName').val(),
					"PageIndex": $('#hdnPageIndex').val(),
					"SavedReport": $('#drpSavedReport').val(),
					"CastCatStr": CastCatStr,
				};
				$.ajax({
					type: "POST",
					url: URL + "/SearchExams",
					data: JSON.stringify(obj),
					contentType: "application/json;charset=utf-8",
					dataType: "json",
					success: function (data)
					{
						var datas = $.parseJSON(data.d);
						if(datas.StudentList != '')
						{
						    debugger;
							$('#tblStudentList').html(datas.StudentList);
							var paging = datas.Paging.replace('../../Images/arrowRight.gif','../../../Images/arrowRight.gif');
							paging = paging.replace('../../Images/arrowLeft.gif','../../../Images/arrowLeft.gif');
							$('#pagging').html(paging);
							$('#lblTotalRecords').html('Total Records : ' + datas.TotalRecords + '&nbsp;&nbsp;&nbsp;&nbsp;');
						}
						else
						{
							$('#tblStudentList').html('<tr><td colspan="13">No Records Available</td></tr>');
						}
						window.setTimeout(function () { CloseHlsPopup(); },400);
					},
					error: function (xhr, status, error)
					{
						var err = eval("(" + xhr.responseText + ")");
						console.log(err.Message);
					}
				});
			}
			else
			{
				CloseHlsPopup();
				LoadingMessage('Your session has expired, we are redirecting to login page','<b>Please Wait ...</b>');
				window.setTimeout(function(){ window.location = '/Pages/BaseFramework/Security/Login.aspx'; },2000);
			}
        },
		error: function (xhr, status, error)
		{
			var err = eval("(" + xhr.responseText + ")");
			console.log(err.Message);
		}
    });
}
function ChangePage(pageindex)
{
	$('#hdnPageIndex').val(pageindex);
	SearchExams();
}
function GenerateReport()
{
    if ($("#drpSelectedFields option").length > 0 || parseInt($('#drpSavedReport').val()) != 0)
	{
		$.ajax({
			type: "POST",
			url: URL + "/GetSession",
			data: '{}',
			contentType: "application/json;charset=utf-8",
			dataType: "json",
			success: function (dt)
			{
				if(dt.d > 0)
				{
					LoadingMessage('Loading Details','<b>Please Wait ...</b>');
					var OrderByStr = '', ClassStr = '', ExamStr = '', CustomFields = '', CastCatStr = '';
					$("#drpSelectedFieldsO option").each(function(index, element) {
						OrderByStr = OrderByStr + $(this).text() + ',';
					});
					$("#drpSelectedFields option").each(function(index, element) {
						CustomFields = CustomFields + $(this).text() + ',';
					});
					$('#castecategorychkdropdown option:selected').each(function (i, sel) {
					    CastCatStr = CastCatStr + $(sel).val() + ',';
					});
					if($('#chkClass').is(':checked'))
					{
						$('#dvClass').children('input[type=checkbox]').each(function(index, element) {
							if($(this).is(':checked'))
							{
								ClassStr = ClassStr + $(this).attr('attrid') + ',';
							}
						});
					}
					if($('#chkExam').is(':checked'))
					{
						$('#dvExam').children('input[type=checkbox]').each(function(index, element) {
							if($(this).is(':checked'))
							{
								ExamStr = ExamStr + $(this).attr('attrid') + ',';
							}
						});
					}
					if ($('#chkCastCategory').is(':checked')) {
					    $('#dvCastCategory').children('input[type=checkbox]').each(function (index, element) {
					        if ($(this).is(':checked')) {
					            CastCatStr = CastCatStr + $(this).attr('attrid') + ',';
					        }
					    });
					}
					var isSaveReport = $('#chkSaveReport').is(':checked') ? 1 : 0;
					var isCommon = $('#chkIsCommon').is(':checked') ? 1 : 0;
					var isCommonForOrg = $('#chkIsCommonForOrg').is(':checked') ? 1 : 0;
					var obj = {
						"DepartmentId": $('#drpDepartment').val(),
						"ClassId": $('#drpClass').val(),
						"DivisionId": $('#drpDivision').val(),
						"ExamId": $('#drpExam').val(),
						"IdNumber": $('#txtIdNo').val(),
						"FirstName": $('#txtFirstName').val(),
						"LastName": $('#txtLastName').val(),
						"StatusId": $('#drpStatus').val(),
						"FromMark": $('#txtFMark').val(),
						"ToMark": $('#txtTMark').val(),
						"FromGrade": $('#txtFGradePoint').val(),
						"ToGrade": $('#txtTGradePoint').val(),
						"FromRank": $('#txtFRankNumber').val(),
						"ToRank": $('#txtTRankNumber').val(),
						"FromPercentage": $('#txtFPercentage').val(),
						"ToPercentage": $('#txtTPercentage').val(),
						"FromPercentile": $('#txtFPercentile').val(),
						"ToPercentile": $('#txtTPercentile').val(),
						"Grade": $('#txtGrade').val(),										
						"OrderByStr": OrderByStr,
						"CustomFields": CustomFields,						
						"ClassStr": ClassStr,
						"ExamStr": ExamStr,
						"isSaveReport": isSaveReport,					
						"isCommon": isCommon,
						"isCommonForOrg": isCommonForOrg,
						"ReportName": $('#txtReportName').val(),
						"PageIndex": $('#hdnPageIndex').val(),
						"SavedReport": $('#drpSavedReport').val(),
						"CastCatStr": CastCatStr,
					};
					$.ajax({
						type: "POST",
						url: URL + "/GenerateReport",
						data: JSON.stringify(obj),
						contentType: "application/json;charset=utf-8",
						dataType: "json",
						success: function (data)
						{
							$('#btnGenerate').click();
							window.setTimeout(function () { CloseHlsPopup(); },400);
						},
						error: function (xhr, status, error)
						{
							var err = eval("(" + xhr.responseText + ")");
							console.log(err.Message);
						}
					});
				}
				else
				{
					CloseHlsPopup();
					LoadingMessage('Your session has expired, we are redirecting to login page','<b>Please Wait ...</b>');
					window.setTimeout(function(){ window.location = '/Pages/BaseFramework/Security/Login.aspx'; },2000);
				}
			},
			error: function (xhr, status, error)
			{
				var err = eval("(" + xhr.responseText + ")");
				console.log(err.Message);
			}
		});
	}
	else
	{
		alert('select atleast one field in custom field');
	}
}
function DeleteReport(Id) {
    $.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt) {
            if (dt.d > 0) {
                var x = confirm('Do you want to delete?');
                if (x == true) {
                    LoadingMessage('Loading Details', '<b>Please Wait ...</b>');
                    var obj = {
                        "Id": Id
                    };
                    $.ajax({
                        type: "POST",
                        url: URL + "/DeleteReport",
                        data: JSON.stringify(obj),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            alert('Deleted successfully.... Please Refresh the Page');
                            CloseHlsPopup();
                        },
                        error: function (xhr, status, error) {
                            var err = eval("(" + xhr.responseText + ")");
                            console.log(err.Message);
                        }
                    });
                }
            }
            else {
                CloseHlsPopup();
                LoadingMessage('Your session has expired, we are redirecting to login page', '<b>Please Wait ...</b>');
                window.setTimeout(function () { window.location = '/Pages/BaseFramework/Security/Login.aspx'; }, 2000);
            }
        },
        error: function (xhr, status, error) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function ViewReport(Id, Title, ColumnName) {
    $.ajax({
        type: "POST",
        url: URL + "/GetSession",
        data: '{}',
        contentType: "application/json;charset=utf-8",
        dataType: "json",
        success: function (dt) {
            if (dt.d > 0) {
                var x = confirm('Do you want to Download?');
                if (x == true) {
                    LoadingMessage('Loading Details', '<b>Please Wait ...</b>');
                    var obj = {
                        "Id": Id,
                        "Title": Title,
                        "ColumnName": ColumnName
                    };
                    $.ajax({
                        type: "POST",
                        url: URL + "/ViewReport",
                        data: JSON.stringify(obj),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            $('#btnSaveReport').click();
                            CloseHlsPopup();
                        },
                        error: function (xhr, status, error) {
                            var err = eval("(" + xhr.responseText + ")");
                            console.log(err.Message);
                        }
                    });
                }
            }
            else {
                CloseHlsPopup();
                LoadingMessage('Your session has expired, we are redirecting to login page', '<b>Please Wait ...</b>');
                window.setTimeout(function () { window.location = '/Pages/BaseFramework/Security/Login.aspx'; }, 2000);
            }
        },
        error: function (xhr, status, error) {
            var err = eval("(" + xhr.responseText + ")");
            console.log(err.Message);
        }
    });
}

function ResetControls() {
    $('.multi-select-button').html('-- Select --');

    
    $('#drpDepartment').val(0);

    $('#chkCastCategory').prop('checked', false);
    $('#dvCastCategory').html('');
    $('#dvCastCategory').hide();
    $('#dvCastCategory').css('height', '0');
    $("#dvCastCategory").slimScroll({ destroy: true });
}
function ShowSubjectlist() {
   
    if ($('#chkIssubject').is(':checked')) {
        if (parseInt($('#drpClass').val()) == 0) {

            $('#chkIssubject').prop('checked', false);
            alert('Select Class');
        }
        if (parseInt($('#drpExam').val()) == 0) {

            $('#chkIssubject').prop('checked', false);
            alert('Select Exam');
        }
        var obj = {
            "ClassId": $('#drpClass').val(),
            "ExamId": $('#drpExam').val(),
        };
        $.ajax({
            type: "POST",
            url: URL + "/GetSubjectList",
            data: JSON.stringify(obj),
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (data) {

                var obj1 = $.parseJSON(data.d);
                $('#drpAvailableFields').append(obj1.SubjectNames.replace(new RegExp("{","g"),"[").replace(new RegExp("}","g"),"]"));
                $('#drpAvailableFieldsO').append(obj1.SubjectNames.replace(new RegExp("{", "g"), "[").replace(new RegExp("}", "g"), "]"));
               
            },
            error: function (xhr, status, error) {
                var err = eval("(" + xhr.responseText + ")");
                console.log(err.Message);
            }
        });
    }
    else {
        BindDropDowns();
    }
   
}