// Technique TI Ltda
// rah@tech-it.com.br
// version 1.0 - 01/12/1999
// version 1.1 - 20/04/2001

// return the value of obj[selectedIndex] where obj is a option button
function getSelectedOption(obj) {
  for(var i=0;i<obj.length; i++) {
    if (obj[i].checked==true) return obj[i].value;
  }
}

// se objOption[i].checked where obj[i].value match objField.value
function setSelectedOption(objField,obj) {
  for(var i=0;i<obj.length; i++) {
    if (obj[i].value==objField.value) {
		obj[i].checked=true;
		break;
	} 
  }
}

function printThisPage() {
	var Browser;
	if (navigator.appName.toUpperCase().indexOf('EXPLORER') >= 0 ) {
		var Inicio = navigator.appVersion.indexOf(';') +6;
		Browser = navigator.appVersion.substring(Inicio, navigator.appVersion.indexOf(';', Inicio) -1);		  
		if (Browser >= 5) window.print(); else alert('Para imprimir pressione Ctrl+P');
	} else if (navigator.appName.toUpperCase().indexOf('NETSCAPE') >= 0) {
		Browser = navigator.appVersion.substring(0,3);
		if (Browser >= 4.7) window.print(); else alert('Para imprimir pressione Ctrl+P');			
	} else alert('Para imprimir pressione Ctrl+P');
}

// check functions
function CheckDouble(key) {
  if(event.keyCode==44) event.keyCode=46;
  if(event.keyCode!=46 && (event.keyCode<48 || event.keyCode>57)) event.keyCode=null;
}
function CheckText(key) {
}
function CheckLong(key) {	
	if(event.keyCode<48 || event.keyCode>57) event.keyCode=null;
}
function CheckDate(key) {	
	if(event.keyCode!=45 && (event.keyCode<47 || event.keyCode>57)) event.keyCode=null;
}
function CheckTime(key) {	
	if(event.keyCode!=58 && (event.keyCode<47 || event.keyCode>57)) event.keyCode=null;
}


function SelectAllItem(listSource) {
	l1 = listSource.length;
	for ( i=0; i<l1; i++){
		listSource.options[i].selected=true;
	}
}
function MoveListItem(listSource, listDest) {
	l1 = listSource.length;
	for ( i=0; i<l1; i++){
      if (listSource.options[i].selected == true ) {
          l2 = listDest.length;
          listDest.options[l2]= new Option(listSource.options[i].text);
          listDest.options[l2].value = listSource.options[i].value;
	  }
	}
	for ( i=l1 -1; i>=0; i--){
     if (listSource.options[i].selected == true ) {
        listSource.options[i] = null;
	 }
	}
}
function MoveAllListItem(listSource, listDest) {
	l1 = listSource.length;
	for ( i=0; i<l1; i++){
	  l2 = listDest.length;
	  listDest.options[l2]= new Option(listSource.options[i].text);
	  listDest.options[l2].value = listSource.options[i].value;
	}
	for ( i=l1 -1; i>=0; i--){
	listSource.options[i] = null;
	}
}
function ReadList(listSource, hiddenField) {
	l1 = listSource.length;
	r = "";
	for (i=0; i<l1; i++){
	 r += listSource.options[i].value;
	 if (i<(l1-1)) r +=";";
	}
	hiddenField.value = r;
}