/*************************************************************
***  FelitHuang Create @ 2005-10-13
***
***  This JScript Is To Show Tips For Items.
***  To Include This JScript Before Using The Tips Show/Hide Function.
***
*************************************************************/

/***  To Create The Tip Object, This Should Call Before Show/Hide  ***/
function QQShowTipCreate()
{
	if (!document.getElementById("QQSHOWTIPDIV"))
	{
		var e = document.createElement("DIV");
		e.id = "QQSHOWTIPDIV";
		e.style.position = "absolute";
		e.style.visibility = "hidden";
		e.style.zIndex = 1001;
		e.innerHTML	= '<table border="1" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">'
					+ '<tr><td align="center"><img id="QQSHOWTIPIMG" src="" alt="预览"></td></tr>'
					+ '<tr><td height="24" align="center" valign="middle" id="QQSHOWTIPINFO"></td></tr>'
					+ '</table>';
		document.body.appendChild(e);
	}
};

/*** This TipShow Function Should Be Call Only By The MouseEvents  ***/
function QQShowTipShow(strUrl, strName)
{
	try
	{
		var e = arguments[2] || window.event;
		if (!e)
		{
			return false;
		}
		if (!document.getElementById("QQSHOWTIPDIV"))
		{
			QQShowTipCreate();
		}

		if (document.getElementById("QQSHOWTIPIMG").src!=strUrl)
		{
			document.getElementById("QQSHOWTIPIMG").src = strUrl;
		}
		document.getElementById("QQSHOWTIPINFO").innerHTML = strName;

		var wTipDiv = document.getElementById("QQSHOWTIPDIV").scrollWidth;
		var hTipDiv = document.getElementById("QQSHOWTIPDIV").scrollHeight;

		var wBody = document.body.clientWidth;
		var hBody = document.body.clientHeight;

		var xPos = typeof(e.clientX)!="undefined" ? e.clientX : (e.pageX-document.documentElement.scrollLeft);
		var yPos = typeof(e.clientY)!="undefined" ? e.clientY : (e.pageY-document.documentElement.scrollTop);

		xPos = (xPos+wTipDiv<=wBody) ? (xPos+document.documentElement.scrollLeft+10) : (xPos+document.documentElement.scrollLeft-10-wTipDiv);
		yPos = (yPos+hTipDiv<=hBody) ? (yPos+document.documentElement.scrollTop+10) : (yPos+document.documentElement.scrollTop-10-hTipDiv);

		document.getElementById("QQSHOWTIPDIV").style.left = xPos+"px";
		document.getElementById("QQSHOWTIPDIV").style.top = yPos+"px";
		document.getElementById("QQSHOWTIPDIV").style.visibility = "visible";
	}
	catch(e)
	{
		return false;
	}
	return true;
};

function QQShowTipHide()
{
	try
	{
		if (!document.getElementById("QQSHOWTIPDIV"))
		{
			QQShowTipCreate();
		}
		document.getElementById("QQSHOWTIPDIV").style.visibility = "hidden";
		document.getElementById("QQSHOWTIPIMG").removeAttribute("src");
	}
	catch(e)
	{
		return false;
	}
	return true;
};

function DisplayItemTips(sHtml, objEvent, sId, sCss, index)
{
	var x = 0;
	var y = 0;
	var iBodyX = document.documentElement.scrollLeft;
	var iBodyY = document.documentElement.scrollTop;
	if((objEvent.x)&&typeof(objEvent.x)!="undefined")
	{
		x = objEvent.clientX+iBodyX;
		y = objEvent.clientY+iBodyY;
	}
	else
	{
		x = objEvent.pageX;
		y = objEvent.pageY;
	}
	if(!document.getElementById(sId))
	{
		var oDiv = document.createElement("div");
		oDiv.id = sId;
		oDiv.setAttribute("class", sCss);
		oDiv.setAttribute("className",sCss);
		oDiv.style.display = "none";
		oDiv.style.position = "absolute";
		oDiv.style.zIndex = index;
		document.body.appendChild(oDiv);
		document.getElementById(sId).innerHTML = sHtml;
	}
	var objItemTips = document.getElementById(sId);
	objItemTips.style.position = "absolute";
	var iX = x - 20;
	var iY = y + 20;
	if((iX + 130)>document.body.scrollWidth) iX = document.body.scrollWidth - 130;
	objItemTips.style.left = iX + "px";
	objItemTips.style.top = iY + "px";
	document.getElementById(sId).innerHTML = sHtml;
	return objItemTips;
};

