function showWindow(ID)
{
document.getElementById(ID).style.display="";
}

function hideWindow(ID)
{
document.getElementById(ID).style.display="none";
//ID.style.display="none";
}

function chkAll(obj){
	if(obj.id == "allTrainType"){
		if(obj.checked == true){
			$(".william_trainType").attr("checked", true);
		}else{
			$(".william_trainType").attr("checked", false);
		}
	}else if(obj.id == "allTime"){
		if(obj.checked == true){
			$(".william_time").attr("checked", true);
		}else{
			$(".william_time").attr("checked", false);
		}
	}
	
	formData();
}


function formData(){
	var typeG	=	document.getElementById("initials-G").checked;
	var typeD	=	document.getElementById("initials-D").checked;
	var typeZ	=	document.getElementById("initials-Z").checked;
	var typeT	=	document.getElementById("initials-T").checked;
	var typeK	=	document.getElementById("initials-K").checked;
	var typeL	=	document.getElementById("initials-L").checked;
	
	var AM	=	document.getElementById("AM").checked;
	var Morning	=	document.getElementById("Morning").checked;
	var PM1	=	document.getElementById("PM1").checked;
	var PM2	=	document.getElementById("PM2").checked;
	
//注释做扩展用，请勿删除！－－chou。	
	var sign=false;
	if(typeG&&typeD&&typeZ&&typeT&&typeK&&typeL)//&&ArrAM&&ArrPM1&&ArrPM2)
	{
		var sign=true;
		$("#allTrainType").attr("checked",true);
	}else{
		$("#allTrainType").attr("checked",false);
	}
	
	if(!typeG&&!typeD&&!typeZ&&!typeT&&!typeK&&!typeL)//&&!ArrAM&&!ArrPM1&&!ArrPM2)
	{
		var sign=true;
	}	
	
	
	if(Morning && AM && PM1 && PM2){
		$("#allTime").attr("checked",true);
	}else{
		$("#allTime").attr("checked",false);
	}
	
	
//	var sign=false;

	if(sign)
	{
		var Divs	=	document.getElementsByName("carnet");
		var length	=	Divs.length;


		for(var i=0;i<length;i++)
		{
			
			
			if((!AM && !Morning && !PM1 && !PM2) || (AM && Morning && PM1 && PM2)){
				Divs[i].style.display="";
				continue;
			}

			
			var time1=Divs[i].getAttribute("time1").replace(/:.*/,"");
			var time =parseInt(time1, 10);
			
			var blMorning = false;
			var blAM = false;
			var blPM1 = false;
			var blPM2 = false;
			
			
			
			if(time<6){
				blMorning = true;
			}else if(time >= 6 && time < 12){
				blAM = true;
			}else if(time >=12 && time < 18){
				blPM1 = true;
			}else if(time >= 18 && time <= 24){
				blPM2 = true;
			}
			
			
			if((Morning && blMorning) || (AM && blAM) || (PM1 && blPM1) || (PM2 && blPM2)){
				Divs[i].style.display="";
			}else{
				Divs[i].style.display="none";
			}
			
			
		}	
	}
	else
	{
		var Divs	=	document.getElementsByName("carnet");
		var length	=	Divs.length;

		for(var i=0;i<length;i++)
		{
			var type =Divs[i].getAttribute("type").substring(0,1).toUpperCase().replace(/\d/,"L");
			var time1=Divs[i].getAttribute("time1").replace(/:.*/,"");
			var time =parseInt(time1, 10);
		
			sign=false;
			//车次类型
			if(!sign&&typeG&&type=="G")
			{
				sign=true;
			}	
			if(!sign&&typeD&&type=="D")
			{
				sign=true;
			}
			if(!sign&&typeZ&&type=="Z")
			{
				sign=true;
			}
			if(!sign&&typeT&&type=="T")
			{
				sign=true;
			}
			if(!sign&&typeK&&type=="K")
			{
				sign=true;
			}				
			if(!sign&&typeL&&type!="G"&&type!="D"&&type!="Z"&&type!="T"&&type!="K")
			{
				sign=true;
			}
			
			//出发时间
			if(sign && (Morning || AM || PM1 || PM2)){
				var blMorning = false;
				var blAM = false;
				var blPM1 = false;
				var blPM2 = false;
				
				
				
				if(time < 6){
					blMorning = true;
				}else if(time >= 6 && time < 12){
					blAM = true;
				}else if(time >= 12 && time < 18){
					blPM1 = true;
				}else if(time >= 18 && time <= 24){
					blPM2 = true;
				}
				
				
				if((Morning && blMorning) || (AM && blAM) || (PM1 && blPM1) || (PM2 && blPM2)){
					sign = true;
				}else{
					sign = false;
				}
				
			}
			//到达时间

			//最后决定是否显示
			if(sign)
			{
				Divs[i].style.display="";
			}
			else
			{
				Divs[i].style.display="none";
			}
		}		
	}
}




