var tipsImgArr = ["newhome/images/preview1.jpg", "newhome/images/preview2.jpg", "newhome/images/preview3.jpg", "newhome/images/preview4.jpg"], 
	tips_timer = null,
	j = 3;
//浏览器
var Browser = (function(){
    var userAgent = navigator.userAgent.toLowerCase();
    var env = null;
    return (env = userAgent.match(/msie ([\d.]+)/)) ? {type:"MSIE", version:env[1]} :
           (env = userAgent.match(/firefox\/([\d.]+)/)) ? {type:"FireFox", version:env[1]} :
           (env = userAgent.match(/opera.([\d.]+)/)) ? {type:"Opera", version:env[1]} :
           (env = userAgent.match(/version\/([\d.]+).*safari/)) ? {type:"Safari", version:env[1]} :
           (env = userAgent.match(/chrome\/([\d.]+)/)) ? {type:"Chrome", version:env[1]} :
           {type:"Unknown", version:0};
})();
//返回对象
function $id(id){ return document.getElementById(id);}
//鼠标位置
function getPos(obj){
	var pos = [];
	pos[0] = obj.offsetLeft; //X
	pos[1] = obj.offsetTop;  //Y
	while(obj = obj.offsetParent){
		pos[0] += obj.offsetLeft;
		pos[1] += obj.offsetTop;
	}
	return pos;
}
//显示
function newShowTips(obj,way,imgIndex,imgHeight){
	var featureTips = $id("featureTips");
	var pos = getPos(obj);
	$id("featureTipsImg").src = tipsImgArr[imgIndex];
	featureTips.style.left = pos[0]-60 + "px";   //图片向左偏移的距离
	if(way == "down"){
		tips_timer = setInterval(function(){tipsAnimateDown();},10);
	} else{
		//tips_timer = setInterval(function(){tipsAnimateUp(imgHeight);},10);
	}
	//IMG逐渐向上移动
	function tipsAnimateDown(){
		if(j == 3){
			featureTips.style.display = "block";
		}
		if(j >= 0) {
			featureTips.style.top = (pos[1] + 45 + j * 15) + "px";
			setOpacity();
			j--;
		} else{
			clearInterval(tips_timer);
			tips_timer = null;
			j = 3;
		}
	}
	function tipsAnimateUp(imgHeight) {
		if(j == 3){
			featureTips.style.display = "block";
		}
		if(j >= 0){
			featureTips.style.top = (pos[1] - imgHeight - 10 - j * 15) + "px";
			setOpacity();
			j--;
		} else{
			clearInterval(tips_timer);
			tips_timer = null;
			j = 3;
		}
	}
	//逐渐显示
	function setOpacity() {
		if(Browser.type == 'MSIE'){
			featureTips.filters.alpha.opacity = 100 - j * 25;
		} else{
			featureTips.style.opacity = 1 - j * 0.25;
		}
	}
}
//隐藏
function newHideTips() {
	$id("featureTips").style.display = "none";
	clearInterval(tips_timer);
	tips_timer = null;
	j = 3;
	$id("featureTipsImg").src = "";
}
