﻿function QSubmit(submitcase)
{

	if(CourtStr==""){alert("請至少選擇一個法院!!");return;}
	
	//混合搜尋項目
	var BidDateStr=""
	if((aspnetForm.ctl00$Content$TextBoxDateStart.value=="") || (aspnetForm.ctl00$Content$TextBoxDateEnd.value==""))
	{
		alert('投標日輸入錯誤');
		return;
	}else{
		BidDateStr += "&DateStart=" + aspnetForm.ctl00$Content$TextBoxDateStart.value;
		BidDateStr += "&DateEnd=" + aspnetForm.ctl00$Content$TextBoxDateEnd.value;
	}
	var ShouldStr=""
	if (aspnetForm.Should.checked==false){ShouldStr += "&Should=0";}
		
	var BuildStr=""
	if (aspnetForm.ctl00$Content$ListBuild$TextBoxRoad.value!=""){BuildStr += "&Build=" + escape(aspnetForm.ctl00$Content$ListBuild$TextBoxRoad.value);}
	
	var AgraStr="";
	if (aspnetForm.ctl00$Content$ListAgrarian$DropDownListCity.value != ""){AgraStr += escape(aspnetForm.ctl00$Content$ListAgrarian$DropDownListCity.value)};
	if (aspnetForm.ctl00$Content$ListAgrarian$DropDownListArea.value != ""){AgraStr += escape(aspnetForm.ctl00$Content$ListAgrarian$DropDownListArea.value)};
	if (aspnetForm.ctl00$Content$ListAgrarian$DropDownListParagraph.value != ""){AgraStr += escape(aspnetForm.ctl00$Content$ListAgrarian$DropDownListParagraph.value)};
	if (aspnetForm.ctl00$Content$ListAgrarian$DropDownListMinParagraph.value != ""){AgraStr += escape(aspnetForm.ctl00$Content$ListAgrarian$DropDownListMinParagraph.value)};
	if (aspnetForm.ctl00$Content$ListAgrarian$TextBoxAgrarianNO.value != ""){AgraStr += escape(aspnetForm.ctl00$Content$ListAgrarian$TextBoxAgrarianNO.value + "地號")};
    if (AgraStr!=""){AgraStr = "&Agrarian=" + AgraStr}

	var BKindStr=""
	if (aspnetForm.ProBKind.value!=""){BKindStr += "&BKind=" + escape(aspnetForm.ProBKind.value)};
	
	var LKindStr=""
	if (aspnetForm.ProLKind.value!=""){LKindStr += "&LKind=" + escape(aspnetForm.ProLKind.value)};
	
	var BSizeStr=""
	if((aspnetForm.BSizeMin.value!="") && (aspnetForm.BSizeMax.value!=""))
	{
		if(aspnetForm.BSizeMin.value==""){aspnetForm.BSizeMin.value=aspnetForm.BSizeMax.value}
		if(aspnetForm.BSizeMax.value==""){aspnetForm.BSizeMax.value=aspnetForm.BSizeMin.value}
		if(aspnetForm.BSizeMin.value-aspnetForm.BSizeMax.value>0)
		{
			var tmpvalue = aspnetForm.BSizeMin.value
			aspnetForm.BSizeMin.value=aspnetForm.BSizeMax.value
			aspnetForm.BSizeMax.value=tmpvalue
		}
		BSizeStr += "&BSizeMin=" + aspnetForm.BSizeMin.value + "&BSizeMax=" + aspnetForm.BSizeMax.value;
	}
	
	var LSizeStr=""
	if((aspnetForm.LSizeMin.value!="") && (aspnetForm.LSizeMax.value!=""))
	{
		if(aspnetForm.LSizeMin.value==""){aspnetForm.LSizeMin.value=aspnetForm.LSizeMax.value}
		if(aspnetForm.LSizeMax.value==""){aspnetForm.LSizeMax.value=aspnetForm.LSizeMin.value}
		if(aspnetForm.LSizeMin.value-aspnetForm.LSizeMax.value>0)
		{
			var tmpvalue = aspnetForm.LSizeMin.value
			aspnetForm.LSizeMin.value=aspnetForm.LSizeMax.value
			aspnetForm.LSizeMax.value=tmpvalue
		}
		LSizeStr += "&LSizeMin=" + aspnetForm.LSizeMin.value + "&LSizeMax=" + aspnetForm.LSizeMax.value;
	}
	
	var PriceStr=""
	if((aspnetForm.ProPriceMin.value!="") && (aspnetForm.ProPriceMax.value!=""))
	{
		if(aspnetForm.ProPriceMin.value==""){aspnetForm.ProPriceMin.value=aspnetForm.ProPriceMax.value}
		if(aspnetForm.ProPriceMax.value==""){aspnetForm.ProPriceMax.value=aspnetForm.ProPriceMin.value}
		if(aspnetForm.ProPriceMin.value-aspnetForm.ProPriceMax.value>0)
		{
			var tmpvalue = aspnetForm.ProPriceMin.value
			aspnetForm.ProPriceMin.value=aspnetForm.ProPriceMax.value
			aspnetForm.ProPriceMax.value=tmpvalue
		}
		PriceStr += "&PriceMin=" + aspnetForm.ProPriceMin.value + "&PriceMax=" + aspnetForm.ProPriceMax.value;
	}
	
	var UintPriceStr=""
	if((aspnetForm.UnitPriceMin.value!="") && (aspnetForm.UnitPriceMax.value!=""))
	{
	    if(aspnetForm.UnitPriceMin.value==""){aspnetForm.UnitPriceMin.value=aspnetForm.UnitPriceMax.value}
	    if(aspnetForm.UnitPriceMax.value==""){aspnetForm.UnitPriceMax.value=aspnetForm.UnitPriceMin.value}
		if(aspnetForm.UnitPriceMin.value-aspnetForm.UnitPriceMax.value>0)
		{
			var tmpvalue = aspnetForm.UnitPriceMin.value
			aspnetForm.UnitPriceMin.value=aspnetForm.UnitPriceMax.value
			aspnetForm.UnitPriceMax.value=tmpvalue
		}
		UintPriceStr += "&UnitPriceMin=" + aspnetForm.UnitPriceMin.value + "&UnitPriceMax=" + aspnetForm.UnitPriceMax.value;
	}
	
	var CheckStr=""
	if(aspnetForm.ProCheck.value!=""){CheckStr += "&Check=" + aspnetForm.ProCheck.value};
	
	var BidStr=""
	if((aspnetForm.ProAuction2.value!="") && (aspnetForm.ProAuction.value!=""))
	{
		switch(aspnetForm.ProAuction2.value)
		{
			case "1":
				BidStr += "&Bid==";break;
			case "2":
				BidStr += "&Bid=>=";break;
			case "3":
				BidStr += "&Bid=<=";break;
		}
		BidStr += aspnetForm.ProAuction.value;
	}
	var StateStr=""
	if(aspnetForm.ProState.value!=""){StateStr += "&State=" + aspnetForm.ProState.value};
	
	var RedrectStr="AuctionSelectResult.aspx?Court=" + CourtStr
	
	switch(submitcase)
	{
		//投標日查詢
		case "Date":
	        if(BidDateStr=="")
	        {
		        alert('投標日輸入錯誤');
		        return;
	        }else{
		        RedrectStr += BidDateStr + ShouldStr
	        }				
			break;
		//建物座落查詢
		case "Build":
			if (BuildStr=="")
			{
				alert('建物座落請至少輸入一項');
				return;
			}else{
				RedrectStr += BuildStr;
				break;
			}
		//建物種類
		case "BuildKind":
			if(BKindStr=="")
			{
				alert('請先選擇建物種類');
				return;
			}else{
				RedrectStr += BKindStr;
				break;
			}
		//地目
		case "AgrarianKind":
			if(LKindStr=="")
			{
				alert('請先選擇地目');
				return;
			}else{
				RedrectStr += "&LKind=" + LKindStr;
				break;
			}
		//建物總坪數
		case "BSize":
			if(BSizeStr=="")
			{
				alert('建物坪數輸入錯誤');
				return;
			}else{
				RedrectStr += BSizeStr;
				break;
			}
		//土地總坪數
		case "LSize":
			if(LSizeStr)
			{
				alert('土地坪數輸入錯誤');
				return;
			}else{
				RedrectStr += LSizeStr;
				break;
			}
		//總底價
		case "Price":
			if(PriceStr=="")
			{
				alert('總底價輸入錯誤');
				return;
			}else{
				RedrectStr += PriceStr;
				break;
			}
		//坪單價
		case "UnitPrice":
			if(UintPriceStr=="")
			{
				alert('坪單價輸入錯誤');
				return;
			}else{
				RedrectStr += UintPriceStr;
				break;
			}
		//點交狀況
		case "Check":
			if(CheckStr=="")
			{
				alert('請先選擇點交狀況');
				return;
			}else{
				RedrectStr += CheckStr;
				break;
			}
		//屋齡
		case "Old":
			break;
		//拍次
		case "Auction":
			if(BidStr=="")
			{
				alert('拍次選擇錯誤');
				return;
			}else{
				RedrectStr += BidStr;
				break;
			}
		//拍賣狀況
		case "State":
			if(StateStr=="")
			{
				alert('請先選擇拍賣狀況');
				return;
			}else{
				RedrectStr += StateStr;
				break;
			}
		//土地座落查詢
		case "Agrarian":
			if (AgraStr=="")
			{
				alert('土地座落請至少輸入一項');
				return;
			}else{
				RedrectStr += AgraStr;
				break;		
			}
		//案號查詢
		case "Caption":
			if(aspnetForm.ctl00$Content$TextBoxCaption.value=="")
			{
				alert('請先輸入案號');
				return;
			}else{
				RedrectStr += "&Caption=" + escape(aspnetForm.ctl00$Content$TextBoxCaption.value);
				break;
			}
		//債務人查詢
		case "Debtor":
			if(aspnetForm.ctl00$Content$TextBoxDebtor.value=="")
			{
				alert('請先輸入債務人');
				return;
			}else{
				RedrectStr += "&Debtor=" + escape(aspnetForm.ctl00$Content$TextBoxDebtor.value);
				break;
			}
		//停拍查詢
		case "StopDate":
		    RedrectStr += "&DateStart=" + aspnetForm.ctl00$Content$DropDownListStopDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListStopDate.value.length-3);
		    RedrectStr += "&DateEnd=" + aspnetForm.ctl00$Content$DropDownListStopDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListStopDate.value.length-3);
		    RedrectStr += "&State=0";
			break;
		//新增案件查詢
		case "AddDate":
			RedrectStr += "&AddDateStart=" + aspnetForm.ctl00$Content$DropDownListAddDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListAddDate.value.length-3);
			RedrectStr += "&AddDateEnd=" + aspnetForm.ctl00$Content$DropDownListAddDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListAddDate.value.length-3);
			break;
		//投標查詢
		case "AuctionDate":
		    RedrectStr += "&DateStart=" + aspnetForm.ctl00$Content$DropDownListAuctionDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListAuctionDate.value.length-3);
		    RedrectStr += "&DateEnd=" + aspnetForm.ctl00$Content$DropDownListAuctionDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListAuctionDate.value.length-3);
			break;
		//拍賣結果查詢
		case "ResultDate":
			if (aspnetForm.ctl00$Content$DropDownListResultDate.value=="" || aspnetForm.ctl00$Content$DropDownListResultDate.value=="更早日期")
			{
				ResultDateWin=window.open("AuctionSelectDate.aspx?Court=" + CourtStr + "&Case=Result","ResultDateWin","width=400,height=300,left=" + (screen.width-400)/2 + ",top=" + (screen.Height-300)/2);
				return;
			}else{
			    var tmpdate=aspnetForm.ctl00$Content$DropDownListResultDate.value.substring(0,aspnetForm.ctl00$Content$DropDownListResultDate.value.length-3);
				RedrectStr += "&ResultDateStart=" + tmpdate + "&ResultDateEnd=" + tmpdate 
				break;
			}
		//應買公告
		case "Should":
			var now = new Date();
			RedrectStr += "&ShouldDate=" + now.getFullYear() + "/" + (now.getMonth()+1) + "/" + now.getDate();
			break;
		//店面案件
		case "Shop":
	        if(BidDateStr=="")
	        {
		        alert('投標日輸入錯誤');
		        return;
	        }else{
			    RedrectStr += BidDateStr + "&BKind=" + escape('店面');
	        }
			break;
		//捷運案件
		case "ExpressageKS":
			RedrectStr="AuctionExpressageKS.aspx?Court=KSD,KSG"
			RedrectStr += BidDateStr + BuildStr + AgraStr + BKindStr + LKindStr + BSizeStr + LSizeStr + PriceStr + UintPriceStr + CheckStr + BidStr + StateStr;
	        NewExpressageWin = window.open(RedrectStr,"NewExpressageWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	        NewExpressageWin.focus();		
			return;
 		//捷運案件
		case "ExpressageTC":
			RedrectStr="AuctionExpressageTC.aspx?Court=TCD,TCG"
			RedrectStr += BidDateStr + BuildStr + AgraStr + BKindStr + LKindStr + BSizeStr + LSizeStr + PriceStr + UintPriceStr + CheckStr + BidStr + StateStr;
	        NewExpressageWin = window.open(RedrectStr,"NewExpressageWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	        NewExpressageWin.focus();		
			return;
 		//捷運案件
		case "ExpressageTP":
			RedrectStr="AuctionExpressageTP.aspx?Court=TPD,PCD,SLD,TPG,PCG,SLG"
			RedrectStr += BidDateStr + BuildStr + AgraStr + BKindStr + LKindStr + BSizeStr + LSizeStr + PriceStr + UintPriceStr + CheckStr + BidStr + StateStr;
	        NewExpressageWin = window.open(RedrectStr,"NewExpressageWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	        NewExpressageWin.focus();		
			return;
 		//學區查詢
		case "SchoolArea":
			RedrectStr="AuctionSchoolArea.aspx?Court=TPD,PCD,SLD,TPG,PCG,SLG,KSD,KSG"
			RedrectStr += BidDateStr + BuildStr + AgraStr + BKindStr + LKindStr + BSizeStr + LSizeStr + PriceStr + UintPriceStr + CheckStr + BidStr + StateStr;
	        NewExpressageWin = window.open(RedrectStr,"NewExpressageWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	        NewExpressageWin.focus();		
			return;
       //監控案件
		case "Monitor":
	        NewMonitorWin = window.open('AuctionMonitor.aspx',"NewMonitorWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	        NewMonitorWin.focus();		
			return;
       //瀏覽紀錄
		case "History":
	        NewMonitorWin = window.open('AuctionHistory.aspx',"NewHistoryWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	        NewMonitorWin.focus();		
			return;
		case "All":
		    var SingleSearch = false;
			if(aspnetForm.ctl00$Content$TextBoxDebtor.value!="")
			{
			    if(SingleSearch==false){SingleSearch=confirm('您是否單查詢債務人?');};
			    RedrectStr += "&Debtor=" + escape(aspnetForm.ctl00$Content$TextBoxDebtor.value);
			};
			if(aspnetForm.ctl00$Content$TextBoxCaption.value!="")
			{
			    if(SingleSearch==false){SingleSearch=confirm('您是否單查詢案號?');};
			    RedrectStr += "&Caption=" + escape(aspnetForm.ctl00$Content$TextBoxCaption.value);
			};
			if(SingleSearch==false)
			{				
			    RedrectStr += BidDateStr + ShouldStr + BuildStr + AgraStr + BKindStr + LKindStr + BSizeStr + LSizeStr + PriceStr + UintPriceStr + CheckStr + BidStr + StateStr;
			}
			break;
	}
				
	AuctionSearchWin = window.open(RedrectStr,"AuctionSearchWin","width=800,height=650,resizable=yes,scrollbars=yes,status=yes,left=" + (screen.width-800)/2 + ",top=" + (screen.Height-650)/2);
	AuctionSearchWin.focus();		
}