/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function setOpenerFieldValue(Campo, Valore){
  var dato= Valore.toString();
  var el1=window.opener.getElm(Campo);
  el1.value=dato;
 }

 function setFieldValue(Campo, Valore){
  var dato= Valore.toString();
		var el1;
		el1=getElm(Campo);
		el1.value=dato;
	}


	/*
		* Da sistemare, non legge il campo di  input !!
		* 
	function setArrayValue(Campo, Valore, Position){
		alert(Campo+' - '+Valore+' - '+Position);
  var dato= Valore.toString();
		var el1;
		var x=parseInt(Position);
		el1=getElm(Campo);
		alert(el1.length);
		el1[x].value=dato;
	}*/



function setTextAreaValue(Campo, Valore){
  var dato= Valore.toString();
  var el1=getElm(Campo);
  el1.getElementsByTagName('textarea').item(0).setAttribute('value', dato)
 }

function getFieldValue(Campo){
  var el1=getElm(Campo);
  return (el1.value);
 }

 function setRadioValue(Campo, Position){
  var i=parseInt(Position);
  var el1=document.getElementsByName(Campo);
  el1[i].checked=true;
 }

/*
	* Da sistemare non funziona!!
	*
function setCheckBoxValue(Campo, Position){
	 var i=parseInt(Position);
  var el1=getElm(Campo);
		el1[i].status=true;
		}*/


 function setSelectValue(Campo, Valore){
  for (var i=0; i < Campo.length; i++) {
	if (Trim(Campo[i].value) == Trim(Valore))
	  Campo[i].selected=true;
  }
 }

 function removeRow(idriga){
    var last_tr=getElm(idriga);
    last_tr.removeChild(last_tr.lastChild);
   }



// AGGIUNGE I VALORI OPTION IN UN CAMPO SELECT
 function appendOption(field, cd, text){
  var elOptNew = window.opener.document.createElement('option');
  elOptNew.text = text;
  elOptNew.value = cd;
  var elSel = getElm(field);

  try {
    elSel.add(elOptNew, null);
  }
  catch(ex) {
    elSel.add(elOptNew);
  }
}

// Evidenzia Bordo del DIV
function setColorDiv(idDiv, color) {
  var el1=getElm(idDiv);
		el1.style.borderStyle="solid";
  el1.style.borderColor=color;
 }

// Visualizza Box DIV
function openBox(str) {
  var el1=getElm(str);
  el1.style.display="inline";
 }

// Nascondi Box DIV
function closeBox(str) {
  var el1=getElm(str);
  el1.style.display="none";
 }

// Chiusura PopUp
function closePopUp() {
  parent.parent.GB_hide();
}

 // Visualizza il Box DIV e cambia il pulsante da apri a chiudi
 function openBoxDiv(d, popen, pclose){
  openBox(d);
  var elm1= getElm(popen);
  var elm2= getElm(pclose);
  elm1.style.display="none";
  elm2.style.display="inline";
 }
 // Nasconde il Box DIV e cambia il pulsante da chiudi a apri
 function closeBoxDiv(d, popen, pclose){
  closeBox(d);
  var elm1= getElm(popen);
  var elm2= getElm(pclose);
  elm1.style.display="inline";
  elm2.style.display="none";
 }

 function View(str){
 alert(str);
 }

/*
 * Da Correggere non funziona !!
 */
function ViewArray(Campo){
	var elm1= getElm(Campo);
 for (var i=0; i < elm1.length; i++) {
	  alert(elm1[i]);
 }
}

// FINESTRA per Stampe PDF
function goPDF(url){
var wdt = screen.width;
var hgt = screen.height;
var x = Math.round((wdt -900)/2);
var y = Math.round((hgt -650 )/2);
window.open(url, 'StampaPDF','toolbar=none,directories=none,scrollbars=auto,status=yes,width=900,height=650,left=' + x + ',screenX=' + x + ',top=' + y + ',screenY=' + y + '');
}

// FINESTRA HIDDEN
function openHideWin(nome, url){
var wdt = screen.width;
var hgt = screen.height;
var alta=150,larga=300;
var x = Math.round((wdt -larga)/2);
var y = Math.round((hgt -alta )/2);
window.open(url, nome,'toolbar=none,directories=none,scrollbars=auto,status=yes,width=300,height=150,left=' + x + ',screenX=' + x + ',top=' + y + ',screenY=' + y + '');
}



// FINESTRA STANDARD
function go(url){
window.open(url, '_self');
}

// FINESTRA STANDARD
function goOut(url){
window.open(url, '_blank');
}

// SUBMIT CON PARAMETRI NASCOSTI
function goSubmit(nameForm, url){
 setFieldValue('newURL', url);
 document.forms[nameForm].submit();
}

// FINESTRA DI ACCESSO NEGATO
function openDeniedPage(){
window.open('deniedPage.jsp', '_self');
}

// FINESTRA esterna
function goExternal(titolo,url){
//window.open(url, '_black', 'width=802,height=600,toolbar=none');
var win = new GB_showCenter(titolo,'../'+url,550,820,'');

}
