//stc.js
// NON utilizzato in STC
//*******************JAVASCRIPT INITIALIZING FUNCTIONS********************************************************
//functions initialize functions

window.onload=callfunctions;
function callfunctions() {
        formValidationOverRules();
}

//
// NON utilizzato in STC
//_____________________________________________________________________________________________________________________________
//right click disabling
/*
function clickconIE() {
        if (event.button==2) {
                return false;
        }
}

function clickconNS(e){
        if (document.layers||document.getElementById&&!document.all)  {
                if (e.which==2||e.which==3) {
                        return false;
                }
        }
}

if (document.layers){
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickconNS;
}else if (document.all&&!document.getElementById) {
        document.onmousedown=clickconIE;
}
document.oncontextmenu=new Function("return false");
*/
//
// NON utilizzato in STC
//*******************FORM VALIDATION FUNCTIONS****************************************************************************
//form onFocus and onBlur functions:
//CODICE MOLTO TOZZO RIPRESO DA QUELLO SOTTO (funziona solo da solo): (vedi anche assoeurope_form.css) McLaud2k4

function formValidationOverRules() {
        if (!document.getElementsByTagName) return;
        var allInputs = document.getElementsByTagName("input");
        for (var i = 0; i < allInputs.length; i++) {

                //input type password fields
                if (allInputs[i].type == 'password') {
                        allInputs[i].onfocus = function() {
                                if (this.value=='password') this.value='';
                        }
                        allInputs[i].onblur = function() {
                                if (this.value=='' && this.getAttribute("name")=="password") this.value='password';
                        }
                }

                if (allInputs[i].type != 'text') continue
                        //var allInput = allInputs[i];
                        allInputs[i].onfocus = function() {
                                //this.className = 'boxFocus';
                                //log system
                                if (this.value=='username') this.value='';
                                //
                                if (this.value=='Nome') this.value='';
                                if (this.value=='Impresa') this.value='';
                                if (this.value=='Indirizzo') this.value='';
                                if (this.value=='Telefono') this.value='';
                                if (this.value=='Fax') this.value='';
                                if (this.value=='E-mail') this.value='';
                                if (this.value=='Oggetto') this.value='';
                                if (this.value=='Stampante-plotter utilizzato') this.value='';
                                if (this.value=='Software CAD utilizzato') this.value='';
                        }
                        allInputs[i].onblur = function() {
                                //this.className = 'boxBlur';
                                //log system
                                if (this.value=='' && this.getAttribute("name")=="username") this.value='username';
                                //
                                if (this.value=='' && this.getAttribute("name")=="mail_name") this.value='Nome';
                                if (this.value=='' && this.getAttribute("name")=="mail_company") this.value='Impresa';
                                if (this.value=='' && this.getAttribute("name")=="mail_address") this.value='Indirizzo';
                                if (this.value=='' && this.getAttribute("name")=="mail_telephone") this.value='Telefono';
                                if (this.value=='' && this.getAttribute("name")=="mail_fax") this.value='Fax';
                                if (this.value=='' && this.getAttribute("name")=="mail_from") this.value='E-mail';
                                if (this.value=='' && this.getAttribute("name")=="mail_subject") this.value='Oggetto';
                                if (this.value=='' && this.getAttribute("name")=="mail_printer") this.value='Stampante-plotter utilizzato';
                                if (this.value=='' && this.getAttribute("name")=="mail_software") this.value='Software CAD utilizzato';
                        }

        }
        //textareas
        var allTextAreas = document.getElementsByTagName("textarea");
        for (var i = 0; i < allTextAreas.length; i++) {
        var allTextArea = allTextAreas[i];
                        allTextAreas[i].onfocus = function() {
                                this.className = 'boxFocus';
                                if (this.value=='Messaggio') this.value='';
                                if (this.value=='Descrizione prodotto') this.value='';
                        }
                        allTextAreas[i].onblur = function() {
                                this.className = 'boxBlur';
                                if (this.value=='' && this.getAttribute("name")=="mail_body") this.value='Messaggio';
                                if (this.value=='' && this.getAttribute("name")=="mail_body2") this.value='Descrizione prodotto';
                        }
        }
                        //rel external --- overrides the target="_blank" tag:
        //Before:<a href="document.html" target="_blank">external link</a>
        //After:<a href="document.html" rel="external">external link</a>
         var anchors = document.getElementsByTagName("a");
         for (var i=0; i<anchors.length; i++) {
           var anchor = anchors[i];
           if (anchor.getAttribute("href") &&
                   anchor.getAttribute("rel") == "external")
                 anchor.target = "_blank";
         }
}


