var currentInput;
var key = "";
var isShow = false;
var activeDiv;

var dataRequest = "";//返回数据的分隔符
var kwlength;//关键字最小长度
var autoTab;//是否回车后自动转到下一个文本框
var parameterName;//回传时的参数名
var TargetControlId;
var TargetPage;
var fPostBack = false;
jQuery.fn.AutoComplete = function(request, option){
   TargetControlId = option.TargetControlId || "";
   TargetPage = option.TargetPage || "";
   if(TargetPage=="Quotation")
	fPostBack = true;
    this.each(function(){        
        if(this.tagName.toLowerCase() == "input" && $(this).attr("type").toLowerCase() == "text" && $(this).attr("id")==TargetControlId)
        {
            $(this).keydown(function(e){
                selectText(e.keyCode,this);
            });            
            $(this).keyup(function(e){
                searchKey(e.keyCode);
            });
            $(this).blur(function(){
                hideText();
            });
            if($(this).attr("id").indexOf("tbAirline")<0
				&& $(this).attr("id").indexOf("tbFromMonth")<0
				&& $(this).attr("id").indexOf("tbToMonth")<0
				&& $(this).attr("id").indexOf("tbStopover")<0)
            {
				$(this).focus(function(e){
					setPos($(this).attr("id"),0);
					InitialKey(e.keyCode,this);
				});
            }
            //if($(this).attr("id").indexOf("tbAirline")==0)
			//{
			//	$(this).focus(function(e){
			//		//alert("ss");
			//		WebQuotationAirlineGet(e.keyCode);
			//	});
            //}
        }
    });    
    if(request.length == 0) throw "request is required";
    dataRequest = request;
    kwlength = option.kwlength || 3 ;
    seperator = option.seperator || ",";
    autoTab = option.autoTab || false;
    parameterName = option.parameterName || ""; 
    $("body").prepend("<div id='floor' class='floor' style='z-index:10'></div>")
    $("#floor").hide();
}

function showText()
{
    text = document.getElementById(currentInput.attr("id"));
    div = document.getElementById("floor");
    div.style.left = getPos(text,"Left") + "px";
    div.style.top = getPos(text,"Top") + text.offsetHeight + "px";
    //div.style.width = text.offsetWidth - 2 + "px";
    $("#floor").show();
}

function hideText()
{
    $("#floor").hide();
    $("#floor").html("");
    key="";    
    currentInput = null;
    isShow = false;
    //if(fPostBack)
		//FormCheckSubmit();
}

function getPos(el,ePro)				
{
    var ePos=0;
    while(el!=null)
    {		
        ePos+=el["offset"+ePro];
        el=el.offsetParent;
    }
    return ePos;
}

function searchKey(keycode)
{
    if(keycode == 38 || keycode == 40 || keycode == 13 || keycode == 27 || keycode == 9) return;    
    if(currentInput != null && (key == "" || currentInput.val() != key) && currentInput.val().length >= kwlength)
    {
		var dataSource;
		var dataNum=0;
		if(currentInput.attr("id") =="tbAirline")
		{
			WebQuotationAirlineGet(currentInput.val());
			return;
			//dataSource ="/Data/AirlineData.aspx";
			//dataNum = 1;
		}
		else if(currentInput.attr("id") =="tbStopover")
		{
			if(TargetPage == "Agent")
				AgentCitySelect(currentInput.val());
			else
				WebQuotationBeyondCityGet(currentInput.val());
			return;
			//dataSource ="/Data/StopOverCityData.aspx";
			//dataNum = 2;
		}
		else if(currentInput.attr("id") =="tbFromMonth"
				||currentInput.attr("id") =="tbToMonth")
		{
			dataSource ="/Data/MonthData.aspx";
			dataNum = 3;
		}
		else
		{
			dataSource ="/Data/CityData.aspx";
			dataNum = 4;
		}
		
        var divs = "";
        jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: dataSource,            
            data: parameterName != "" ? parameterName + "=" + currentInput.val():(currentInput.attr("name") == null ? currentInput.attr("id") + "=" + currentInput.val():currentInput.serialize()),
            success: function(msg){                
                if(msg.length==0)
                {
                    hideText();
                    return;
                }
                var datas = msg.split(seperator);
                if(datas.length == 2)
                {
					currentInput.val(datas[0]);
					if(dataNum == 4)
						document.getElementById("UCSearchCriteria1_dlReturnCity").value = datas[0];
					divs+="<div class=selected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ datas[0] +"</div>";
					$("#floor").html(divs);
					isShow = true;
					showText();
					setPos(currentInput.attr("id"),0);
					return;
                }
                $.each(datas, function(i, n){
                    if(n.length > 0) divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ n +"</div>";
                });
                $("#floor").html(divs);
                isShow = true;
                showText();

            }
        });
        key = currentInput.val();
    }    
    //Techie
    //if(key.length == 0 || key.length <= kwlength) hideText(); 
    if(key.length == 0 || key.length < kwlength) hideText(); 
}
////////////////techie
function InitialKey(keycode,sInput)
{
    currentInput = $("#"+sInput.id);
    if(currentInput != null && currentInput.val().length ==0)
    {
            var divs = "";
            jQuery.ajax({
                type: "Get",
                dataType: "text",
                url: "",            
                data: parameterName != "" ? parameterName + "=" + currentInput.val():(currentInput.attr("name") == null ? currentInput.attr("id") + "=" + currentInput.val():currentInput.serialize()),
                success: function(msg){                
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>&nbsp;</div>"; 
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>CHICAGO (ORD)</div>"; 
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>LOS ANGELES (LAX)</div>"; 
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>NEW YORK (JFK)</div>"; 
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>SAN FRANCISCO (SFO)</div>"; 
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>SEATTLE (SEA)</div>"; 
                   divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>WASHINGTON (IAD)</div>"; 
                    $("#floor").html(divs);
                    isShow = true;
                    showText(); 
                }
            });
    }    
}
////////////////////////
function findNextInput(target)
{   
    var index;
    $("input[@type=text]").each(function(i){
        if($(this).attr("id") == target.attr("id")) index = i;
    });
    return $("input[@type=text]")[ index + 1 ];
}

function selectText(keycode,sInput)
{    
    currentInput = $("#"+sInput.id);
    if(keycode == 13)
    {        
        if(autoTab) $(findNextInput(currentInput)).focus();
        hideText();
    }
    if(!isShow) return;
    if(keycode == 27) hideText();    
    selectedDiv = $("#floor>div[@class=selected]");
    if(selectedDiv.text() != "")
    {
        selectedDiv.attr("class","unselected");
        if(keycode == 38)
        {
            if(selectedDiv.prev().text() != "")
            {
                selectedDiv.prev().attr("class","selected");
                currentInput.val(selectedDiv.prev().text());
            }
            else
            {
                $("#floor>div:last").attr("class","selected");
                currentInput.val($("#floor>div:last").text());                
            }
        }
        else if(keycode == 40)
        {
            if(selectedDiv.next().text() != "")
            {
                selectedDiv.next().attr("class","selected");
                currentInput.val(selectedDiv.next().text());
            }
            else
            {
                $("#floor>div:first").attr("class","selected");
                currentInput.val($("#floor>div:first").text());                
            }
        }            
    }
    else if(keycode == 38)
    {
        $("#floor>div:last").attr("class","selected");
        currentInput.val($("#floor>div:last").text());
    }
    else if(keycode == 40)
    {
        $("#floor>div:first").attr("class","selected");
        currentInput.val($("#floor>div:first").text());        
    }
// /////////////////////techie////////////////////////////////////
//var techieReturnCity = document.getElementById("UCSearchCriteria1_dlReturnCity"); 
//var techieDepartureCity = document.getElementById("UCSearchCriteria1_dlDepartureCity"); 
//            techieReturnCity.value=techieDepartureCity.value; 
////////////////////////////   ////////////////////////////////////
}

