﻿var iBrowserType = 0;
function GetBrowserType() {
    /*
    0 = Unknown Browser
    1 = Safari
    2 = Internet Explorer
    3 = Firefox
    4 = Netscape
    5 = Opera
    6 = Camino
    7 = Firebird
    8 = Google Chrome
    */
    var browser_detect = navigator.userAgent.toLowerCase();
   
    if ((browser_detect.indexOf("safari") + 1)) { iBrowserType = 1; }
    else if ((browser_detect.indexOf("msie") + 1)) { iBrowserType = 2; }
    else if ((browser_detect.indexOf("firefox") + 1)) { iBrowserType = 3; }
    else if ((browser_detect.indexOf("netscape") + 1)) { iBrowserType = 4; }
    else if ((browser_detect.indexOf("opera") + 1)) { iBrowserType = 5; }
    else if ((browser_detect.indexOf("camino") + 1)) { iBrowserType = 6; }
    else if ((browser_detect.indexOf("firebird") + 1)) { iBrowserType = 7; }
    
    if (browser_detect.indexOf("chrome") == 87) { iBrowserType = 8; }
}
//-->
GetBrowserType();

//	Hàm trả về tọa độ X của chuột
function mouseX(e) {
	if (!e)	e=window.event;		
	var mouseX = 0;
	if(e.pageX)	
	{
	    mouseX = e.pageX;
	}
	if(e.clientX)
	{
	    mouseX = e.clientX;
	}
	return mouseX+body().scrollLeft;
}
//	Hàm trả về tọa độ Y của chuột
function mouseY(e) {	
	if (!e)	e=window.event;	
	var mouseY = 0;
	if(e.pageY)	mouseY = e.pageY;
	if(e.clientY) mouseY = e.clientY;	
	return mouseY+body().scrollTop;
}
function mouseY1(e) {	
	if (!e)	e=window.event;	
	var mouseY = 0;
	if(e.pageY)	mouseY = e.pageY;
	if(e.clientY) mouseY = e.clientY;	
	return mouseY;
}
//function setPosition(obj,top,left){
//	obj.style.left=left+'px';
//	obj.style.top =top + 'px';
//}
///////////////////////////////////////////////////////////////////////////////////////////////////
//	Trả về đối tượng body
///////////////////////////////////////////////////////////////////////////////////////////////////

function body(){
    // IF NOT Safari, chrome
    if(iBrowserType != 1 && iBrowserType != 8)
        return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
    else  
        return document.body;
}
function moveImages(e,tagID)
{
    
    var TagId = document.getElementById(tagID);
    var x = mouseX(e)+ 15 ;
    var y = mouseY(e) - TagId.offsetHeight - 14 ;
    if(mouseY1(e) < 200)
    {
       y = mouseY(e)  + 20 ;
    }
    if(mouseX(e) > 600 )
    {
        x = mouseX(e)- TagId.offsetWidth - 14;
        y = mouseY(e)+5;
        
        
    }
    TagId.style.left = x+'px';
    TagId.style.top = y+'px';
       
       
    
    TagId.style.display = "block";
}
function hideImages(tagID)
{    
    var TagId = document.getElementById(tagID);
    TagId.style.display = "none";
}
//function moveImages1(e)
//{
//  
//    var TagId = document.getElementById("image1");
//    var x = mouseX(e)- TagId.offsetWidth - 14;  
//     if(mouseX(e) < 400 ){
//        x = mouseX(e) + 14 ;
//    }       
//    var y = mouseY(e)+15;
//    TagId.style.top = y+'px';;
//    TagId.style.left = x+'px';;
//    TagId.style.display = "block";
//}
//function hideImages1()
//{    
//    var TagId = document.getElementById("image1");
//    TagId.style.display = "none";
//}
