var mdiv=document.createElement("div"),timeOut=null;
function rmtips(){
	try {
		if(timeOut){window.clearTimeout(timeOut);timeOut=null}
		if(mdiv){document.body.removeChild(mdiv);}
	}catch(e){
		//alert(e);
	}
		
}
function ycrmtips(){
	window.clearTimeout(timeOut);
	timeOut=window.setTimeout('rmtips()',100);
}
//动态生成提示框
function tips(a,b,c){
	    var html='';
		mdiv.className='zn_room_tips';
		mdiv.style.width=c+'px'
		mdiv.style.left=(gL(a)-parseInt(mdiv.style.width)/2+50)+'px';		
	    html+=b;
	    mdiv.innerHTML=html;
	    rmtips();		
	    a.onmouseout=ycrmtips;
	    document.body.appendChild(mdiv);	
	    mdiv.style.top=(gT(a)+20)+'px';
}

function _g(id){return document.getElementById(id)}
function gL(x){var l=0;while(x){l+=x.offsetLeft;x=x.offsetParent;}return l}
function gT(x){var t=0;while(x){t+=x.offsetTop;x=x.offsetParent;}return t}


//动态生成提示框
function tips2(a,b,c,d,e,f){  
	    //this,v1,支付方式,奖金,附加服务,担保
	    var html='';
		mdiv.className='zn_room_tips';
		mdiv.style.width='200px';
		mdiv.style.zIndex='999999';
		mdiv.style.left=(gL(a)-parseInt(mdiv.style.width)/2+35)+'px';	
	    if(b=='v1'){
			html+='<div class="zn_rt_con">';
			if(c=="T")
			{
			   if(d!="")
				{
					html+='<p '+isHotelBack_display+'>网上成功订购此房型,每间夜可获得<span style="color:Red">'+d+'</span>元奖金(如您订购一间住两晚或两间住一晚,均为两间夜,成功入住后,可以获得<span style="color:Red">'+(d*1*2)+'</span>元奖金)</p>';
				}
				if(f!="null"&&f)
				{
					html+='<p class="zn_rt_con_fj">支付方式：'+GetPaymentType2(c);
				}
				if(e!="null"&&e)
				{
					html+='<br/>'+e;
					html+='</p>';		
					html+='</div>';
				}
			} 
		} 
		if(b=="v2")
		{
			html+='<div class="zn_rt_con">';
			f= f.replace("艺龙","本站");
			f= f.replace("elong","本站");
			f= f.replace("住哪","本站");
			
			html+='<p>'+f+'</p>';
			html+='</p>';		
			html+='</div>';
		}
	//window.clipboardData.setData("text",html);
    mdiv.innerHTML=html;
	rmtips();		
	a.onmouseout=ycrmtips;
	document.body.appendChild(mdiv);	
	mdiv.style.top=(gT(a)+20)+'px';
}

function GetPaymentType2(f){
	if(f=='T'){
		return '现 付';
	}else if(f=='S'){
		return '预 付';	
	}else if(f=='Y'){
		return '预 付';
	}
}


function tips3(obj,v1,a,b,c){
	 //this,v1,奖金,附加服务,担保
		window.clearTimeout(timeOut);
		var mhtml='',mWidth=300;
		if(v1=='v2'){
			mWidth=200
			mhtml='网上成功订购此房型，您入住酒店并结帐，每间夜可获得<span style="color:Red">'+a+'</span>元奖金';
		}
		if(v1=='v3'){
			c= c.replace("艺龙","本站");
			c= c.replace("elong","本站");
			c= c.replace("住哪","本站");
			mhtml=c.replace(/(\d{2})\.(\d{2})\.(\d{2})/g,'20$1-$2-$3');
		}
		var vhtml='\
		<div class="com_arrow1" id="com_arrow"></div>\
		<div class="com_way"  id="com_way" style="width: '+mWidth+'px;">\
			<div class="com_way_son">'+mhtml+'</div>\
		</div>\
		';
		mdiv.innerHTML=vhtml;
		document.body.appendChild(mdiv);
		var xy=_xy(obj);
		var L1=xy[0]+obj.offsetWidth/2-6.5,T1=xy[1]+obj.offsetHeight+6;
		var T2=T1+5,L2=(document.body.offsetWidth<L1+mWidth/2)?(document.body.offsetWidth-mWidth-10):L1-mWidth/2+6.5;
		if(L2<10)L2=10;
		var T4=document.body.scrollTop||document.documentElement.scrollTop;
		var H4=document.documentElement.clientHeight||document.body.clientHeight;
		if((T2+_g('com_way').offsetHeight)>(T4+H4)){
			T1=xy[1]-6-5;
			T2=T1-_g('com_way').offsetHeight+4;
			_g('com_arrow').className='com_arrow2';			
		}
		_g('com_arrow').style.top=T1+'px';
		_g('com_arrow').style.left=L1+'px';
		_g('com_way').style.top=T2+'px';
		_g('com_way').style.left=L2+'px';
		_g('com_way').onmouseover=function(){window.clearTimeout(timeOut);};
		_g('com_way').onmouseout=ycrmtips;
		obj.onmouseout=ycrmtips;

}



//保留几位小数
function round(num,length){
    
    var v=1;
    for(var i=0;i<length;i++)
    {
        v=v*10;
    }
    
    num=num*v;
    num=Math.round(num);
    return (num/v).toFixed(length);
    
}