//_____________________________________________________________________________________________________________________________
//
// NON utilizzato in STC
var i,j,l_n,l_e;
var notizia,evento;
var news,eventi = new Array();
var t1,t2='';

// NON utilizzato in STC
function scroller(testo1,testo2)
{
 t1=testo1;
 t2=testo2;
 i=0;
 j=0;
 l_n,l_e=0;

 if (t1.length>0)
 {
  news = t1.split("~~");
  l_n = news.length;
  notizia = document.getElementById("new");
  t_n = setInterval("scroller_news();",2200);
 }

 if (t2.length>0)
 {
  eventi = t2.split("~~");
  l_e = eventi.length;
  evento = document.getElementById("evento");
  t_e = setInterval("scroller_eventi();",2200);
 }
}

// NON utilizzato in STC
function scroller_eventi()
{ //alert('evento: '+evento+'\nj: '+j+'\nl_e: '+l_n);
  evento.innerHTML = eventi[j];
  j++;
  if (j == l_e) j = 0;
}

// NON utilizzato in STC
function scroller_news()
{
  notizia.innerHTML = news[i];
  i++;
  if (i == l_n) i = 0;
}

// ******************* utilizzato in STC **********************
function viewimg(nome_file,percorso)

{

 var l = 564;

 var h = 422;

 var winleft = (screen.width - l) / 2;

 var winUp = (screen.height - h) / 2;

 var dimensioni = 'width='+l+',height='+h+',left='+winleft+',top='+winUp+',scrollbars=no';

 //var dimensioni= "width="+l+"px,height="+h+"px";

 var popup = window.open("","mappa_ingrandita",dimensioni);

 popup.document.write("<html><head>"

                                        +"<style>"

                                        +"a:link {color:'#ffffff'; text-decoration:none;}"

                                        +"a:hover {color:'#ffffff'; text-decoration:none;}"

                                        +"a:visited {color:'#ffffff'; text-decoration:none;}"

                                        +".up {position:absolute; left:520px; top:10px; z-index:102; border:1px solid #aaaaaa; padding:0 2 0 2;}"

                                        +"body { background-color: #6B90A5;"

                                        +"font-family: Verdana, Arial, Helvetica, sans-serif;"

                                        +"font-size: 60%;"

                                        +"letter-spacing: 0.15pt;}"

                                        +"</style><title>STC snc - la mappa</title>"

                                        +" </head>"

                                        +"<body topmargin='0' marginheight='0' leftmargin='0' marginwidth='0' scroll='no' link='#ffffff' alink='#ffffff' vlink='#ffffff' oncontextmenu='javascript:return false'>"

                                        +"<div align=center valign=middle><img src='"+percorso+"images/"+nome_file+"' border='1' alt='STC \r\n- mappa con le sole strade principali'></div>"

                                        +"<div class='up'>"

                                        +"<a href='javascript:self.window.print()' title='stampa la mappa'><img border=0 align='middle' src='"+percorso+"images/stmp.gif'></a>&nbsp;&nbsp;"

                                        +"<a href='javascript:self.close()' title='chiudi la mappa'><img border=0 align='middle' src='"+percorso+"images/close.gif'></a>"

                                        +"</div></body></html>"

                                        );

 popup.document.close();

 //popup.moveTo (0,0);

 popup.focus();

}

// utilizzato in STC
function openp(nome_file,percorso,l,h) {
        var doc=percorso+nome_file;

        if (l=='') l = screen.width -140;
        if (h=='') h = screen.height -220;

        var winleft = (screen.width - l) / 2;
        var winUp = (screen.height - h) / 2;
        var dimensioni = 'width='+l+',height='+h+',left='+winleft+',top='+winUp+',scrollbars=yes';
        //var popup = window.open(doc,"",dimensioni);
        var info = window.open(doc,"",dimensioni);
        //info.document.location = doc;
        info.document.close();
        info.focus();
}

