var type  = 0;
$(function() {	

	$('#member_phone').blur(function(){
					
		var member_id = $('#member_id').attr('value');
		var member_phone = $('#member_phone').attr('value');
		
		if(member_phone == '请输入手机号')
		{
			$('#O_PWD_TXT').attr('value' , '');
			$('.O_PWD').hide(500);	
			return;
		}	
		
		if(member_id == 0)
		{
			$.ajax({
				type:'POST',
				url:root + '?m=login.getMemberByAccount&mobile='+member_phone,
				success: function (data) {
					if(data != 0)
					{
						$('.O_PWD').show(500);
						$('#O_PWD_TXT').attr('value' , '');
						alert('此电话已注册,请填写登录密码，如从未更改，密码默认为手机号码');
						type = 1;
						$('#O_PWD_TXT').focus();
					}else{
						type = 0;
						$('#O_PWD_TXT').attr('value' , '');
						$('.O_PWD').hide(500);	
					}
					
				},
				cache: false
			});
		}
								  
	});

	

	$('#close_time').change(function(){
				
		var begin_time = $('#begin_time').attr('value');								 
		var close_time = $('#close_time').attr('value');			
		
		var my_time = $('#times').attr('value');
		
		var room_id = $('#room_id').attr('value');
		
		
		
		var time = close_time - begin_time;

		
		$.ajax({
			type:'POST',
			url:root + '?m=ktv.getPriceInfo&my_time=' + my_time+'&begin_time=' + begin_time+'&close_time='+close_time+'&room_id=' +  room_id,
			success: function (data) {	
		
			 eval("var data = " + data);
					
				if(data != '')
				{
				
					$('#O_Price_info').html('￥' + data['lastPrice'] );
					$('#O_Price_remark').html(data['remark']);
					
					$('#book_price').attr('value' , data['lastPrice']);
					$('#all_price').attr('value' , data['Price']);
				}else{
					$('#O_Price_info').html('该时段未定义价格，请前往KTV前台咨询');
					$('#all_price').attr('value' , 0);
					$('#book_price').attr('value' , 0);
				}
			},
			cache: false
		});
		
				
	});
	
	$('#begin_time').change(function(){
				
		var begin_time = $('#begin_time').attr('value');								 
		var close_time = $('#close_time').attr('value');			
		
		var my_time = $('#times').attr('value');
		var room_id = $('#room_id').attr('value');
		
		
		
		var time = close_time - begin_time;

		
		$.ajax({
			type:'POST',
			url:root + '?m=ktv.getPriceInfo&my_time=' + my_time+'&begin_time=' + begin_time+'&close_time='+close_time+'&room_id=' +  room_id,
			success: function (data) {				
		
				if(data != '')
				{
					$('#O_Price_info').html('￥' + data );
					$('#all_price').attr('value' , data);
				}else{
					$('#O_Price_info').html('该时段未定义价格，请前往KTV前台咨询');
					$('#all_price').attr('value' , 0);
				}
			},
			cache: false
		});
		
	
				
	});
	
	
	

	
});

