//recebe uma string no formato de data e retorna um objeto Date
function Trim(str){
	var i = 0;
	var j = str.length;
	while(str.charCodeAt(i) == 32)
		i++;
	while(str.charCodeAt(j - 1) == 32)
		j--;
	if(i >= j)
		return("");
	return(str.substring(i, j));
}

function getDate(STRING_DATE){
	var DIA, MES, ANO;
	STRING_DATE = formatDate(STRING_DATE);
	if(STRING_DATE != ""){
		DIA = parseInt(STRING_DATE.substring(0, STRING_DATE.indexOf("/")), 10);
		MES = parseInt(STRING_DATE.substring(STRING_DATE.indexOf("/") + 1, STRING_DATE.lastIndexOf("/")), 10) - 1;
		ANO = parseInt(STRING_DATE.substring(STRING_DATE.lastIndexOf("/") + 1, STRING_DATE.length), 10);
		return(new Date(ANO, MES, DIA));
	}
	else{
		return(new Date());
	}
}

function formatAno(ANO){
	if(ANO >= 0 && ANO < 100)
		if(ANO < 40)
			ANO += 2000;
		else
			ANO += 1900;
	return(ANO);
}

//recebe uma string no formato "dd/mm/aaaa" ou "d/m/aa" ou "d/m/a" e retorna true se a data for valida
function isDate(STRING_DATE) {
	var DIA, MES, ANO;
	var BARRAS = 0;
	if(STRING_DATE.length < 5 || STRING_DATE.length > 10)
		return(false);
	for(var i = 0; i < STRING_DATE.length; i++)
		if(STRING_DATE.charCodeAt(i) == 47)
			BARRAS++;
	if(BARRAS != 2)
		return(false);
	DIA = parseInt(STRING_DATE.substring(0, STRING_DATE.indexOf("/")), 10);
	MES = parseInt(STRING_DATE.substring(STRING_DATE.indexOf("/") + 1, STRING_DATE.lastIndexOf("/")), 10);
	ANO = parseInt(STRING_DATE.substring(STRING_DATE.lastIndexOf("/") + 1, STRING_DATE.length), 10);
	if(isNaN(DIA) || isNaN(MES) || isNaN(ANO))
		return(false)
	ANO = formatAno(ANO);
	if(((DIA > 31) || (DIA <= 0) || (MES > 12) || (MES <= 0) || (ANO > 9999) || (ANO < 0)) ||       
     ((DIA == 31) && ((MES == 2) || (MES == 4) || (MES == 6) || (MES == 9) || (MES == 11))) ||
     ((DIA == 30) && (MES == 2)) ||
     ((DIA == 29) && (MES == 2) && ((ANO % 4) || ((!(ANO % 100)) && (ANO % 400))))){
		return(false);
	}
	return(true);
}

//recebe uma string somente com numeros e barras (/)
function formatDate(STRING_DATE){
	var DIA, MES, ANO;
	var BARRAS = 0;
	for(var i = 0; i < STRING_DATE.length; i++)
		if(STRING_DATE.charCodeAt(i) == 47)
			BARRAS++;
	if(BARRAS == 0){
		if(STRING_DATE.length < 6 || STRING_DATE.length > 8)
			return("");
		DIA = STRING_DATE.substring(0, 2);
		MES = STRING_DATE.substring(2, 4);
		ANO = STRING_DATE.substring(4, STRING_DATE.length);
		STRING_DATE = DIA + "/" + MES + "/" + ANO;
	}
	if(isDate(STRING_DATE)){
		DIA = STRING_DATE.substring(0, STRING_DATE.indexOf("/"));
		MES = STRING_DATE.substring(STRING_DATE.indexOf("/") + 1, STRING_DATE.lastIndexOf("/"));
		ANO = STRING_DATE.substring(STRING_DATE.lastIndexOf("/") + 1, STRING_DATE.length);
		if(DIA.length == 1)
			DIA = "0" + DIA;
		if(MES.length == 1)
			MES = "0" + MES;
		ANO = formatAno(parseInt(ANO, 10)).toString();
		if(ANO.length < 4){
			ANO = "000" + ANO;
			ANO = ANO.substring(ANO.length - 4, ANO.length);
		}
		return(DIA + "/" + MES + "/" + ANO);
	}
	else
		return("");
}

