function loginSubmit(login, uc)
{
	var username = login.elements['username'];
	var password = login.elements['password'];
    if(!loginCheck(login)) return false;
	if(uc == 1) return true;
	citsAjax.post(login.action, 'action=ajax&username='+username.value+'&password='+password.value, function(data){
		if(data == 1)
		{
			$('#logined_username').html(username.value);
			$('#div_login').hide();
			$('#div_logined').show();
		}
		else
		{
			alert('登录失败');
			redirect(login.action);
		}
		username.value = password.value = '';
	});
	return false;
}

function logout(url)
{
	citsAjax.get(url+'&id='+Math.random()*5, function(data){
		if(data != 1) alert(data);
	});
	$('#div_logined').hide();
	$('#div_login').show();
}

function loginshow()
{
	var auth = getcookie('auth');
	if(auth != null)
	{
		$('#logined_username').html(getcookie('username'));
		$('#div_login').hide();
		$('#div_logined').show();
		if(document.getElementById('header_om'))
		{
			citsAjax.get('order/show-attren.php', function(data){
				if(data != '')
				{
					var Arr = data.split('#');
					var str = '<div id="show-attren"><a href="javascript:omClose();" class="v_ri">x</a>';
					str += Arr[0] != '0' ? '您有<b>'+Arr[0]+'</b>个未付款订单，<a href="order/index.php?status=0" class="ared">立即支付</a><br>' : '';
					str += Arr[1] != '0' ? '共有<b>'+Arr[1]+'</b>个已付款订单，<a href="order/index.php?status=1" class="ared">打印凭证</a>' : '';
					str += '</div>';
					$('body').append(str);
				}
			});
		}
	}
	else
	{
		$('#div_logined').hide();
		$('#div_login').show();
	}
}
$(function(){loginshow();});
function omClose()
{
	$('#show-attren').remove();
	citsAjax.get('order/show-attren.php?action=close', function(data){});
}

function quickMember(func){
	$("select").each(function(){this.style.visibility="hidden";});
	var url = "http://" + window.location.hostname + "/member/quickNew.php?";
	if(func){url += "func="+encodeURI(func);}
	$('body').append('<div id="quickNew-overlay"></div><div id="quickNew-lightbox"><iframe name="quickNew-iframe" id="quickNew-iframe" frameborder="0" marginheight="0" marginwidth="0" src="'+url+'"></iframe></div>');
	$("#quickNew-overlay").click(function(){quickClose();});
	var PXY = quickPageSize();
	$("#quickNew-overlay").css({width:PXY[0],height:PXY[1],opacity:0.8}).fadeIn();
	var XY = quickPageScroll();
	quickSetBox();
}
function quickClose(){$('#quickNew-lightbox').remove();$('#quickNew-overlay').fadeOut(function(){$('#quickNew-overlay').remove();});$("select").each(function(){this.style.visibility="visible";});}
function quickSetBox(){var XY = quickArr();var PXY = quickPageSize();var SXY = quickPageScroll();$('#quickNew-lightbox').css({width:XY.X, height:XY.Y, left:((PXY[0]-XY.X)/2), top:30+SXY[1]+(PXY[3]/10)});}
function quickArr(){return {'X':694,'Y':415};}
function quickPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}
windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;}
function quickPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;}
function LOGIN__CHECK(){var auth = getcookie('auth');if(auth != null && auth != ''){return true;}else{quickMember('image_submit()');return false;}}
