$(document).ready(function () {
	"use strict";

	

	/*----------------------------- Custom Js -----------------------*/

	$('#btnTrack').on('click', function () {

		var IDs = [];
		var str = $('#txtTrack').val().replace(/(?:\r\n|\r|\n)/g, ',');
		var partsOfStr = str.split(',');
		for (var i = 0; i < partsOfStr.length; i++) {
			IDs.push(partsOfStr[i]);
		}
		var newArray = IDs.filter(function (v) { return v !== '' });

		
		if (newArray.length == 1) {

		    $.ajax({
		        type: "GET",
		        url: "/Home/TrackView?Id=" + newArray[0],
		        dataType: "html",
		        beforeSend: function () {
		            $.blockUI({
		                css: {
		                    border: 'none',
		                    padding: '15px',
		                    backgroundColor: '#000',
		                    '-webkit-border-radius': '10px',
		                    '-moz-border-radius': '10px',
		                    opacity: .5,
		                    color: '#fff'
		                }
		            });
		        },
		        success: function (data) {
		            $('#Content').empty();
		            $('#Content').html(data);
		       
		        },
		        error: function (jqXhr) {
		            $('#Content').empty();
		            alert("Please Enter Correct Credentials");
		        },
		        complete: function () {
		            $.unblockUI();
		        }
		    });
		}
		else if (newArray.length > 1) {

		    var postData = { values: newArray };
		    $.ajax({
		        type: "POST",
		        url: "/Home/SearchResult",
		        data: postData,
		        dataType: "html",
		        traditional: true,
		        beforeSend: function () {
		            $.blockUI({
		                css: {
		                    border: 'none',
		                    padding: '15px',
		                    backgroundColor: '#000',
		                    '-webkit-border-radius': '10px',
		                    '-moz-border-radius': '10px',
		                    opacity: .5,
		                    color: '#fff'
		                }
		            });
		        },
		        success: function (data) {
		            $('#Content').empty();
		            $('#Content').html(data);

		        },
		        error: function (jqXhr) {
		            $('#Content').empty();
		            alert("Please Enter Correct Credentials");
		        },
		        complete: function () {
		            $.unblockUI();
		        }
		    });
		}
		else{
		    alert("Please Enter Correct Credentials");
		}

        

	});











	/*-------------- Pre-loader ------------------*/
	$("#loading").delay(200).fadeOut(500);
	$("#loading-center").on('click', function () {
		$("#loading").fadeOut(500);
	});


}(jQuery));