/* ----------------------------------------------------------------------------------------------------
* 个人中心
* ----------------------------------------------------------------------------------------------------
*/

function inibid(param)
{
	//仅用于存在.不作具体功能.
	return false;
}
function categories()
{
	//仅用于存在.不作具体功能.	
	return false;
}


/* 左侧菜单 */
function memberHandler()
{
	$(".subMenu dt").click(function(){
		if ($(this).hasClass("collapse")){
			$(this).removeClass("collapse").nextAll("dd").show();
		}else{
			$(this).addClass("collapse").nextAll("dd").hide();
		}
	});
	$(".subMenu a").click(function(){
		$(".subMenu").children("dd").removeClass("currentMenu");
		$(this).parent().addClass("currentMenu");
	});
}



function check_dl_ok(){
	removeDialogbox("#check_dl");
}


function inimember()
{
	var admin_islogin;
	var admin_mb_id;
	var mb_nickname;
	var admin_mb_key;
	var content;
	admin_islogin=getCookie('admin_islogin');
	admin_mb_id=getCookie('admin_mb_id');
	admin_mb_key=getCookie('admin_mb_key');

	//控制打开关闭浮动层
	openDiv();
	var regNow = "";//'<a id="qLink" href="'+APP+'/User/register" title="注册闪拍账户"><img src="'+IMG_PATH+'/regNow.gif" width="106" height="24" /></a>';
	var getPoint ="";// '<a id="qLink" href="javascript:paycountnow();" title="充值获得更多闪点"><img src="'+IMG_PATH+'/getPoint.gif" width="106" height="24" /></a>';
	
	$.ajax({
		url: APP+"/Admin/inimember/",
		cache: false,
		type: "POST",
		"data": '',
		success: function(content){
			
			$("#userInfo").html(content);
			if(admin_islogin){
				$("#fixedDivState").html(getPoint);
			}else{
				$("#fixedDivState").html(regNow);
			}
			
		//	opentopbox();//控制打开个人获得的浮动层

			/* 当前页面登录 */
			$("#signin").click(function(){
				loadloginbox();
			}).focus(function(){
				$(this).blur();
			});
		}
	});
}

//打开个人获得的浮动层
function opentopbox(){
	var topboxopen=getCookie('topboxopen');
	var proTopshowvalue=getCookie('proTopshowvalue');
	var admin_islogin=getCookie('admin_islogin');
	proTopshowvalue=proTopshowvalue / 10;
	if((topboxopen!='1')&& admin_islogin ){
		$("#proTop").show();
		$("#proTopshowvalue").text(proTopshowvalue);
	}else{
		$("#proTop").hide();
		$("#proTopshowvalue").text(proTopshowvalue);
	}
}

//admin_islogin
$(document).ready(function(){
	$("#webimBtn").click(function(){
		if(!$(this).hasClass("webimOn"))
		{
			$("#fixedDiv").show("fast");
			$("#webimBtn").addClass("webimOn").attr("title","隐藏");	
			setCookie('DivIsOpen','1');
		}else{
			$("#fixedDiv").hide("fast");
			$("#webimBtn").removeClass("webimOn").attr("title","展开");
			delCookie('DivIsOpen');
		}
	}).focus(function(){
		$(this).blur();
	});
});

function openDiv(){
	var IsOpen=getCookie('DivIsOpen');
	if(IsOpen=='1'){
		$("#fixedDiv").show("fast");
		$("#webimBtn").addClass("webimOn").attr("title","隐藏");	
	}else{
		$("#fixedDiv").hide("fast");
		$("#webimBtn").removeClass("webimOn").attr("title","展开");
	}
}

//退出
function logout(){
	var IsExit = confirm("您确实要安全退出吗?");
	if(IsExit)
	{
		$.post(APP+"/Admin/UserLogout",'',function(msg){
			if(msg){//先保留msg这个值以备以后使用
			//	client_clear();
			}
			location.href=REQUEST_URI;
		});
	}
	return IsExit;
}

