﻿var isIE = document.all;
var isNN = !document.all && document.getElementById;
var isN4 = document.layers;
var nn = document.layers ? true : false;
var DOM2 = document.getElementById ? true : false;
function getPageCoords(element) {
    var coords = { x: 0, y: 0 };
    while (element) {
        coords.x += element.offsetLeft;
        coords.y += element.offsetTop;
        element = element.offsetParent;
    }
    return coords;
}
function addUser(user) {
    self.document.getElementById("ctl00_ContentPlaceHolder1_TextBox14").value = user;
}
function delPaziente(id_studio, id, cognome, nome, email) {
    if (confirm("Sei sicuro di voler eliminare il paziente?")) {
        self.document.location.href = "Specialista_clienti.aspx?delP=" + id + "&cognome=" + cognome + "&nome=" + nome + "&email=" + email + "&idstudio=" + id_studio;
    }
}
function datiPaziente(id) {    
    if (id.toString().indexOf("-") != -1) {
        self.document.location.href = "Specialista_clienti.aspx?datiP=" + id;
    } else {
        self.document.location.href = "Specialista_clienti.aspx?datiS=" + id;
    }
}
function modStudio(id) {    
    self.document.location.href = "RegistraStudio.aspx?idS=" + id;
}
function delColl(id) {
    if (confirm("Sei sicuro di voler eliminare il collaboratore?")) {
        self.document.location.href = "Specialista_collaboratori.aspx?delP=" + id;
    }
}
function modColl(id) {
    self.document.location.href = "Specialista_collaboratori.aspx?datiP=" + id;
}

