/*------------------------------------------------------------------------------------------
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();
						$('#subflag').attr("value","yes");
						
				});
				$('#closed').mouseover(function () { $(this).css('cursor', 'pointer'); });
				
				
				
				$('#orderStatusButton').click(function () {
				    var salesNumber = $('#orderNumber').val();
						var salesPayerMeail = $('#salesPayerMeail').val();
	                    if(salesPayerMeail=="")
						{ alert("Please fill in Paypal!");
						   return false;}
						 if(salesNumber=="")
						{ alert("Please fill in Order No.!");
						   return false;} 
						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> <p>' + data['salesNumber']+'</p>');
						$('#salesClientName').html('<span>Buyer Name:</span><p>' + data['salesClientName']+'</p>');
						$('#salesProductName').html('<span>Product:</span> <p>' + data['salesProductName']+'</p>');
						$('#paypalTime').html('<span>Start Time:</span> <p>' + data['paypalTime']+'</p>');
						$('#roomLevel').html('<span>Current Level:</span> <p>' + data['roomLevel']+'</p>');
						
						$('#registername').val(data['salesClientName']);
						
						
						$('#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:'#2c5a6f',left:0, top:0});
						$('#fly-container').show();
						$('#fly-container').animate({'opacity':0.5});
				}
		});
}
