//script phong to thu nho anh
// De chay duoc nhat thiet phai chen mot the div vao cuoi trang
//<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>

//////////////////////
var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

// resize fix for ns4
var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// avoid error of passing event object in older browsers
if (nodyn) { event = "nope" }

///////////////////////  CUSTOMIZE HERE   ////////////////////
// settings for tooltip 
// Do you want tip to move when mouse moves over link?
var tipFollowMouse= true;	
// Be sure to set tipWidth wide enough for widest image
var tipWidth= 500;
var offX= 20;	// how far from mouse to show tip
var offY= 12; 
var tipFontFamily= "Verdana, arial, helvetica, sans-serif";
var tipFontSize= "8pt";
// set default text color and background color for tooltip here
// individual tooltips can have their own (set in messages arrays)
// but don't have to
var tipFontColor= "#000000";
var tipBgColor= "#DDECFF"; 
var tipBorderColor= "#000080";
var tipBorderWidth= 1;
var tipBorderStyle= "ridge";
var tipPadding= 4;

// tooltip content goes here (image, description, optional bgColor, optional textcolor)
// to layout image and text, 2-row table, image centered in top cell
// these go in var tip in doTooltip function
// startStr goes before image, midStr goes between image and text
////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles for all but ns4. 
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

window.onload = initTip;

/////////////////////////////////////////////////
//  doTooltip function
//			Assembles content for tooltip and writes 
//			it to tipDiv
/////////////////////////////////////////////////
var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
var midStr = ' border="0"></td></tr><tr><td valign="top" align="center">';
var endStr = '</td></tr></table>';
function doTooltip(evt,imgName, Text,width) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	/*if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	*/
	var curBgColor ="#ffffff";
	var curFontColor ="#000000";
	//imgName='image/sanpham/'+ imgName;
	if (ie4||ie5||ns5) {
		var tip = '<table width="' + width + '" border=0><tr><td align="center" width="100%"><img src="' + imgName + ' " width=' + width + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">'+Text+'</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) positionTip(evt);
}

/////////////////////////////////////////////////////////////
//  positionTip function
//		If tipFollowMouse set false, so trackMouse function
//		not being used, get position of mouseover event.
//		Calculations use mouseover event position, 
//		offset amounts and tooltip width to position
//		tooltip within window.
/////////////////////////////////////////////////////////////
function positionTip(evt) {
	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft;
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop;
	}
	// tooltip width and height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+offY): winHt-(tpHt+offY)+"px";
	else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}




//Script khi di chuot hien dong` chu~ phuc vu quang cao tren text
//De chay duoc nhat thiet phai chen doan ma sau vao cuoi trang
//<div id="GALBox" style="text-align: left; position: absolute; z-index: 100; visibility: hidden; left: 202px; top: 6962px;" onmouseover="this.style.visibility='visible';" onmouseout="this.style.visibility='hidden';"></div>


///////////
 //  %%product_title%% %%version%%
    //	Copyright ©2005-%%current_year%% All rights reserved by www.thevbgeek.com
    //	Code may not be used in whole or part without written permission.
    //  You may not distribute this or any of files in whole or significant part
    //	without explicit written permission.
    // ---------------- %%product_title%% IS NOT FREE SOFTWARE ----------------
	// http://www.thevbgeek.com
    // Licensed to %%domain%% %%email%%
    // License key: %%licensekey%%
    // Downloaded: %%download_date%%

// change to gal_opens=1; for RTL
var gal_opens=0;

//change timeout
var gal_timeout=1000;

var posx = 0;
var posy = 0;

document.documentElement.onmousemove = mousexy;

var tempX = 0;
var tempY = 0;

var gleftpx;
var gtoppx;
var grightpx;
var gheightpx;
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = ((userAgent.indexOf('opera') != -1) || (typeof(window.opera) != 'undefined'));
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == 'Apple Computer, Inc.'));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf('msie 4.') != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));
var is_mac    = (userAgent.indexOf('mac') != -1);

