var showing = false;
var newColor = new Array();
var newBgColor = new Array();
var newBgImg = new Array();

var oldColor = new Array();
var oldBgColor = new Array();
var oldBgImg = new Array();

var objShowed = new Array();
var objOvering = new Array();

function showMenu(obj,showObj,curLevel,menuType,nClr,nBgImg,nBgClr)
{
	showObj = eval(showObj);
	objShowed[curLevel] = showObj;
	objOvering[curLevel] = obj;
	
	if(nClr) 
	{
		newColor[curLevel] = nClr;
		oldColor[curLevel] = objOvering[curLevel].style.color;
	}
	if(nBgClr)
	{
		newBgColor[curLevel] = nBgClr;
		oldBgColor[curLevel] = objOvering[curLevel].style.backgroundColor;
	}
	if(nBgImg) 
	{
		newBgImg[curLevel] = nBgImg;
		oldBgImg[curLevel] = objOvering[curLevel].style.backgroundImage;
	}	

	if(objShowed.length > curLevel + 1)
	{
		objShowed.slice(objShowed.length - curLevel - 1, curLevel + 1);
		objOvering.slice(objOvering.length - curLevel - 1, curLevel + 1);
		newColor.slice(newColor.length - curLevel - 1, curLevel + 1);
		newBgColor.slice(newBgColor.length - curLevel - 1, curLevel + 1);
		newBgImg.slice(newBgImg.length - curLevel - 1, curLevel + 1);
		oldColor.slice(oldColor.length - curLevel - 1, curLevel + 1);
		oldBgColor.slice(oldBgColor.length - curLevel - 1, curLevel + 1);
		oldBgImg.slice(oldBgImg.length - curLevel - 1, curLevel + 1);
	}
	
	for(var i = 0; i <= curLevel; i++)
	{
		objOvering[i].style.color = newColor[i];
		objOvering[i].style.backgroundColor = newBgColor[i];

		if(newBgImg[i] != null)
		{
			objOvering[i].style.backgroundImage = 'url('+newBgImg[i]+')';
		}
		
		if(objShowed[curLevel] != null)
		{
			objShowed[curLevel].style.display = "";
			if(document.all)
			{
				if(menuType==null)
				{
					objShowed[curLevel].style.left = objOvering[curLevel].offsetLeft;
					objShowed[curLevel].style.top = objOvering[curLevel].offsetTop + obj.offsetHeight;
				}
				else
				{
					objShowed[curLevel].style.left = objOvering[curLevel].offsetLeft + objOvering[curLevel].offsetWidth;
					objShowed[curLevel].style.top = objOvering[curLevel].offsetTop + 8;
				}
			}
			else
			{
				myLeft = (screen.width - 730)/2;
				if(menuType==null)
				{
					objShowed[curLevel].style.left = objOvering[curLevel].offsetLeft + myLeft;
					objShowed[curLevel].style.top = objOvering[curLevel].offsetTop + objOvering[curLevel].offsetHeight;
				}
				else
				{
					objShowed[curLevel].style.left = objOvering[curLevel].offsetLeft + objOvering[curLevel].offsetWidth + myLeft + 3;
					objShowed[curLevel].style.top = objOvering[curLevel].offsetTop + 225;
				}
			}
			showing = true;
		}
	}
	//prevObj = obj;
}

