function UPP (campo) { campo.value = (campo.value.toUpperCase()); }

function checkSospensione()
{
	if (document.SuspendForm.fIUT.value == "" ) {
	    strmsg = "Attenzione: Il campo \n'Identificativo univoco titolare (IUT)'\n dev'essere valorizzato";
    	alert(strmsg)
		document.SuspendForm.fIUT.focus();
		document.SuspendForm.fIUT.select();
		return false
	}
	if (document.SuspendForm.fIUT.value.length < 11){
		strmsg = "Attenzione: nel campo \n'Identificativo univoco titolare (IUT)'\n risultano inseriti soltanto ";
		strmsg = strmsg + document.SuspendForm.fIUT.value.length + " caratteri.\n";
    	alert(strmsg)
    	document.SuspendForm.fIUT.focus();
    	document.SuspendForm.fIUT.select();
    	return false
    }
	if (document.SuspendForm.fPUK.value == "" ) {
    	strmsg = "Attenzione: Il campo \n'Codice (RRC)'\n dev'essere valorizzato";
    	alert(strmsg)
      	document.SuspendForm.fPUK.focus();
      	document.SuspendForm.fPUK.select();
      	return false
	}
	if (isNaN(document.SuspendForm.fPUK.value)){
    	strmsg = "Attenzione: Il campo \n'Codice (RRC)'\n puo' contenere soltanto numeri.";
		alert(strmsg)
   	  	document.SuspendForm.fPUK.focus();
      	document.SuspendForm.fPUK.select();
      	return false
	}
	if (document.SuspendForm.fPUK.value.length < 10){
		strmsg = "Attenzione: nel campo \n'Codice (RRC)'\n risultano inserite soltanto ";
		strmsg = strmsg + document.SuspendForm.fPUK.value.length + " cifre su 10 previste.\n";
    	alert(strmsg)
    	document.SuspendForm.fPUK.focus();
    	document.SuspendForm.fPUK.select();
    	return false
    }
	if (document.SuspendForm.fPUK.value != document.SuspendForm.fPUKr.value) {
    	strmsg = "Attenzione: Il codice RRC inserito non è stato confermato correttamente.";
    	alert(strmsg)
   	  	document.SuspendForm.fPUKr.focus();
      	document.SuspendForm.fPUKr.select();
      	return false;
	}
	if (document.SuspendForm.fDT_FINE_SOS.value == "" ) {
    	strmsg = "Attenzione: Il campo \n'Data fine sospensione'\n dev'essere valorizzato";
    	alert(strmsg)
      	document.SuspendForm.fDT_FINE_SOS.focus();
      	document.SuspendForm.fDT_FINE_SOS.select();
      	return false
	}
	var rc = check_date(document.SuspendForm.fDT_FINE_SOS);
	if ( rc == 1 ) {
	    strmsg = "La data inserita non è valida !";	
		alert(strmsg)
	  	document.SuspendForm.fDT_FINE_SOS.focus();
    	document.SuspendForm.fDT_FINE_SOS.select();
    	return false
	} else {
		var str=Date();
		var tempo= new Array()
		tempo=str.split(" ");
		var dataOdierna = tempo[4];
		switch (tempo[1])
 		{
		 	case "Jan":
				dataOdierna+="01"
				break;
			case "Feb":
				dataOdierna+="02"
				break;
			case "Mar":
				dataOdierna+="03"
				break;
			case "Apr":
				dataOdierna+="04"
				break;
			case "May":
				dataOdierna+="05"
				break;
			case "Jun":
				dataOdierna+="06"
				break;
			case "Jul":
				dataOdierna+="07"
				break;
			case "Aug":
				dataOdierna+="08"
				break;
			case "Sep":
				dataOdierna+="09"
				break;
			case "Oct":
				dataOdierna+="10"
				break;
			case "Nov":
				dataOdierna+="11"
				break;
			case "Dec":
				dataOdierna+="12"
				break;
		}
		dataOdierna+=tempo[2];
		if ( rc < dataOdierna ) {
		    strmsg = "Data di fine sospensione antecedente la data odierna.\nVerificare la data del computer. ";	
			alert(strmsg)
		  	document.SuspendForm.fDT_FINE_SOS.focus();
    		document.SuspendForm.fDT_FINE_SOS.select();
	    	return false
		}
	}
	var OldsHost = window.location.host;
	
//alert ("**PROVA**\n\nnewurl= "+OldsHost);		
	var NewsHost = "ncar.infocert.it"		
    if( OldsHost.indexOf("firmsv")!=-1 )
	{
		//var NewsHost = "webtelemacosv.icnet"
		var NewsHost = "ncarsv.intra.infocert.it"	
	}
	if( OldsHost.indexOf("firmts")!=-1 )
	{
		//var NewsHost = "webtelemacots.icnet"
		var NewsHost = "ncarts.intra.infocert.it"	
	}
	if( OldsHost.indexOf("firma.infocert.it")!=-1 )
	{
//		var NewsHost = "webtelemaco.infocamere.it"
		//var NewsHost = "carn.infocamere.it"
		var NewsHost = "ncar.infocert.it"		
	}
	if( OldsHost.indexOf("vlew03")!=-1 )
	{
//		var NewsHost = "webtelemaco.infocamere.it"
		//var NewsHost = "carn.infocamere.it"
                var NewsHost = "ncar.infocert.it"		
	}

//    var newurl = "https://" + NewsHost + "/cara/servlet/ServletRVI";
      //var newurl = "https://" + NewsHost + "/cara/servlet/ServletNRI";
      var newurl = "https://" + NewsHost + "/acarj/servlet/ServletNRI";	

//alert ("**DEBUG**\n\nnewurl= "+newurl);		

    document.SuspendForm.action = newurl;
    document.SuspendForm.submit();

} 


