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("id")==TargetControlId)
        {
            $(this).keydown(function(e){
                selectText(e.keyCode,this);
            });            
            $(this).keyup(function(e){
                searchKey(e.keyCode);
            });
            $(this).blur(function(){
                hideText(this);
            });
            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>")
    $("body").click(function(e){
		if(e.srcElement.id.indexOf('City') < 0 && e.srcElement.id != 'tbFromMonth' && e.srcElement.id != 'tbToMonth')
		{
			hideText();
		}
		
    });
    $("#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 showTextStopOver()
{	
	currentInput = $("#tbStopover");
    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 showTextAirline()
{	
	currentInput = $("#tbAirline");
    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(_obj)
{
	if(_obj != undefined && _obj.id != "" && ( _obj.id == 'UCSearchCriteria1_dlDepartureCity' || _obj.id == 'UCSearchCriteria1_dlReturnCity' || _obj.id.indexOf('SearchCityBase') > 0)) return;
    $("#floor").hide();
    $("#floor").html("");
    key="";    
    currentInput = null;
    isShow = false;
    //if(fPostBack)
		//FormCheckSubmit();
}

function hideText_Base(sDiv)
{
    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);
	
	$("#floor").hide();
    $("#floor").html("");
    key="";    
    currentInput = null;
    isShow = false;
}

function mouseover_Base(sDiv)
{    
    $("#floor").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
}

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")
		{
			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?GetBySearchText=true";
			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;
                }
                if(dataNum != 4)
                {
                var datas = msg.split(seperator);
                if(datas.length == 2)
                {
if(currentInput.attr("id") !="tbFromMonth"
				&&currentInput.attr("id") !="tbToMonth")
{
						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();
if(currentInput.attr("id") !="tbFromMonth"
				&&currentInput.attr("id") !="tbToMonth")
{
						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(msg);
                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)
{
    	document.getElementById(sInput.id).style.backgroundImage ="url('http://www.signettours.com/images/spinner.gif')";
	document.getElementById(sInput.id).style.backgroundRepeat ="no-repeat";

    currentInput = $("#"+sInput.id);
    if(currentInput != null)
    {
            var divs = "";
            jQuery.ajax({
                type: "Get",
                dataType: "text",
                url: "Data/CityData.aspx?GetCityOrderByAlphabet=true",            
                data: parameterName != "" ? parameterName + "=" + currentInput.val():(currentInput.attr("name") == null ? currentInput.attr("id") + "=" + currentInput.val():currentInput.serialize()),
                success: function(msg){       
		    document.getElementById(sInput.id).style.backgroundImage="";
         
                    $("#floor").html(msg);
                    isShow = true;
                    showText(); 
                }
            });
    }    
}

function ShowQuickList(sInput)
{	
	/*
    currentInput = $("#"+sInput.id);
    
    if(currentInput != null)
    {
            var divs = "";             
            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 onclick_Base(sDiv)
{   
	switch(sDiv.id)
	{
		case "HCity":
			$("#HCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "ACity":
			$("#ACitySon").css("display","block");
			$("#CCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "CCity":
			$("#CCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "DCity":
			$("#DCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "GCity":
			$("#GCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "KCity":
			$("#KCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "MCity":
			$("#MCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "NCity":
			$("#NCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "PCity":
			$("#PCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "QCity":
			$("#QCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#CCitySon").css("display","none");
			$("#NCitySon").css("display","none");
			$("#QCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "TCity":
			$("#TCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#XCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#XCity").attr("class","unselected");
			break;
		case "XCity":
			$("#XCitySon").css("display","block");
			$("#ACitySon").css("display","none");
			$("#HCitySon").css("display","none");
			$("#GCitySon").css("display","none");
			$("#DCitySon").css("display","none");
			$("#MCitySon").css("display","none");
			$("#PCitySon").css("display","none");
			$("#KCitySon").css("display","none");
			$("#TCitySon").css("display","none");
			$("#ACity").attr("class","unselected");
			$("#HCity").attr("class","unselected");
			$("#GCity").attr("class","unselected");
			$("#DCity").attr("class","unselected");
			$("#MCity").attr("class","unselected");
			$("#PCity").attr("class","unselected");
			$("#CCity").attr("class","unselected");
			$("#NCity").attr("class","unselected");
			$("#QCity").attr("class","unselected");
			$("#KCity").attr("class","unselected");
			$("#TCity").attr("class","unselected");
			break;
	}
	 
    $("#floor").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
}

function onclick_BaseSearch(sDiv,index,column)
{
	$("#SearchCity" + index).css("display","inline-block");
	for(var i=0;i < column;i ++)
	{
		if(i != index)
		{
			$("#SearchCity" + i).css("display","none");
			$("#SearchCityBase" + i).attr("class","unselected");
		}
	}
	
    $("#floor").children("div").attr("class","unselected");
    $(sDiv).attr("class","selected");
    
    return true;
}
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>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,'4')>11-Day Golden China</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'S')>9-Day Yangtze South</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'Y')>9-Day Yunnan</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'3')>Beijing,Xian,Guilin 9 Days</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'P')>5-Day Glimpse of Beijing</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeChina',this,'B')>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>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')>Kanto+Beijing 9 Days</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'A')>5-Day Glimpse of Tokyo</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'J')>6-Day Kanto</div>"; 
               //var today= new Date();   
               //if(today.getYear() == 2010 && today.getDate()<20)
               //{ 
                    divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'K')>7-Day Kansai</div>";                
               //} 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'C')>9-Day Japan Classics</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'7')>Hokkaido 7 Days</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'9')>9-Day Hokkaido & Tohoku</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'F')>Hokkaido 10 Days</div>"; 
               //divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeJapan',this,'Q')>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>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')>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>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')>Taiwan 6 Days</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeTaiwan',this,'M')>Taiwan 7 Days</div>"; 
               divs+="<div class=unselected onclick=hideRegion() onmouseout = $(this).attr('class','unselected') onmouseover = mouseoverRegion('hidTourTypeTaiwan',this,'O')>Taiwan 10 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/english/V4/quotation/QuotationResults.aspx?Type="+document.getElementById("hidTourType").value
		this.form.action="/Quotation.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();
	
	
	//TourDate
	if(Request('Type')=='TourAvailability')
	{
			  var curFrom=new Date(Request('PeriodFrom'));
			  var curTo=new Date(Request('PeriodTo'));
			  
			  var sTourDate_PeriodMonthFrom = dateIntToString(curFrom.getMonth());
				var sTourDate_PeriodYearFrom = curFrom.getFullYear();
				
				var sTourDate_PeriodMonthTo = dateIntToString(curTo.getMonth());
				var sTourDate_PeriodYearTo = curTo.getFullYear();
				
				SetValueToControls('tbFromMonth',sTourDate_PeriodMonthFrom);
				SetValueToControls('tbFromYear',sTourDate_PeriodYearFrom);
				
				SetValueToControls('tbToMonth',sTourDate_PeriodMonthTo);
				SetValueToControls('tbToYear',sTourDate_PeriodYearTo);
	}
  else if(Request('Type')=='TourOnly' || Request('Type')=='Package')
	{
			////getQueryStringValue Quotation Page
			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");
	}
	else
		{
				SetValueToControls('tbFromMonth',sCMonth);
				SetValueToControls('tbFromYear',sCYear);
				
				SetValueToControls('tbToMonth',sCMonth);
				SetValueToControls('tbToYear',sCYear);
		}
}
function SetTourDateDefaultValue()
{
			setPeriodTime();
			
			if(Request('Country')=="China")
			{
				$("#chkChina").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeChina','TourType');
//				if($("#TourTypeHTML").html()=='')
//					$("#TourTypeHTML").html("<strong>All China Tours</strong>"); 
			}
			if(Request('Country')=="Japan")
			{
				$("#chkJapan").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeJapan','TourType');
				//if($("#TourTypeHTML").html()=='')
					//$("#TourTypeHTML").html("<strong>All Japan Tours</strong>"); 
			}
			if(Request('Country')=="Thailand")
			{
				$("#chkThailand").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeThailand','TourType');
				if($("#TourTypeHTML").html()=='')
					$("#TourTypeHTML").html("<strong>All Thailand Tours</strong>"); 
			}
			if(Request('Country')=="Taiwan")
			{
				$("#chkTaiwan").attr("checked", true); 
				TourValueDefaultValue($("#TourTypeHTML"),'hidTourTypeTaiwan','TourType');
				if($("#TourTypeHTML").html()=='')
					$("#TourTypeHTML").html("<strong>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=='S')
		{
			$(SpanObj).html("<strong>9-Day Yangtze South</strong>"); 
			document.getElementById(hidValue).value='S'; 
		}
		else if(mValue=='Y')
		{
			$(SpanObj).html("<strong>9-Day Yunnan</strong>"); 
			document.getElementById(hidValue).value='Y'; 
		}
		else if(mValue=='3')
		{
			$(SpanObj).html("<strong>Beijing,Xian,Guilin 9 Days</strong>"); 
			document.getElementById(hidValue).value='3'; 
		}  
		else if(mValue=='4')
		{
			$(SpanObj).html("<strong>11-Day Golden China</strong>"); 
			document.getElementById(hidValue).value='4'; 
		}  
		else if(mValue=='P')
		{
			$(SpanObj).html("<strong>5-Day Glimpse of Beijing</strong>"); 
			document.getElementById(hidValue).value='P'; 
		} 
		else if(mValue=='B')
		{
			$(SpanObj).html("<strong>Kanto+Beijing 9 Days</strong>"); 
			document.getElementById(hidValue).value='B'; 
		}
		else if(mValue=='A')
		{
			$(SpanObj).html("<strong>5-Day Glimpse of Tokyo</strong>"); 
			document.getElementById(hidValue).value='A'; 
		}
		else if(mValue=='J')
		{
			$(SpanObj).html("<strong>6-Day Kanto</strong>"); 
			document.getElementById(hidValue).value='J'; 
		} 
		else if(mValue=='K')
		{
			$(SpanObj).html("<strong>7-Day Kansai</strong>"); 
			document.getElementById(hidValue).value='K'; 
		}
		else if(mValue=='C')
		{
			$(SpanObj).html("<strong>9-Day Japan Classics</strong>"); 
			document.getElementById(hidValue).value='C'; 
		}
		else if(mValue=='7')
		{
			$(SpanObj).html("<strong>Hokkaido 7 Days</strong>"); 
			document.getElementById(hidValue).value='7'; 
		}
		else if(mValue=='9')
		{
			$(SpanObj).html("<strong>9-Day Hokkaido & Tohoku</strong>"); 
			document.getElementById(hidValue).value='9'; 
		}
		else if(mValue=='F')
		{
			$(SpanObj).html("<strong>Hokkaido 10 Days</strong>"); 
			document.getElementById(hidValue).value='F'; 
		}
		else if(mValue=='Q')
		{
			$(SpanObj).html("<strong>Kyushu 8 Days</strong>"); 
			document.getElementById(hidValue).value='Q'; 
		}
		else if(mValue=='T')
		{
			$(SpanObj).html("<strong>Thailand 6 Days</strong>"); 
			document.getElementById(hidValue).value='T'; 
		}
		else if(mValue=='W')
		{
			$(SpanObj).html("<strong>Taiwan 6 Days</strong>"); 
			document.getElementById(hidValue).value='W'; 
		}
		else if(mValue=='M')
		{
			$(SpanObj).html("<strong>Taiwan 7 Days</strong>"); 
			document.getElementById(hidValue).value='M'; 
		}else if(mValue=='O')
		{
			$(SpanObj).html("<strong>Taiwan 10 Days</strong>"); 
			document.getElementById(hidValue).value='O'; 
		}
	}
	else 
	{
		if(strName=="TourTypeChina")
			$(SpanObj).html("<strong>All China Tours</strong>"); 
		else if(strName=="TourTypeJapan")
			$(SpanObj).html("<strong>All Japan Tours</strong>"); 
		else if(strName=="TourTypeThailand")
			$(SpanObj).html("<strong>All Thailand Tours</strong>"); 
		else if(strName=="TourTypeTaiwan")
			$(SpanObj).html("<strong>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 = "Japan";
	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");
	if(currentInput.val() == " ")
	{
		currentInput.val(currentInput.val().replace(" ",''));
	}

	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)
                {
document.getElementById("tbStopover").style.backgroundImage="";
                    return;
                }
                var divs="";
                var datas = msg.split(',');
                 if(datas.length == 2)
                {
currentInput = $("#tbStopover");
					currentInput.val(datas[0]);
					divs+="<div class=unselected onmouseout = $(this).attr('class','unselected') onmouseover = mouseover(this)>"+ datas[0] +"</div>";
					$("#floor").html(divs);
					isShow = true;
					showTextStopOver(); 
					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;
                showTextStopOver(); 
				//$("#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)
                {
			document.getElementById("tbAirline").style.backgroundImage ="";
                    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;
							showTextAirline();
							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;
                showTextAirline();
				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",  
            //http://www.signettours.com/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=LOS ANGELES (LAX)"
						+"&ReturnCity=LOS ANGELES (LAX)"
						+"&"+ sPricechk +"=yes"
						+"&"+ sCountry +"="+sTourTypePara
						+"&PeriodFromMonth="+sTourDate_PeriodMonthFrom
						+"&PeriodFromYear="+sTourDate_PeriodYearFrom
						+"&PeriodToMonth="+sTourDate_PeriodMonthTo
						+"&PeriodToYear="+sTourDate_PeriodYearTo
						+"&BudgetFrom=&BudgetTo=&StopOverCity=&Airline=&hidAirline="
						+"&From=v4";
					$("#sTourNav").attr("href",sReturnPrice);
					
            }
        });
}
//]]>