﻿// JScript File

function DeleteOuterOfObject(){
    theObjects = document.getElementsByTagName("object"); 
    for (var i = 0; i < theObjects.length; i++) 
    { 
        theObjects[i].outerHTML = theObjects[i].outerHTML; 
    }//
}//end DeleteOuterOfObject
//
function clearTextbox(objid){
    
    var obj = document.getElementById (objid);
    obj.value = "";
    obj.style["color"] = "#000";
}//end clearTextbox
/***************************//************************/
/*
function clickIE()
{
if (document.all) {(message);return false;}}

function clickNS(e)
{
if (document.layers||(document.getElementById&&!document.all)) 
{
if (e.which==2||e.which==3) {(message);return false;}
}
}
if (document.layers) 
{
document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
}
else
{
document.onmouseup=clickNS;document.oncontextmenu=clickIE;
}

document.oncontextmenu=new Function("return false")
*/
/********************************/
/*function right(e) {
if (navigator.appName == 'Netscape' && 
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && 
(event.button == 2 || event.button == 3)) {
alert("Sorry, you do not have permission to right click.");
return false;
}
else if(navigator.appName=='FireFox' && (event.button == 2 || event.button == 3)) 
 {
alert("Sorry, you do not have permission to right click.");
return false;
}
return true;
}

document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
*/
/******************************* ko cho phep click phai chuot tren cac trinh duyet"************************/
/*
var message='Sorry, No Right Click Allowed!!!';

function clickIE6(){

if (event.button==2){

alert(message);

return false;

}

}

function clickNS4(e){

if (document.layers||document.getElementById&&!document.all){

if (e.which==2||e.which==3){

alert(message);

return false;

}

}

}

if (document.layers){

document.captureEvents(Event.MOUSEDOWN);

document.onmousedown=clickNS4;

}

else if (document.all&&!document.getElementById){

document.onmousedown=clickIE6;

}

document.oncontextmenu=new Function('alert(message);return false')
*/
/******************************************************/

//
function CountDown(field, countfield, maxlimit) 
{   
    if (field.value.length > maxlimit)	{	
            field.value = field.value.substring(0, maxlimit);
    }            
    else { 
            countfield.value = maxlimit - field.value.length;
    }  
}//

/***********************************************
* VietAd (www.vietad.vn) Ajax ToolTip
***********************************************/

var offsetxpoint = 30; //Customize x offset of tooltip
var offsetypoint = 0; //Customize y offset of tooltip
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip = false;

var tipobj;

function ietruebody()
{
	return (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
}

// Ajax Show Tooltip
function VietAd_ShowTooltip(externalFile)
{	
	if((document.readyState == "complete") || (!ie))
	{
		if(!document.getElementById('VietAdTooltip'))
		{
			try
			{		
				/* Create tooltip content div */
				tipobj = document.createElement('img'); 
				tipobj.className = 'VietAdTooltip';
				tipobj.id = 'VietAdTooltip';		
				tipobj.style.display='block';
				tipobj.style.position = 'absolute';
				document.body.appendChild(tipobj);
			}
			catch(e)
			{	
				return;		
			}
		}		
		
		//ajax_loadContent('VietAdTooltip',externalFile);	
		document.getElementById('VietAdTooltip').src=externalFile;
		
		enabletip = true;
		
	}
}

// Positioning Tooltip
function VietAd_PositionTooltip(e)
{
	if (enabletip)
	{
		var curX = (ns6) ? e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY = (ns6) ? e.pageY : event.clientY+ietruebody().scrollTop;
		
		//Find out how close the mouse is to the corner of the window
		var rightedge  = ie&&!window.opera ? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge = ie&&!window.opera ? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;

		var leftedge = (offsetxpoint<0) ? offsetxpoint*(-1) : -1000;

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge < tipobj.offsetWidth)
		{
			//move the horizontal position of the menu to the left by it's width
			tipobj.style.left = ie ? ietruebody().scrollLeft + event.clientX-tipobj.offsetWidth + "px" : window.pageXOffset + e.clientX - tipobj.offsetWidth + "px";
		}
		else if (curX < leftedge)
		{
			tipobj.style.left = "5px";
		}
		else
		{
			//position the horizontal position of the menu where the mouse is positioned
			tipobj.style.left = curX + offsetxpoint + "px";
		}

		//same concept with the vertical position
		if (bottomedge < tipobj.offsetHeight)
		{
			tipobj.style.top = ie ? ietruebody().scrollTop + event.clientY-tipobj.offsetHeight - offsetypoint + "px" : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + "px";
		}
		else
		{
			tipobj.style.top = curY + offsetypoint + "px";
		}
			
		tipobj.style.visibility = "visible";
	}
}

// Hide Tooltip
function VietAd_HideTooltip()
{
	if ((ns6||ie) && (tipobj))
	{
		enabletip = false;
		
		tipobj.style.visibility = "hidden";
		tipobj.style.left = "-1000px";
		tipobj.style.backgroundColor = '';
		tipobj.style.width = '';
	}
}

document.onmousemove = VietAd_PositionTooltip;
/******************* chong boi den******************************/

/*function disableselect(e){
return false
}
function reEnable(){
return true
}
//if IE4+
document.onselectstart=new Function ("return false")
//if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}*/
/****************div on top**********************/
function showHideGB(){
var gb = document.getElementById("gb");
var w = gb.offsetWidth;
gb.opened ? moveGB(0, 30-w) : moveGB(20-w, 0);
gb.opened = !gb.opened;
}
function moveGB(x0, xf){
var gb = document.getElementById("gb");
var dx = Math.abs(x0-xf) > 10 ? 5 : 1;
var dir = xf>x0 ? 1 : -1;
var x = x0 + dx * dir;
gb.style.right = x.toString() + "px";
if(x0!=xf){setTimeout("moveGB("+x+", "+xf+")", 10);}
}
