// FUNCTIONS
function isIe() {
	if(navigator.appName == "Microsoft Internet Explorer") { 
		return true;
	}
	return false;
}
function getE(id) { 
	return document.getElementById(id);
}
function getElHeight(el) {
	try{
		h = el.style.pixelHeight;
		if(!isDefined(h) || h == 0)
			h = el.offsetHeight;
		if(!isDefined(h) || h == 0)
			h = el.clientHeight;
	} catch(e) {
		h = el.offsetHeight;
	}
	return h;
}
function getElWidth(el) {
	try{
		w = el.style.pixelWidth;
		if(!isDefined(w) || w == 0)
			w = el.offsetWidth;
		if(!isDefined(w) || w == 0)
			w = el.clientWidth;
	} catch(e) {
		w = el.offsetWidth;
	}
	return w;
}
function noPx(v) {
	if(v) {
		return Math.round(v.substr(0, v.length-2));
	} else {
		return false;
	}
}
function setT(f, t) { 
	setTimeout(f, t);
}
function goTo (uri) {
	window.location.assign(uri);
	return true;
}
function getMouseXY(e)	{
	if (!e)
		var e = window.event;
	
	//x = e.clientX;
	//y = e.clientY;
	
	if (e.pageX) {
		x = e.pageX;
		y = e.pageY;
	} else if (e.clientX) {
		x =	e.clientX + document.body.scrollLeft - document.body.clientLeft;
		y = e.clientY + document.body.scrollTop - document.body.clientTop;
		
		if (document.body.parentElement && document.body.parentElement.clientLeft) {
			var bodParent = document.body.parentElement;
			x += bodParent.scrollLeft - bodParent.clientLeft;
			y += bodParent.scrollTop - bodParent.clientTop;
		}
	}

	return {'x':x,'y':y};
}
function getWinSize(winObj) { // retorna o tamanho da janela argumento
	var myWidth = 0, myHeight = 0;
	if( typeof( winObj.innerWidth ) == 'number' ) {
		myWidth = winObj.innerWidth;
		myHeight = winObj.innerHeight;
	} else if( winObj.document.documentElement && ( winObj.document.documentElement.clientWidth || winObj.document.documentElement.clientHeight ) ) {
		myWidth = winObj.document.documentElement.clientWidth;
		myHeight = winObj.document.documentElement.clientHeight;
	} else if( winObj.document.body && ( winObj.document.body.clientWidth || winObj.document.body.clientHeight ) ) {
		myWidth = winObj.document.body.clientWidth;
		myHeight = winObj.document.body.clientHeight;
	}
	return {'w':myWidth,'h':myHeight};
}
function getWinScroll(winObj) {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( winObj.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = winObj.pageYOffset;
    scrOfX = winObj.pageXOffset;
  } else if( winObj.document.body && ( winObj.document.body.scrollLeft || winObj.document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = winObj.document.body.scrollTop;
    scrOfX = winObj.document.body.scrollLeft;
  } else if( winObj.document.documentElement && ( winObj.document.documentElement.scrollLeft || winObj.document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = winObj.document.documentElement.scrollTop;
    scrOfX = winObj.document.documentElement.scrollLeft;
  }
  return {'x':scrOfX,'y':scrOfY};
}
function freshStyle(p)
	{
		if(isIe()) {
			var content = p.innerHTML;
			if(content != '') {
				p.innerHTML = '';
				setTimeout( function () {
					p.innerHTML = content; 					
					var elements = new Array ();
					try {
						var children = p.getElementsByTagName( "*" );
				
						for ( var i = 0; i < children.length; i++ ) {
							children[i].className = children[i].className;
						}
					} catch (err) { alert(err); } ;
				} , 100 );
			}
		}
	}
function getStyle( element, cssRule ) {
	if( document.defaultView && document.defaultView.getComputedStyle ) {
		var value = document.defaultView.getComputedStyle( element, '' ).getPropertyValue( cssRule );
	}
	else if ( element.currentStyle ) var value = element.currentStyle[ cssRule ];
	else                             var value = false;
	return value;
}
function abreJanela(uri, nome, w, h) {
	return window.open(uri, nome, 'width='+w+',height='+h+',dependent=no,scrolling=no,scrollbars=no,toolbar=no,location=no,status=no,menubar=no');
}	
function abreJanelaCenter(uri, nome, w, h) {
	var win = abreJanela(uri, nome, w, h);
	win.moveTo(screen.width/2 - w/2, screen.height/2 - h/2 - 50);
	win.focus();
	return win;
}
function microtime(get_as_float) { 
    var now = new Date().getTime() / 1000;
    var s = parseInt(now); 
    return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}