//退出
function client_clear(){
	delCookie('dmin_islogin');
	delCookie('admin_mb_id');
	//11:37 2010-9-29 添加页码
	delCookie('admin_mb_pageno');

}
//11:41 2010-9-29 Add
function client_SetPageNo(pageno)
{
	setCookie("admin_mb_pageno",pageno)
}
function client_GetPageNoToUrlParam()
{
	var pageno= 1;
    pageno= getCookie('admin_mb_pageno');
    if (isNaN(pageno)) pageno=1;
    if(pageno<2)
    	return "";
    else
    	return "&p="+pageno;
}
//11:41 2010-9-29 Add End
//更新用户状态
function updateuser() {
	if(window.isfoucs==0){//如果当前页面不是在激活的状态
		return;
	}

    $.ajax({
        type: "POST",
        url:APP+"/Admin/ajaxcheckuser/",
		"data": '',
        success: function(msg){
            if(msg==2){						//证明已经被封了或是没登陆
                logout();
            }else{
                setTimeout("updateuser()", 60000);//60S
            }
        }
    });
}



//加载登录信息[弹出框]
function loadloginbox(){
	addDialogbox("#ajaxSignin","登录",10001,502);
	//quitScreenMask();


	$.ajax({
		url: APP+"/Admin/signin",
		cache: false,
		"data": '',
		success: function(msg){
			$("#ajaxSignin .dialogboxContent").prepend(msg);
			initStyle();
			if($("#userID").attr("value") == ""){
				$("#userID").focus();
			}else{
				$("#userPW").focus();
			}
		}
	});
}

//登录操作
function ajaxlogin() {
	var exp  = new Date();
//	var codehtml='<label for="logincode">验证码:</label>'+'<input type="text" class="input fl space" id="logincode" name="logincode" style="width:60px;" maxlength="4" />'+'<img id="verifyImg_login" class="fl" src="'+APP+'/User/verify/'+exp.getTime()+'" onclick="fleshVerify(\'verifyImg_login\')" title="点击刷新验证码" />';
	var pass=$.formValidator.pageIsValid('loginform');//验证是否允许提交.
	var loginwrongtime=getCookie('loginwrongtime');
	
	if(pass){
		var queryString = $('#loginform').formSerialize();
		//alert(queryString);
		$.post(APP+"/Admin/ajaxlogin",queryString,function(msg){
			if(msg==1){
				if(loginwrongtime>2){
					$('#verifycodeInput').removeClass("displayNone");
					$('#verifycodeInput').html(codehtml);
				}
				showtips('用户名或密码不正确，请确认','tips',3);
			}else if(msg==3){
				$('#verifycodeInput').removeClass("displayNone");
				$('#verifycodeInput').html(codehtml);
				showtips('验证码有误，请重新输入','tips',3);
			}else if(msg==2){
				showtips('您的账号已经被冻结，请联系拍拍客服','tips',3);
			}else{
			//	dologinurl();//跳转本页 /admin/
				location.href= APP + REQUEST_URI + "Default";
				//location.href= APP + "/admin1/Default";//17:12 2010-10-16 修改,方便测试新后台界面
			}
		});
	}
}

//已有相同用户名的处理方式
//隐藏发送按钮
function showresendbtn() {
	//已有相同的用户名
	$('#sendbtn').attr("style","display:none");
	$('#resendbtn').removeAttr("style");
}

//已有相同用户名的处理方式
//隐藏重发发送按钮
function hideresendbtn() {
	//已有相同的用户名
	$('#resendbtn').attr("style","display:none");
	$('#sendbtn').removeAttr("style");
}

//找回密码
function ajaxgetpwd() {
	var pass=$.formValidator.pageIsValid('getpwdform');

	if(pass){
		var queryString = $('#getpwdform').formSerialize();
		//alert(queryString);
		$.post(APP+"/Admin/getpwd",queryString,function(msg){
			if(msg=='1'){//先保留msg这个值以备以后使用,原值0
				showtips('操作成功，系统已发送邮件到您邮箱','tips',1);
			}else{
				showtips(msg,'tips',2);
			}
		});
	}
}