function hideMenu(obj,showObj,curLevel)
{
	showObj = eval(showObj);
	
	for(var i = curLevel; i < objShowed.length; i++)
	{
		if(objShowed[i]!=null) 
		{
			showing = false;
			objShowed[i].style.display = 'none';
		}
	}
	if(objOvering[curLevel] != null) 
	{
		if(oldColor[curLevel] != null)
		{
			objOvering[curLevel].style.color = oldColor[curLevel];
		}
		if(oldBgColor[curLevel] != null)
		{
			objOvering[curLevel].style.backgroundColor = oldBgColor[curLevel];
		}
		if(oldBgImg[curLevel] != null)
		{
			objOvering[curLevel].style.backgroundImage = oldBgImg[curLevel];
		}
	}

	objShowed[curLevel] = showObj;
	objOvering[curLevel] = obj;

	if(objShowed.length > curLevel + 1)
	{
		objShowed.slice(objShowed.length - curLevel - 1, curLevel + 1);
		objOvering.slice(objOvering.length - curLevel - 1, curLevel + 1);
		newColor.slice(newColor.length - curLevel - 1, curLevel + 1);
		newBgColor.slice(newBgColor.length - curLevel - 1, curLevel + 1);
		newBgImg.slice(newBgImg.length - curLevel - 1, curLevel + 1);
		oldColor.slice(oldColor.length - curLevel - 1, curLevel + 1);
		oldBgColor.slice(oldBgColor.length - curLevel - 1, curLevel + 1);
		oldBgImg.slice(oldBgImg.length - curLevel - 1, curLevel + 1);
	}	
}
function showMe(obj,curLevel)
{
	for(var i = 0; i <= curLevel; i++)
	{
		objShowed[i].style.display = '';
		objOvering[i].style.color = newColor[i];
		objOvering[i].style.backgroundColor = newBgColor[i];
		if(newBgImg[i] != null) objOvering[i].style.backgroundImage = 'url('+newBgImg[i]+')';
	}
}

function hideMe(obj,curLevel)
{
	obj.style.display = 'none';
	if(prevObj!=null) 
	{
		if(oldColor != null) prevObj.style.color = oldColor;
		if(oldBgColor != null) prevObj.style.backgroundColor = oldBgColor;
		if(oldBgImg != null) prevObj.style.backgroundImage = oldBgImg;
	}
}

snewColor = null;
snewBgColor = null;
snewBgImg = null;

soldColor = null;
soldBgColor = null;
soldBgImg = null;

function changeColor(obj,snClr,snBgImg,snBgClr)
{
	snewColor = snClr;
	snewBgColor = snBgClr;
	snewBgImg = snBgImg;
	
	if(snewColor != null) 
	{
		soldColor = obj.style.color;
		obj.style.color = snewColor;
	}
	if(snewBgColor != null) 
	{
		soldBgColor = obj.style.backgroundColor;
		obj.style.backgroundColor = snewBgColor;
	}
	if(snewBgImg != null) 
	{
		soldBgImg = obj.style.backgroundImage;
		obj.style.backgroundImage = 'url('+snewBgImg+')';
	}
	
}

