/*
 * 悬浮“在线咨询”使用：设定url。
 */
function open_online(url_str) {
	var win_online = window
			.open(
					url_str,"",
					"top=200,left=400,width=397,height=400,toolbar=no,menubar=no,scrollbars=yes,title=no");
	win_online.focus();
}



/*
 * 悬浮“在线咨询”使用：完整控制移动的脚本。
 */

///////外部脚本控制程序开始/////// 
///////程序名：os_drag.js /////// 

//记录页面的垂直滚动位置的变量。 
lastScrollY=0; 

//在程序中校准图像在页面中的位置。 
with (document.all.elDRAGone) { 
	style.pixelTop=offsetTop+158; 
	//style.pixelLeft=offsetLeft+1035; 
	style.pixelLeft=document.body.offsetWidth-178; 
	//alert(document.body.offsetWidth);
} 

//在页面上定位图像的函数。 
function position_img() { 
	//计算出页面垂直滚动的偏移量。 
	diffY = document.body.scrollTop-lastScrollY; 
	//保存本次页面滚动位置。 
	lastScrollY=document.body.scrollTop; 
	//移动图像到原来的窗口位置。 
	document.all.elDRAGone.style.pixelTop += diffY; 
} 

//建立记录图像初始位置的变量，用于计算图像是否被拖动过。 
originX=originY=0; 

//如果图像被拖动过，则offset_pixel变量的值大于0。 
offset_pixel=0; 

//记录图像在文档中的现行坐标值。 
currentX = currentY = 0; 

//保存被拖动对象的变量。 
whichEl = null;      

//onmousedown事件调用的图像抓取函数。   
function grabEl() {   
	//只允许用鼠标左键拖动！   
	if (event.button !=1) {
		return;
	} 

	//将鼠标点击的对象存入whichEl变量。 
	whichEl=event.srcElement; 
	//判断是否为可拖动的对象。 
	while(whichEl.id.indexOf("DRAG")==-1){ 
		whichEl=whichEl.parentElement; 
		if (whichEl==null){
			return;
		} 
	} 

	//记录图像抓取时的初始窗口位置。 
	originX=event.clientX; 
	originY=event.clientY; 

	//将拖动判别变量设为0值。 
	offset_pixel=0; 

	//校准图像在文档上的位置。 
	whichEl.style.pixelLeft=whichEl.offsetLeft; 
	whichEl.style.pixelTop=whichEl.offsetTop; 

	//记录图像相对于文档的现行位置坐标。 
	currentX=event.clientX+document.body.scrollLeft;    
	currentY=event.clientY+document.body.scrollTop; 
} 

//onmousemove事件调用的图像移动函数。 
function moveEl() {   
	//如果没有抓取拖动的对象，则返回。   
	if (whichEl==null){
		return;
	}
	
	//如果拖动了图像，则将变量offset_pixel 
	//赋予大于0的值，以标记图像已被拖动。 
	//从而使图像在拖动完成后不执行链接功能。 
	offset_X=Math.abs(event.clientX-originX); 
	offset_Y=Math.abs(event.clientY-originY); 
	offset_pixel=offset_X+offset_Y; 

	//计算拖动时新的文档坐标的位置。 
	newX=event.clientX+document.body.scrollLeft;    
	newY=event.clientY+document.body.scrollTop; 

	//计算出现行位置与拖动前初始位置的偏差。 
	distanceX=newX-currentX; 
	distanceY=newY-currentY; 

	//用现行位置更新初始位置变量。 
	currentX=newX; 
	currentY=newY; 

	//实际移动图像的位置。 
	whichEl.style.pixelLeft +=distanceX; 
	whichEl.style.pixelTop +=distanceY; 

	event.returnValue=false;   
} 

//onmouseup函数调用的图像放置函数。 
//表明拖动过程结束。 
function dropEl() {  
	whichEl=null; 
} 

//根据图像是否被拖动过来决定是否执行 
//与图像有关的链接。 
function if_link(){ 
	if(offset_pixel>0){
		//如果图像被拖动过，则此函数返回假， 
		//不执行与图像有关的链接。 
		return false; 
	}else {
		//否则返回真值，执行图像的链接。 
		return true; 
	}
} 

//改变可拖动对象为十字光标的句柄函数。 
function curEl(){ 
	Over_Element=event.srcElement; 
	while(Over_Element.id.indexOf("DRAG")==-1){ 
		Over_Element=Over_Element.parentElement; 
		if (Over_Element==null){
			return;
		} 
	} 
//	event.srcElement.style.cursor = "move"; //说明：原来有，后来我想单独在图片上显示可移动的光标，所以隐藏此处；
	//我增加的代码-开始
	var if_img;
	img_element = event.srcElement;
	while(true){
		if_img = img_element.id.indexOf("IMG");
		if(if_img != -1){
			event.srcElement.style.cursor = "move";
			break;
		}
		img_element = img_element.parentElement;
		if (img_element==null){
			break;
		} 
	}
	//我增加的代码-结束
} 

//以下是在文档中设定的鼠标事件句柄。 
document.onmousedown = grabEl; 
document.onmousemove = moveEl; 
document.onmouseup = dropEl; 
document.onmouseover = curEl; 

//定时调用图像移动函数，此时为300毫秒。 
action = window.setInterval("position_img()",300); 

///////外部脚本控制程序结束///////