// Catch possible bugs with WebTV and other older browsers


function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}
function mousexy(e)
{
    if (is_ie)
    {
	    tempX = event.clientX;
	    tempY = event.clientY;
    }
    else
    {
	    tempX = e.clientX ;
	    tempY = e.clientY;
    }
    tempY = tempY + document.documentElement.scrollTop;
	tempX = tempX + document.documentElement.scrollLeft;
    //window.status = tempX + " " + tempY;
}


function GAL_watch()
{

    e = fetch_object("GALBox");
    if (e.style.visibility == 'visible')
    {
	    var leftpx  = e.offsetLeft;
	    var toppx   = e.offsetTop;
	    var rightpx = e.offsetWidth;
        var heightpx = e.offsetHeight;

	    while ((e = e.offsetParent) != null)
	    {
	        leftpx  += e.offsetLeft;
	        toppx   += e.offsetTop;
	    }
        //status = leftpx;
        if ((tempX > leftpx) && (tempX < (leftpx + rightpx)) && (tempY > toppx) && (tempY < (heightpx + toppx)))
        {
            setTimeout("GAL_watch()", gal_timeout);
            gal_opens = 1;

        }
        else
        {
	        if ((tempX > gleftpx) && (tempX < (gleftpx + grightpx)) && (tempY > gtoppx) && (tempY < (gheightpx + gtoppx)))
            {
	            setTimeout("GAL_watch()", gal_timeout);
	            gal_opens = 1;
            }
            else
            {
	            gal_opens = 0;
	            fetch_object("GALBox").style.visibility = 'hidden';
            }
        }

    }

}

function GAL_popup(e,offset,width, box_style, value,value_style, title, title_style)
{

	var anchorright = 0;
    if (!offset)
    {
    	offset = 1;
    }

	gleftpx 	= e.offsetLeft;
	gtoppx 	= e.offsetTop;
    grightpx = e.offsetWidth;
    gheightpx = e.offsetHeight;

	while ((e = e.offsetParent) != null)
	{
		gleftpx 	+= e.offsetLeft;
		gtoppx	+= e.offsetTop;
	}

    var toppx = gtoppx;
    var leftpx = gleftpx;
    var rightpx = grightpx;

    if (is_ie)
	{
    	toppx	+= 15;
    }
    else
    {
        toppx 	+=12;
    }

	var dest = fetch_object("GALBox");
    toppx=toppx-offset;

    if (width)
    {
    	width = " Width='" + width + "' ";
    }
    else
    {
    	width = " Width='300px' ";
    }
	var innerhtml="<table border='0' cellpadding='0' cellspacing='0' " + width + "><tr><td onmouseover=\"GAL_keepopen();\" onmouseout=\"GAL_hidepopup();\"><div " + box_style + width + " >";
    if (title)
    {
    	innerhtml=innerhtml + "<div " + title_style + " >" + title + "</div>";
    }
    innerhtml= innerhtml + "<div " + value_style + " >" + value + "</div></div></td><tr></table>";
    dest.innerHTML=innerhtml;

    //alert(innerhtml);


    if (anchorright == 1)
    {
	    rightpx = leftpx - dest.offsetWidth + rightpx;
	    if (rightpx<0)
	    {
	        rightpx = 0;
	    }
    	var anchor = rightpx + "px";
    }
    else
    {
        if (document.documentElement)
        {
        	if (document.documentElement.clientWidth < (leftpx + dest.offsetWidth))
            {
            	leftpx = document.documentElement.clientWidth - dest.offsetWidth;
            }
        }
        var anchor = leftpx + "px";
    }

    dest.style.left = anchor;
    dest.style.top  = toppx + "px";

	dest.style.visibility='visible';
    gal_opens = 2;
    setTimeout("GAL_watch()", 1000);
}

function GAL_hidepopup()
{
    gal_opens--;
}
function GAL_keepopen(){
    gal_opens++;
}