function formData_old()
{
	var typeG	=	document.getElementById("initials-G").checked;
	var typeD	=	document.getElementById("initials-D").checked;
	var typeZ	=	document.getElementById("initials-Z").checked;
	var typeT	=	document.getElementById("initials-T").checked;
	var typeK	=	document.getElementById("initials-K").checked;
	var typeL	=	document.getElementById("initials-L").checked;
	
	var AM	=	document.getElementById("AM").checked;
	var Morning	=	document.getElementById("Morning").checked;
	var PM1	=	document.getElementById("PM1").checked;
	var PM2	=	document.getElementById("PM2").checked;
	
/*	var ArrAM	=	document.getElementById("ArrAM").checked;
	var ArrPM1	=	document.getElementById("ArrPM1").checked;
	var ArrPM2	=	document.getElementById("ArrPM2").checked;*/
//注释做扩展用，请勿删除！－－chou。	
	var sign=false;
	if(typeG&&typeD&&typeZ&&typeT&&typeK&&typeL)//&&ArrAM&&ArrPM1&&ArrPM2)
	{
		var sign=true;
	}
	
	if(!typeG&&!typeD&&!typeZ&&!typeT&&!typeK&&!typeL)//&&!ArrAM&&!ArrPM1&&!ArrPM2)
	{
		var sign=true;
	}	
//	var sign=false;

	if(sign)
	{
		var Divs	=	document.getElementsByName("carnet");
		var length	=	Divs.length;


		for(var i=0;i<length;i++)
		{
			var time1=Divs[i].getAttribute("time1").replace(/:.*/,"");
			var time =parseInt(time1);
			sign=true;
			
			if(Morning&&time1>6){
				sign=false;
			}
			if(AM&&(time1<6||time1>=12))
			{
				sign=false;
			}
			
//			if(AM&&time1>=12)
//			{
//			//	alert('test');
//				sign=false;
//			}	
			if(PM1&&(time1<12||time1>18))
			{
				sign=false;
			}			
			if(PM2&&time1<=18)
			{
				sign=false;
			}
			if(sign)
			Divs[i].style.display="";
			else Divs[i].style.display="none";
		}	
	}
	else
	{
		var Divs	=	document.getElementsByName("carnet");
		var length	=	Divs.length;

		for(var i=0;i<length;i++)
		{
			var type =Divs[i].getAttribute("type").substring(0,1).toUpperCase().replace(/\d/,"L");
//			alert(type);
			var time1=Divs[i].getAttribute("time1").replace(/:.*/,"");
			var time =parseInt(time1);
//			alert(time1);
//			var ArrTime	=	parseInt(Divs[i].getAttribute("arrtime"));
			
			sign=false;
			//车次类型
			if(!sign&&typeG&&type=="G")//||type=="D"))
			{
				sign=true;
			}	
			if(!sign&&typeD&&type=="D")
			{
				sign=true;
			}
			if(!sign&&typeZ&&type=="Z")
			{
				sign=true;
			}
			if(!sign&&typeT&&type=="T")
			{
				sign=true;
			}
			if(!sign&&typeK&&type=="K")
			{
				sign=true;
			}				
			if(!sign&&typeL&&type!="G"&&type!="D"&&type!="Z"&&type!="T"&&type!="K")
			{
				sign=true;
			}
			
			//出发时间
			if(sign){
			
			if(Morning&&time1>6){//加
				sign=false;
			}
					
			if(AM&&(time1<6||time1>=12))//加
			{

				sign=false;
			}
				
//			if(AM&&time1>=12)
//			{
//				sign=false;
//			}	
			if(PM1&&(time1<12||time1>18))
			{
				sign=false;
			}			
			if(PM2&&time1<=18)
			{
				sign=false;
			}
			}
			//到达时间

/*
if(!sign&&ArrAM&&ArrTime>=10600&&ArrTime<=11200)
			{
				sign=true;
			}	
			if(!sign&&ArrPM1&&ArrTime>=11200&&ArrTime<=11800)
			{
				sign=true;
			}
			if(!sign&&ArrPM2&&(ArrTime<=10600||ArrTime>=11800))
			{
				sign=true;
			}*/
			
			//最后决定是否显示
			if(sign)
			{
				Divs[i].style.display="";
			}
			else
			{
				Divs[i].style.display="none";
			}
		}		
	}
}
//排序
function formUp(attribute,ID)
{
	var icon	=	ID+"icon";
	var iconObj	=	document.getElementById(icon);

	if("down"==iconObj.className)
	{
		var Method	=	0;//title	=	title+"从高到低";
		iconObj.className="up";
	}
	else
	{
		var Method	=	1;//title	=	title+"从低到高";
		iconObj.className="down";
	}
//	var Method	=	0;

	
	var Divs	=	document.getElementsByName("carnet");
	var length	=	Divs.length
	var DivArray	=	new Array();
	for(var i=0;i<length;i++)
	{
		DivArray[i]	= Divs[i];
	}
	DivArray.sort(GetSort(attribute,Method));
	
	try
	{
	var SortDiv	=	document.createDocumentFragment();
	for(i=0;i<length;i++)
	{
		SortDiv.appendChild(DivArray[i]);
	}
	document.getElementById("sort").appendChild(SortDiv);
	}
	catch(Err)
	{
		alert(Err.description);
	}
}

function GetSort(attributeName,Method)
{
	return function KGetSort(tr1,tr2)
	{
		var x	=	parseInt(tr1.getAttribute(attributeName));
		var y	=	parseInt(tr2.getAttribute(attributeName));
		if(Method==1)
		{
			if(x<y)
			{
				return -1;
			}
			else
			{
				return 1;
			}
		}
		else
		{
			if(x<y)
			{
				return 1;
			}
			else
			{
				return -1;
			}		
		}
	}
}