function checkSblocco(maschera){

//strOut = "\n\n";
//for (i=0;i<maschera.elements.length;i++) {
//strOut += maschera.elements[i].name + ": "
//    + maschera.elements[i].value + "\n";
//}
// return confirm(strOut);
//alert (strOut);
	var NewsHost = "cafu.infocert.it"
	var OldsHost = window.location.host;
    if( OldsHost.indexOf("firmsv")!=-1 ) {
		var NewsHost = "cafusv.intra.infocert.it"
	}
    if( OldsHost.indexOf("firmts")!=-1 ) {
		var NewsHost = "cafuts.intra.infocert.it"
	}
    if( OldsHost.indexOf("firma.infocert.it")!=-1 ) {
		var NewsHost = "cafu.infocert.it"
	}
	var newurl = "https://" + NewsHost + "/unblock/ServletUNB";

	if (isNaN(maschera.fPUK.value)){
    	strmsg = "Attenzione: Il campo PUK puo' contenere soltanto numeri.";
	    alert(strmsg)
      	maschera.fPUK.focus();
      	maschera.fPUK.select();
      	return false
	}
	if (isNaN(maschera.fSC.value)){
    	strmsg = "Attenzione: Il campo SC puo' contenere soltanto numeri.";
    	alert(strmsg)
      	maschera.fSC.focus();
      	maschera.fSC.select();
      	return false
	}
	if (maschera.fPUK.value==""){
    	alert("Attenzione: il campo PUK e' obbligatorio!")
      	maschera.fPUK.focus();
      	maschera.fPUK.select();
      	return false
	}
	if (maschera.fPUK.value.length < 8){
		strmsg = "Attenzione: nel campo PUK risultano inserite soltanto ";
		strmsg = strmsg + maschera.fPUK.value.length + " cifre.\n\n";
		strmsg = strmsg + "Il PUK corrisponde alle ultime 8 cifre del codice segreto\n";
		strmsg = strmsg + "contenuto all'interno della busta di revoca\n";
	    alert(strmsg)
	    maschera.fPUK.focus();
	    maschera.fPUK.select();
	    return false
	}
	if (maschera.fSC.value==""){
    	alert("Attenzione: il campo Identificativo Smart Card e' obbligatorio!")
      	maschera.fSC.focus();
      	maschera.fSC.select();
      	return false
	}

	if (maschera.fSC.value.length < 16){
		strmsg = "Attenzione: L' Identificativo Smart Card e' di 16 cifre e ne risultano \n";
		strmsg = strmsg + "inserite soltanto " + maschera.fSC.value.length + ".";
    	alert(strmsg)
    	maschera.fSC.focus();
    	maschera.fSC.select();
    	return false
	}

	if (maschera.fSC.value.indexOf("1201")==0)   {
		strmsg = "Attenzione: non possono essere sbloccate  \n";
		strmsg = strmsg + "le smart card con numero seriale che inizia 1201...";
		alert(strmsg)
    	maschera.fSC.focus();
    	maschera.fSC.select();
    	return false
	}
	if (maschera.fSC.value.indexOf("1401")==0 || maschera.fSC.value.indexOf("1501")==0 || maschera.fSC.value.indexOf("1402")==0 || maschera.fSC.value.indexOf("1502")==0)   {
		strmsg = "Attenzione: per sbloccare questo tipo di smart card \n";
		strmsg = strmsg + "utilizzare la funzione 'PIN PUK Management' del programma\n";
		strmsg = strmsg + "PinManager incluso nel pacchetto CARDOS API\n\n";
		strmsg = strmsg + "Vedi: Hardware -> Smartcard -> note su CARDOS API 2.2";
    	alert(strmsg)
    	maschera.fSC.focus();
    	maschera.fSC.select();
    	return false
	}
	if (maschera.fSC.value.indexOf("7420")==0 || maschera.fSC.value.indexOf("1204")==0 )   {
		strmsg = "Attenzione: per sbloccare questo tipo di smart card \n";
		strmsg = strmsg + "utilizzare Dike Util";
    	alert(strmsg)
    	maschera.fSC.focus();
    	maschera.fSC.select();
    	return false
	}
//if (confirm("Confermi i dati inseriti ?")){
//    alert (newurl)	
//    document.RegForm.action = newurl;
//    document.RegForm.submit();
//	return true
//  }
//alert (newurl)	
//return false
//alert ("togliere svinfocardl\n\nnewurl= "+newurl);	
	maschera.action = newurl;
	maschera.submit();
	return true
}

