	var http_request=false;	
    if(window.XMLHttpRequest){//Mozilla浏览器
     http_request=new XMLHttpRequest();
     if(http_request.overrideMimeType){//设置MIME类别
       http_request.overrideMimeType("text/xml");
     }
    }
    else if(window.ActiveXObject){//IE浏览器
     try{
      http_request=new ActiveXObject("Msxml2.XMLHttp");
     }catch(e){
      try{
      http_request=new ActiveXobject("Microsoft.XMLHttp");
      }catch(e){}
     }
    }
    if(!http_request){//异常，创建对象实例失败
     alert("Error initializing XMLHttpRequest!");     
    }
	//处理返回信息的函数
  	function processrequest(){
   		if(http_request.readyState==4 || http_request.readyState=="complete"){//判断对象状态
     		if(http_request.status==200){//信息已成功返回，开始处理信息
      			document.getElementById(reobj).innerHTML=http_request.responseText;
     		}else{//页面不正常
      			alert("您所请求的页面不正常！");
     		}
   		}else if (request.status == 404){
         	alert("Request URL does not exist");
		}else{
         	alert("Error: status code is " + request.status);
		 }
  }
  function dopage(obj,url){
	reobj=obj;
	var geturl = encodeURI(url);
	geturl = encodeURI(geturl);
	http_request.open("GET",geturl,true);
    http_request.onreadystatechange=processrequest;   
    http_request.send(null);	
  }  
function showllist(obj,div_id){
		var rid_value = document.getElementById(obj).value;
		dopage(div_id,"showRegion.php?rid="+rid_value); 
}
function Search_line(){
		var title = document.getElementById("title").value;
		title = encodeURIComponent(title);
		var tourtypeID =  document.getElementById("tourtypeID").value;
		var AreaID =  document.getElementById("AreaID").value;
		var Traveldays =  document.getElementById("Traveldays").value;		
		if(title == "" && tourtypeID == "" && AreaID=="" && Traveldays == ""){
			alertWindow('温馨提示','请选择查询的条件！',200,100);
		}else{
			window.location.href="Search_line.php?title="+title+"&ttid="+tourtypeID+"&AreaID="+AreaID+"&day="+Traveldays+"&page=1";//跳转页面
		}		
}
function find_hotel(){	
	var hotelName = document.getElementById("hotelName").value;
	 hotelName = encodeURIComponent(hotelName);
	var cityID =  document.getElementById("cid").value;
	var rid =  document.getElementById("rid").value;
	var star =  document.getElementById("star").value;
	var price =  document.getElementById("price").value;
	if(hotelName == "" && cityID == "" && rid == "" && star == "" && price==""){
		alertWindow('温馨提示','请选择查询的条件！',200,100);
	}else if(hotelName != "" || cityID != "" || rid != "" || star != "" || price!="") {		
		window.location.href="hotel.php?cid="+cityID+"&hotelName="+hotelName+"&rid="+rid+"&mid="+price+"&star="+star+"&lid=''&page=1";//跳转页面
	}
}
function Search_visa(){
	var cname = document.getElementById("cname").value;
	cname = encodeURIComponent(cname);
	if(cname == ""){
		alertWindow('温馨提示','请输入国家的名称！',200,100);
	}else {		
		window.location.href="find_visa.php?cname="+cname;//跳转页面
	}
}
function alertWindow(title,url,width,height)
{
var titleheight = "22"; // 提示窗口标题高度 
var bordercolor = "#666699"; // 提示窗口的边框颜色 
var titlecolor = "#FFFFFF"; // 提示窗口的标题颜色 
var titlebgcolor = "#666699"; // 提示窗口的标题背景色
var bgcolor = "#FFFFFF"; // 提示内容的背景色

var iWidth = document.documentElement.clientWidth;
var iHeight = document.documentElement.clientHeight;

var bgObj = document.createElement("div");
//两种方法都行
//msgObj.setAttribute("id","window_box");
bgObj.id = "div_grey";
bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=10);opacity:0.1;background-color:#000000;z-index:101;";
document.body.appendChild(bgObj);

var msgObj = document.createElement("div");
msgObj.id = "window_box";
msgObj.style.cssText = "position:absolute;font:11px '宋体';top:" + (iHeight - height) / 2 + "px;left:" + (iWidth - width) / 2 + "px;width:" + width + "px;height:" + height + "px;text-align:center;border:1px solid " + bordercolor + ";background-color:" + bgcolor + "; z-index:102;";
document.body.appendChild(msgObj);