function mouseover(sDiv)
{    
    $("#floor").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
    currentInput.val($(sDiv).text());
               ///techie
      var techieReturnCity = document.getElementById("UCSearchCriteria1_dlReturnCity");
      if(currentInput.attr("id").indexOf("UCSearchCriteria1_dlReturnCity")>=0
      ||currentInput.attr("id").indexOf("UCSearchCriteria1_dlDepartureCity")>=0)
            techieReturnCity.value=currentInput.val(); 
//////////////////////////    
setPos(currentInput.attr("id"),0);
}



function mouseoverRegion(hidTourValue,sDiv,value)
{    
    $("#divRegion").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
    $("#TourTypeHTML").html("<strong>" + $(sDiv).text().replace("(","<br/>(") + "</strong>"); 
    document.getElementById(hidTourValue).value=value; 
}			
function DisplayDiv(Type,Tour)
	{
		
		//document.getElementById("tbAirline").value = "";
		//document.getElementById("tbStopover").value = "";
		//document.getElementById("hidAirline").value = "";
		
		
		$("#divRegion").hide();
		$("#divRegion").html("");
		if(document.getElementById("chkChina").checked==false && document.getElementById("chkJapan").checked==false && document.getElementById("chkThailand").checked==false
			 && document.getElementById("chkTaiwan").checked==false)
		{
			RegionAll();
			return;
		}
		document.getElementById("chkAllCountry").checked=false;
		$("body").prepend("<div id='divRegion' class='floor' style='z-index:10'></div>")
        $("#divRegion").hide();
		if(Tour == 'China')
		{
			if(!fPostBack)
			{
				//document.getElementById("trTourTypeTop").style.display = "";
				document.getElementById("trTourType").style.display = "";
			}
			else
			{
				document.getElementById("trTourType").style.display = "";
			}
			document.getElementById("chkJapan").checked=false;
			document.getElementById("chkThailand").checked=false;
			document.getElementById("chkTaiwan").checked=false;
			document.getElementById("hidTourTypeJapan").value='';
			document.getElementById("hidTourTypeThailand").value='';
			document.getElementById("hidTourTypeTaiwan").value='';
			$("#TourTypeHTML").html("<strong>全部中國團 <br>(All China Tours)</strong>"); 
    
			if(document.getElementById("chkChina").checked==false)
			{
				document.getElementById("hidTourTypeChina").value='';  	 
				return;
		    }
		    var divs = "";
            jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: dataRequest, 
            success: function(msg){                
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'S10')>黃山江南10天8夜 (Yellow Mountain and Shanghai 10 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'S9')>黃山江南9天7夜 (Yellow Mountain and Shanghai 9 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'Y')>雲南8天6夜 (Yunnan 8 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'3')>京西桂9天7夜 (Beijing,Xian,Guilin 9 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'4')>京西桂滬11天9夜 (Golden China 11 days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'X')>川湘11天9夜 (Jiuzhaigo,Changsha,Chengdu 11Days)</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'P')>北京5天3夜 (Beijing 5 Days)</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'B')>雙京9天7夜 (Kanto+Beijing 9 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'')>全部中國團 (All China Tours)</div>"; 
                $("#divRegion").html(divs);
                showTourType("chkChina");
            }
        });
		}
		else if(Tour == 'Japan')
		{
			//if(!fPostBack)
				//document.getElementById("trTourTypeTop").style.display = "none";
			document.getElementById("trTourType").style.display = "";
			document.getElementById("chkChina").checked=false;
			document.getElementById("chkThailand").checked=false;
			document.getElementById("chkTaiwan").checked=false;
			document.getElementById("hidTourTypeChina").value=''; 
			document.getElementById("hidTourTypeThailand").value='';
			document.getElementById("hidTourTypeTaiwan").value='';
			$("#TourTypeHTML").html("<strong>全部日本團 <br>(All Japan Tours)</strong>"); 
			if(document.getElementById("chkJapan").checked==false)
			{
				document.getElementById("hidTourTypeJapan").value='';
				return;
		    }
		    var divs = "";
            jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: dataRequest, 
            success: function(msg){                
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'B')>雙京9天7夜 (Kanto+Beijing 9 Days)</div>";                
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'I')>日光6天4夜 (Nikko 6 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'J')>關東6天4夜 (Kanto 6 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'K')>關西7天5夜 (Kansai 7 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'C')>關東+關西9天7夜 (Kanto+Kansai 9 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'7')>北海道7天5夜 (Hokkaido 7 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'9')>北海道+東北9天7夜 (Hokkaido 9 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'F')>北海道+東北10天8夜 (Hokkaido 10 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'Q')>九州8天7夜 (Kyushu 8 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'')>全部日本團 (All Japan Tours)</div>"; 
                $("#divRegion").html(divs);
                showTourType("chkJapan");
            }
        });
		}
		else if(Tour == 'Thailand')
		{
			//if(!fPostBack)
				//document.getElementById("trTourTypeTop").style.display = "none";
			document.getElementById("trTourType").style.display = "";
			document.getElementById("chkChina").checked=false;
			document.getElementById("chkJapan").checked=false;
			document.getElementById("chkTaiwan").checked=false;
			document.getElementById("hidTourTypeChina").value=''; 
			document.getElementById("hidTourTypeJapan").value='';
			document.getElementById("hidTourTypeTaiwan").value='';
			$("#TourTypeHTML").html("<strong>全部泰國團 <br>(All Thailand Tours)</strong>"); 

			if(document.getElementById("chkThailand").checked==false)
			{
				document.getElementById("hidTourTypeThailand").value='';
				return;
		    }
		    var divs = "";
            jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: dataRequest, 
            success: function(msg){                
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeThailand',this,'T')>泰國6天4夜 (Thailand 6 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeThailand',this,'')>全部泰國團 (All Thailand Tours)</div>"; 
                $("#divRegion").html(divs);
                showTourType("chkThailand");
            }
        });
		}
		else if(Tour == 'Taiwan')
		{
			//if(!fPostBack)
				//document.getElementById("trTourTypeTop").style.display = "none";
			document.getElementById("trTourType").style.display = "";
			document.getElementById("chkChina").checked=false;
			document.getElementById("chkJapan").checked=false;
			document.getElementById("chkThailand").checked=false;
			document.getElementById("hidTourTypeChina").value=''; 
			document.getElementById("hidTourTypeJapan").value='';
			document.getElementById("hidTourTypeThailand").value='';
			$("#TourTypeHTML").html("<strong>全部臺灣團 <br>(All Taiwan Tours)</strong>"); 

			if(document.getElementById("chkTaiwan").checked==false)
			{
				document.getElementById("hidTourTypeTaiwan").value='';
				return;
		    }
		    var divs = "";
            jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: dataRequest, 
            success: function(msg){                
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeTaiwan',this,'W')>臺灣6天4夜 (Taiwan 6 Days)</div>"; 
	       divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeTaiwan',this,'M')>臺灣西部7天5夜 (Taiwan 7 Days)</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeTaiwan',this,'')>全部臺灣團 (All Taiwan Tours)</div>"; 
                $("#divRegion").html(divs);
                showTourType("chkTaiwan");
            }
        });
		}
	}
	function showTourType(cCountry)
{
	var mCountry = cCountry;
    text = document.getElementById(mCountry);
    div = document.getElementById("divRegion");
    div.style.left = getPos(text,"Left") + "px";
    div.style.top = getPos(text,"Top") + text.offsetHeight + "px";
    $("#divRegion").show();
}
	function hideRegion()
	{
		$("#divRegion").hide();
		$("#divRegion").html("");
		if(document.getElementById("chkAllCountry").checked==true)
		{
			//alert("1");
			PeriodToTime("all","all","all");
		}
		else
		{
			var sValueChina = "";
			var sValueJapan = "";
			var sValueThailand = "";
			var sValueTaiwan = "";
			
			if(document.getElementById("chkChina").checked==true)
				sValueChina = $("#hidTourTypeChina").val()!=""?$("#hidTourTypeChina").val():"all";
				
			if(document.getElementById("chkJapan").checked==true)
				sValueJapan = $("#hidTourTypeJapan").val()!=""?$("#hidTourTypeJapan").val():"all";
				
			if(document.getElementById("chkThailand").checked==true)
				sValueThailand = $("#hidTourTypeThailand").val()!=""?$("#hidTourTypeThailand").val():"all";
				
			if(document.getElementById("chkTaiwan").checked==true)
				sValueTaiwan = $("#hidTourTypeTaiwan").val()!=""?$("#hidTourTypeTaiwan").val():"all";

			
			//alert(sValueChina + ";" + sValueJapan + ";" + sValueThailand);
			PeriodToTime(sValueChina,sValueJapan,sValueThailand,sValueTaiwan);
		}
		//if(fPostBack)
			//FormCheckSubmit();
	}