function checkPagamentoRinnovo(form)
{
	var sHost = window.location.host;
	var nProtocol = "https://";
	if (sHost.indexOf("firmsv") != -1) {
//    	sHost = "webtelemacosv.icnet/cara/jplug/rinnversc.jsp";
    	sHost = "webtelemacosv.icnet/cafd/apprin/rinnversc.jsp";
    } 
	if (sHost.indexOf("firmts") != -1){
//		sHost = "webtelemacots.icnet/cara/jplug/rinnversc.jsp";
		sHost = "webtelemacots.icnet/cafd/apprin/rinnversc.jsp";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
//		sHost = "webtelemaco.infocamere.it/cara/jplug/rinnversc.jsp";			
		sHost = "webtelemaco.infocamere.it/cafd/apprin/rinnversc.jsp";			
    } 
	var newurl = nProtocol + sHost;
	/* commento B.Baldacchini
	if (confirm("N.B.\nPrima di procedere alla verifica controllare la corretta configurazione"))*/{
		form.href = newurl
  	}
	return false;
}


function goToRinnovo ()
{

	//alert("Il servizio di rinnovo sarà nuovamente disponibile dopo le ore 13:00");
	//return false

	var OldsHost = window.location.host;

	if( OldsHost.indexOf("firmsv")!=-1 ){
    	var NewsHost = "webtelemacosv.icnet"
	}
	if( OldsHost.indexOf("firmts")!=-1 ) {
		var NewsHost = "webtelemacots.icnet"
	}
    if( OldsHost.indexOf("www.firma.infocert.it")!=-1 ) {
		var NewsHost = "webtelemaco.infocamere.it"
	}

//	var newurl = "https://" + NewsHost + "/cara/jplug/rinnsc.jsp";
	var newurl = "https://" + NewsHost + "/cafd/apprin/rinnsc.jsp";	
	
	//	alert(newurl);
 
	document.Rinnovo.action = newurl;
	document.Rinnovo.submit();
	return true

}
//aggiornamento per la pagina di rinnovo. per far convivere 3 pulsanti insieme
function goToRinnovo2 ()
{

	

	var OldsHost = window.location.host;

	if( OldsHost.indexOf("firmsv")!=-1 ){
    	var NewsHost = "webtelemacosv.icnet"
	}
	if( OldsHost.indexOf("firmts")!=-1 ) {
		var NewsHost = "webtelemacots.icnet"
	}
    if( OldsHost.indexOf("www.firma.infocert.it")!=-1 ) {
		var NewsHost = "webtelemaco.infocamere.it"
	}

//	var newurl = "https://" + NewsHost + "/cara/jplug/rinnsc.jsp";
	var newurl = "https://" + NewsHost + "/cafd/apprin/rinnsc.jsp";	
	
	//	alert(newurl);
 
	document.Rinnovo2.action = newurl;
	document.Rinnovo2.submit();
	return true

}
function goToRinnovo3 ()
{

	

	var OldsHost = window.location.host;

	if( OldsHost.indexOf("firmsv")!=-1 ){
    	var NewsHost = "webtelemacosv.icnet"
	}
	if( OldsHost.indexOf("firmts")!=-1 ) {
		var NewsHost = "webtelemacots.icnet"
	}
    if( OldsHost.indexOf("www.firma.infocert.it")!=-1 ) {
		var NewsHost = "webtelemaco.infocamere.it"
	}

//	var newurl = "https://" + NewsHost + "/cara/jplug/rinnsc.jsp";
	var newurl = "https://" + NewsHost + "/cafd/apprin/rinnsc.jsp";	
	
	//	alert(newurl);
 
	document.Rinnovo3.action = newurl;
	document.Rinnovo3.submit();
	return true

}
//Fine aggiornamento per far convivere i 3 pulsanti


