
// radio button to change drop down menu 
<!--
function uncheckRadio() {
 var choice = document.form1.RadioGroup1;
 for (i = 0; i < choice.length; i++) {
  if ( choice[i].checked = true ) 
   choice[i].checked = false; 
 }
}

function change(arr,arrV) {
var el = document.getElementById('sel');
el.options.length = 0;
for(var i = 0; i< arr.length; i++ ) {
el.options[el.options.length] = new Option( arr[i], arrV[i]);
}
}

function getCheckedValue()
{
	var nm = parseInt(document.getElementById("dlFromMonth").value);
	var ny = parseInt(document.getElementById("dlFromYear").value);
	if(document.getElementById("dlFromMonth").value == document.getElementById("dlToMonth").value
		&& document.getElementById("dlFromYear").value == document.getElementById("dlToYear").value)
		{
			nm = nm+1;
			if(nm >12)
			{
				ny = ny + 1;
			}
			nm = nm % 12;
			return nm + '/1/' + ny;
		}
	return getValue('dlToMonth') + '/1/' + getValue('dlToYear');
}

function getValue(obj)
{
	var Cobj = obj;
	var mValue = document.getElementById(Cobj)==null?"":document.getElementById(Cobj).value;
	return mValue;
}
function nowTime()
{
	var da,ny,nm,insMonthF,insMonthT,mFlag;
	
	da = new Date();
	ny = da.getFullYear();
	nm = da.getMonth();
	
	insMonthF = document.getElementById("dlFromMonth");
	insMonthT = document.getElementById("dlToMonth");
	insMonthF.options[nm].selected = true;
	nm = nm+6;
	if(nm >=12)
	{
		ny = ny + 1;
	}
	nm = nm % 12;

	insMonthT.options[nm].selected = true;
	//fill the data to year
	setYears("dlToYear",ny);
	
}
function setYears(sYear,ny)
{
	var ny = ny;
	var insYear = sYear;
	insYear = document.getElementById(insYear);
	insYear.value = ny;
}

function SetValueToControls(sControl,sValue)
{
	var mControl = sControl;
	var mValue = sValue;
	document.getElementById(mControl).value = mValue;
}
function SetDefaultValues()
{
//////////////////////////////Country
		if(Request('Country')!='')
		{
			if(Request('Country')=='China')
			{
				document.getElementById("r0").checked=true;
				SetValueToControls("hidCountry","China");
				DefaultValue('China');
			}
			else if(Request('Country')=='Japan')
			{
				document.getElementById("r1").checked=true;
				SetValueToControls("hidCountry","Japan");
				DefaultValue('Japan');
			}
			else if(Request('Country')=='Thailand')
			{
				document.getElementById("r2").checked=true;
				SetValueToControls("hidCountry","Thailand");
				DefaultValue('Thailand');
			}
			else if(Request('Country')=='Taiwan')
			{
				document.getElementById("r3").checked=true;
				SetValueToControls("hidCountry","Taiwan");
				DefaultValue('Taiwan');
			}
		}

/////////////////////////////TourType
		if(Request('TourType')!='')
		{
			SetValueToControls("hidTourType",Request("TourType"));
			SetValueToSelectControl("sel",Request("TourType"));
		}
/////////////////////////////Language
		if(Request('Language')!='')
		{
			SetValueToSelectControl("sLanguage",Request("Language"));
		}
/////////////////////////////Period From & To
		var myDate = StringToDate(Request("PeriodFrom"));
		SetValueToSelectControl("dlFromMonth",myDate.getMonth() + 1);
		SetValueToSelectControl("dlFromYear",myDate.getYear());

		myDate = StringToDate(Request("PeriodTo"));
		SetValueToSelectControl("dlToMonth",myDate.getMonth() + 1);
		SetValueToSelectControl("dlToYear",myDate.getYear());


//////////////////
}
function StringToDate(DateStr)   
{       
    var converted = Date.parse(DateStr);   
    var myDate = new Date(converted);   
    if (isNaN(myDate))   
       {    
        var arys= DateStr.split('-');   
           myDate = new Date(arys[0],--arys[1],arys[2]);   
       }   
    return myDate;
} 

function SetValueToSelectControl(sControl,sValue)   
{       
		var mControl = document.getElementById(sControl);
		for (m=mControl.options.length-1;m>0;m--)
		{
				if(mControl.options[m].value == sValue)
					mControl.options[m].selected = true;
		}
} 

function rdbRegionClick()
{
	var sTourTypeChina,sTourTypeJapan,sTourTypeThailand,sTourTypeTaiwan = "";
	var sCountry = document.getElementById('hidCountry').value;
	if(sCountry=='China')
	{
		sTourTypeChina = "S";
		document.getElementById('hidTourType').value = sTourTypeChina;
	}
	else if(sCountry=='Japan')
	{
		sTourTypeJapan = "B";
		document.getElementById('hidTourType').value = sTourTypeJapan;
	}
	else if(sCountry=='Thailand')
	{
		sTourTypeThailand = "T";
		document.getElementById('hidTourType').value = sTourTypeThailand;
	}
	else if(sCountry=='Taiwan')
	{
		sTourTypeTaiwan = "W";
		document.getElementById('hidTourType').value = sTourTypeTaiwan;
	}
	TourDatePeriodToTime(sTourTypeChina,sTourTypeJapan,sTourTypeThailand,sTourTypeTaiwan);
}

function selChange()
{
	var sTourTypeChina,sTourTypeJapan,sTourTypeThailand,sTourTypeTaiwan = "";
	var sCountry = document.getElementById('hidCountry').value;
	if(sCountry=='China')
	{
		sTourTypeChina = document.getElementById('hidTourType').value;
	}
	else if(sCountry=='Japan')
	{
		sTourTypeChina = document.getElementById('hidTourType').value;
	}
	else if(sCountry=='Thailand')
	{
		sTourTypeChina = document.getElementById('hidTourType').value;
	}
	else if(sCountry=='Taiwan')
	{
		sTourTypeChina = document.getElementById('hidTourType').value;
	}
	TourDatePeriodToTime(sTourTypeChina,sTourTypeJapan,sTourTypeThailand,sTourTypeTaiwan);
	
}
function TourDatePeriodToTime(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(';');
				var cur=new Date(Date.parse(datas[0].replace(/-/g,"/")));
				
				var el = document.getElementById('dlToMonth');
				for(var i = 0; i< el.options.length; i++ ) 
				{
					if(el.options[i].value == cur.getMonth()+1)
						el.options[i].selected = true;
				}

				var el = document.getElementById('dlToYear');
				el.options.length = 0;
				el.options[el.options.length] = new Option(cur.getFullYear(),cur.getFullYear());
				
				//for(var i = 0; i< arr.length; i++ ) {
				//el.options[el.options.length] = new Option( arr[i], arrV[i]);
				//}
				//alert(cur);
				//$("#tbToMonth").val(dateIntToString(cur.getMonth()));
				//$("#tbToYear").val(cur.getFullYear());
            }
        });
}

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;
}
}

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);

}
*/
}
}
//-->