//判断是否在登陆页还是用ajax的形式登陆
function dologinurl()
{
	location.href = location.href;
	return ;
	if(REQUEST_URI =='/Admin/register')
	{
		location.href=APP+'/Admin/Default';//zd 17:08 2010-10-16 修改:测试新界面
	}else{
		location.href=REQUEST_URI + "Default";
	}
}

//订单确认[后台]:订单确认表示要付款,即要调取支付宝支付界面.暂时不调取
function CheckOrderFormAndUpdate(id,CheckState)
{
	var IsSubmit = false;
	if(CheckState==1)
	{
		if(confirm("您是否支付该订单的货款?\r\n"))IsSubmit = true;
		else IsSubmit = false;
	}
	else
	{
		if(confirm("您是否取消该订单?\r\n")) IsSubmit = true;
		else IsSubmit = false;
	}
	
	if(IsSubmit)
	{
	
		$.ajax({
			type:"POST",
			url: APP+'/Admin/Work_Order_Check/'+ CheckState + "&t=" + new Date().getTime(),
			cache: false,
			"data": {"Oid":id},
			success: function(msg)
			{
				//ShowErrorMsg(msg);
				if(msg=="0")
				{
					if(CheckState==1)
						msg = "<font color='green'><b>已付款</b></font>&nbsp;&nbsp;[<a href=\"javascript:void(0);\" onclick=\"CheckOrderFormAndUpdate("+ id +",0)\" >取消</a>]";     //已付款者可以取消表示付款终结
					else
	         			msg = "<font color='red'><b>已取消</b></font>&nbsp;&nbsp;[<a href=\"javascript:void(0);\" onclick=\"CheckOrderFormAndUpdate("+ id +",1)\" >付款</a>]";//取消后可以付款从而完成交易.
					$('#TdOrderCheck_'+id).html(msg);
				}
				else
				{
					ShowErrorMsg("操作失败"+ msg);
				}
			},
			error:function(msg)
			{
				ShowErrorMsg(msg.responseText);
			}
		});

		
	//	SimpleAjax(APP+'/Admin/Work_Order_Check/'+ CheckState +'/'+ id ,'TdOrderCheck_'+id);
	}
	else
	{
		ShowErrorMsg("操作取消");
	}
		
}



function CheckVendueAndUpdate(id,CheckState)
{
	var IsSubmit = false;
	if(confirm("您是否确认修改此状态(改状态为 [ "+ (CheckState==1?"已成交":"正在竞拍中...") +") ] ?\r\n")) IsSubmit = true;
	else
	{	
	 	IsSubmit = false;	
	}
	if(IsSubmit)
	{
	
		$.ajax({
			type:"POST",
			url: APP+'/Admin/Work_Vendue_Check/'+ CheckState + "&t=" + new Date().getTime(),
			cache: false,
			"data": {"Oid":id},
			success: function(msg)
			{
				//ShowErrorMsg(msg);
				if(msg=="0")
				{
					if(CheckState==1)
						msg = "<font color='red'><b>已成交</b></font>&nbsp;&nbsp;[<a href=\"javascript:void(0);\" onclick=\"CheckVendueAndUpdate("+ id +",0)\" >取消</a>]";     //已付款者可以取消表示付款终结
					else
	         			msg = "<font color='green'><b>正在竞拍中...</b></font>&nbsp;&nbsp;[<a href=\"javascript:void(0);\" onclick=\"CheckVendueAndUpdate("+ id +",1)\" >成交</a>]";//取消后可以付款从而完成交易.
					$('#TdOrderCheck_'+id).html(msg);
				}
				else
				{
					ShowErrorMsg("操作失败"+ msg);
				}
			},
			error:function(msg)
			{
				ShowErrorMsg(msg.responseText);
			}
		});

		
	//	SimpleAjax(APP+'/Admin/Work_Order_Check/'+ CheckState +'/'+ id ,'TdOrderCheck_'+id);
	}
	else
	{
		ShowErrorMsg("操作取消");
	}
		
}