function ResetUp() {
    alert("Caricamento immagine non consentito!!\n sono ammessi solo file .jpg, .png o .gif");
}
function Anteim() {
    alert("Caricamento avvenuto con successo.");
}
function delPres(id) {
    if (confirm("Sei sicuro di voler eliminare la prestazione?")) {
        self.document.location.href = "Specialista_prestazioni.aspx?delP=" + id;
    }
}
function datipres(id) {
    self.document.location.href = "Specialista_prestazioni.aspx?datiP=" + id;
}
function HMI(id) {
    div = document.getElementById(id);
    tempX = -1200;
    tempY = -1200;
    if (isIE) {
        div.style.top = tempY;
        div.style.left = tempX;
    } else {
        div.style.top = tempY + "px";
        div.style.left = tempX + "px";
    }
    div.style.visibility = "hidden";
}
function SMI(id) {
    id1 = id.replace("V_", "Pi_");
    p = getPageCoords(document.getElementById(id1));
    tempX = p.x - 25;
    tempY = p.y + 12;
    div = document.getElementById(id);
    if (isIE) {
        div.style.top = tempY;
        div.style.left = tempX;
    } else {
        div.style.top = tempY + "px";
        div.style.left = tempX + "px";
    }
    div.style.visibility = "visible";
}
function showCal() {
    self.document.getElementById("Calen").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function hideCal() {
    self.document.getElementById("Calen").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
}
function CloseNewapSimple() {
    self.document.getElementById("newApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
    self.document.getElementById("AGINSERT").src = "base.htm";
}
function CloseNewapp(sms) {
    self.document.getElementById("newApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
    self.document.getElementById("AGDEL").src = "base.htm";
    self.document.getElementById("ctl00_ContentPlaceHolder1_HiddenField3").value = "1";
    hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenField3';
    var hiddenField = $get(hiddenFieldID);
    __doPostBack(hiddenFieldID, '');

    tiplayer = nn ? document.layers.tip : DOM2 ? document.getElementById('ctl00_divsms') : document.all.tooltip
    if (nn) {
        tiplayer.document.open(); tiplayer.document.write(sms); tiplayer.document.close();
    }
    else tiplayer.innerHTML = sms;
    
}
function CloseDelSimple() {
    self.document.getElementById("delApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
    self.document.getElementById("AGINSERT").src = "base.htm";
    self.document.getElementById("ctl00_ContentPlaceHolder1_HiddenField3").value = "1";
    hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenField3';
    var hiddenField = $get(hiddenFieldID);
    __doPostBack(hiddenFieldID, '');
}
function CloseDelapp(sms) {
    self.document.getElementById("delApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
    self.document.getElementById("AGINSERT").src = "base.htm";
    self.document.getElementById("ctl00_ContentPlaceHolder1_HiddenField3").value = "1";
    hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenField3';
    var hiddenField = $get(hiddenFieldID);
    __doPostBack(hiddenFieldID, '');

    tiplayer = nn ? document.layers.tip : DOM2 ? document.getElementById('ctl00_divsms') : document.all.tooltip
    if (nn) {
        tiplayer.document.open(); tiplayer.document.write(sms); tiplayer.document.close();
    }
    else tiplayer.innerHTML = sms;
    
}
function CloseModora(sms) {

    self.document.getElementById("delApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
    self.document.getElementById("AGINSERT").src = "base.htm";
    self.document.getElementById("ctl00_ContentPlaceHolder1_HiddenField3").value = "1";
    hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenField3';
    var hiddenField = $get(hiddenFieldID);
    __doPostBack(hiddenFieldID, '');

    if (sms != undefined) {
        tiplayer = nn ? document.layers.tip : DOM2 ? document.getElementById('ctl00_divsms') : document.all.tooltip
        if (nn) {
            tiplayer.document.open(); tiplayer.document.write(sms); tiplayer.document.close();
        }
        else tiplayer.innerHTML = sms;
    }
    
}
function CloseModoraSimple() {
    self.document.getElementById("delApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
    self.document.getElementById("AGINSERT").src = "base.htm";
    self.document.getElementById("ctl00_ContentPlaceHolder1_HiddenField3").value = "1";
    hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenField3';
    var hiddenField = $get(hiddenFieldID);
    __doPostBack(hiddenFieldID, '');
}

function updateSMS(sms) {

    tiplayer = nn ? document.layers.tip : DOM2 ? document.getElementById('ctl00_divsms') : document.all.tooltip
    if (nn) {
        tiplayer.document.open(); tiplayer.document.write(sms); tiplayer.document.close();
    }
    else tiplayer.innerHTML = sms;
}


function OnMenuItemClick(s, e) {
    switch (e.itemName) {
        case "app_n":
            // nuovo appuntamento
            var selObj = document.getElementById('ctl00_ContentPlaceHolder4_DropDownList1');
            var selIndex = selObj.selectedIndex;
            var datast = s.selection.interval.start.localeFormat("d") + " " + s.selection.interval.start.format("t");
            var dataen = s.selection.interval.end.localeFormat("d") + " " + s.selection.interval.end.format("t");
            self.document.getElementById("AGINSERT").src = "agenda_iserimento.aspx?idstudio=" + selObj.options[selIndex].value + "&datas=" + datast + "&datae=" + dataen;
            self.document.getElementById("newApp").style.display = "";
            self.document.getElementById("trasparenza").style.display = "";
            e.handled = true;
            break;
        case "app_i":
            // update appuntamento
            var selObj = document.getElementById('ctl00_ContentPlaceHolder4_DropDownList1');
            var selIndex = selObj.selectedIndex;
            var datast = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.start.localeFormat("d") + " " + s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.start.localeFormat("t").replace(".", ":");
            var dataen = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.end.localeFormat("d") + " " + s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.end.localeFormat("t").replace(".", ":");
            var idut = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId;
            self.document.getElementById("delApp").style.display = "";
            self.document.getElementById("trasparenza").style.display = "";
            self.document.getElementById("AGDEL").src = "agenda_Dettaglio.aspx?idstudio=" + selObj.options[selIndex].value + "&datas=" + datast + "&datae=" + dataen + "&idut=" + idut;
            e.handled = true;
            break;
        case "app_d":
            //elimina appuntamento
            var selObj = document.getElementById('ctl00_ContentPlaceHolder4_DropDownList1');
            var selIndex = selObj.selectedIndex;
            var datast = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.start.localeFormat("d") + " " + s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.start.localeFormat("t");
            var dataen = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.end.localeFormat("d") + " " + s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentInterval.end.localeFormat("t");
            var idut = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId;
            self.document.getElementById("delApp").style.display = "";
            self.document.getElementById("trasparenza").style.display = "";
            self.document.getElementById("AGDEL").src = "agenda_delete.aspx?idstudio=" + selObj.options[selIndex].value + "&datas=" + datast + "&datae=" + dataen + "&idut=" + idut;
            e.handled = true;
            break;
        case "app_dH":
            //elimina tutti appuntamenti
            var selObj = document.getElementById('ctl00_ContentPlaceHolder4_DropDownList1');
            var selIndex = selObj.selectedIndex;
            var datast = s.selection.interval.start.localeFormat("d")
            self.document.getElementById("delApp").style.display = "";
            self.document.getElementById("trasparenza").style.display = "";
            self.document.getElementById("AGDEL").src = "agenda_delete_hall.aspx?idstudio=" + selObj.options[selIndex].value + "&data=" + datast;
            e.handled = true;
            break;
        
        default:
            e.handled = false;
    }
}
function OnDragAndDrop(s, e) {
    var selObj = document.getElementById('ctl00_ContentPlaceHolder4_DropDownList1');
    var selIndex = selObj.selectedIndex;
    var datast = e.operation.helper.selectedAppointments[0].operationInterval.start.localeFormat("d") + " " + e.operation.helper.selectedAppointments[0].operationInterval.start.localeFormat("t").replace(".", ":");
    var dataen = e.operation.helper.selectedAppointments[0].operationInterval.end.localeFormat("d") + " " + e.operation.helper.selectedAppointments[0].operationInterval.end.localeFormat("t").replace(".", ":");
    var idut = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId;
    self.document.getElementById("delApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
    self.document.getElementById("AGDEL").src = "agenda_update_ora.aspx?idstudio=" + selObj.options[selIndex].value + "&datas=" + datast + "&datae=" + dataen + "&idut=" + idut;
    e.handled = true;
}
function OnResize(s, e) {
    var selObj = document.getElementById('ctl00_ContentPlaceHolder4_DropDownList1');
    var selIndex = selObj.selectedIndex;
    var datast = s.appointments[s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId].operationInterval.start.localeFormat("d") + " " + s.appointments[s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId].operationInterval.start.localeFormat("t").replace(".", ":");
    var dataen = s.appointments[s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId].operationInterval.end.localeFormat("d") + " " + s.appointments[s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId].operationInterval.end.localeFormat("t").replace(".", ":");
    var idut = s.appointmentSelection.selectedAppointmentViewInfos[0].appointmentId;
    self.document.getElementById("delApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
    self.document.getElementById("AGDEL").src = "agenda_update_ora.aspx?idstudio=" + selObj.options[selIndex].value + "&datas=" + datast + "&datae=" + dataen + "&idut=" + idut;
    e.handled = true;
}
function TimeOutSes() {
    self.document.location.href = "Default.aspx?TOXS=456tryr564ertde453";
}
function AcquistaPagina() {
    if (confirm("Per poter pubblicare la tua pagina devi procedere con l'acquisto. Vuoi aquistarla ora?")) {
        self.document.location.href = "Ecommerce.aspx?idprod=3";
    }
}
function updatePAG(pag) {
    if (pag == "1") {
        self.document.getElementById("ctl00_Image1").src = "img/ppy.jpg";
    } else {
        self.document.getElementById("ctl00_Image1").src = "img/ppn.jpg";
    }
}
function contaCar() {
    var leng = parseInt(self.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value.length, 10);    
    var con = 160 - leng;
    self.document.getElementById("ctl00_ContentPlaceHolder1_TextBox1").value = con;

    if (con < 1) {
        self.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value = self.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value.substring(0, 159);
    }
}
function showSceltLog() {
    self.document.getElementById("SCELTLOG").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
    
}
function showSceltLogREG() {
    self.document.getElementById("SCELTREGCORSI").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
    
}
function hideSceltlog() {
    self.document.getElementById("SCELTLOG").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";   
}

function hideSceltlogREG() {
    self.document.getElementById("SCELTREGCORSI").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
}
function showLegenda() {
    self.document.getElementById("AGINSERT").src = "agenda_legenda.aspx";
    self.document.getElementById("newApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function showEle() {
    self.document.getElementById("fraExp").src = "Elenco_appuntamenti.aspx";
    self.document.getElementById("DivExp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function CloseEXPSimple() {
    self.document.getElementById("fraExp").src = "base.htm";
    self.document.getElementById("DivExp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
}
function showCerca() {
    self.document.getElementById("AGINSERT").src = "agenda_ricerca_orario.aspx";
    self.document.getElementById("newApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function showDemo(id) {
    self.document.getElementById("AGINSERT").src = "video/video.aspx?id="+id;
    self.document.getElementById("newApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
var openF = "0";
function showListDemo() {
    self.document.getElementById("AGINSERT").src = "video/video.aspx";
    self.document.getElementById("newApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function delR(dat, tip) 
{
    if (tip == "1") {
        //self.document.getElementById('ctl00_ContentPlaceHolder1_HiddenFieldCar').value = dat;
        hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenFieldCar';
        var hiddenField = $get(hiddenFieldID);
        if (hiddenField) 
        {
            hiddenField.value = dat;
            __doPostBack(hiddenFieldID, '');        
        }
    }
    if (tip == "2") {
        self.document.getElementById('ctl00_ContentPlaceHolder1_HiddenFieldMod').value = dat;
        hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenFieldMod';
        var hiddenField = $get(hiddenFieldID);
        if (hiddenField) 
        {
            hiddenField.value = dat;
            __doPostBack(hiddenFieldID, '');        
        }
    }
}
function InsertAppClie(idst, id, cogn, nom, email, cell) {
    if (cell == undefined) {
        cell = "";
    }
    if (email == undefined) {
        email = "";
    }
    self.document.getElementById("AGINSERT").src = "agenda_iserimento_cliente.aspx?id=" + id + "&cogn=" + cogn + "&nom=" + nom + "&email=" + email + "&cell=" + cell + "&idst=" + idst;
    self.document.getElementById("newApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function visappCli(id, cogn, nom) {
    self.document.getElementById("AGINSERT").src = "agenda_Dettaglio_cliente.aspx?id=" + id + "&cogn=" + cogn + "&nom=" + nom;
    self.document.getElementById("newApp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function CloseSimpleApp() {
    self.document.getElementById("AGINSERT").src = "base.htm";
    self.document.getElementById("newApp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
}
function completeReg(tipe) {
    if (tipe == "1") {
        alert("OPERAZIONE COMPLETATA!! \nriceverà notifica non appena avremo ricevuto il pagamento.");
    }
    if (tipe == "2") {
        alert("OPERAZIONE COMPLETATA CON SUCCESSO!!");
    }
    if (tipe == "3") {
        alert("ATTENZIONE!! IMPOSSIBILE ESEGUIRE L'OPERAZIONE, RIPROVA IN SEGUITO!!");
    }
    if (tipe == "4") {
        alert("REGISTRAZIONE COMPLETATA CON SUCCESSO!!");
    } 
    self.document.location.href = "default.aspx";
}
function showRec() {
    self.document.getElementById("fraExp").src = "Specialista_recupero.aspx";
    self.document.getElementById("DivExp").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}
function CloseRec() {
    self.document.getElementById("fraExp").src = "base.htm";
    self.document.getElementById("DivExp").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
}
function addRegSpe(){
    if (confirm("REGISTRAZIONE AL CORSO AVVENUTA CON SUCCESSO!!\n\n\n\nScegli una username e una password \ne potrai ricevere appuntamenti di NUOVI pazienti via internet.\n\n LA REGISTRAZIONE A MIAGENDA.IT E' ASSOLUTAMENTE GRATUITA.")) {
        self.document.location.href = "RegistraSpecialista.aspx?complete=1";
    }
    else 
    {
        self.document.location.href = "default.aspx";
    }
}
function showFatt() 
{
    self.document.getElementById("fraFatt").src = "RegistraFattura.aspx";
    self.document.getElementById("DivFatt").style.display = "";
    self.document.getElementById("trasparenza").style.display = "";
}

function closeFatt() {
    alert("Registrazione avvenuta con successo, le invieremo la fattura all'indirizzo riportato.");
    self.document.getElementById("fraFatt").src = "base.htm";
    self.document.getElementById("DivFatt").style.display = "none";
    self.document.getElementById("trasparenza").style.display = "none";
}
function delAppUT(id) {
    if (confirm("SEI SICURO DI VOLER DISDIRE L'APPUNTAMENTO?")) {
        self.location.href = "Utente_appuntamenti.aspx?delapp=" + id;
    }
}
function hideimhome() {
    if (self.document.getElementById("imHome") != null) {
        self.document.getElementById("imHome").style.display = "none";
        self.document.getElementById("RegCenter").style.display = "";
    }
}
function viewimhome() {
    if (self.document.getElementById("imHome") != null) {
        self.document.getElementById("imHome").style.display = "";
        self.document.getElementById("RegCenter").style.display = "none";
    }
}
function RicercaPost(pos) {
    toppag();
    self.document.getElementById("ctl00_ContentPlaceHolder1_HiddenField1").value = pos;
    hiddenFieldID = 'ctl00_ContentPlaceHolder1_HiddenField1';
    var hiddenField = $get(hiddenFieldID);
    __doPostBack(hiddenFieldID, '');
}

function toppag() {   
    window.scrollTo(0, 0);
}