function getValue(obj)
{
	var Cobj = obj;
	var mValue = document.getElementById(Cobj)==null?"":document.getElementById(Cobj).value;
	return mValue;
}
function getCheckboxValue(Cobj)
{
	var mValue="";
	if(document.getElementById(Cobj).checked == true)
		mValue = "yes";
	else
		mValue = "no";
	return mValue;
}
function FormCheck()
{
	if(document.getElementById('trCitySelectDeparting') == null)
	{
		if(document.getElementById('trCitySelect').style.display=='') 
		{
				if($("#UCSearchCriteria1_dlDepartureCity").val() == '') 
			{ 
					$("#UCSearchCriteria1_dlDepartureCity").focus();
					return false;
			}
				if($("#UCSearchCriteria1_dlReturnCity").val() == '') 
			{ 
					$("#UCSearchCriteria1_dlReturnCity").focus();
					return false;
			}
		}
	}
	else
	{
		if(document.getElementById('trCitySelectDeparting').style.display=='') 
		{
				if($("#UCSearchCriteria1_dlDepartureCity").val() == '') 
			{ 
					$("#UCSearchCriteria1_dlDepartureCity").focus();
					return false;
			}
				if($("#UCSearchCriteria1_dlReturnCity").val() == '') 
			{ 
					$("#UCSearchCriteria1_dlReturnCity").focus();
					return false;
			}
		}
	}
	return true;
}
function FormCheckSubmit()
{
if(FormCheck())
	{
		var loader = document.getElementById("loading"); 
		var _frame = document.getElementById("frmResultID"); 
        loader.style.display = "";  
        _frame.style.visibility = "hidden";   
        goto_top();

		frames["frmResult"].location="/signet/V4/quotation/QuotationResults.aspx?Type="+document.getElementById("hidTourType").value
		+"&DepartureCity="+getValue("UCSearchCriteria1_dlDepartureCity")
		+"&ReturnCity="+getValue("UCSearchCriteria1_dlReturnCity")
		+'&chkChina='+getCheckboxValue('chkChina')
		+'&chkJapan='+getCheckboxValue('chkJapan')
		+'&chkThailand='+getCheckboxValue('chkThailand')
		+'&chkTaiwan='+getCheckboxValue('chkTaiwan')
		+'&chkAllCountry='+getCheckboxValue('chkAllCountry')
		+'&TourTypeChina='+getValue('hidTourTypeChina')
		+'&TourTypeJapan='+getValue('hidTourTypeJapan')
		+'&TourTypeThailand='+getValue('hidTourTypeThailand')
		+'&TourTypeTaiwan='+getValue('hidTourTypeTaiwan')
		+"&PeriodFromMonth="+getValue("tbFromMonth")
		+"&PeriodFromYear="+getValue("tbFromYear")
		+"&PeriodToMonth="+getValue("tbToMonth")
		+"&PeriodToYear="+getValue("tbToYear")
		+"&BudgetFrom="+getValue("tbBudgetLow")
		+"&BudgetTo="+getValue("tbBudgetHigh")
		+"&StopOverCity="+getValue("tbStopover")
		+"&Airline="+getValue("tbAirline")
		+"&TourStartingDate="+Request("TourStartingDate")
		+"&DepartureDate="+Request("DepartureDate")
		+"&TourCode="+Request("TourCode")
		+"&TourEndingDate="+Request("TourEndingDate")
		+"&TourDate="+Request("TourDate")
		+"&Language="+Request("Language")
		+"&From=v4";
	}
}
function popWin(theURL,winName,theW,theH) { 
    theTop = (window.screen.height-theH)/2; 
    theLeft = (window.screen.width-theW)/2; 
    var features = "toolbar=0,scrollbars=yes,left=" + theLeft + ",top=" + theTop + ",width=" + theW + ",height=" + theH; 
    window.SubWin = window.open(theURL,winName,features); 
    } 
			

			
function IsNumber()
{		
	if(event.keyCode<48 || event.keyCode>57)
	{
		event.keyCode=0;
	}
} 
function IsIE()
{
	if (window.navigator.userAgent.indexOf("MSIE")>=1)
	{			
		return true;					
	}
	else
	{		
		return false;
	}
}
		