//formata a string com segundos
function FormatTimeSegundos(STRING_HOUR){
	var HOR, MIN, SEG;
	var DOISPONTOS = 0;

	if(STRING_HOUR.length == 0)
		return("");

	
	for(var i = 0; i < STRING_HOUR.length; i++)
		if(STRING_HOUR.charCodeAt(i) == 58)
			DOISPONTOS++;

	if(DOISPONTOS == 0){
		
		if(isNaN(STRING_HOUR))
			return("");
		
		if(STRING_HOUR.length == 1 && STRING_HOUR < 24){
			HOR = "0" + STRING_HOUR;
			MIN = "00";
			SEG = "00";
			STRING_HOUR = HOR + ":" + MIN + ":" + SEG;
				return(STRING_HOUR);}

		if(STRING_HOUR.length == 2 && STRING_HOUR < 24){
			HOR = STRING_HOUR;
			MIN = "00";
			SEG = "00";
			STRING_HOUR = HOR + ":" + MIN + ":" + SEG;
				return(STRING_HOUR);}

		if(STRING_HOUR.length > 6)
			return("");
		
		HOR = STRING_HOUR.substring(0, 2);
		MIN = STRING_HOUR.substring(2, 4);
		if (MIN.length == 1)
		{
			MIN = "0" + MIN;
		}
		SEG = STRING_HOUR.substring(4, 6);
		if (SEG.length == 0)
		{
			SEG = "00";
		}

		if (SEG.length == 1)
		{
			SEG = "0" + SEG;
		}

		if(HOR > 23 || MIN > 59 || SEG > 59)
			return("");

		STRING_HOUR = HOR + ":" + MIN + ":" + SEG;
			return(STRING_HOUR);
	}

	else if(DOISPONTOS == 1){
		HOR = STRING_HOUR.substring(0, STRING_HOUR.indexOf(":"));
		MIN = STRING_HOUR.substring(STRING_HOUR.indexOf(":") + 1, STRING_HOUR.length);
		
		if(isNaN(HOR))
			return("");
		
		if(isNaN(MIN))
			return("");
				
		if(HOR > 23 || MIN > 59)
			return("");
		
		if(HOR.length == 0 || HOR.length > 2)
			return("");

		if(MIN.length == 0 || MIN.length > 2)
			return("");

		if(HOR.length == 1)
			HOR = "0" + HOR;

		if(MIN.length == 1)
			MIN = MIN + "0";

		SEG = "00";
		STRING_HOUR = HOR + ":" + MIN + ":" + SEG;
		
			return(STRING_HOUR);
	}
	else if(DOISPONTOS == 2){
		HOR = STRING_HOUR.substring(0, STRING_HOUR.indexOf(":"));
		MIN = STRING_HOUR.substring(HOR.length+1, STRING_HOUR.indexOf(":", HOR.length+1));
		SEG = STRING_HOUR.substring(HOR.length + MIN.length + 2, STRING_HOUR.length);
		if (SEG.length == 0)
		{
			SEG = "00";
		}

		if (SEG.length == 1)
		{
			SEG = "0" + SEG;
		}
		
		if(isNaN(HOR))
			return("");
		
		if(isNaN(MIN))
			return("");
				
		if(isNaN(SEG))
			return("");

		if(HOR > 23 || MIN > 59 || SEG > 59)
			return("");
		
		if(HOR.length == 0 || HOR.length > 2)
			return("");

		if(MIN.length == 0 || MIN.length > 2)
			return("");

		if(SEG.length == 0 || SEG.length > 2)
			return("");

		if(HOR.length == 1)
			HOR = "0" + HOR;

		if(MIN.length == 1)
			MIN = MIN + "0";

		if(SEG.length == 1)
			SEG = SEG + "0";

		STRING_HOUR = HOR + ":" + MIN + ":" + SEG;
		
			return(STRING_HOUR);
	}
	else
		return("");
}

