/*****************************************************************************
    $Id: functions.js,v 1.5 2002/08/19 20:21:35 djresonance Exp $
    Copyright 2002 Brandon Tallent

    This file is part of phpTest.

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/

  var up, down;
  var min1, sec1;
  var cmin1, csec1, cmin2, csec2;


  function popup(url, width, height)
  {
      day = new Date();
      id = day.getTime();
      eval("page" + id + " = window.open(url, '" + id + "', 'toolbar = 0, scrollbars = 1, location = 0, statusbar = 0, menubar = 0, resizable = 1, width = " + width + ", height = " + height + "');");
  }

  function goto_url(object)
  {
      window.location.href = object.options[object.selectedIndex].value;
  }

  function minutes(data)
  {
      for (var i = 0; i <data.length; i++) if (data.substring(i, i + 1) == ":") break;
      return (data.substring(0, i));
  }

  function seconds(data)
  {
      for (var i = 0; i <data.length; i++) if(data.substring(i, i + 1) == ":") break;
      return (data.substring(i + 1, data.length));
  }

  function Display(min, sec)
  {
      var disp;
      if (min <= 9) disp = "0";
      else disp = " ";
      disp += min + ":";
      if (sec <= 9) disp += "0" + sec;
      else disp += sec;
      return (disp);
  }

  function Down()
  {
      cmin2 = 1 * minutes(document.countdown.start_time.value);
      csec2 = 0 + seconds(document.countdown.start_time.value);
      DownRepeat();
  }

  function DownRepeat()
  {
      if (--csec2 == -1) {
          csec2 = 59;
          cmin2--;
      }

      document.countdown.time.value = Display(cmin2, csec2);
      if ((cmin2 == 0) && (csec2 == 0)) alert("Time's up!");
      else down = setTimeout("DownRepeat()", 1000);
  }
  
  
function openClose(id)
{
     
   if(document.getElementById) {
      element = document.getElementById(id);
   } else if(document.all) {
      element = document.all[id];
   } else return;

   if(element.style) {
      if(element.style.display == 'block' ){
         element.style.display = 'none';
      } else {
         element.style.display = 'block';
      }
   }
}

function ukryj_blok()
{
 var blok = document.getElementById('rozwin');
 blok.style.display = "none";
} 

function dodaj_opcje(element,ile)
{
    var forma = document.getElementById('potwierdzenie_testu'); 
	var obiekt = document.getElementById(element);

	    for (x=0; x<ile; x++) { 
       // var dzien = (x < 9)? '0'+(new String(x+1)) : x+1; //dodajemy zero wiodące (i +1 bo dni są liczone od 0) 
	        var NowyOption = new Option(x+1, x+1, 0, 0); 
	        obiekt.options[x] = NowyOption; 
	    }
}		

$(function() {
    $('#chat').live('inview', function(event, isVisible) {
		$('#chat').after('<IFRAME src="shoutbox.html" align="center" frameborder="no" scrolling="no" width="730px" height="660px" >');
		$('#chat').remove();
    });
});
