// common.js
/**
* @returns A string which specifies which is the current
* browser in which we are running.
*
* Currently-supported browser detection and codes:
* * 'opera' -- Opera
* * 'msie' -- Internet Explorer
* * 'safari' -- Safari
* * 'firefox' -- FireFox
* * 'mozilla' -- Mozilla
*
* If we are unable to property identify the browser, we
* return an empty string.
*
* @type String
*/
function getBrowserName() {
	var browserName = "";
	var ua = navigator.userAgent.toLowerCase();
	if ( ua.indexOf( "opera" ) != -1 ) {
		browserName = "opera";
	} else if ( ua.indexOf( "msie" ) != -1 ) {
		browserName = "msie";
	} else if ( ua.indexOf( "safari" ) != -1 ) {
		browserName = "safari";
	} else if ( ua.indexOf( "mozilla" ) != -1 ) {
		if ( ua.indexOf( "firefox" ) != -1 ) {
			browserName = "firefox";
		} else {
			browserName = "mozilla";
		}
	}
	return browserName;
}

//change the opacity for different browsers
function changeOpacity(id, opacity) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
	//	for IE8 -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";	
}

var browserName = getBrowserName();

function getPositionLeft(obj){
	var el = obj;
	var pL = 0;
	while(el){pL+=el.offsetLeft;el=el.offsetParent;}
	return pL;
}

function getPositionTop(obj){
	var el = obj;
	var pT = 0;
	while(el){pT+=el.offsetTop;el=el.offsetParent;}
	return pT;
}

var x_min = 1177;
var x_max = 1177 + 170;
var y_min = 352;
var y_max = 352 + 346;

function setMouseCusor() {
	//if (document.activeElement.id == "L42" || document.activeElement.id == "L42_image") {
	//	document.activeElement.style.cursor = 'pointer';
	//}
	var x = window.event.clientX;
	var y = window.event.clientY;
	if (x > x_min && x < x_max && y > y_min && y < y_max) {
		document.body.style.cursor = 'pointer';
	} else {
		document.body.style.cursor = 'auto';
	}	
}

function relocate(url) {
	window.location.href = url;
}