function showTourOnly(flag)
{
	if(document.getElementById('trCitySelectDeparting') == null)
		document.getElementById('trCitySelect').style.display=flag;
	else
		{
			document.getElementById('trCitySelectDeparting').style.display=flag;
			document.getElementById('trCitySelectReturning').style.display=flag;
		}
	document.getElementById('trAirline').style.display=flag;
	document.getElementById('trStopover').style.display=flag;
	if(flag == '')
		document.getElementById('hidTourType').value ='Package';
	else
		document.getElementById('hidTourType').value = 'TourOnly';
		
}
function SetValueToControls(sControl,sValue)
{
	var mControl = sControl;
	var mValue = sValue;
	document.getElementById(mControl).value = mValue;
}
function dateIntToString(mInt)
{
	var Months=new Array(12);
	Months[0]="Jan";
	Months[1]="Feb";
	Months[2]="Mar";
	Months[3]="Apr";
	Months[4]="May";
	Months[5]="Jun";
	Months[6]="Jul";
	Months[7]="Aug";
	Months[8]="Sep";
	Months[9]="Oct";
	Months[10]="Nov";
	Months[11]="Dec";
	return Months[mInt];
}
function StringIntTodate(mString)
{
	if(mString == "Jan")
		return "1";
	else if(mString == "Jan")
		return "1";
	else if(mString == "Feb")
		return "2";
	else if(mString == "Mar")
		return "3";
	else if(mString == "Apr")
		return "4";
	else if(mString == "May")
		return "5";
	else if(mString == "Jun")
		return "6";
	else if(mString == "Jul")
		return "7";
	else if(mString == "Aug")
		return "8";
	else if(mString == "Sep")
		return "9";
	else if(mString == "Oct")
		return "10";
	else if(mString == "Nov")
		return "11";
	else if(mString == "Dec")
		return "12";
}
function setIndexDefault()
{
	var d=new Date();
	
	var tMonth = d.getMonth();
	var cMonth = dateIntToString(tMonth);

	$("#tbFromMonth").val(cMonth);
	var tYear = d.getFullYear();
	$("#tbFromYear").val(tYear);
	tMonth = (tMonth+6) ;
	if(tMonth >=12)
		tYear = tYear + 1;
	tMonth = tMonth% 12;
	cMonth = dateIntToString(tMonth);
	//$("#tbToMonth").val(cMonth);
	//$("#tbToYear").val(tYear);
	PeriodToTime("all","all");
}
function setPeriodTime()
{
		var d=new Date();
			var sCMonth = dateIntToString(d.getMonth());
			var sCYear = d.getFullYear();
	
			////getQueryStringValue
			if(Request('PeriodFromMonth')!='')
				SetValueToControls('tbFromMonth',Request('PeriodFromMonth'));
			else
				SetValueToControls('tbFromMonth',sCMonth);
				
			if(Request('PeriodFromYear')!='')
				SetValueToControls('tbFromYear',Request('PeriodFromYear'));
			else
				SetValueToControls('tbFromYear',sCYear);
				
			if(Request('PeriodToMonth')!='')
				SetValueToControls('tbToMonth',Request('PeriodToMonth'));
			else
				 PeriodToTime("all","all");
				
			if(Request('PeriodToYear')!='')
				SetValueToControls('tbToYear',Request('PeriodToYear'));
			else
				PeriodToTime("all","all");
}
function SetTourDateDefaultValue()
{
			
			setPeriodTime();
			if(Request('Country')=="China")
			{
				$("#chkChina").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeChina','TourType');
				if($("#TourTypeHTML").html()=='')
					$("#TourTypeHTML").html("<strong>全部中國團<br>(All China Tours)</strong>"); 
			}
			if(Request('Country')=="Japan")
			{
				$("#chkJapan").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeJapan','TourType');
				if($("#TourTypeHTML").html()=='')
					$("#TourTypeHTML").html("<strong>全部日本團<br>(All Japan Tours)</strong>"); 
			}
			if(Request('Country')=="Thailand")
			{
				$("#chkThailand").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeThailand','TourType');
				if($("#TourTypeHTML").html()=='')
					$("#TourTypeHTML").html("<strong>全部泰國團<br>(All Thailand Tours)</strong>"); 
			}
			if(Request('Country')=="Taiwan")
			{
				$("#chkTaiwan").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeTaiwan','TourType');
				if($("#TourTypeHTML").html()=='')
					$("#TourTypeHTML").html("<strong>全部臺灣團<br>(All Taiwan Tours)</strong>"); 
			}
			/*
			if(document.getElementById("chkChina").checked==true)
			if(document.getElementById("chkJapan").checked==true)
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeJapan','TourTypeJapan');
			if(document.getElementById("chkThailand").checked==true)
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeThailand','TourTypeThailand');
			if(document.getElementById("chkTaiwan").checked==true)
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeTaiwan','TourTypeTaiwan');
			if(document.getElementById("chkChina").checked==false && document.getElementById("chkJapan").checked==false && document.getElementById("chkThailand").checked==false
			&& document.getElementById("chkTaiwan").checked==false)
				document.getElementById("chkAllCountry").checked=true;
			if(document.getElementById("chkAllCountry").checked==true && Request('Type')=='')
			setIndexDefault();
			*/
			//////////////////
}
function SetDefaultValue()
{

////getQueryStringValue
SetValueToControls('UCSearchCriteria1_dlReturnCity',unescape(Request('ReturnCity')));
SetValueToControls('UCSearchCriteria1_dlDepartureCity',unescape(Request('DepartureCity')));
if(Request('PeriodFromMonth')!='')
	SetValueToControls('tbFromMonth',Request('PeriodFromMonth'));
if(Request('PeriodFromYear')!='')
	SetValueToControls('tbFromYear',Request('PeriodFromYear'));
if(Request('PeriodToMonth')!='')
	SetValueToControls('tbToMonth',Request('PeriodToMonth'));
if(Request('PeriodToYear')!='')
	SetValueToControls('tbToYear',Request('PeriodToYear'));
	
SetValueToControls('tbBudgetLow',Request('BudgetFrom'));
SetValueToControls('tbBudgetHigh',Request('BudgetTo'));
SetValueToControls('tbStopover',unescape(Request('StopOverCity')));
SetValueToControls('tbAirline',unescape(Request('Airline')));
SetValueToControls('hidAirline',unescape(Request('hidAirline')));


if(Request('Type')!='')
{
	if(Request('Type')=='Package')
	{
	   document.getElementById("rdbTourTypeP").checked=true;
           showTourOnly('');
	}
	else
	{
	   document.getElementById("rdbTourTypeT").checked=true;
	   showTourOnly('none');
	}
}

ckbDefaultValue('chkChina');
ckbDefaultValue('chkAllCountry');
ckbDefaultValue('chkJapan');
ckbDefaultValue('chkThailand');
ckbDefaultValue('chkTaiwan');

if(document.getElementById("chkChina").checked==true)
	TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeChina','TourTypeChina');
if(document.getElementById("chkJapan").checked==true)
	TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeJapan','TourTypeJapan');
if(document.getElementById("chkThailand").checked==true)
	TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeThailand','TourTypeThailand');
if(document.getElementById("chkTaiwan").checked==true)
	TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeTaiwan','TourTypeTaiwan');
if(document.getElementById("chkChina").checked==false && document.getElementById("chkJapan").checked==false && document.getElementById("chkThailand").checked==false
 && document.getElementById("chkTaiwan").checked==false)
    document.getElementById("chkAllCountry").checked=true;
if(document.getElementById("chkAllCountry").checked==true && Request('Type')=='')
 setIndexDefault();
//////////////////
}
function TourValueDefaultValue(SpanObj,hidValue,strName)
{
	var mValue = Request(strName);
	if(mValue!='')
	{
		if(mValue=='S10')
		{
			$(SpanObj).html("<strong>黃山江南10天8夜 <br/>(Yellow Mountain and Shanghai 10 Days)</strong>"); 
			document.getElementById(hidValue).value='S10'; 
		}
		else if(mValue=='S9')
		{
			$(SpanObj).html("<strong>黃山江南9天7夜 <br/>(Yellow Mountain and Shanghai 9 Days)</strong>"); 
			document.getElementById(hidValue).value='S9'; 
		}
		else if(mValue=='Y')
		{
			$(SpanObj).html("<strong>雲南8天6夜 <br/>(Yunnan 8 Days)</strong>"); 
			document.getElementById(hidValue).value='Y'; 
		}
		else if(mValue=='3')
		{
			$(SpanObj).html("<strong>京西桂9天7夜 <br/>(Beijing,Xian,Guilin 9 Days)</strong>"); 
			document.getElementById(hidValue).value='3'; 
		}  
		else if(mValue=='4')
		{
			$(SpanObj).html("<strong>京西桂滬11天9夜 <br/>(Golden China 11 days)</strong>"); 
			document.getElementById(hidValue).value='4'; 
		}  
		else if(mValue=='X')
		{
			$(SpanObj).html("<strong>川湘11天9夜 <br/>(Jiuzhaigo,Changsha,Chengdu 11Days)</strong>"); 
			document.getElementById(hidValue).value='X'; 
		}  
		else if(mValue=='P')
		{
			$(SpanObj).html("<strong>北京5天3夜 <br/>(Beijing 5 Days)</strong>"); 
			document.getElementById(hidValue).value='P'; 
		} 
		else if(mValue=='B')
		{
			$(SpanObj).html("<strong>雙京9天7夜 <br/>(Kanto+Beijing 9 Days)</strong>"); 
			document.getElementById(hidValue).value='B'; 
		}
		else if(mValue=='I')
		{ 
			$(SpanObj).html("<strong>日光6天4夜 <br/>(Nikko 6 Days)</strong>"); 
			document.getElementById(hidValue).value='I'; 
		} 		
		else if(mValue=='J')
		{
			$(SpanObj).html("<strong>關東6天4夜 <br/>(Kanto 6 Days)</strong>"); 
			document.getElementById(hidValue).value='J'; 
		} 
		else if(mValue=='K')
		{
			$(SpanObj).html("<strong>關西7天5夜 <br/>(Kansai 7 Days)</strong>"); 
			document.getElementById(hidValue).value='K'; 
		}
		else if(mValue=='C')
		{
			$(SpanObj).html("<strong>關東+關西9天7夜 <br/>(Kanto+Kansai 9 Days)</strong>"); 
			document.getElementById(hidValue).value='C'; 
		}
		else if(mValue=='7')
		{
			$(SpanObj).html("<strong>北海道7天5夜 <br/>(Hokkaido 7 Days)</strong>"); 
			document.getElementById(hidValue).value='7'; 
		}
		else if(mValue=='9')
		{
			$(SpanObj).html("<strong>北海道+東北9天7夜 <br/>(Hokkaido 9 Days)</strong>"); 
			document.getElementById(hidValue).value='9'; 
		}
		else if(mValue=='F')
		{
			$(SpanObj).html("<strong>北海道+東北10天8夜 <br/>(Hokkaido 10 Days)</strong>"); 
			document.getElementById(hidValue).value='F'; 
		}
		else if(mValue=='Q')
		{
			$(SpanObj).html("<strong>九州8天7夜 <br/>(Kyushu 8 Days)</strong>"); 
			document.getElementById(hidValue).value='Q'; 
		}
		else if(mValue=='T')
		{
			$(SpanObj).html("<strong>泰國6天4夜 <br/>(Thailand 6 Days)</strong>"); 
			document.getElementById(hidValue).value='T'; 
		}
		else if(mValue=='W')
		{
			$(SpanObj).html("<strong>臺灣6天4夜 <br/>(Taiwan 6 Days)</strong>"); 
			document.getElementById(hidValue).value='W'; 
		}
		else if(mValue=='M')
		{
			$(SpanObj).html("<strong>臺灣西部7天5夜 <br/>(Taiwan 7 Days)</strong>"); 
			document.getElementById(hidValue).value='M'; 
		}
	}
	else 
	{
		if(strName=="TourTypeChina")
			$(SpanObj).html("<strong>全部中國團<br>(All China Tours)</strong>"); 
		else if(strName=="TourTypeJapan")
			$(SpanObj).html("<strong>全部日本團<br>(All Japan Tours)</strong>"); 
		else if(strName=="TourTypeThailand")
			$(SpanObj).html("<strong>全部泰國團<br>(All Thailand Tours)</strong>"); 
		else if(strName=="TourTypeTaiwan")
			$(SpanObj).html("<strong>全部臺灣團<br>(All Taiwan Tours)</strong>"); 
			
	}
}
function ckbDefaultValue(strName)
{
	if(Request(strName)=='yes')
		document.getElementById(strName).checked=true;
	else
		document.getElementById(strName).checked=false;
}
function Request(strName){ 
 var strHref = window.location.search;
 var intPos = strHref.indexOf("?"); 
 var strRight = strHref.substr(intPos + 1); 
 var arrTmp = strRight.split("&"); 
 for(var i = 0; i < arrTmp.length; i++) { 
 var arrTemp = arrTmp[i].split("="); 
 if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1]; 
 } 
 return ""; 
} 


