﻿// File JScript

/* inizio Play mp3 */
var ua = navigator.userAgent.toLowerCase(); 
var browser; 

function detect(text) { 
    stringposition = ua.indexOf(text) + 1; 
    data = text; 
    return stringposition; 
}   

if (detect('msie')) {browser = 'Internet Explorer';} 
else if (detect('safari')) browser = 'Safari'; 
else if (detect('avant')) browser = 'Avant'; 
else if (detect('firefox')) browser = 'Firefox'; 
else if (detect('opera')) browser = 'Opera'; 
else if (!detect('compatible')) {browser = 'Netscape Navigator'; version = ua.charAt(8);} 
else browser = 'unknown';

function PlayChord(surl){
   if (browser == 'Internet Explorer') { 
    PlayIE(surl);
   } else if (browser == 'Firefox') {
    PlayFirefox(surl);
   } else if (browser == 'Opera') {
    PlayFirefox(surl);
   } else if (browser == 'Safari') {
    PlayFirefox(surl);
   }
}

function PlayIE(url) {
  document.all.sound.src = url;
}

function PlayFirefox(surl) {
  document.getElementById("dummyspan").innerHTML=
    "<embed width=0 heigth=0 src='"+surl+"' hidden=true autostart=true loop=false>";
}

function SendToStamp(id) {
    window.open('AddToStamp.aspx?Id='+id,'Print_'+id,'width=1,height=1,left=0,top=0,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function SendToZip(id, Note) {
    window.open('AddToZip.aspx?Id='+id+'&Note='+Note,'Print_'+id,'width=1,height=1,left=0,top=0,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

/*  fine Play mp3 */

/* inizio Stampa */

var stampaTop=false;
var stampaMiddle=true;
var stampaBottom=false;

/* Fine Stampa */
                    
function hide_control(contr)
    {
        document.getElementById(contr).style.display="none";
    }
    
function show_control(contr)
    {
        document.getElementById(contr).style.display="block";
    }
                    
function hide_multiple_control(name, count)
    {
        for (var i=1;i<=count;i++)
            {
                if (document.getElementById(name+i)==null)
                {
                
                }
                else
                {
                  document.getElementById(name+i).style.display="none";
                }
            }        
    }
                    
function show_multiple_control(name, count)
    {
        for (var i=1;i<=count;i++)
            {
                if (document.getElementById(name+i)==null)
                {
                
                }
                else
                {
                    document.getElementById(name+i).style.display="block";
                }
            }        
    }
    
/* inizio scroller */

// <![CDATA[

var scrollDiv;
var hDiv;
var tClip;
var bClip;
var wClip;
var interval;
var topPos = 0;

function initScroller(id) {
    scrollDiv = document.getElementById(id);   
    var margin = parseInt(scrollDiv.offsetTop);
    
    var scrollDiv__controls = document.getElementById(id + '__controls');

    /* Style per il div interno (testo) */
    scrollDiv.style.width    = (scrollDiv.parentNode.offsetWidth - (margin * 2)) - 24 + 'px';
    scrollDiv.style.height   = 'auto';
    scrollDiv.style.overflow = 'hidden';
    
    /* Style per il div esterno (contenitore) */
    scrollDiv.parentNode.style.overflow = 'hidden';
    
    /* Style per il div con i controlli (testo) */
    scrollDiv__controls.style.display = 'block';  


    /* Impostazioni per visualizzare la parte di testo superiore */
    hDiv  = scrollDiv.offsetHeight;

    tClip = 0;   
    wClip = scrollDiv.parentNode.offsetWidth - (margin * 2);
    bClip = scrollDiv.parentNode.offsetHeight - (margin * 2);

    scrollDiv.style.clip = 'rect('+ tClip +'px,'+ wClip +'px,'+ bClip +'px,0)';   
    // alert("tClip:"+tClip+"\nwClip:"+wClip+"\nbClip:"+bClip+"\n");
}

function scroll(scrollBy, time) {
    tClip += scrollBy;
    bClip += scrollBy;
    topPos -= scrollBy;

    
    if (tClip < 0 || bClip > hDiv) {
        tClip -= scrollBy;
        bClip -= scrollBy;
        topPos += scrollBy;    
    }
    
    
    scrollDiv.style.clip = 'rect('+ tClip +'px, '+ wClip +'px, '+ bClip +'px, 0)';   
    scrollDiv.style.top = topPos + 'px';    
    interval = setTimeout('scroll('+ scrollBy +', '+ time +')', time);
}

function stopScroll() {
    if (interval) clearTimeout(interval);
}

// ]]>

/* fine scroller*/



function show_top_chord()
    {
//        hide_control('table_scroll_top');
//        hide_control('nasc_scroll_top');
//        show_control('mostra_scroll_top');
        
        hide_control('table_print_top');
        hide_control('nasc_print_top');
        show_control('mostra_print_top');
    }
    
function hide_top_chord()

    {
//        show_control('table_scroll_top');
//        show_control('nasc_scroll_top');
//        hide_control('mostra_scroll_top');
        
        show_control('table_print_top');
        show_control('nasc_print_top');
        hide_control('mostra_print_top');
    }
    
function hide_middle_chord(imageCounter)
    {
        hide_control('nasc_scroll_middle');
        show_control('mostra_scroll_middle');
        hide_multiple_control('accordo_scroll_middle_',imageCounter);
        
        hide_control('nasc_print_middle');
        show_control('mostra_print_middle');
        hide_multiple_control('accordo_print_middle_',imageCounter);
    }
    
function show_middle_chord(imageCounter)

    {
        show_control('nasc_scroll_middle');
        hide_control('mostra_scroll_middle');
        show_multiple_control('accordo_scroll_middle_',imageCounter);
        
        show_control('nasc_print_middle');
        hide_control('mostra_print_middle');
        show_multiple_control('accordo_print_middle_',imageCounter);
    }
    
function hide_bottom_chord()
    {
//        hide_control('table_scroll_bottom');
//        hide_control('nasc_scroll_bottom');
//        show_control('mostra_scroll_bottom');
        
        hide_control('table_print_bottom');
        hide_control('nasc_print_bottom');
        show_control('mostra_print_bottom');
    }
    
function show_bottom_chord()

    {
//        show_control('table_scroll_bottom');
//        show_control('nasc_scroll_bottom');
//        hide_control('mostra_scroll_bottom');
        
        show_control('table_print_bottom');
        show_control('nasc_print_bottom');
        hide_control('mostra_print_bottom');
    }
    
function view_printer()
    {
        show_control('tbl_printer');
        hide_control('tbl_scroller');
    }

function view_scroller()
    {
        show_control('tbl_scroller');
        hide_control('tbl_printer');
    }

function print_scores()
    {
        show_control('a_top_link');
        show_control('a_bottom_link');
        hide_control('tbl_menu_printer');
        window.print();
        hide_control('a_top_link');
        hide_control('a_bottom_link');
        show_control('tbl_menu_printer');
    }
