﻿// File JScript
function nascondi() {
    if ((document.getElementById('storiaDiv')))
        document.getElementById('storiaDiv').style.display = 'none';


    if ((document.getElementById('ctl00_incH1_incMR_tcMR_tpMRD_incMRD_PanelDest'))) {
        if (document.getElementById('ctl00_incH1_incMR_tcMR_tpMRD_incMRD_PanelDest').style.display = '') showDDL()
        document.getElementById('ctl00_incH1_incMR_tcMR_tpMRD_incMRD_PanelDest').style.display = 'none';

    }

    if (document.getElementById('ctl00_incH1_incMR_tcMR_tpMotoreRicercaEventi').style.display != 'none') showDDL()
    if (document.getElementById('ctl00_incH1_incMR_tcMR_tpMotoreRicercaPerche').style.display != 'none') showDDL()
    if (document.getElementById('ctl00_incH1_incMR_tcMR_tpMotoreRicercaMappa').style.display != 'none') {
        showDDL();
        //document.getElementById('mappaItalia').style.display = 'none';
    } 
    
    //showDDL()
}
document.onclick = nascondi
        
function posiziona(scwEle, elName) {

    var offsetTop = parseInt(scwEle.offsetTop, 10) + parseInt(scwEle.offsetHeight, 10), offsetLeft = parseInt(scwEle.offsetLeft, 10);
    scwTargetEle = scwEle;
    do {
        scwEle = scwEle.offsetParent;
        offsetTop += parseInt(scwEle.offsetTop, 10);
        offsetLeft += parseInt(scwEle.offsetLeft, 10);

    }
    while (scwEle.tagName != 'BODY' && scwEle.tagName != 'HTML');
    document.getElementById(elName).style.top = offsetTop + 'px';
    document.getElementById(elName).style.left = offsetLeft + 'px';
}

 function stampa(url){
 window.open(url,'stampaWin','width=800,height=600,scrollbars=yes');
  }
  
   function invia(url){
 window.open(url,'stampaWin','width=800,height=600,scrollbars=yes');
  }

function sistema(immagine){
    //alert(document.getElementById("immagine").width)
    var rapporto=immagine.width/immagine.height


    if (immagine.width>600) {
    immagine.width=600;
    }

    if (immagine.height>500) {
    immagine.height=500;
    immagine.width=500*rapporto;
    }
    //autoFit();
}

var fadeStep=1;
function showPhoto(img){
    document.getElementById("divGallery").style.display=''
    document.getElementById("Divfoto_overlay").className=''
    fade()
    document.getElementById("imgGallery").src=img.src.replace("small_","")
}

function hidePhoto(){
    document.getElementById("divGallery").style.display='none'
    document.getElementById("imgGallery").src=""
}

function fade(){
    var objToFade=document.getElementById("Divfoto_overlay");
    if (fadeStep<4) {
        objToFade.className="foto_overlay_" + fadeStep;
        fadeStep=fadeStep+1;
        setTimeout("fade()",100);
    }
    else{
        fadeStep=1;
    }
}

function callback(id_partenza)
	{
	window.open('recall_login.aspx?id_partenza='+id_partenza,'callback_utente','scrollbars=yes,width=668,height=572');
	}
	
	function reqinfo(id_partenza)
	{
	window.open('reqinfo_login.aspx?id_partenza='+id_partenza,'reqinfo_utente','scrollbars=yes,width=668,height=572');
}

function callback_prenota(id_partenza) {
    window.open('pren_login.aspx?id_partenza=' + id_partenza, 'prenotazione_utente', 'scrollbars=yes,width=668,height=572');
}

function toggleLayer(whichLayer){  
var elem, vis;  
if( document.getElementById ) 
// this is the way the standards work    
elem = document.getElementById( whichLayer );  
else
 if( document.all ) 
 // this is the way old msie versions work      
 elem = document.all[whichLayer];  
 else if( document.layers ) 
 // this is the way nn4 works   
  elem = document.layers[whichLayer];  
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if (vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)
      vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';
  vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block';
}

function chiudiDiv(nomeDiv) {
    document.getElementById(nomeDiv).style.display = 'none';

}

var isIE6;
    isIE6 = /msie|MSIE 6/.test(navigator.userAgent);

function posizionaCentrato(obj, larghezzaDiv, distDaTop) {

    

    if (isIE6) {
        var bloccoDiv;
        var ns4popImp;
        var ie4popImp;
        var ns6popImp;
        ns4popImp = (document.layers) ? true : false
        ie4popImp = (document.all) ? true : false
        ns6popImp = (document.getElementById) ? true : false
        if (ns4popImp) bloccoDiv = obj;
        if (ie4popImp) bloccoDiv = obj.style;
        if (ns6popImp) {
            bloccoDiv = obj.style;
        }
        
        obj.style.position='absolute';
        obj.style.left='';
        obj.style.top='';
        obj.style.marginLeft='';
        obj.style.marginTop='';

        bloccoDiv.xpos = parseInt(bloccoDiv.left);
        bloccoDiv.ypos = parseInt(bloccoDiv.top);

        moveToGenerico(bloccoDiv, parseInt((document.body.clientWidth / 2) - (larghezzaDiv / 2)), distDaTop)
    }
}


function moveToGenerico(obj, x, y) {

    obj.xpos = x;
    obj.left = obj.xpos + 'px';
    obj.ypos = y;
    obj.top = obj.ypos + 'px';
}

function centraDivBeta(){
posizionaCentrato(document.getElementById("betaDiv"), 450, 210);
}

function hideDDL() {
    if (isIE6) {
        var colS = document.all.tags("SELECT");
        if (colS != null) {
            for (i = 0; i < colS.length; i++) {
                colS[i].style.visibility = "hidden";
            }
        }
    }
}

function showDDL() {
    if (isIE6) {
        var colS = document.all.tags("SELECT");
        if (colS != null) {
            for (i = 0; i < colS.length; i++)
                colS[i].style.visibility = "inherit";
        }
    }
}

function nascondiLoadingDiv() {
    document.getElementById('LOADING').style.display = 'none';
    document.getElementById('aspnetForm').style.display = '';
    
    //showDDL()
}

function mostraLoadingDiv() {
    document.getElementById('LOADING').style.display = '';
    document.getElementById('aspnetForm').style.display = 'none';
   //hideDDL()
}
