﻿var isok=1;
var oldp=0;
var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	
function $id(id)
{
	if (typeof(id) == "string")
	{
		return document.getElementById(id);	
	}
}

if(navigator.userAgent.indexOf("MSIE")>=0)
{
	g_browserVer = 1;//ie
}
else
{
	g_browserVer = 2;//ff
}

	
var g_browserVer;
var g_tipsImgArr = [
	"img/1.png",
	"img/2.png",
	"img/22.png",
	"img/3.png",
	"img/4.png",
	"img/5.png"
];
var g_tips_timer = null;
var g_tips_j = 3;
//<!-- Hide 
	//function killErrors() { 
		//return true; 
	//} 
	//window.onerror = killErrors; 
	// --> 
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(xleft,xtop,way,imgIndex,imgHeight)
{
	var featureTips = $id("featureTips");
	//var pos = getPos(obj);
	
	if (g_browserVer==1 && (ie55 || ie6 ) && g_tipsImgArr[imgIndex].indexOf(".png")!=-1 ) 
	{
		imgdata="<SPAN style=\"POSITION: relative; FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ g_tipsImgArr[imgIndex] +"', sizingMethod='scale'); WIDTH: 300px; DISPLAY: inline-block; WHITE-SPACE: pre-line; BACKGROUND: none transparent scroll repeat 0% 0%; HEIGHT: 220px\"></SPAN>";
	}
	else
	{
		imgdata="<img src='"+ g_tipsImgArr[imgIndex] +"'>";
	}

	$id("featureTipsImg").innerHTML = imgdata;
	
	featureTips.style.left = xleft + "px";
	if (way == "down")
	{
		g_tips_timer = setInterval(function(){tipsAnimateDown()},10);
	}
	else
	{
		g_tips_timer = setInterval(function(){tipsAnimateUp(imgHeight)},10);
	}
	function tipsAnimateDown()
	{
		if (g_tips_j == 3)
		{
			featureTips.style.display = "block";
		}
		if (g_tips_j >= 0)
		{
			featureTips.style.top = (xtop + 20 + g_tips_j * 15) + "px";
			setOpacity();
			g_tips_j--;
		}
		else
		{
			clearInterval(g_tips_timer);
			g_tips_timer = null;
			g_tips_j = 3;
		}
	}
	function tipsAnimateUp(imgHeight)
	{
		if (g_tips_j == 3)
		{
			featureTips.style.display = "block";
		}
		if (g_tips_j >= 0)
		{
			featureTips.style.top = (xtop- imgHeight - 10 - g_tips_j * 15) + "px";
			setOpacity();
			g_tips_j--;
		}
		else
		{
			clearInterval(g_tips_timer);
			g_tips_timer = null;
			g_tips_j = 3;
		}
	}
	function setOpacity()
	{
		if (g_browserVer == 1)
		{
			featureTips.filters.alpha.opacity = 100 - g_tips_j * 25;
		}
		else
		{
			featureTips.style.opacity = 1 - g_tips_j * 0.25;
		}
	}
}

function newHideTips()
{
	isok=1;
	$id("featureTips").style.display = "none";
	clearInterval(g_tips_timer);
	g_tips_timer = null;
	g_tips_j = 3;
	//$id("featureTipsImg").src = "";
	$id("featureTipsImg").innerHTML = "";
}

var g_j = 0;
function countImg()
{
	if (++g_j >= g_tipsImgArr.length)
	{
		//document.getElementById("features").style.visibility = "visible";
	}
}

var tempImgArea = $id("tempImgArea");
for (var i=0; i<g_tipsImgArr.length; i++)
{
	var img = document.createElement("img");
	img.onload = function(){countImg()};
	img.src = g_tipsImgArr[i];
	tempImgArea.appendChild(img);
}
var tempWindowImg = ["images/window.gif","images/clew-success.gif","images/clew-info.gif"]
for (var i=0; i<tempWindowImg.length; i++)
{
	var img = document.createElement("img");
	img.src = tempWindowImg[i];
	tempImgArea.appendChild(img);
}

function test(p)
{
var pos = getPos($id("active"));
var xleft=pos[0];
var xtop=pos[1];
if (p==1){xtop=180;xleft=xleft+40;}
if (p==2){xtop=320;xleft=xleft+10;}
if (p==3){xtop=450;xleft=xleft-30;}
if (p==4){xtop=560;xleft=xleft-120;}
if (p==5){xtop=640;xleft=xleft-250;}
if (p==6){xtop=690;xleft=xleft-360;}


if(isok==1 || oldp!=p)
{

	$id("sound").src = "";
	if(isok==0){newHideTips();}
	isok=0;
	oldp=p;
	newShowTips(xleft,xtop,'down',(p-1),'316');

}
}