//<![CDATA[
var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer()
{
var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
var moveby = 15;

y -= Math.ceil(y * moveby / 100);
if (y < 0) {
y = 0;
}

if (goto_top_type == 1) {
document.documentElement.scrollTop = y;
}
else {
document.body.scrollTop = y;
}

if (y == 0) {
clearInterval(goto_top_itv);
goto_top_itv = 0;
$("body").css("overflow", "auto");
$("body").css("max-height", "none");
}
}

function goto_top()
{
if (goto_top_itv == 0) {
if (document.documentElement && document.documentElement.scrollTop) {
goto_top_type = 1;
document.documentElement.scrollTop = 0;
}
else if (document.body && document.body.scrollTop) {
goto_top_type = 2;
document.body.scrollTop = 0;
}
else {
goto_top_type = 0;
}

/*if (goto_top_type > 0) {
$("body").css("overflow", "hidden");
$("body").css("margin", "0");
$("body").css("width", "100%");
$("body").css("height", "100%");
//$("body").css("max-height",document.body.clientHeight);
goto_top_itv = setInterval('goto_top_timer()', 1);

}
*/
}
}
function RegionAll()
{
	//document.getElementById("tbAirline").value = "";
	//document.getElementById("tbStopover").value = "";
	//document.getElementById("hidAirline").value = "";
		
	document.getElementById("chkChina").checked=false;
	document.getElementById("chkJapan").checked=false;
	document.getElementById("chkThailand").checked=false;
	document.getElementById("chkTaiwan").checked=false;
	document.getElementById("chkAllCountry").checked=true;
	//if(!fPostBack)
		//document.getElementById("trTourTypeTop").style.display = "none";
	document.getElementById("trTourType").style.display = "none";
	
	document.getElementById("hidTourTypeChina").value=''; 
	document.getElementById("hidTourTypeJapan").value='';
	document.getElementById("hidTourTypeThailand").value='';
	document.getElementById("hidTourTypeTaiwan").value='';
    $("#TourTypeHTML").html(""); 
    hideRegion();
	 //if(fPostBack)
		//FormCheckSubmit();
}
function PeriodToTime(sTourTypeChina,sTourTypeJapan,sTourTypeThailand,sTourTypeTaiwan)
{
	jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: "/Data/PeriodToTime.aspx",            
            data: "TourTypeChina=" + sTourTypeChina + "&TourTypeJapan=" + sTourTypeJapan + "&TourTypeThailand=" + sTourTypeThailand + "&TourTypeTaiwan=" + sTourTypeTaiwan,
            success: function(msg){  
            if(msg.length==0)
                {
                    return;
                }
                var datas = msg.split(seperator);
				var cur=new Date(Date.parse(datas[0].replace(/-/g,"/")));
				$("#tbToMonth").val(dateIntToString(cur.getMonth()));
				$("#tbToYear").val(cur.getFullYear());
            }
        });
}
function AirlineDatamouseover(sDiv,sValue)
{    
	document.getElementById("hidAirline").value = sValue;
    $("#floor").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
    
    //if(sValue == 0)
	//	currentInput.val('');
	//else
		currentInput.val($(sDiv).text());
    setPos(currentInput.attr("id"),0);
		
}
function MonthFill(sID)
{    
	currentInput = $(sID);
	var divs="";
	var m=0;
	for(m=0;m<12;m++)
	{
		var n = dateIntToString(m);
		divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ n +"</div>";
		
	}
	$("#floor").html(divs);
	isShow = true;
	showText();
}

function checkIEVersion()
{
  var   X,V,N;   
  X = 0;
  V=navigator.appVersion;   
  N=navigator.appName;   
  if(N=="Microsoft Internet Explorer")     
    X=parseFloat(V.substring(V.indexOf("MSIE")+5,V.lastIndexOf("Windows")));
  else   
    X=parseFloat(V);   
  return X;
}

function setPos(obj, pos) { 
var e =document.getElementById(obj); 
    if(e.createTextRange) { 
        var range = e.createTextRange(); 
        range.move("character", e); 
        range.select(); 
    } else if(e.selectionStart) { 
        e.focus(); 
        e.setSelectionRange(pos, pos); 
    } 
} 

