var IsTure,Flag,ZipString,OrderArray;
function ReOrder(f){
 OrderArray = new Array();
 IsTure = document.form1.IsTrue.value;
 //Reform.StartDate.focus();
 if(IsTure == 0){
	ZipString = document.getElementById("Flight1").getAttribute("ZipString");
	Flag = 1;}
 else if(document.getElementById("AirLineGo").style.display == ""){
	ZipString = document.getElementById("Flight1").getAttribute("ZipString");
	Flag = 1;}
 else{
	ZipString = document.getElementById("Flight2").getAttribute("ZipString");
	Flag = 2;}
 if(f == "L")
	OrderByPrice();
 else if(f == "F")
	OrderByDate();
 else
	OrderByAirLine();
}
function ReOrder22(f,flag22){
 OrderArray = new Array();
 //IsTure = form1.IsTrue.value;
 //Reform.StartDate.focus();
 if(flag22 == 1){
	ZipString = document.getElementById("Flight1").getAttribute("ZipString");
	Flag = 1;}
 else{
	ZipString = document.getElementById("Flight2").getAttribute("ZipString");
	Flag = 2;}
 if(f == "L")
	OrderByPrice();
 else if(f == "F")
	OrderByDate();
 else
	OrderByAirLine();
}
function OrderByPrice(){
 var subStr,NewZip="";
 var str = ZipString.split("@");
 for(var i=1;i<str.length;i++){
	subStr = str[i].split("|")[2];
	InsertArray(subStr,i);}
 for(i=0;i<OrderArray.length;i++){
	document.getElementById("Flight_item"+Flag+"_"+(i+1)).innerHTML = OrderArray[i][2];
	NewZip += "@"+str[OrderArray[i][0]];}
 document.getElementById("Flight"+Flag).setAttribute("ZipString",NewZip) ;
}
function OrderByDate(){
 var subStr,NewZip="";
 var str = ZipString.split("@");
 for(var i=1;i<str.length;i++){
	subStr = str[i].split("|")[1];
	InsertArray(subStr,i);}
 for(i=0;i<OrderArray.length;i++){
	
	document.getElementById("Flight_item"+Flag+"_"+(i+1)).innerHTML = OrderArray[i][2];
	NewZip += "@"+str[OrderArray[i][0]];}
 document.getElementById("Flight"+Flag).setAttribute("ZipString",NewZip) ;
}
function OrderByAirLine(){
 var subStr,NewZip="";
 var str = ZipString.split("@");
 for(var i=1;i<str.length;i++){
	subStr = str[i].split("|")[0];
	InsertArray(subStr,i);}
 for(i=0;i<OrderArray.length;i++){
	  
	document.getElementById("Flight_item"+Flag+"_"+(i+1)).innerHTML = OrderArray[i][2];
	NewZip += "@"+str[OrderArray[i][0]];}
 document.getElementById("Flight"+Flag).setAttribute("ZipString",NewZip) ;
}
function InsertArray(str,num){
 var oLen = OrderArray.length;
 var pos = -1;
 if(oLen == 0)
	OrderArray[0] = new Array(num,str,document.getElementById("Flight_item"+Flag+"_"+num).innerHTML);
 else{
	for(var i=0;i<oLen;i++){
		if(str < OrderArray[i][1]){
			pos = i;
			break;}}
	if(pos == -1)
		OrderArray[oLen] = new Array(num,str,document.getElementById("Flight_item"+Flag+"_"+num).innerHTML);
	else{
		OrderArray[oLen] = new Array(OrderArray[oLen-1][0],OrderArray[oLen-1][1],OrderArray[oLen-1][2]);
		for(i=oLen-1;i>pos;i--){
			OrderArray[i] = new Array(OrderArray[i-1][0],OrderArray[i-1][1],OrderArray[i-1][2]);}
		OrderArray[pos] = new Array(num,str,document.getElementById("Flight_item"+Flag+"_"+num).innerHTML);}
	}
}