 // -----------------------------------------
 // main script for www.borisbidjansaberi.com
 // -----------------------------------------

  // -----------------------------------------
  // Displays logo and inits showing of other items
  // -----------------------------------------
  function DisplayLogo()
  {
        // get logo and display it
        var logo = $("logo_ll");
        Effect.Appear(logo, {duration : 3.0});

        // hide logo and display other items
        setTimeout("HideLogo();", 4000);
  };

  // -----------------------------------------
  // hides logo and displays all other items
  // -----------------------------------------
  function HideLogo()
  {
       var elementToHide = $("logo_ll");
       Effect.Fade(elementToHide, {duration: 2.0});

       // display other items
       setTimeout("DisplayImage();", 2300);
  };

  // -----------------------------------------
  // Actually displays items
  // -----------------------------------------
  function DisplayImage()
  {
      // get all items to be displayed
      var image = $("logo_img");
      Effect.Appear(image, {duration: 3.0});
      setTimeout("FadeImage();", 3300);
  };
  
  function FadeImage() {
       Effect.Fade("logo_img", {duration:2.0, afterFinish:LoadMainPage});
  };

    // ------------------------------------------
    // hides startpage and inits loading of mainpage
    // ------------------------------------------
    function LoadMainPage()
    {
        Effect.Fade('start_page', {duration: 2.0, afterFinish: LoadMainPage2});
    };

    // ------------------------------------------
    // shows all neccessary elements instantly (used when loading subpages)
    // ------------------------------------------
    function ShowAll() {
        // get elements
        var image = $("logo_image");
        var contact = $("contact_table");
        var container = $("main_container");

        // make it appear smoothly (variable duration)
        Effect.Appear(container, { duration: 1.0 });        
        Effect.Appear(image, { duration: 1.1 });
        Effect.Appear(contact, { duration: 1.1 });
    };
    // ------------------------------------------
    // loads mainpage
    // ------------------------------------------
    function LoadMainPage2()
    {
        // get logo by id
        var container = $("main_container");
        // start slideshow
        Effect.Appear(container, {duration: 1.0});

        // wait with final appearences
        setTimeout("ShowElements();", 100);
    };

    // ---------------------------------------------------
    // shows all spare website elements
    // ---------------------------------------------------
    function ShowElements()
    {
        // get elements
        var image = $("logo_image");
        var contact = $("contact_table");

        // make it appear smoothly (variable duration)
        Effect.Appear(image, {duration: 2.0});
        Effect.Appear(contact, {duration: 2.0});
    };


    // ------------------------------------------
    // preloading the flash movie (set in body onload)
    // ------------------------------------------
    function preloadFlash() 
    {
        flashmovie = new Image();
        flashmovie.src = "http://localhost/BorisBidjanSaberi/resource/system/flash/bbs_ss10.flv";
    };

    // ---------------------------------------------------
    // ON CLICK MOVE PRESS CONTAINER
    // ---------------------------------------------------
    var isPressMoving = false;
    var isPressOpen = false;
    var isPressClosed = true;


     function onPressClick()
     {
         if (isPressOpen)
         {
                 closePress();
         }

         else if (isPressClosed)
         {
                  openPress();
         }

     }

     function closePress()
     {
         isPressOpen = false;
         Effect.SlideUp('para01', { duration: 1.0, afterFinish: onPressClosed});
     }

      function onPressClosed()
      {
         isPressClosed = true;
      }

      function openPress()
      {
         isPressClosed = false;
         Effect.SlideDown('para01', { duration: 1.0, afterFinish: onPressOpen});
      }

      function onPressOpen()
      {
         isPressOpen = true;
      }


     // ---------------------------------------------------
     // ON CLICK MOVE COMERCIAL CONTAINER
     // ---------------------------------------------------
     var isComercialMoving = false;
     var isComercialOpen = false;
     var isComercialClosed = true;


     function onComercialClick()
     {
             if (isComercialOpen)
             {
                     closeComercial();
             }

             else if (isComercialClosed)
             {
                     openComercial();
             }

     }

     function closeComercial()
     {
             isComercialOpen = false;
             Effect.SlideUp('para02', { duration: 1.0, afterFinish: onComercialClosed});
     }

     function onComercialClosed()
     {
             isComercialClosed = true;
     }

     function openComercial()
     {
             isComercialClosed = false;
             Effect.SlideDown('para02', { duration: 1.0, afterFinish: onComercialOpen});
     }

     function onComercialOpen()
     {
             isComercialOpen = true;
     }

