/*------------------------------------------------------------------------------------------
order.status.js
da peng
dp165137419@163.com
------------------------------------------------------------------------------------------*/



(function ($) {
    $(document).ready(function () {
		    $('#hint').show();
				$('#hint').css('left', (window.screen.width - $('#hint').width()) / 2 + $(window).scrollLeft());
				$('#hint').css('top', window.screen.height / 2 - $('#hint').height() + $(window).scrollTop());
				$('#hint').click(function () { $(this).hide(); });
				
				
				
				$('#closed').click(function () {
				    $('#fly-order-number').hide();
						$('#fly-container').animate({'opacity':1});
						$('#fly-container').hide();
				});
				$('#closed').mouseover(function () { $(this).css('cursor', 'pointer'); });
				
				
				
				$('#orderStatusButton').click(function () {
				    var salesNumber = $('#orderNumber').val();
						var salesPayerMeail = $('#salesPayerMeail').val();
						var strUrl = 'configs/ajax/order.status.ajax.php';
						var sendData = {'salesNumber':salesNumber, 'salesPayerMeail':salesPayerMeail};
						orderStatusHandle(strUrl, sendData);
				});
				
				
				
				$('#hint').hide();
		});
})(jQuery);



function orderStatusHandle (strUrl, sendData) {
		$.ajax({
		    type: 'POST', 
				url: strUrl, 
				data: sendData, 
				dataType: 'json', 
				error: function (a, b) {
				    alert(b);
				}, 
				beforSend: function () {
				    $('#hint').show();
						$('#hint').css('left', (window.screen.width - $('#hint').width()) / 2 + $(window).scrollLeft());
				    $('#hint').css('top', window.screen.height / 2 - $('#hint').height() + $(window).scrollTop());
				}, 
				success: function (data) {
						$('#hint').hide();
						$('#fly-order-number').show();
						
						
						
						if (!data['flag']) {
							  data['salesNumber'] = '';
								data['salesClientName'] = '';
								data['salesProductName'] = '';
								data['paypalTime'] = '';
								data['roomLevel'] = '';
						} 
						$('#salesNumber').html('<span>Order Number :</span> ' + data['salesNumber']);
						$('#salesClientName').html('<span>Customer\'s Name :</span>' + data['salesClientName']);
						$('#salesProductName').html('<span>Product :</span> ' + data['salesProductName']);
						$('#paypalTime').html('<span>Start Time :</span> ' + data['paypalTime']);
						$('#roomLevel').html('<span>Current Level :</span> ' + data['roomLevel']);
						
						
						
						$('#fly-order-number').css('left', (window.screen.width - $('#fly-order-number').width()) / 2 + $(window).scrollLeft());
						$('#fly-order-number').css('top', window.screen.height / 2 - $('#fly-order-number').height() + $(window).scrollTop());
						
						
						
						$('#fly-container').width($(window).width());
						var maxH = $(document).height() > window.screen.height ? $(document).height() : window.screen.height;
						$('#fly-container').height(maxH);
						$('#fly-container').css({background:'#3cc',left:0, top:0});
						$('#fly-container').show();
						$('#fly-container').animate({'opacity':0.5});
				}
		});
}