/** 对于网站公共的一些ajax处理函数都放在这里 **/

//检查用户登录状态
function checkUserStatus()
{
	var tempurl = "/ajax_userstatus.php";

	//start ajax 
	$.ajax({url: tempurl,
		type: 'GET',
		dataType: 'json',
		timeout: 20000,
		data: ' ',
		error: function(){alert('读取数据出错了'); 
		},
		success: function(rs){
			$("#id_loginhtml").html(rs[0]+" ");
		}
	});//end of ajax
}

$(document).ready(function() {
	//检查区域和所在状态
	checkUserStatus();

	$('#basicModal input.basic, #basicModal a.basic').click(function (e) {
		e.preventDefault();
		//$('#basicModalContent').modal();
	});

});

//弹出用户注册窗口
function do_reg()
{
	$('<iframe src=\"/reg.php\" width=\"600\" height=\"430\" frameboder=\"0\" scrolling=\"no\" border=\"0\"></iframe>').modal({containerCss: {
    height: 430,
    width: 600,
    backgroundColor: '#fff',
    border: '3px solid #ccc'  }});
	return false;
}

//弹出用户登录窗口
function do_login()
{
	$('<iframe src=\"/login.php\" width=\"500\" height=\"180\" frameboder=\"0\" scrolling=\"no\" border=\"0\"></iframe>').modal({containerCss: {
    height: 180,
    width: 500,
    backgroundColor: '#fff',
    border: '3px solid #ccc'  }});
	return false;
}

//取回用户名密码窗口
function do_getpwd()
{
	//TODO:
	$('取回密码').modal();
}

//用户资料修改窗口
function do_modify()
{
	$('<iframe src=\"/modify.php\" width=\"600\" height=\"430\" frameboder=\"0\" scrolling=\"no\" border=\"0\"></iframe>').modal({containerCss: {
    height: 430,
    width: 600,
    backgroundColor: '#fff',
    border: '3px solid #ccc'  }});
	return false;
}

//订单添加窗口
function do_orders(id)
{
	$('<iframe src=\"/shop/orders.php?id='+id+'\" width=\"600\" height=\"465\" frameboder=\"0\" scrolling=\"no\" border=\"0\"></iframe>').modal({containerCss: {
    height: 465,
    width: 600,
    backgroundColor: '#fff',
    border: '3px solid #ccc'  }});
	return false;
}



//调用关闭窗口，然后重新检查用户登录状态
function do_close()
{
	$.modal.close(); 
	checkUserStatus();
}