//recebe uma string somente com numeros e barras (:)
function FormatTime(STRING_HOUR){
	var HOR, MIN;
	var DOISPONTOS = 0;

	for(var i = 0; i < STRING_HOUR.length; i++)
		if(STRING_HOUR.charCodeAt(i) == 58)
			DOISPONTOS++;

	if(DOISPONTOS == 0){
		
		if(isNaN(STRING_HOUR))
			return("");
		
		if(STRING_HOUR.length == 1 && STRING_HOUR < 24){
			HOR = "0" + STRING_HOUR;
			MIN = "00";
			STRING_HOUR = HOR + ":" + MIN;
				return(STRING_HOUR);}

		if(STRING_HOUR.length == 2 && STRING_HOUR < 24){
			HOR = STRING_HOUR;
			MIN = "00";
			STRING_HOUR = HOR + ":" + MIN;
				return(STRING_HOUR);}

		if(STRING_HOUR.length != 4)
			return("");
		
		HOR = STRING_HOUR.substring(0, 2);
		MIN = STRING_HOUR.substring(2, 4);

		if(HOR > 23 || MIN > 59)
			return("");

		STRING_HOUR = HOR + ":" + MIN;
			return(STRING_HOUR);
	}

	else if(DOISPONTOS == 1){
		HOR = STRING_HOUR.substring(0, STRING_HOUR.indexOf(":"));
		MIN = STRING_HOUR.substring(STRING_HOUR.indexOf(":") + 1, STRING_HOUR.length);
		
		if(isNaN(HOR))
			return("");
		
		if(isNaN(MIN))
			return("");
				
		if(HOR > 23 || MIN > 59)
			return("");
		
		if(HOR.length == 0 || HOR.length > 2)
			return("");

		if(MIN.length == 0 || MIN.length > 2)
			return("");

		if(HOR.length == 1)
			HOR = "0" + HOR;

		if(MIN.length == 1)
			MIN = MIN + "0";

		STRING_HOUR = HOR + ":" + MIN;
			return(STRING_HOUR);
	}
	else
		return("");
}

//recebe uma string somente com numeros e barras (:)
function FormatLongTime(STRING_HOUR){
	var HOR, MIN;
	var DOISPONTOS = 0;

	for(var i = 0; i < STRING_HOUR.length; i++)
		if(STRING_HOUR.charCodeAt(i) == 58)
			DOISPONTOS++;

	if(DOISPONTOS == 0){
		
		if(isNaN(STRING_HOUR))
			return("");
		
		if(STRING_HOUR.length == 1){
			HOR = "0" + STRING_HOUR;
			MIN = "00";
			STRING_HOUR = HOR + ":" + MIN;
				return(STRING_HOUR);}

		if(STRING_HOUR.length == 2){
			HOR = "" + STRING_HOUR;
			MIN = "00";
			STRING_HOUR = HOR + ":" + MIN;
				return(STRING_HOUR);}

		if(STRING_HOUR.length == 3){
			HOR = STRING_HOUR;
			MIN = "00";
			STRING_HOUR = HOR + ":" + MIN;
				return(STRING_HOUR);}

		HOR = STRING_HOUR.substring(0, 3);
		MIN = STRING_HOUR.substring(3, 4);

		if(MIN > 59)
			return("");

		STRING_HOUR = HOR + ":" + MIN;
			return(STRING_HOUR);
	}

	else if(DOISPONTOS == 1){
		HOR = STRING_HOUR.substring(0, STRING_HOUR.indexOf(":"));
		MIN = STRING_HOUR.substring(STRING_HOUR.indexOf(":") + 1, STRING_HOUR.length);
		
		if(isNaN(HOR))
			return("");
		
		if(isNaN(MIN))
			return("");
				
		if(MIN > 59)
			return("");
		
		if(HOR.length == 0 || HOR.length > 3)
			return("");

		if(MIN.length == 0 || MIN.length > 2)
			return("");

		if(HOR.length == 1)
			HOR = "0" + HOR;

		if(HOR.length == 2)
			HOR = "" + HOR;

		if(MIN.length == 1)
			MIN = MIN + "0";

		STRING_HOUR = HOR + ":" + MIN;
			return(STRING_HOUR);
	}
	else
		return("");
}


