﻿// script na zmenu pozadi podle ID Elementu LAP 08/2009 //
// obrazek by mel by pouze ve formatu "<nazev>_<cislo>.jpg" "pokus_1.jpg" //
///////////////////////////////////////////////////////////////////////////////////////////////
// <head>
//   <title>Untitled Page</title>
//   <script src="/core/scripts/effects/changebackground/changebackground.js" language="javascript" type="text/javascript"></script>
//   <script language="javascript" type="text/javascript">
//       // vytvoreni instance scriptu, toto umozni, aby mohlo na jedne strance bezet i vice nezavislych scriptu
//       var pozadi = new FxChangeBackground(1,'pozadi',14,'pokus_','/UserFiles/.design_web/');
//
//       // var pazadi = new FxChangeBackground(<interval vymeny v sec>,'<nazev objektu u ktereho ma dojit k vymene>',<celkovy pocet obrazku>,'<pocatecni nazev obrazku viz nize>','<umisteni obrazku>');
//       // obrazek by mel by pouze ve formatu "<nazev>_<cislo>.jpg" "pokus_1.jpg" //
//       // script sam zameni poradove cislo obrazku
//       
//       // spusteni casovace scriptu
//       pozadi.start();
//   </script>  
//</head>
//<body id="body" style="background-repeat: no-repeat;">
//<div id="pazadi" style="width: 600px;height: 400px;"></div>
//
//</body>
//</html>
///////////////////////////////////////////////////////////////////////////////////////////////
 
 var PrictureCount    = 1;    // pocatecni obrazek
 function FxChangeBackground(interval,element,count,picturename,picturepath)
 {
    this.Name = element;
    this.Interval = interval;
    this.Element = element;
    this.TotalCount = count;
    this.PrictureName = picturename;    if(this.PrictureName == "undefined") this.PrictureName = "";
    this.PricturePath = picturepath;     if(this.PricturePath == "undefined") this.PricturePath = "/";  
    
    this.changeBackground = function()
    {
        PrictureCount = PrictureCount + 1;
        window.document.getElementById(this.Element).style.backgroundImage = 'url(' + this.PricturePath + this.PrictureName + PrictureCount + '.jpg)';
        if(PrictureCount == this.TotalCount)
            PrictureCount = 1;
    }
    
    this.start = function()
    {
        window.setInterval(this.Name + ".changeBackground()", this.Interval * 1000); //pravidelna zmena, 1000 je sekunda
    }
 }