function selPC()
{
    var args=arguments;    
	// campi di tipo testo 
	var tx=args[1]?args[1]:1;
    window.opener.document.getElementById('id_aziendapc').value = args[0];
    window.opener.document.getElementById('aggiungi').value = 1;
    opener.document.forms[0].submit();
    window.close();
}
function go2URL(address)
{
  var elFrame = document.getElementById('doiFrame');
  elFrame.src = address;
}
function newWin(url,width,height)
{

	if (height == -1 || width == -1)
		window.open(url,'name', 'width= ' +  screen.availWidth +  ',height= ' +  screen.availHeight + ',status= yes , location = yes, toolbar = yes, menubar = yes,resizable = yes ,scrollbars = yes ');
	else
	{
		openWindow(url, width,height)
    }
}

function openWindow(url, w, h) {
    var options = "width=" + w + ",height=" + h + ",";
    options += "resizable=yes,scrollbars=yes,status=no,";
    options += "menubar=no,toolbar=no,location=no,directories=no";
    var newWin = window.open(url, 'newWin', options);
    newWin.focus();
  }

function salva2(){
	
	var args=arguments;
	// campi di tipo testo 
	var tx=args[0]?args[0]:0;
	// campi mail

	if(tx!="0"){	
		for(i=0;i<tx.length;i++){
			var ele= tx[i].split('#');
			
			if(!validaTesto(document.getElementById(ele[0]),ele[1]))
				return false;		
		}
	}
	
		if(document.getElementById("check")!=null)
		document.getElementById("check").value=1;
		
		document.forms[0].submit();
	//document.forms[0].submit();
}



function elimina(msg)
{
	check = confirm(msg);
	if(check){
		return true;
	}else{
		return false;
		}
}

function validaTesto(obj) {
	var Label=(arguments[1]?arguments[1]:obj.name);
	if (obj.value==""){
		alert('Il campo ' + Label + ' \u00e8 obbligatorio');
		obj.focus();
		obj.select();
		return false;
	}
	if (obj.value.match(/[>§@<]/)){
		alert('Caratteri non ammessi nel campo ' + Label);
		obj.focus();
		obj.select();
		return false;
	}
	return true;
}

function apri (URL){
	var args=arguments;
	var w=args[1]?args[1]:280;
	var h=args[2]?args[2]:300;
	var l=args[3]?args[3]:((screen.width-w)/2);
	var t=args[4]?args[4]:((screen.height-h)/2);
	var s=args[5]?args[5]:'no';
	var name=args[6]?args[6]:'';
	var f=args[7]?args[7]:'no';
	var features ="menubar=no,toolbar=no,width="+w+",height="+h+",status=no,scrollbars="+s+",top="+t+",left="+l+",resizable=no";
	finestra = window.open(URL,name,features);
	if(f=='yes')
		finestra.focus()
}

function newWindow(address)
{
	var maxW = screen.width;
	var maxH = screen.height;
	var w = 800;
	var h = 600;
	var _top = Math.floor((maxH - h) / 2);
	var _left = Math.floor((maxW - w) / 2);
	
	var win = window.open(address,'doiW',"toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width="+w+",height="+h);
	win.moveTo(_left,_top);
	win.focus();
}


function openSchedaProdotto(idProd,Type,w,h,target)
{
	var win = null;
	var maxW = screen.width;
	var maxH = screen.height;
	var _top = Math.floor((maxH - h) / 2);
	var _left = Math.floor((maxW - w) / 2);
	if (Type == 'P')
	{
		win = window.open('SchedaProdotto.asp?ID='+idProd,'Scheda_Prodotto',"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+w+",height="+h);
		win.moveTo(_left,_top);
		win.focus();
	}
	else
	{
		win  = window.open('SchedaProdotto.asp?ID='+idProd+'&type='+Type,target);
		document.target = target;
	}
	
}




