// JavaScript Document 航线
var clickNumber=0;
var isLT=false;
var positions=[{left:10,top:600,width:10,height:15},{left:175,top:600,width:10,height:15},{left:340,top:600,width:10,height:15},{left:515,top:600,width:10,height:15}]
var ends={width:674,height:437,left:149,top:75}
function goTravel(){
	isLT=false;
	var ename=$('ename').value.trim();
	var tname=$('tname').value.trim();
	var sex=$('tsex0').checked?$('tsex0').value:$('tsex1').value;
	var tbirthyear=$('tbirthyear').value;
	var tbirthmonth=$('tbirthmonth').value;
	var tbirthday=$('tbirthday').value;
	var tidcard=$('tidcardnumber').value.trim();
	var tbirthplace=$('tbirthplace').value.trim();
	var taddress=$('taddress').value.trim();
	var tphone=$('tphone').value.trim();
	var tmobile=$('tmobile').value.trim();
	var tqq=$('tqq').value.trim();
	var tmsn=$('tmsn').value.trim();
	var tcompanyaddress=$('tcompanyaddress').value.trim();
	var tcompanyphone=$('tcompanyphone').value.trim();
	var tjob=$('tjob').value.trim();
	var tbirth=tbirthyear+'年'+tbirthmonth+'月'+tbirthday+'日';
	var tgo=$('tgoyear').value+'年'+$('tgomonth').value+'月'+$('tgoday').value+'日';
	var tback=$('tbackyear').value+'年'+$('tbackmonth').value+'月'+$('tbackday').value+'日';
	var tinfo=$('tinfo').value.trim();
	var tcountry=travelCountrysl[clickNumber];
	if(ename==''||tname==''||tidcard==''||tbirthplace==''||taddress==''||tphone==''||tmobile==''||tqq==''||tmsn==''||tcompanyaddress==''||tcompanyphone==''||tjob==''||tinfo==''){
		displayErrmsg(false);
		errMsgDescription('请完全填写资料,以便我们及时联系,谢谢合作！');
		return false;
	}
	if(!checkQQ(tqq)){
		displayErrmsg(false);
		errMsgDescription('qq号码不正确,请重新填写！');
		return false;
	}
	if(!checkIDCard(tidcard,tbirthyear,tbirthmonth,tbirthday)){
		displayErrmsg(false);
		errMsgDescription('身份证填写错误,请重新填写！');
		return false;
	}
	if(!checkPhone(tphone)){
		displayErrmsg(false);
		errMsgDescription('住宅电话号码填写错误,请重新填写！');
		return false;
	}
	if(!checkMobile(tmobile)){
		displayErrmsg(false);
		errMsgDescription('手机号码填写错误,请重新填写！');
		return false;
	}
	diplayErrmsgLoading();
	goLoginEvent(function(){
						  GM_xmlHttp({
									 method:'post',
									 url:'/go_thistravel.asp?action=gotravel',
									 send:'cnName='+tname+'&enName='+ename+'&birthday='+tbirth+'&sex='+sex+'&idCard='+tidcard+'&livePosition='+taddress+'&housePhone='+tphone+'&mobile='+tmobile+'&qq='+tqq+'&msn='+tmsn+'&company='+tcompanyaddress+'&companyPhone='+tcompanyphone+'&position='+tjob+'&goTime='+tgo+'&backTime='+tback+'&travelLine='+tinfo+'&birthPosition='+tbirthplace+'&travelCountry='+tcountry,
									 onload:function(xpr){
										 var sr=xpr.responseText;
										 if(sr.contains('true')){
											 displayErrmsg(false);
											 errMsgDescription('谢谢您的添加，我们会在1-2个工作日内与您联系.',true);
											 
											 isLT=true;
										 }else{
											 displayErrmsg(false);
											 errMsgDescription('递交申请资料失败,请重新递交！');
										 }
									 }
									 });
						  });
	return false;
}

function closetravelpanels(){
	if(isLT){
		clearTravelForm(); 
		goTravelevent($('contentadd'),ends,positions[clickNumber],false);
	}
}
System.Events.addEvent($('loginCCC'),function(){
closetravelpanels();},'click',false);
function clearTravelForm(){
	$('ename').value='';
	$('tname').value='';
	$('tidcardnumber').value='';
	$('tbirthplace').value='';
	$('taddress').value='';
	$('tphone').value='';
	$('tmobile').value='';
	$('tqq').value='';
	$('tmsn').value='';
	$('tcompanyaddress').value='';
	$('tcompanyphone').value='';
	$('tjob').value='';
	$('tinfo').value='';
}
var intertravel;
function goTravelevent(obj,start,end,is){
	if(typeof(obj)!='object'&&typeof(start)!='object'&&typeof(end)!='object')return;
	if(is)obj.style.display='block';
	obj.style.width=start.width+'px';
	obj.style.height=start.height+'px';
	obj.style.top=start.top+'px';
	obj.style.left=start.left+'px';
	clearInterval(intertravel);
	intertravel=setInterval(function(){
		setObjStyles(obj,start,end,is);
	},10);
}
function setObjStyles(obj,start,end,is){
		var width=parseInt(obj.style.width);
		var height=parseInt(obj.style.height);
		var top=parseInt(obj.style.top);
		var left=parseInt(obj.style.left);
		var steps=(end.width-width);
		var stepss=(end.height-height);
		var steptops=(end.top-top);
		var steplefts=(end.left-left);
		var steptop=steptops/5|5;
		var stepleft=steplefts/5|5;
		var steph=stepss/5|5;
		var step=steps/5|5;
		if(Math.abs(steps)<=20){
			step=steps;
			steph=stepss;
			steptop=steptops;
			stepleft=steplefts;
		}
		if(steps==0&&stepss==0&&steptops==0&&steplefts==0){
			clearInterval(intertravel);
			if(!is)obj.style.display='none';
		}
		width+=step;
		obj.style.width=width+'px';
		height+=steph;
		obj.style.height=height+'px';
		top+=steptop;
		left+=stepleft;
		obj.style.top=top+'px';
		obj.style.left=left+'px';
}
function closedisplay(){
	goTravelevent($('contentadd'),ends,positions[clickNumber],false);
}
var travelCountrys=["韩国出境","日本出境","国内游","其他境外游"];
var travelCountrysl=["韩国","日本","国内","其他境外"];
function gotraveldisplay(i){
	clickNumber=i;
	clearTravelForm(); 
	$('ttitle').innerHTML=travelCountrys[i]+'申请人基本资料：';
	goTravelevent($('contentadd'),positions[i],ends,true);
}