var sTourDate_PeriodFrom;
var sTourDate_PeriodTo;
var sTourDate_Country;
var sTourDate_TourType;
function TourDateValue()
{
	sTourDate_PeriodFrom = StringIntTodate(document.getElementById("tbFromMonth").value) + "/1" + "/" +  document.getElementById("tbFromYear").value;
	sTourDate_PeriodTo = StringIntTodate(document.getElementById("tbToMonth").value) + "/30" + "/" + document.getElementById("tbToYear").value;
	sTourDate_Country = "China";
	sTourDate_TourType="";
	//sTourDate_TourType="S";
	if(document.getElementById("chkChina").checked==true)
	{
		sTourDate_Country="China";
		sTourDate_TourType = $("#hidTourTypeChina").val();
	}
	if(document.getElementById("chkJapan").checked==true)
	{
		sTourDate_Country="Japan";
		sTourDate_TourType = $("#hidTourTypeJapan").val();
	}
	if(document.getElementById("chkThailand").checked==true)
	{
		sTourDate_Country="Thailand";
		sTourDate_TourType = $("#hidTourTypeThailand").val();
	}
	if(document.getElementById("chkTaiwan").checked==true)
	{
		sTourDate_Country="Taiwan";
		sTourDate_TourType = $("#hidTourTypeTaiwan").val();
	}
}
function WebQuotationBeyondCityGet(Prefix)
{
	//setPos('tbStopover',0);
	//document.getElementById("tbStopover").value = "";
	var sAlnID = document.getElementById("hidAirline").value;
	if(sAlnID == '')
		{
			sAlnID = 0;
			//document.getElementById("tbAirline").focus();
			//return;
		}
	document.getElementById("tbStopover").style.backgroundImage ="url('http://www.signettours.com/images/spinner.gif')";
	document.getElementById("tbStopover").style.backgroundRepeat ="no-repeat";

	//$("#sStopOver").html("<img src='http://www.signettours.com/images/spinner.gif'/>"); 
	currentInput = $("#tbStopover");
	var sTourType = "";
	if(document.getElementById("chkAllCountry").checked==true)
		sTourType = 'ALL'
	else if(document.getElementById("chkChina").checked==true)
		sTourType = document.getElementById("hidTourTypeChina").value==""?"ALL CHINA":document.getElementById("hidTourTypeChina").value;
	else if(document.getElementById("chkJapan").checked==true)
		sTourType = document.getElementById("hidTourTypeJapan").value==""?"ALL JAPAN":document.getElementById("hidTourTypeJapan").value;
	else if(document.getElementById("chkThailand").checked==true)
		sTourType = document.getElementById("hidTourTypeThailand").value==""?"ALL THAILAND":document.getElementById("hidTourTypeThailand").value;
	else if(document.getElementById("chkTaiwan").checked==true)
		sTourType = document.getElementById("hidTourTypeTaiwan").value==""?"ALL TAIWAN":document.getElementById("hidTourTypeTaiwan").value;
	//alert(sTourType);
	
	var sPeriodFrom = document.getElementById("tbFromYear").value + "/" + StringIntTodate(document.getElementById("tbFromMonth").value) + "/1";
	var sPeriodTo = document.getElementById("tbToYear").value + "/" + StringIntTodate(document.getElementById("tbToMonth").value) + "/30";
	var sDepartingCity = document.getElementById("UCSearchCriteria1_dlDepartureCity").value;
	var sReturnCity = document.getElementById("UCSearchCriteria1_dlReturnCity").value;
	jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: "/Data/StopOverCityData.aspx",            
            data: "sTourType=" + sTourType + "&sAlnID=" + sAlnID + "&sPeriodFrom=" + sPeriodFrom + "&Prefix=" + Prefix + "&sPeriodTo=" + sPeriodTo + "&sDepartingCity=" + sDepartingCity + "&sReturnCity=" + sReturnCity,
            success: function(msg){  
            if(msg.length==0)
                {
                    return;
                }
                var divs="";
                var datas = msg.split(',');
                 if(datas.length == 2)
                {
					currentInput.val(datas[0]);
					divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ datas[0] +"</div>";
					$("#floor").html(divs);
					isShow = true;
					showText();
					document.getElementById("tbStopover").style.backgroundImage="";
					//$("#sStopOver").html(""); 
					return;
                }
                divs += "<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>&nbsp;</div>";
                $.each(datas, function(i, n){
                    if(n.length > 0) 
                    {
							divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ n +"</div>";
					}
                });
                $("#floor").html(divs);
                isShow = true;
                showText();
				//$("#sStopOver").html(""); 
				document.getElementById("tbStopover").style.backgroundImage="";
            }
        });
}


function WebQuotationAirlineGet(Prefix)
{
	//setPos('tbAirline',0);
	document.getElementById("tbStopover").value = "";
	//document.getElementById("tbAirline").value = "";
	
	document.getElementById("tbAirline").style.backgroundImage ="url('http://www.signettours.com/images/spinner.gif')";
	document.getElementById("tbAirline").style.backgroundRepeat ="no-repeat";

	//$("#sAirline").html("<img src='http://www.signettours.com/images/spinner.gif'/>"); 
	currentInput = $("#tbAirline");
	
	var sTourType = "";
	if(document.getElementById("chkAllCountry").checked==true)
		sTourType = 'ALL'
	else if(document.getElementById("chkChina").checked==true)
		sTourType = document.getElementById("hidTourTypeChina").value==""?"ALL CHINA":document.getElementById("hidTourTypeChina").value;
	else if(document.getElementById("chkJapan").checked==true)
		sTourType = document.getElementById("hidTourTypeJapan").value==""?"ALL JAPAN":document.getElementById("hidTourTypeJapan").value;
	else if(document.getElementById("chkThailand").checked==true)
		sTourType = document.getElementById("hidTourTypeThailand").value==""?"ALL THAILAND":document.getElementById("hidTourTypeThailand").value;
	else if(document.getElementById("chkTaiwan").checked==true)
		sTourType = document.getElementById("hidTourTypeTaiwan").value==""?"ALL TAIWAN":document.getElementById("hidTourTypeTaiwan").value;

	//alert(sTourType);
	
	var sPeriodFrom = document.getElementById("tbFromYear").value + "/" + StringIntTodate(document.getElementById("tbFromMonth").value) + "/1";
	var sPeriodTo = document.getElementById("tbToYear").value + "/" + StringIntTodate(document.getElementById("tbToMonth").value) + "/30";
	var sDepartingCity = document.getElementById("UCSearchCriteria1_dlDepartureCity").value;
	var sReturnCity = document.getElementById("UCSearchCriteria1_dlReturnCity").value;
	//alert(sPeriodFrom);
	//alert(sPeriodTo);
	//alert(sDepartingCity);
	//alert(sReturnCity);
	jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: "/Data/AirlineData.aspx",            
            data: "sTourType=" + sTourType + "&sPeriodFrom=" + sPeriodFrom + "&Prefix=" + Prefix + "&sPeriodTo=" + sPeriodTo + "&sDepartingCity=" + sDepartingCity + "&sReturnCity=" + sReturnCity,
            success: function(msg){  
            if(msg.length==0)
                {
                    return;
                }
                var divs="";
                var datas = msg.split(',');
                 if(datas.length == 2)
                {
					if(datas[0].indexOf("|")>=0)
						{
							var sValue = datas[0].split('|');
							currentInput.val(sValue[1]);
							document.getElementById("hidAirline").value = sValue[0];
							divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = AirlineDatamouseover(this,"+ sValue[0] +")>"+ sValue[1] +"</div>";
							$("#floor").html(divs);
							isShow = true;
							showText();
							document.getElementById("tbAirline").style.backgroundImage ="";
							//$("#sAirline").html(""); 
							return;
						}
                }
                divs += "<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = AirlineDatamouseover(this,0)>&nbsp;</div>";
                $.each(datas, function(i, n){
                    if(n.length > 0) 
                    {
						if(n.indexOf("|")>=0)
						{
							var sValue = n.split('|');
							divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = AirlineDatamouseover(this,"+ sValue[0] +")>"+ sValue[1] +"</div>";
						}
					}
                });
                $("#floor").html(divs);
                isShow = true;
                showText();
				document.getElementById("tbAirline").style.backgroundImage ="";
				//$("#sAirline").html(""); 
                
            }
        });
}