function Replace(expression, find, replacewith, start){
	var aux;
	if(start == null)
		start = 0;
	if(find != "")
		while(expression.indexOf(find, start) != -1){
			aux = expression.indexOf(find, start);
			expression = expression.substring(0, aux) + replacewith + expression.substring(aux + find.length, expression.length);
			start = aux + replacewith.length;
		}
	return(expression);
}

function SetSelect(select, value, formatcompare){
	if(formatcompare != true && formatcompare != false){
		formatcompare = false;
	}
	for(var i = 0; i < select.length; i++){
		if(formatcompare){
			if(Trim(select.options[i].value.toUpperCase()) == Trim(value.toUpperCase())){
				select.options[i].selected = true;
				return;
			}
		}
		else{
			if(select.options[i].value == value){
				select.options[i].selected = true;
				return;
			}
		}
	}
}

function SetCheckBox(checkbox, value, formatcompare){
	if(formatcompare != true && formatcompare != false){
		formatcompare = false;
	}
	if(formatcompare){
		if(Trim(checkbox.value.toUpperCase()) == Trim(value.toUpperCase())){
			checkbox.checked = true;
		}
		else{
			checkbox.checked = false;
		}
	}
	else{
		if(checkbox.value == value){
			checkbox.checked = true;
		}
		else{
			checkbox.checked = false;
		}
	}
}

function SetRadio(radio, value, formatcompare){
	if(formatcompare != true && formatcompare != false){
		formatcompare = false;
	}
	for(var i = 0; i < radio.length; i++){
		if(formatcompare){
			if(Trim(radio[i].value.toUpperCase()) == Trim(value.toUpperCase())){
				radio[i].checked = true;
				return;	
			}
		}
		else{
			if(radio[i].value == value){
				radio[i].checked = true;
				return;	
			}
		}
	}
}

//funcao que seta um campo de um formulario (text, textarea, hidden, password, checkbox, radio, select)
//elementname = nome do elemento do formulario que sera setado
//value = o valor a ser setado
//formatcompare = (true/false) se deve comparar com sensitive case no caso de setar um select, um radio ou um checkbox. se nao especificado assume false
//formatcompare = formulario que se encontra o elemento. se nao especificado assume document.forms[0]
function SetElement(elementname, value, formatcompare, form){
	if(form == null){
		if(document.forms.length < 1){
			return;
		}
		form = document.forms[0];
	}
	if(formatcompare != true && formatcompare != false){
		formatcompare = false;
	}
	var element = form.elements[elementname];
	if(element == null){
		return;
	}
	//se existe apenas um campo no formulario (exeto o select onde a propriedade length se refere ao numero de options)
	if(element.length == null){
		if(element.type != null){

			//seta um text ou textarea ou password ou hidden
			if(element.type.toUpperCase() == "TEXT" || element.type.toUpperCase() == "TEXTAREA" || element.type.toUpperCase() == "PASSWORD" || element.type.toUpperCase() == "HIDDEN"){
				element.value = value;
			}

			//seta um checkbox
			if(element.type.toUpperCase() == "CHECKBOX"){
				SetCheckBox(element, value, formatcompare);
			}

			//essa rotina seta um radio quando existir somente um radio
			if(element.type.toUpperCase() == "RADIO"){
				element.checked = true;
			}
		}
	}

	//se existem campos replicados (ou se for um select)
	else{

		//percorre cada replica
		for(var j = 0; j < element.length; j++){

			//se o campo nao tiver um tipo, é um option de um select, entao o select é mandado para ser setado
			if(element[j].type == null){
				SetSelect(element, value, formatcompare);
				break;
			}
			else{

				//se o campo for um radio, manda o grupo de radios para um ser setado
				if(element[j].type.toUpperCase() == "RADIO"){
					SetRadio(element, value, formatcompare);
					break;
				}

				//seta um text ou textarea ou password ou hidden
				if(element[j].type.toUpperCase() == "TEXT" || element[j].type.toUpperCase() == "TEXTAREA" || element[j].type.toUpperCase() == "PASSWORD" || element.type.toUpperCase() == "HIDDEN"){
					element[j].value = value;
				}

				//seta um checkbox
				if(element[j].type.toUpperCase() == "CHECKBOX"){
					SetCheckBox(element[j], value, formatcompare);
				}

				//se existirem selects replicados, eles serao setados nessa rotina
				if(element[j].type.toUpperCase() == "SELECT-ONE"){
					SetSelect(element[j], value, formatcompare);
				}
			}
		}
	}
}