function goToPrenotazioneCNS()
{
	var sHost = window.location.host;
	var nProtocol = "https://";
	
	if (sHost.indexOf("firmsv") != -1) {
    	//sHost = "carnsv.intra.infocamere.it/carpweb/default.do?ref=cns";
        sHost = "ncarsv.intra.infocamere.it/pcarweb/default.do?ref=cns";
    } 
	if (sHost.indexOf("firmts") != -1){
		//sHost = "carnts.intra.infocamere.it/carpweb/default.do?ref=cns";
                sHost = "ncarts.intra.infocamere.it/pcarweb/default.do?ref=cns";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		//sHost = "carn.infocamere.it/carpweb/default.do?ref=cns";
                sHost = "ncar.infocert.it/pcarweb/default.do?ref=cns";
    } 
	var newurl = nProtocol + sHost;
	
	window.open(newurl,'prenotazione','width=580,height=540,scrollbars=yes,toolbar=no,status=no,resizable=1,menubar=no,location=no');

}



function goToPrenotazione()
{
	var sHost = window.location.host;
	var nProtocol = "https://";
	if (sHost.indexOf("firmsv") != -1) {
    	//sHost = "carnsv.intra.infocamere.it/carpweb/default.do";
        sHost = "ncarsv.intra.infocamere.it/pcarweb/default.do";
    } 
	if (sHost.indexOf("firmts") != -1){
		//sHost = "carnts.intra.infocamere.it/carpweb/default.do";
                sHost = "ncarts.intra.infocamere.it/pcarweb/default.do";

    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		//sHost = "carn.infocamere.it/carpweb/default.do";
                sHost = "ncar.infocert.it/pcarweb/default.do";
    } 

var newurl = nProtocol + sHost;

	window.open(newurl,'prenotazione','width=580,height=540,scrollbars=yes,toolbar=no,resizable=1,menubar=no');

}

function goToStoreMarche(form)
{
    var sHost = window.location.host;
    var nProtocol = "http://";
	if (sHost.indexOf("firmsv") != -1) {
	    sHost = "ebusinesssv.intra.infocamere.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "ebusinessts.intra.infocert.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "ebusiness.infocert.it/nemo/negozio/card.do?category=CFD";
    } 

	var newurl = nProtocol + sHost;
	form.href = newurl
}