function PeriodToTimeNavigation(sTourTypePara,sCountryPara,isTourDate)
{
	var sCountry = "TourType" + sCountryPara;
	var sPricechk = "chk" + sCountryPara;
	//var sTourType = sTourTypePara;
	var d=new Date();
	var sTourDate_PeriodMonthFrom = dateIntToString(d.getMonth());
	var sTourDate_PeriodYearFrom = d.getFullYear();
	
	var sNavigation_PeriodFrom;
	var sNavigation_PeriodTo;
	
	var sTourDate_PeriodMonthTo;
	var sTourDate_PeriodYearTo;

	var sReturnTour = "TourAvailability.aspx";
	var sReturnPrice = "faresheet.aspx";
	
	jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: "/Data/PeriodToTime.aspx",  
            ///Data/PeriodToTime.aspx?tourtypeJapan=a          
            //data: "tourtypeJapan=a",
            data: sCountry + "=" + sTourTypePara,
            //data: "TourTypeChina=" + sTourTypeChina + "&TourTypeJapan=" + sTourTypeJapan + "&TourTypeThailand=" + sTourTypeThailand + "&TourTypeTaiwan=" + sTourTypeTaiwan,
            success: function(msg){  
            if(msg.length==0)
                {
                   return;
                }
                var datas = msg.split(';');
				var cur=new Date(Date.parse(datas[0].replace(/-/g,"/")));
				sTourDate_PeriodMonthTo = dateIntToString(cur.getMonth());
				sTourDate_PeriodYearTo = cur.getFullYear();
				
				
				sNavigation_PeriodFrom = StringIntTodate(sTourDate_PeriodMonthFrom) + "/1" + "/" +  sTourDate_PeriodYearFrom;
				sNavigation_PeriodTo = StringIntTodate(sTourDate_PeriodMonthTo) + "/30" + "/" + sTourDate_PeriodYearTo;

				//出团日期
					sReturnTour = "TourAvailability.aspx?Type=TourAvailability"
						+"&TourType="+sTourTypePara
						+"&PeriodFrom="+sNavigation_PeriodFrom
						+"&PeriodTo="+sNavigation_PeriodTo
						+"&Language="
						+"&Country="+sCountryPara
						+"&PeriodFromMonth="+sTourDate_PeriodMonthFrom
						+"&PeriodFromYear="+sTourDate_PeriodYearFrom
						+"&PeriodToMonth="+sTourDate_PeriodMonthTo
						+"&PeriodToYear="+sTourDate_PeriodYearTo
						+"&From=v4";
					$("#sTourNav").attr("href",sReturnTour);
				//价目表
					sReturnPrice = "Quotation.aspx?Type=Package"
						+"&DepartureCity="
						+"&ReturnCity="
						+"&"+ sPricechk +"=yes"
						+"&"+ sCountry +"="+sTourTypePara
						+"&PeriodFromMonth="+sTourDate_PeriodMonthFrom
						+"&PeriodFromYear="+sTourDate_PeriodYearFrom
						+"&PeriodToMonth="+sTourDate_PeriodMonthTo
						+"&PeriodToYear="+sTourDate_PeriodYearTo
						+"&BudgetFrom=&BudgetTo=&StopOverCity=&Airline=&hidAirline="
						+"&From=v4";
					$("#sPriceNav").attr("href",sReturnPrice);
            }
        });
}



function WebQuotationAirlineGet2(Prefix)
{
	//setPos('tbAirline',0);
	//document.getElementById("tbStopover").value = "";
	//document.getElementById("tbAirline").value = "";
	
	document.getElementById("tbAirline").style.backgroundImage ="url('http://www.signettours.com/images/spinner.gif')";
	document.getElementById("tbAirline").style.backgroundRepeat ="no-repeat";

	//$("#sAirline").html("<img src='http://www.signettours.com/images/spinner.gif'/>"); 
	currentInput = $("#tbAirline");
	
	var sTourType = "";
//	if(document.getElementById("chkAllCountry").checked==true)
//		sTourType = 'ALL'
//	else if(document.getElementById("chkChina").checked==true)
//		sTourType = document.getElementById("hidTourTypeChina").value==""?"ALL CHINA":document.getElementById("hidTourTypeChina").value;
//	else if(document.getElementById("chkJapan").checked==true)
//		sTourType = document.getElementById("hidTourTypeJapan").value==""?"ALL JAPAN":document.getElementById("hidTourTypeJapan").value;
//	else if(document.getElementById("chkThailand").checked==true)
//		sTourType = document.getElementById("hidTourTypeThailand").value==""?"ALL THAILAND":document.getElementById("hidTourTypeThailand").value;
//	else if(document.getElementById("chkTaiwan").checked==true)
//		sTourType = document.getElementById("hidTourTypeTaiwan").value==""?"ALL TAIWAN":document.getElementById("hidTourTypeTaiwan").value;

	//alert(sTourType);
	sTourType = document.getElementById("hidTourType").value;
	
//	var sPeriodFrom = document.getElementById("tbFromYear").value + "/" + StringIntTodate(document.getElementById("tbFromMonth").value) + "/1";
//	var sPeriodTo = document.getElementById("tbToYear").value + "/" + StringIntTodate(document.getElementById("tbToMonth").value) + "/30";
//	var sDepartingCity = document.getElementById("UCSearchCriteria1_dlDepartureCity").value;
//	var sReturnCity = document.getElementById("UCSearchCriteria1_dlReturnCity").value;

	var sPeriodFrom = "2010/2/1";
	var sPeriodTo = "2010/10/1";
	var sDepartingCity = "";
	var sReturnCity = "";
	//alert(sPeriodFrom);
	//alert(sPeriodTo);
	//alert(sDepartingCity);
	//alert(sReturnCity);
	jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: "../../../Data/AirlineData.aspx",            
            data: "sTourType=" + sTourType + "&sPeriodFrom=" + sPeriodFrom + "&Prefix=" + Prefix + "&sPeriodTo=" + sPeriodTo + "&sDepartingCity=" + sDepartingCity + "&sReturnCity=" + sReturnCity,
            success: function(msg){  
            if(msg.length==0)
                {
                    return;
                }
                var divs="";
                var datas = msg.split(',');
                 if(datas.length == 2)
                {
					if(datas[0].indexOf("|")>=0)
						{
							var sValue = datas[0].split('|');
							currentInput.val(sValue[1]);
							//document.getElementById("hidAirline").value = sValue[0];
							divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = AirlineDatamouseover2(this,"+ sValue[0] +")>"+ sValue[1] +"</div>";
							$("#floor").html(divs);
							isShow = true;
							showText();
							document.getElementById("tbAirline").style.backgroundImage ="";
							//$("#sAirline").html(""); 
							return;
						}
                }
                divs += "<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = AirlineDatamouseover2(this,0)>&nbsp;</div>";
                $.each(datas, function(i, n){
                    if(n.length > 0) 
                    {
						if(n.indexOf("|")>=0)
						{
							var sValue = n.split('|');
							divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = AirlineDatamouseover2(this,"+ sValue[0] +")>"+ sValue[1] +"</div>";
						}
					}
                });
               
                $("#floor").html(divs);
                isShow = true;
                showText();
				document.getElementById("tbAirline").style.backgroundImage ="";
				//$("#sAirline").html(""); 
                
            }
        });
}

function AirlineDatamouseover2(sDiv,sValue)
{    
	//document.getElementById("hidAirline").value = sValue;
    $("#floor").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
    
    //if(sValue == 0)
	//	currentInput.val('');
	//else
		currentInput.val($(sDiv).text());
    setPos(currentInput.attr("id"),0);
		
}
function getParameterByName(name) 
{ 
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 
  var regexS = "[\\?&]"+name+"=([^&#]*)"; 
  var regex = new RegExp(regexS); 
  var results = regex.exec(window.location.href); 
  if(results == null) 
    return "";
  else 
    return results[1]; 
} 

function AgentCitySelect(Prefix)
{
	currentInput = $("#tbStopover");
	document.getElementById("tbStopover").style.backgroundImage ="url('http://www.signettours.com/images/spinner.gif')";
	document.getElementById("tbStopover").style.backgroundRepeat ="no-repeat";


	var sAlnID = Request("AlnID")==''?"0":Request("AlnID");
	var sTourType = Request("TourType");
	var sPeriodFrom = Request("DepartureDate");
	var sPeriodTo = Request("TourEndingDate");
	
	jQuery.ajax({
            type: "Get",
            dataType: "text",
            url: "/Data/AgentBeyondCityGet.aspx",            
            data: "sTourType=" + sTourType + "&sAlnID=" + sAlnID + "&sPeriodFrom=" + sPeriodFrom + "&Prefix=" + Prefix + "&sPeriodTo=" + sPeriodTo,
            success: function(msg){  
            if(msg.length==0)
                {
                    return;
                }
                var divs="";
                var datas = msg.split(',');
                 if(datas.length == 2)
                {
					currentInput.val(datas[0]);
					divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ datas[0] +"</div>";
					$("#floor").html(divs);
					isShow = true;
					showText();
					document.getElementById("tbStopover").style.backgroundImage="";
					return;
                }
                divs += "<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>&nbsp;</div>";
                $.each(datas, function(i, n){
                    if(n.length > 0) 
                    {
							divs+="<div class=unselected onclick=hideText() onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ n +"</div>";
					}
                });
                $("#floor").html(divs);
                isShow = true;
                showText();
				document.getElementById("tbStopover").style.backgroundImage="";
            }
        });
}