function EditMode(sta, form){
	var i, elementname, pk, no_pk, pk_focus, no_pk_focus;
	if(form == null){
		if(document.forms.length < 1){
			return;
		}
		form = document.forms[0];
	}
	pk = form.elements["mmi_editmode_pk"];
	no_pk = form.elements["mmi_editmode_no_pk"];
	if(pk == null || no_pk == null){
		return;
	}
	if(pk.length == null){
		if(form.elements[pk.value] != null){
			pk_focus = form.elements[pk.value];
			form.elements[pk.value].disabled = sta;
		}
	}
	else{
		for(i = 0; i < pk.length; i++){
			if(form.elements[pk[i].value] != null){
				if(i == 0){
					pk_focus = form.elements[pk[i].value];
				}
				form.elements[pk[i].value].disabled = sta;
			}
		}
	}
	if(no_pk.length == null){
		if(form.elements[no_pk.value] != null){
			no_pk_focus = form.elements[no_pk.value];
			form.elements[no_pk.value].disabled = !sta;
		}
	}
	else{
		for(i = 0; i < no_pk.length; i++){
			if(form.elements[no_pk[i].value] != null){
				if(i == 0){
					no_pk_focus = form.elements[no_pk[i].value];
				}
				form.elements[no_pk[i].value].disabled = !sta;
			}
		}
	}
	if(sta){
		no_pk_focus.focus();
	}
	else{
		pk_focus.focus();
	}
}

function EnableAll(form){
	var i;
	if(form == null){
		if(document.forms.length < 1){
			return;
		}
		form = document.forms[0];
	}
	for(i = 0; i < form.length; i++){
		form.elements[i].disabled = false;
	}
}

function DisableAll(form){
	var i;
	if(form == null){
		if(document.forms.length < 1){
			return;
		}
		form = document.forms[0];
	}
	for(i = 0; i < form.length; i++){		
		form.elements[i].disabled = true;
	}
}

function ReadOnlyAll(form){
	var i;
	if(form == null){
		if(document.forms.length < 1){
			return;
		}
		form = document.forms[0];
	}

	for(i = 0; i < form.length; i++)
		if(form.elements[i].type == "checkbox" || form.elements[i].type == "textarea")
			form.elements[i].disabled = true;
}

function ClearForm(form){
	if(form == null){
		if(document.forms.length < 1){
			return;
		}
		form = document.forms[0];
	}
	form.reset();
}

function resizeDivBody(DIV){
	DIV.style.posWidth = window.screen.availWidth - DIV.style.posLeft - window.screenLeft - 4;
	DIV.style.posHeight = window.screen.availHeight - DIV.style.posTop - window.screenTop - 24;
}
function resizeToScreen(element, space_width, space_height){
	element.style.posWidth = window.document.body.offsetWidth - element.style.posLeft - space_width - 2;
	element.style.posHeight = window.document.body.offsetHeight - element.style.posTop - space_height - 2;
	//element.style.posWidth = window.screen.availWidth - element.style.posLeft - window.screenLeft - 2 - space_width;
	//element.style.posHeight = window.screen.availHeight - element.style.posTop - window.screenTop - 22 - space_height;
}
function resizeToParent(element, space_width, space_height){
	element.style.posWidth = element.parentElement.style.posWidth - element.style.posLeft - space_width - space_width;
	element.style.posHeight = element.parentElement.style.posHeight - element.style.posTop - space_height - space_height;
}
function resizeToElement(element, space_width, space_height, parent){
	element.style.posWidth = parent.style.posWidth - element.style.posLeft - space_width - space_width;
	element.style.posHeight = parent.style.posHeight - element.style.posTop - space_height - space_height;
}

