function dosubmit(){
var username=E('loginForm:username').value;
var psw=E('loginForm:password').value;
var code=E('loginForm:checkcode').value;
if(username=="")
{	alert(_noUser);
	E('loginForm:username').focus();
	return false;
}
if(psw=="")
{	alert(_noPsw);
	E('loginForm:password').focus();
	return false;
}
if(code=="")
{	alert(_noCode);
	E('loginForm:checkcode').focus();
	return false;
}else{
	checkCode(username,psw,code);
	return false;
}
}
function dosubmit2(){
var username=E('loginForm:username').value;
var psw=E('loginForm:password').value;
//var code=E('loginForm:checkcode').value;
if(username=="")
{	alert("用户名不能为空");
	E('loginForm:username').focus();
	return false;
}
if(psw=="")
{	alert("密码不能为空");
	E('loginForm:password').focus();
	return false;
}
checkCode_min(username,psw);
return false;
/*
if(code=="")
{	alert("验证码不能为空");
	E('loginForm:checkcode').focus();
	return false;
}else{
	checkCode_min(username,psw,code);
	return false;
}*/
}
function checkCode(user,psw,code){
		$.post("/model/ajax/homeCheckCode.faces", 
        {username:user,psword:psw,tcode:code},
       	 	function(xml){
        	var status = $(xml).find('status').text();
        	var content = $(xml).find('content').text();
        	if(status=='2'){
         		var content = $(xml).find('content').text();
         		alert(content);
         		changeImage();
         	}else if(status=='0'){
         		alert("验证码错误！");
         		changeImage();
         		E('loginForm:checkcode').focus();
         	}else if(status=='3'){
         		if(confirm(content)){
         			confirmcheckCode(user,psw,code);
         		}
         	}else { 
         		//window.location.href="/ticketSale/bookTicket.faces";
         		//window.location.href="/min/home.faces";
         		window.location.href="/common/redirect.faces";
         	}
         	
         	});
        	
}
function checkCode_min(user,psw){
		$.post("/model/ajax/homeCheckCode_min.faces", 
        {username:user,psword:psw},
       	 	function(xml){
        	var status = $(xml).find('status').text();
        	var content = $(xml).find('content').text();
        	if(status=='2'){
         		var content = $(xml).find('content').text();
         		alert(content);
         		changeImage();
         	}else if(status=='3'){
         		if(confirm(content)){
         			confirmcheckCode(user,psw,code);
         		}
         	}else { 
         		//window.location.href="/ticketSale/bookTicket.faces";
         		window.location.href="/min/preScanTicket_min.faces";
         		
         	}
         	
         	});
        	
}
function confirmcheckCode(user,psw,code){
		$.post("/model/ajax/homeCheckCode.faces", 
        {username:user,psword:psw,confirm:'confirm',tcode:code},
       	 	function(xml){
        	var status = $(xml).find('status').text();
        	var content = $(xml).find('content').text();
        	if(status=='2'){
         		var content = $(xml).find('content').text();
         		alert(content);
         		changeImage();
         	}else if(status=='0'){
         		alert("验证码错误！");
         		changeImage();
         		E('loginForm:checkcode').focus();
         	}else if(status=='3'){
         		if(confirm(content)){
         			alert("执行登录，取消以前登录信息");
         		}else{
         			alert("取消当前登录");
         		}
         	}else {
         		//window.location.href="/ticketSale/bookTicket.faces";
         		window.location.href="/common/redirect.faces";
         		
         	}
         	
         	});
        	
}
function changeImage(){
	$('#verifyImage').attr({src:"/common/image.jsp?temp="+ (new Date().getTime().toString(36))});
}
function dealang(lan){
		$.post("/model/ajax/lang.faces",{lan:lan},
       	 	function(xml){
        	var status = $(xml).find('status').text();
        	if(status=='ok'){
        		location.reload();
         	}else {
         			alert(status);
         	}
         	});
}
/*window.onunload = function(){
	var ie=true;
	if(navigator.appName.indexOf('Microsoft') == -1){
	     ie = false;
	}
	 alert("ie=="+ie);
	if(ie){
			if(self.screenTop>9000){
				//cleanVisitInItem();
				alert('欢迎下次光临中港通!');
			}
	}
}	*/

function compute_buy_count(agencyId){
		
		if(E('buy_count_id').checked){
			$.post("/model/ajax/func_compute_buy_count.faces",{agencyId:agencyId},
	       	 	function(xml){
	        	var count = $(xml).find('count').text();
	        	
	        	E('buy_count').innerHTML=count+"张";
	         	});
         	
        }else{
        	E('buy_count').innerHTML="***";
        }
}
	
