var scrtxt = "Benvenuti nel sito degli E-Toys!!!!";
var lentxt = scrtxt.length;
var width  = 100;
var pos    = 1-width;
var count  = 0;
var max    = 0;

function scorrevole(val) {
  if(val == 1) {
     scrtxt = "...quando di colpo comincia lo show...";
  }
  pos++;
  var scroller = "";
  if(pos == lentxt) {
    pos = 1-width;
  }
  if(pos < 0) {
    for(var i=1; i<=Math.abs(pos); i++) {
      scroller = scroller+" ";}
    scroller = scroller+scrtxt.substring(0,width-i+1);
  }
  else {
    scroller = scroller+scrtxt.substring(pos,width+pos);
  }
  window.status = scroller;
  setTimeout("scorrevole()",150);
}

function PopupCentrata(apri) {
         var w = 650;
         var h = 450;
         var l = Math.floor((screen.width-w)/2);
         var t = Math.floor((screen.height-h)/2);          
            window.open(apri,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=yes");
}

function BigPopup(apri,w,h) {         
         var l = Math.floor((screen.width-w)/2);
         var t = Math.floor((screen.height-h)/2);          
            window.open(apri,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l + ",scrollbars=yes");
}

function LoadImage(w,h,dir,vs) {

         if(vs == 0){count--;}
         else{count++;}

         var root = "../img/fr/" + dir + "/" + count;
         
         if(count <= 1){
            fre_sx = document.getElementById('sx');
            fre_sx.style.visibility =  "hidden";
         }else{
            fre_sx = document.getElementById('sx');
            fre_sx.style.visibility =  "visible";
         }
         
         if(count == max){
            fre_dx = document.getElementById('dx');
            fre_dx.style.visibility =  "hidden";
         }else{
            fre_sx = document.getElementById('dx');
            fre_sx.style.visibility =  "visible";
         }
         
         /* DIR 1 */
         if(dir == 1) {
            max = 15;
            if(count == 6) {
               w = 480;
               h = 320;
            } else if(count == 7 || count == 9) {
               w = 320;
               h = 480;
            } else if(count == 10) {
               w = 300;
               h = 200;
            }
         }
         /* DIR 2 */
         if (dir == 2) {
             max = 9;
             if(count == 1 || count == 3 || count == 9) {
                w = 340;
                h = 453;
             }          
         }
         /* DIR 3 */
         if (dir == 3) {max = 17;}
         /* DIR 4 */
         if (dir == 4) {max = 8;}
         /* DIR 5 */
         if (dir == 5) {max = 22;}
         /* DIR 6 */
         if(dir == 6) {
            max = 15;
            if(count == 3) {
               w = 350;
               h = 467;
            } else if(count == 8 || count == 11) {               
               h = 431;
            } else if(count == 9 || count == 15) {               
               h = 390;
            } else if(count == 10) {
               w = 300;               
               h = 424;
            } else if(count == 12) {
               w = 300;                              
               h = 365;
            } 
         }
         /* DIR 7 */
         if(dir == 7) {
            max = 13;
            if(count == 13){
               w = 500;
               h = 538;
            }
         }
         /* DIR 8 */
         if(dir == 8) {
            max = 8;
         
         }
         /* DIR 9 */
         if(dir == 9) {
            max = 11;
            if(count == 5){
               w = 400;
               h = 533;
            }
         }
         /* DIR 10 */
         if(dir == 10) {
            max = 6;
         }
         /* DIR 11 */
         if(dir == 11) {
            max = 13;
         }
         /* DIR 12 */
         if(dir == 12) {
            max = 20;
         }
         /* DIR 13 */
         if(dir == 13) {
            max = 12;
            if(count == 3){
               w = 400;
               h = 533;
            }
            if(count == 5){
               w = 400;
               h = 533;
            }
            if(count == 10){
               w = 400;
               h = 533;
            }
         }
         /* DIR 14 */
         if(dir == 14) {
            max = 16;
            if(count == 2){
               w = 463;
            }
            if(count == 3 || count == 7 || count == 8 || count == 9 || count == 10 || count == 12){
               w = 533;
            }
         }
         /* DIR 15 */
         if(dir == 15) {
            max = 15;
         }
         /* DIR 16 */
         if(dir == 16) {
            max = 15;
         }
         /* DIR 17 */
         if(dir == 17) {
            max = 20;
            if(count >= 5 && count <= 11){
               w = 533;
               h = 400;
            }
         }
         /* DIR 18 */
         if(dir == 18) {
            max = 10;
            if(count == 1){
               w = 300;
               h = 400;
            }
         }
         /* DIR 19 */
         if(dir == 19) {
            max = 15;
            if(count == 9 || count == 10 || count == 11 || count == 12 || count == 13){
               w = 300;
               h = 400;
            }
         }
          /* DIR 20 */
         if(dir == 20) {
            max = 13;
            if(count == 10 || count == 11){
               w = 300;
               h = 400;
            }
         }
         document.getElementById("loader").innerHTML = ("<center><br><img src=\" " + root + 
                                                        ".jpg\" width=" + w + " height=" + h + 
                                                        "><br></center>");
}

function LoadDiv(div_id) {         
         
         var i;
         ar_div = new Array('demo', 'story', 'ale', 'dav', 'gil', 'mar', 'ric', 'live', 'link', 'friend', 'fri', 'song', 'info', 'mail');                 
         div = document.getElementById(div_id);         
         
         for(i = 0; i <= 13; i++){
             din_div = document.getElementById(ar_div[i]);                 
             if(din_div != div_id){
                din_div.style.visibility = "hidden";
                din_div.style.display    = 'none';
             }             
         }
         div.style.visibility =  "visible";
         div.style.display    = 'block';
}
