var butttext ='Loading images....'
var intcount = 0
var oldcount = 0

function docloud(){
    grayOut(true);
    
    
    if (document.getElementById("hideloading").value == 'show' ){
        
        document.getElementById('loadingspan').style.display='';
    }
    document.getElementById("hideloading").value = 'noshow'
  //  checktoseeloaded();
    makeRequest('clouds.asp','spnclouds');
    addbar(62);
    window.setTimeout("document.getElementById('loadingspan').style.display='none',addbar(2);", 3000);
    
   // document.getElementById('loadingspan').style.display='none'
    
}

function checktoseeloaded(){
   
   
        document.getElementById('loadingspan').style.display='none'    
    }


function ini()
{

document.getElementById("ana_but").disabled = false
document.getElementById("ana_but").value = "animate "
}
var intval=""

function starttime(n,o){
    var i=n
    var old_i = o
    b = i -1
    
    
    document.getElementById("pic_9" ).style.display='none'
    document.getElementById("pic_m").style.display='none'
    document.getElementById("pic_" + b).style.display='none'
    document.getElementById("pic_" + i).style.display=''
    c = document.getElementById("tdate_" + i).value
    document.getElementById("showdate").innerHTML = c
    
    
    
    old_i = i
    i++;
    
     if (i==10){
           //document.getElementById("pic_" + old_i).style.display='none'
           //document.getElementById("pic_m").style.display=''
           //document.getElementById("showdate").innerHTML = "latest"
           document.getElementById("ana_but").disabled = false
            document.getElementById("ana_but").value = "re-play "
           stop_Int();
           
            
        }else{
        
     intval = setTimeout('starttime('+ i +','+ old_i +')',1500)
   } 
}

function stop_Int(){
        
        if(intval!=""){
          window.clearInterval(intval)
      //   alert("stop")
          intval="stop"
        //  myTimer.innerHTML="Interval Stopped"
      }
}

function showana()
{
    //alert(document.images['pic_19'].complete)
    if (document.images['pic_9'].complete == false){
       
       document.getElementById("spnprogressbar").style.display='' 
       if(document.getElementById("spnclouds").style.display != 'none'){
             document.getElementById("loadingspan").style.display='';
        }
        document.getElementById("loadingtext").innerHTML = 'downloading more satellite images.. <BR>this may take a few minutes..<BR><BR>';
        var html = document.getElementById("loadingtext").innerHTML
        var i=0
        var cnt = 0 
        var c = 0
        
        for (i=1;i<=10;i++)
        {
              if (document.images['pic_' + i].complete == false){
                    html = html +  'image ' + i + '<font color=red> loading...</font><BR>' 
              //      cnt++
                   
                   
              }else{
                    html = html +  'image ' + i + '<font color=green> done......</font><BR>' 
                    cnt++
               }  
        }
         
      //  if (cnt > 1){
            cnt = cnt * 10
            if (oldcount == cnt)  {
                if (intcount != 9){
                intcount++
                }
            }else{
                intcount=0
            }
        tb= cnt+ intcount;
            
        //    }
        addbar(tb);
        oldcount = cnt;
    
     
     //   html = html +'Status = ' + (cnt / 10) * 100 +'%' 
     //   document.getElementById("loadingtext").innerHTML = html
        document.getElementById("ana_but").value = butttext;
        //butttext = butttext + '.'
        document.getElementById("ana_but").disabled = true
        window.setTimeout("showana()", 2000);    
    
    }else{
        document.getElementById("spnprogressbar").style.display='none' 
        document.getElementById("loadingspan").style.display='none';
        document.getElementById("ana_but").disabled = true
        document.getElementById("pic_1").style.display='none'
        document.getElementById("ana_but").value="running..."
        starttime(1,20)
    }
}






