/* ENP Soluções 2009 - todos os direitos reservados - all rights reserveds */
// Function to select all Textarea content.
var copytoclip=1
function selectAll(theField) {
	var tempval = theField;
	tempval.focus();
	tempval.select();
	
	if (document.all&&copytoclip==1){
		therange=tempval.createTextRange();
		therange.execCommand('Copy');
	}
}

// Funcrion to select a option in a html select object.
function ddlSelect(ddl, value) {
	for (i=0;i<ddl.length;i++) {
		if (ddl.options[i].value == value) {
			ddl.options[i].selected = true;
			return ddl.options[i];
		}
	}
}

// Function to get a value of an html object.
function getValue(obj) {
	return document.getElementById(obj).value;
}

// Function to set a value of an html object.
function setValue(obj, value) {
	document.getElementById(obj).value =  value;
}

// Function for remove white spaces of an content.
function Trim(str) {
	return str.replace(/^\s+|\s+$/g,'');
}

// Only numbers function.
var isNav4, isNav, isIE;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
	isNav = (navigator.appName=='Netscape') ? true : false;
	isIE = (navigator.appName.indexOf('Microsoft') != -1) ? true : false;
}

if (navigator.appName=='Netscape') {
	isNav4 = (parseInt(navigator.appVersion.charAt(0))==4);
}

function showModal(onlyContainer) {
	if (!onlyContainer) {
		onlyContainer = false;
	}
	
	document.getElementById('DialogContainer').style.display = 'block';
	
	if (onlyContainer == false)
		document.getElementById('FloatDialogPwd').style.display = 'block';
		
	if (isIE==true) {
		document.getElementById('DialogContainer').style.marginTop=0;
		document.getElementById('DialogContainer').style.height=screen.availHeight;
	}
}

function onlyNumbers(e) {
	var keyNumber = (isIE) ? event.keyCode : e.which;
	if (((keyNumber<48)||(keyNumber>57)) && (keyNumber!=13) && (keyNumber!='0') &&(keyNumber!=8) && (keyNumber!=44)){
		if (isIE) event.keyCode=0;
		return false;
	}
}

// Show and hide div ToolTip.
function showToolTip(msg,event) {
	var x = event.clientX;
	var y = event.clientY;
	
	document.getElementById('divToolTip').style.marginTop='-30px';
	document.getElementById('divToolTip').style.marginLeft='200px';
	document.getElementById('divToolTip').innerHTML = '<strong><img src="images/public/tip.png" border="0" /> Dica:</strong> ' + msg;
	document.getElementById('divToolTip').style.display='block';
}
	
function hideToolTip() {
	document.getElementById('divToolTip').style.display = 'none';
}

function previewPDF(id) {
	window.open('include/adm/care/print.php?id='+id,'','fullscreen=yes,location=no');
}

function getCheckboxListValues(checkboxList) {
		var ret = '';
		var e = document.getElementsByName(checkboxList);
		for(var i=0;i<e.length;i++){
			if (e[i].checked == true)  {
				ret+=e[i].value+',';
			}
		}
		return ret;
}