function over_link(page, pkgno){
	location.href= page;
	showContent(pkgno);
}

function openfile(pdf){
	locat = './packages/' + pdf;
	window.open(locat);
}


function change(getid){
	mycontainer = document.getElementById('container');
	city = document.getElementById(getid);
	mycontainer.innerHTML = city.innerHTML;
}


function over(td){
	td.style.cursor = 'hand';
	td.style.backgroundColor = '#ffff66';
}


function out(td){
	td.style.backgroundColor = '#ffffcc';
}


function overp(td){
	td.style.cursor = 'hand';
	td.style.backgroundColor = '#95DDFF';
}


function outp(td){
	td.style.backgroundColor = '#F5F5F5';
}


function overe(td){
	td.style.cursor = 'hand';
	td.style.backgroundColor = '#CDFCEB';
}


function oute(td){
	td.style.backgroundColor = '#F1FEFA';
}

function xover(td){
	td.style.cursor = 'hand';
	td.style.backgroundColor = '#E8F4FF';
}


function xout(td){
	td.style.backgroundColor = '#ffffff';
}

function getXmlHttpRequest(){

if (window.XMLHttpRequest) { // Mozilla, Safari,...
      http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
      try {
        // 新版的 IE
        http_request = new ActiveXObject("Msxml2.XMLHTTP");
      } catch (e) {
        try {
          // 舊版的 IE
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {}
      }
    }

	return http_request;	
}

	xmlhttp = getXmlHttpRequest();


function cityChg(){

	countryTarget = document.getElementById("country");
	countryValue = countryTarget.options[countryTarget.selectedIndex].value;
	
	url = "package_load.php";
	rdTime = new Date().getTime();
	params = "cityChg=y&country="+countryValue+"&timestamp="+rdTime;
	xmlhttp.onreadystatechange = runCityChg;
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);

}


function runCityChg(){
	if((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
		document.getElementById("cityField").innerHTML = xmlhttp.responseText;
		//alert(xmlhttp.responseText);
	}else{
		document.getElementById("cityField").innerHTML = "<img src=images/loading2.gif>";
	}
}



function searchCityChg(){

	countryTarget = document.getElementById("country");
	countryValue = countryTarget.options[countryTarget.selectedIndex].value;

	
	url = "package_load.php";
	rdTime = new Date().getTime();
	params = "searchCityChg=y&searchCountry="+countryValue+"&timestamp="+rdTime;
	
	xmlhttp.open("GET", url+"?"+params, true);
	xmlhttp.onreadystatechange = runSearchCityChg;
	xmlhttp.send(null);

}


function runSearchCityChg(){
	if((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
		document.getElementById("cityField").innerHTML = xmlhttp.responseText;
		//alert(xmlhttp.responseText);
	}else{
		document.getElementById("cityField").innerHTML = "<img src=images/loading2.gif>";
	}
}



function showContent(countryid){
	url = "package_load.php";
	tt = new Date().getTime();
	params = "countryid="+countryid+"&t="+tt;
	xmlhttp.open("GET", url+"?"+params, true);
	xmlhttp.onreadystatechange = runContenChg;
	xmlhttp.send(null);

}

function showContent_internal(countryid){
	url = "intranet_package_load.php";
	tt = new Date().getTime();
	params = "countryid="+countryid+"&t="+tt;
	xmlhttp.open("GET", url+"?"+params, true);
	xmlhttp.onreadystatechange = runContenChg;
	xmlhttp.send(null);

}


function runContenChg(){
	if((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
		document.getElementById("container").innerHTML = xmlhttp.responseText;
	}else{
		document.getElementById("container").innerHTML = "<img src=images/loading.gif>";
	}
}


function citySortChg(){
	url = "package_load.php";
	var countryid = document.getElementById("cidd").value;
	var sortby = document.getElementById("sortby").options[document.getElementById("sortby").selectedIndex].value;
	var cityy = document.getElementById("cityy").options[document.getElementById("cityy").selectedIndex].value;


	tt = new Date().getTime();
	params = "countryid="+countryid+"&cityy="+cityy+"&sortby="+sortby+"&t="+tt;
			
	xmlhttp.open("GET", url+"?"+params, true);
	xmlhttp.onreadystatechange = runcitySortChg;
	xmlhttp.send(null);

}


function runcitySortChg(){
	if((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
		document.getElementById("container").innerHTML = xmlhttp.responseText;
	}else{
		document.getElementById("container").innerHTML = "<img src=images/loading.gif>";
	}
}


function showContentEdit2(countryid){
	//document.getElementById("temp").style.display = "none";
	url = "package_load.php";
	rdTime = new Date().getTime();
	params = "edit=y&countryidedit="+countryid+"&timestamp="+rdTime;
	xmlhttp.onreadystatechange = runContenEditChg2;
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}


function runContenEditChg2(){
	if((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){
		document.getElementById("temp").innerHTML = xmlhttp.responseText;
	}else{
		document.getElementById("container").innerHTML = "<img src=images/loading.gif>";
	}
}




function chkPkgLink(){

	url = "package_load3.php";
	rdTime = new Date().getTime();
	params = "index=yes"+"&timestamp="+rdTime;
	xmlhttp.onreadystatechange = runchkPkgLink;
	xmlhttp.open("GET", url+"?"+params, true);
	//xmlhttp.overrideMimeType('text/xml');
	xmlhttp.send(null);

}


function searchPackage(){
	
	if(document.getElementById("country").options[document.getElementById("country").selectedIndex].value == 0){
		alert("請選擇國家。");
		return false;
	}else{
		document.getElementById("searchForm").submit();
		return true;
	}
	
}