var titleObj = document.createElement("div");
titleObj.id = "title_box";
titleObj.onmousedown = function(event){drag_start2(event,"window_box")};
titleObj.style.cssText = "width:100%; height:" + titleheight +"px; line-height:" + titleheight + "px; background-color:" + titlebgcolor + "; color:" + titlecolor + "; font-size:14px; text-align:left; cursor:move;";
//titleObj.innerHTML = "<div style='width:100%; height:100%; cursor:move;' onmousedown='drag_start2(event,\"window_box\")'><a href='javascript:close_box(\"div_grey\",\"window_box\",\"title_box\",\"content_box\")' title='关闭' id='a_close' style='text-decoration:none; color:#ffffff; float:right;'>×&nbsp;</a>&nbsp;" + title + "</div>";
titleObj.innerHTML = "<a href='javascript:close_box(\"div_grey\",\"window_box\",\"title_box\",\"content_box\")' title='关闭' id='a_close' style='text-decoration:none; color:#ffffff; float:right;'>×&nbsp;</a>&nbsp;" + title;
msgObj.appendChild(titleObj);//在标题最后添加关闭按钮

var contentObj = document.createElement("div");//在弹出窗口里添加东西
contentObj.id = "content_box";
contentObj.style.cssText = "width:100%; height:" + (height - titleheight) + "px; font-size:14px;";
//contentObj.innerHTML = "<iframe src='" + url + "' width='100%' height='100%' scrolling='yes' frameborder='0'></iframe>";
contentObj.innerHTML ="<br>"+ url +"<br><br><input type='button' value='关闭' onclick='close_box(\"div_grey\",\"window_box\",\"title_box\",\"content_box\")' />";
msgObj.appendChild(contentObj);//追加在后面
}


//==================================================================================
//拖动鼠标时用到的JS
//==================================================================================
var oldX,oldY;    // 记录鼠标移动事件发生前鼠标的位置
var dragElem;    // 记录被拖曳的对象

function $(nodeId)
{
return document.getElementById(nodeId);
}
// 获得事件发生的主体
function getEventElement(evt)
{
evt=evt||event;
return evt.srcElement||evt.target;
}
// 获取结点的计算样式
function getStyle(node)
{
return node.currentStyle||document.defaultView.getComputedStyle(node, null);
}
// 拖动的动作
function drag(evt)
{
evt=evt||event;    // 为了兼容IE和firefox，firefox执行evt，IE则执行evt=event
var node=dragElem;

if(node != null) //if语句后来加上去的
{
   node.style.top=parseInt(getStyle(node).top||0)+evt.clientY-oldY+'px';
   node.style.left=parseInt(getStyle(node).left||0)+evt.clientX-oldX+'px';
   //node.style.right=parseInt(getStyle(node).right||0)-evt.clientX+oldX+'px';
   //0px 越往左越小 930px
   oldX=evt.clientX, oldY=evt.clientY;
}
}
// 拖动开始
// 注册拖曳结束时的执行函数
// 注册拖曳事件的执行函数
function drag_start(evt,nodeId)
{
evt = evt||event;

oldX = evt.clientX;
oldY = evt.clientY;
dragElem=$(nodeId);
getEventElement(evt).onmouseup=drag_end;
getEventElement(evt).onmousemove=drag;
}
// 对 drag_start 进行了改良
function drag_start2(evt,nodeId)
{
evt=evt||event;
oldX=evt.clientX;
oldY=evt.clientY;
dragElem=$(nodeId);

document.body.onmousemove=drag;
document.body.onmouseup=drag_end;
}
// 拖曳结束，释放onmousemove事件执行函数
function drag_end(evt)
{
evt = evt||event;
dragElem = null;
getEventElement(evt).onmousemove = null;
getEventElement(evt).onmouseup = null;
}
function close_box(obj_1,obj_2,obj_3,obj_4)
{//先隐藏，再清除建立的对象。不这样做，会有问题。
$(obj_1).style.display = "none";
$(obj_2).style.display = "none";
$(obj_2).removeChild($(obj_3));
$(obj_2).removeChild($(obj_4));
document.body.removeChild($(obj_1));
document.body.removeChild($(obj_2));
}