function DisplayItemPriceTips(sName, sPrice, sVipPrice, objEvent, iTime, nDiscount, nVipDiscount,iType)
{
	if(typeof(iType) == "undefined")
		iType = 1;
	function PRICETxt(iPrice, iDiscount, iPrePrice)
	{
		iPrice = parseInt(iPrice);
		iDiscount = parseInt(iDiscount);
		if (window.DSAsystem && window.DSAsystem.DSAdata && window.DSAsystem.DSAdata[0]!=0)
		{
		     return (iDiscount>=0 && iDiscount<100) ? ('<del class="em f_d"><strong>'+QBPrice(iPrice)+'</strong></del> <ins class="em">'+QBPrice(Math.round(iPrice*iDiscount/100))+'Q币('+(iDiscount/10)+'折)'+'</ins>') : (QBPrice(iPrice)+'Q币');
		}
	  else
		{
			  
			  return (iDiscount>=0 && iDiscount<100) ? ('<del class="em f_d"><strong>'+QBPrice(iPrePrice)+'</strong></del> <ins class="em">'+QBPrice(iPrice)+'Q币'+'</ins>') : (QBPrice(iPrice)+'Q币');
		}
	}
	var str = "";
	str += '<div class="tipGlobal">';
	str += '	<h3>点击图片换装</h3>';
	str += '	<p>';
	str += '		价&nbsp;&nbsp;&nbsp;格：<span>--Q币</span><br />';
	if(iType == 2)
	{
		str += '		<em>红钻价：<span>--Q币</span></em><br />';
	}
	else
	{
		str += '		<em><font color="#FF9900"><B>红钻免费穿</B></font><span style="display:none">--</span></em><br />';
	}
	str += '		<em>有效期：<span>--</span></em><br />';
	if (window.DSAsystem && window.DSAsystem.DSAdata && window.DSAsystem.DSAdata[0]!=0)
	{
		str += '		<em>只有点击<strong class="btns">购买、赠送</strong>才能享受折扣</em><br />';
	}
	str += '	</p>';
	str += '</div>'; 
	var oDiv = DisplayItemTips(str, objEvent, "id_itemprice_tips", "p_tips", 199);
	var iPrice = parseInt(sPrice);
	var iDiscount = parseInt(nDiscount);
	var iRowPrice = Math.round(iPrice/iDiscount*100);
	oDiv.getElementsByTagName("SPAN")[0].innerHTML = PRICETxt(sPrice, nDiscount,iRowPrice);
	oDiv.getElementsByTagName("SPAN")[1].innerHTML = PRICETxt(sVipPrice, nVipDiscount,iRowPrice);
	oDiv.getElementsByTagName("SPAN")[2].innerHTML = iTime ? iTime : "  ";	
	oDiv.style.display = "";
};

function HideItemPriceTips()
{
	if(document.getElementById("id_itemprice_tips"))document.getElementById("id_itemprice_tips").style.display = "none";
};
function DisplaySetPriceTips(sName, sPrice, sVipPrice, objEvent)
{
	var str = "";
	str += '<div class="tipGlobal col-two">';
	str += '	<h3>点击图片换装</h3>';
	str += '	<p>';
	//str += '		<span class="nowrap text-overflow item-name">--</span><br />';
	str += '		<em>价&nbsp;&nbsp;&nbsp;格：<span>--</span>Q币</em><br />';
	str += '		<em>红钻价：<span>--</span>Q币</em><br />';
	str += '	</p>';
	str += '	<div class="alpha"></div>';
	str += '</div>'; 
	var oDiv = DisplayItemTips(str, objEvent, "id_setprice_tips", "p_tips", 199);
	//oDiv.getElementsByTagName("SPAN")[0].innerHTML = sName.escHtml();
	oDiv.getElementsByTagName("SPAN")[0].innerHTML = QBPrice(sPrice);
	oDiv.getElementsByTagName("SPAN")[1].innerHTML = QBPrice(sVipPrice);	
	oDiv.style.display = "";
};

function HideSetPriceTips()
{
	if(document.getElementById("id_setprice_tips"))document.getElementById("id_setprice_tips").style.display = "none";
};