function restoreColor(obj)
{
	if(soldColor != null) obj.style.color = soldColor;
	if(soldBgColor != null) obj.style.backgroundColor = soldBgColor;
	if(soldBgImg != null) obj.style.backgroundImage = soldBgImg;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function flashWrite(url,w,h,vars,id,bg)
{
	var flashStr=
	"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
	"<param name='allowScriptAccess' value='always' />"+
	"<param name='movie' value='"+url+"' />"+
	"<param name='FlashVars' value='"+vars+"' />"+
	"<param name='wmode' value='transparent' />"+
	"<param name='menu' value='false' />"+
	"<param name='quality' value='high' />"+
	"<embed src='"+url+"' FlashVars='"+vars+"' wmode='transparent' menu='false' quality='high' width='"+w+"' height='"+h+"' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
	"</object>";
	document.write(flashStr);
}

function DisplayFloatBanner(side)
{
	if( side == 0 ) // ko in gi ca
	{
		return;
	}		
	if( FloatBanner.length == 0 )
	{
		return;
	}
		
	document.write('<table cellspacing=0 cellpadding=0 border=0>');
	
	if (side==1) // ben trai
	{
		for (i=0; i<FloatBanner.length; i++)
		{
			if(FloatBanner[i][4]=='0')
			{
				if(FloatBanner[i][0].indexOf(".swf")>0)
				{ 
					document.write('<tr><td>');
					flashWrite(PageHost.concat(FloatBanner[i][0]),FloatBanner[i][5],FloatBanner[i][6],FloatBanner[i][1]);
					document.write('</td></tr>');
	   		}
				else if(FloatBanner[i][1]=='')
				{
					document.write('<tr><td><a href="#"><img src="', PageHost.concat(FloatBanner[i][0]), '" width="',FloatBanner[i][5],'" border=0></a></td></tr>');
				}
				else 
				{
					document.write('<tr><td><a href="',FloatBanner[i][1],'"><img src="', PageHost.concat(FloatBanner[i][0]), '" width="',FloatBanner[i][5],'" border=0></a></td></tr>');
				}
			}
		}
	}
		
	if (side==2) // ben phai
	{
		for (i=0; i<FloatBanner.length; i++)
		{
			if(FloatBanner[i][4]=='1')
			{
				if(FloatBanner[i][0].indexOf(".swf")>0) 
				{
					document.write('<tr><td>');
					flashWrite(PageHost.concat(FloatBanner[i][0]),FloatBanner[i][5],FloatBanner[i][6],FloatBanner[i][1]);
					document.write('</td></tr>');
				}	
				else if(FloatBanner[i][1]=='')
				{
					document.write('<tr><td><a href="#"><img src="', PageHost.concat(FloatBanner[i][0]), '" width="',FloatBanner[i][5],'" border=0></a></td></tr>');
				}
				else 
				{
					document.write('<tr><td><a href="',FloatBanner[i][1],'"><img src="', PageHost.concat(FloatBanner[i][0]), '" width="',FloatBanner[i][5],'" border=0></a></td></tr>');
				}
			}
		}
	}
		
	document.write('</table>');
}

function FloatTopDiv()
{
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	if(!ns)
	{
		startLX = ((document.body.clientWidth - 1230)/2) + 130 , startLY = 105;
		//startRX = ((document.body.clientWidth -770)/2) + 770 +2 , startRY = 62;
		startRX = ((document.body.clientWidth)/2) + 378 , startRY = 105;
	}
	else
	{
		startLX = ((document.body.clientWidth - 1230)/2) + 129 , startLY = 105;
		startRX = ((document.body.clientWidth - 780)/2) + 768 , startRY = 105;
	}
	var d = document;
	function ml(id)
	{
		var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startRX;
		el.y = startRY;
		return el;
	}
	function m2(id)
	{
		var e2=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
		e2.sP=function(x,y){this.style.left=x;this.style.top=y;};
		e2.x = startLX;
		e2.y = startLY;
		return e2;
	}
	window.stayTopLeft=function()
	{
		if (document.documentElement && document.documentElement.scrollTop)
			var pY =  document.documentElement.scrollTop;
		else if (document.body)
			var pY =  document.body.scrollTop;
		if (document.body.scrollTop > 30){startLY = 3;startRY = 3;} else {startLY = 105;startRY = 105;};
		ftlObj.y += (pY+startRY-ftlObj.y)/16;
		ftlObj.sP(ftlObj.x, ftlObj.y);
		ftlObj2.y += (pY+startLY-ftlObj2.y)/16;
		ftlObj2.sP(ftlObj2.x, ftlObj2.y);
		setTimeout("stayTopLeft()", 1);
	}
	ftlObj = ml("divAdRight");
	//stayTopLeft();
	ftlObj2 = m2("divAdLeft");
	stayTopLeft();
}

function ShowAdDiv()
{
	var objAdDivRight = document.getElementById("divAdRight");
	var objAdDivLeft = document.getElementById("divAdLeft");		
	
	if (document.body.clientWidth < 980)
	{
			objAdDivRight.style.display = "none";
		objAdDivLeft.style.display = "none";
	}
	else
	{
		objAdDivRight.style.display = "block";
		objAdDivLeft.style.display = "block";
		FloatTopDiv();
	}
}

//-->