function AgentSelectDefaultValue()
{
	var sDepartureCity = Request("DepartureCity");
	var sReturnCity = Request("ReturnCity");
	var sStopOverCity = Request("StopOverCity"); 
	
	$("#UCSearchCriteria1_dlDepartureCity").val(sDepartureCity);
	$("#UCSearchCriteria1_dlReturnCity").val(sReturnCity);
	$("#tbStopover").val(sStopOverCity);
	
	var sType = Request("Type");
	if(sType=="TourOnly")
	{
		$("#rdbTouronly").attr("checked",'true');
		$("#trDeparting").hide();
		$("#trReturning").hide();
		$("#trStopover").hide();		
	}
	else
		$("#rdbPackage").attr("checked",'true');
	
	if(Request("ExpoTour") == "YES")
		$("#ckbAddExpo").attr("checked",'true');
	if(Request("ExpoDates") != "")
		$("#ddlExpo").val(Request("ExpoDates"));

	$("#rdbPackage").click(function(){
		$("#trDeparting").show();
		$("#trReturning").show();
		$("#trStopover").show();
	});
	$("#rdbTouronly").click(function(){
		$("#trDeparting").hide();
		$("#trReturning").hide();
		$("#trStopover").hide();
	});
	
	if(Request("AddMore")=="YES")
	{
	    $("#trRadio").show();
	}
	else
	{
	    $("#trRadio").hide();
	}
}


	
function AgentSelect_OtherCheckboxOperation(obj)
{
	var flag=false;
	if($(obj).attr("checked") == true)
		flag = true;
	$("input[@type='checkbox']:lt(3):not('#" + $(obj).attr('id') + "')").each(function(){
		$(this).attr("disabled",flag);
	});
}

function AgentSelectSubmit()
{
var oStatus = document.getElementById("ddlExpo");
  
 if(document.getElementById("ckbAddExpo")!=null
  && oStatus.options[oStatus.selectedIndex].value!="")
 {  document.getElementById("ckbAddExpo").checked=true;
 } 
	if($("#rdbPackage").attr("checked") == true)
	{
		if($("#UCSearchCriteria1_dlDepartureCity").val() == '') 
		{ 
				$("#UCSearchCriteria1_dlDepartureCity").focus();
				return false;
		}
			if($("#UCSearchCriteria1_dlReturnCity").val() == '') 
		{ 
				$("#UCSearchCriteria1_dlReturnCity").focus();
				return false;
		}
	}
	var sStopOverCity = $("#tbStopover").val();
	var sDepartureCity = $("#UCSearchCriteria1_dlDepartureCity").val();
	var sReturnCity = $("#UCSearchCriteria1_dlReturnCity").val();

	var sTourType = Request("TourType");
	var sdlDepartureMonth = Request("dlDepartureMonth");
	var sdlDepartureYear = Request("dlDepartureYear");
	var sTourLanguage = Request("TourLanguage");
	var sTourCode = Request("TourCode");
	var sDepartureDate = Request("DepartureDate");
	var sTourStartingDate = Request("TourStartingDate");
	var sTourEndingDate = Request("TourEndingDate");
	var sCountry = Request("Country");
	var sAirline = Request("Airline");
	var salzId = Request("alzId");
	var sReturnAlzId = Request("ReturnAlzId");
	var sTourDate = Request("TourDate");
	var sArrivingCity = Request("ArrivingCity");
	var sArrivingTime = Request("ArrivingTime");
	var sDepartingCity = Request("DepartingCity");
	var sDepartingTime = Request("DepartingTime");
	var sType = Request("Type");
	
	var sAlnID = Request("AlnID");
	var sGroupNumber = Request("GroupNumber");
	var sUserID = Request("UserID");
	var sAgentMemberID = Request("AgentMemberID");
	var sUri = "/signet/Agent/Agent_Reservation.aspx?TourType="+sTourType
		//+"&Type="+sType
		+"&dlDepartureMonth="+sdlDepartureMonth
		+"&dlDepartureYear="+sdlDepartureYear
		+"&TourLanguage="+sTourLanguage
		+"&TourCode="+sTourCode
		+"&DepartureDate="+sDepartureDate
		+"&TourStartingDate="+sTourStartingDate
		+"&TourEndingDate="+sTourEndingDate
		+"&Country="+sCountry
		+"&Airline="+sAirline
		+"&alzId="+salzId
		+"&ReturnAlzId="+sReturnAlzId
		+"&TourDate="+sTourDate
		+"&ArrivingCity="+sArrivingCity
		+"&ArrivingTime="+sArrivingTime
		+"&DepartingCity="+sDepartingCity
		+"&DepartingTime="+sDepartingTime
		+"&AlnID="+sAlnID
		+"&StopOverCity="+sStopOverCity
		+"&DepartureCity="+sDepartureCity
		+"&ReturnCity="+sReturnCity
		+"&GroupNumber="+sGroupNumber
		+"&AgentMemberID="+sAgentMemberID
		+"&UserID="+sUserID;
		
	if($("#rdbPackage").attr("checked") == true)
		sUri = sUri + "&Type=Package";
	else if($("#rdbTouronly").attr("checked") == true)
		sUri = sUri + "&Type=TourOnly";
	if($("#ckbAddExpo").attr("checked") == true)
		sUri = sUri + "&ExpoTour=YES";
	if($("#ddlExpo").val() != "")
		sUri = sUri + "&ExpoDates=" + $("#ddlExpo").val();
	$("#hidUri").val(sUri);
	//$("#frmResultID",parent.document.body).attr("src",sUri)
	return true;;
}
function AgentAvailSubmit()
{
	if(FormCheck())
	{
		var loader = document.getElementById("loading"); 
		var _frame = document.getElementById("frmResultID"); 
    loader.style.display = "";  
    _frame.style.visibility = "hidden";   
    goto_top();

		var sTourType = "";
	var sPeriodFrom = StringIntTodate(document.getElementById("tbFromMonth").value) + "/1" + "/" +  document.getElementById("tbFromYear").value;
	var d = new Date(document.getElementById("tbToYear").value,document.getElementById("tbToMonth").value,0);
	var sPeriodTo = StringIntTodate(document.getElementById("tbToMonth").value) + "/" + d.getDate() + "/" + document.getElementById("tbToYear").value;
		if(getValue("hidTourTypeChina")!= "")
			sTourType = getValue("hidTourTypeChina");
		else if(getValue("hidTourTypeJapan")!= "")
			sTourType = getValue("hidTourTypeJapan");
		else if(getValue("hidTourTypeThailand")!= "")
			sTourType = getValue("hidTourTypeThailand");
		else if(getValue("hidTourTypeTaiwan")!= "")
			sTourType = getValue("hidTourTypeTaiwan");
			
		frames["frmResult"].location="/signet/Agent/Agent_TourAvailability.aspx?Type="+document.getElementById("hidTourType").value
		+"&DepartureCity="+getValue("UCSearchCriteria1_dlDepartureCity")
		+"&ReturnCity="+getValue("UCSearchCriteria1_dlReturnCity")
		+"&TourType="+sTourType
		+"&PeriodFrom="+sPeriodFrom
		+"&PeriodTo="+sPeriodTo
		+"&StopOverCity="+getValue("tbStopover");
	}
		return false;
}
//]]>