function goToStoreRinnovo(form)
{
	var sHost 		= window.location.host;
    var nProtocol 	= "http://";
	if (sHost.indexOf("firmsv") != -1) {
    	sHost = "storesv.intra.infocamere.it/stor/servlet/JRinnovoCertificato";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "storets.intra.infocamere.it/stor/servlet/JRinnovoCertificato";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "store.infocamere.it/stor/servlet/JRinnovoCertificato";
    } 

	
	var newurl = nProtocol + sHost;
	if (confirm("N.B.\nPrima di procedere all'acquisto verificare \nche il rinnovo NON sia gratuito\n(accedendo all'apposita funzione di verifica)")){
		form.href = newurl
	}
	return false;
}

function goToStoreCertificati()
{
    var sHost = window.location.host;
    var nProtocol = "http://";
	if (sHost.indexOf("firmsv") != -1) {
	    sHost = "storesv.intra.infocamere.it/stor/servlet/JCertificati";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "storets.intra.infocamere.it/stor/servlet/JCertificati";
    } 
	if (sHost.indexOf("www.firma.infocamere.it") != -1){
		sHost = "store.infocamere.it/stor/servlet/JCertificati";
    } 
	var newurl = nProtocol + sHost;
	document.gotostore.action = newurl;
	document.gotostore.submit();
	return true
}

function goToMarcatura(form)
{
	var sHost 		= window.location.host;
	var nProtocol 	= "https://";	
	if (sHost.indexOf("firmsv") != -1){
		sHost = "carmsv.intra.infocamere.it/carm.dts/ServletDTS";   
    } 
	if (sHost.indexOf("firmts") != -1) {
	    sHost = "carmts.intra.infocamere.it/carm.dts/ServletDTS";
	} 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "www.carm.infocamere.it/carm.dts/ServletDTS";
	} 
	var newurl = nProtocol + sHost;
  
//   alert(newurl);
  	
	form.action= newurl;
	form.submit();
	return true;
	
	
}

function goToEbusinessMarche(form)
{
    var sHost = window.location.host;
    var nProtocol = "http://";
	if (sHost.indexOf("firmsv") != -1) {
	    sHost = "ebusinesssv.intra.infocamere.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "ebusinessts.intra.infocert.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "ebusiness.infocert.it/nemo/negozio/card.do?category=CFD";
    } 

//  alert(sHost);

	var newurl = nProtocol + sHost;
	form.href = newurl
}
function goToEbusinessSoftware(form)
{
    var sHost = window.location.host;
    var nProtocol = "http://";
	if (sHost.indexOf("firmsv") != -1) {
	    sHost = "ebusinesssv.intra.infocamere.it/nemo/negozio/card.do?category=CFDS";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "ebusinessts.intra.infocert.it/nemo/negozio/card.do?category=CFDS";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "ebusiness.infocert.it/nemo/negozio/card.do?category=CFDS";
    } 

	var newurl = nProtocol + sHost;
	form.href = newurl
}
function goToEbusinessCertificatiWeb()
{
    var sHost = window.location.host;
    var nProtocol = "http://";
	if (sHost.indexOf("firmsv") != -1) {
	    sHost = "ebusinesssv.intra.infocamere.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "ebusinessts.intra.infocert.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "ebusiness.infocert.it/nemo/negozio/card.do?category=CFD";
    } 
	var newurl = nProtocol + sHost;
	document.gotoebusiness.action = newurl;
//	document.gotoebusiness.submit();
	return true
}

function goToEbusinessRinnovo(form)
{
	var sHost 		= window.location.host;
    var nProtocol 	= "http://";
	if (sHost.indexOf("firmsv") != -1) {
    	sHost = "ebusinesssv.intra.infocamere.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("firmts") != -1){
		sHost = "ebusinessts.intra.infocamere.it/nemo/negozio/card.do?category=CFD";
    } 
	if (sHost.indexOf("www.firma.infocert.it") != -1){
		sHost = "ebusiness.infocert.it/nemo/negozio/card.do?category=CFD";
    } 

	
	var newurl = nProtocol + sHost;
/* commento B.Baldacchini
if (confirm("N.B.\nPrima di procedere all'acquisto verificare \nche il rinnovo NON sia gratuito\n(accedendo all'apposita funzione di verifica)"))*/{
		form.href = newurl
	}
	return false;
}