function clearSelect(select, deletefirst){
	var aux;
	var index;
	if(deletefirst != true && deletefirst != false){
		deletefirst = true;
	}
	if(deletefirst){
		aux = select.length;
		index = 0;
	}
	else{
		aux = select.length - 1;
		index = 1;
	}
	for(var i = 0; i < aux; i++){
		select.options[index] = null;
	}
}

function navigate2(URL){
	window.document.body.insertAdjacentHTML("BeforeEnd","<A id='HTTP_REFERER' href='" + URL + "'></A>");
	window.HTTP_REFERER.click();
}

function get_radio(RADIO){
	//se tiver apenas um radio
	if(RADIO.length == null){
		return(RADIO.value);
	}
	else{
		for(var i=0; i<RADIO.length; i++)
			if(RADIO[i].checked == true)
				return(RADIO[i].value);
	}
}

//formata um numero recebendo o proprio, a precisao de casas
//decimais, se deseja(true) completar as casa decimais com zeros
// e se o separador decimal será um ponto(default true) ou virgula(false)
function js_FormatNumber(NUMBER,PRECISION,TAM_ESQUERDA,ZEROS,POINT){
	if((POINT != true && POINT != false) || POINT == true){
		POINT = ".";
	}
	else{
		POINT = ","
	}
	var ZEROS_ESQUERDA = "";
	if(isNaN(TAM_ESQUERDA) || TAM_ESQUERDA == null){
		TAM_ESQUERDA = 0;
	}
	else{
		TAM_ESQUERDA = parseInt(TAM_ESQUERDA);
	}
	if(ZEROS == null){
		ZEROS = false;
	}
	var NUM = NUMBER.toString();
	NUM = js_replace(NUM,",",".");
	NUM = parseFloat(NUM);
	if(isNaN(NUM)){
		return("NaN");
	}
	if(PRECISION == null){
		PRECISION = 0;
	}
	if(PRECISION == 0){
		ZEROS = false
		NUM = Math.round(NUM);
	}
	NUM = NUM.toString();
	var SEP = NUM.indexOf(".");
	if(SEP != -1){
		var NUM_AUX = NUM.substr(SEP + 1);
		var AUX = PRECISION - NUM_AUX.length + 1;
		for(var i=0; i<AUX; i++){
			NUM = NUM + "0";
		}
		var TEMP = 0;
		var ATUAL = 0;
		var SOMA = 0;
		var ANT;
		var TOT = SEP+PRECISION;
		for(var w=NUM.length - 2; w>=TOT; w--){
			ANT = 1;
			if(NUM.charAt(w) == "."){
				ANT = 2;
				w--;
				TOT--;
			}
			TEMP = parseInt(NUM.charAt(w + ANT)) + SOMA;
			if(TEMP > 5){
				ATUAL = parseInt(NUM.charAt(w)) + 1;
				if(ATUAL >= 10){
					if(w == TOT){
						TOT--;
					}						
					if(w == 0){
						NUM = "10" + NUM.substr(1);
						SEP++;
						break;
					}
					else{
						NUM = NUM.substring(0,w) + "0" + NUM.substr(w + 1);
						SOMA = 10;
					} 
				}
				else{
					SOMA = 0;
					NUM = NUM.substring(0,w) + ATUAL + NUM.substr(w + 1);
				}
			}
		}
		for(var y=SEP; y<TAM_ESQUERDA; y++){
			ZEROS_ESQUERDA += "0"
		}
		NUM = NUM.substr(0,SEP + PRECISION + 1)
		if(ZEROS){
			return(ZEROS_ESQUERDA + NUM.substr(0,SEP) + POINT + NUM.substr(SEP + 1));
		}
		NUM = parseFloat(NUM);
		return(ZEROS_ESQUERDA + js_replace(NUM.toString(),".",POINT));
	}
	for(var e=NUM.length; e<TAM_ESQUERDA; e++){
		ZEROS_ESQUERDA += "0"
	}
	if(ZEROS){
		NUM = NUM + POINT;
		for(var j=0; j<PRECISION; j++){
			NUM += "0";
		}
	}
	return(ZEROS_ESQUERDA + NUM);
}

function formatNumberMoedaBR(valor){
	var valorCampo;
	valorCampo = valor;
	while (valorCampo.indexOf(".") > -1)
		valorCampo = valorCampo.replace(".", "");
	if (valorCampo.length > 0)
		valorCampo = js_FormatNumber(valorCampo, 2, 0, true, false)
	if (valorCampo.length > 6){
		var novoValorCampo = valorCampo.substr(valorCampo.length - 6);
		for(var i = 9; i < valorCampo.length; i = i + 3){
			novoValorCampo = valorCampo.substr(valorCampo.length - i, 3) + "." + novoValorCampo;
		}
		i = i - 3;
		var x = valorCampo.substr(0, valorCampo.length - i);
		if (x.length > 0)
			novoValorCampo = x + "." + novoValorCampo;
		valorCampo = novoValorCampo;
	}
	return(valorCampo);
}

function help(sql, valoratual, label, campo_label, tabela, title, isdate, start, isdefaul, brother, qtdvalues){
	if(start == true){
		start = "1";
	}
	else{
		start = "0";
	}
	if(isdefaul == false){
		isdefaul = "0";
	}
	else{
		isdefaul = "1";
	}
	if(title != ""){
		title = title;
	}
	else{
		title = "";
	}
	if(isdate == true){
		isdate = "1";
	}
	else{
		isdate = "0";
	}

	if(qtdvalues == undefined)
		qtdvalues = 1;

	if(isNaN(qtdvalues))
		qtdvalues = 1;
	
	if(brother == true)
		return(window.showModalDialog("help.asp?QtdValues=" + qtdvalues + "&SQL=" + sql + "&LABEL=" + label + "&CAMPO_LABEL=" + campo_label + "&TABELA=" + tabela + "&TITLE=" + title + "&ISDATE=" + isdate + "&START=" + start + "&ISDEFAULT=" + isdefaul, valoratual, "dialogwidth:500px;dialogheight:335px;center:yes;status:no;help:no;"));
	else
		return(window.showModalDialog("class/help.asp?QtdValues=" + qtdvalues + "&SQL=" + sql + "&LABEL=" + label + "&CAMPO_LABEL=" + campo_label + "&TABELA=" + tabela + "&TITLE=" + title + "&ISDATE=" + isdate + "&START=" + st+ st+ "&ISDEFAULT=" + isdefaul, valoratual, "dialogwidth:500px;dialogheight:335px;center:yes;status:no;help:no;"));
}

//adiciona um option no select
function AddOption(oSelect, Text, Value, Selected) {
	var oOption = document.createElement("OPTION");  
	if(Selected != true && Selected != false){
		Selected = false;
	}
	oOption.text = Text;
	oOption.value = Value;  
	oSelect.add(oOption);
	oOption.selected = Selected;
}

//VITOR HUGO (13/10/2004)
//verifica se um componente é brando ou zerado (se passar o parametro verificaZerado como true) e já da a mensagem
function verBranco(componente, campo, verificaZerado) {
	if (Trim(componente.value) == ""){
		if(campo != "") {
			if (componente.type == "select-one") {
				alert('Selecione o campo ' + campo);
			} else {
				alert(campo + ' não pode ser em branco.');
			}
							
			if (!componente.disabled)
				componente.focus();
		}
		
		return true;
	}
					
	if (verificaZerado) {
		if (parseFloat(componente.value)==0) {
			if(campo != "") {
				alert(campo + ' não pode ser em zerado.');
				componente.focus();
			}
			return true;
		}
	}
	return false;
}


