// POP-UP
function popUp(URL) 
	{
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=150,left = 590,top = 350');");
	}
	
function popUpfun(URL, WIDTH, HEIGHT) 
	{
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + WIDTH + ",height=" + HEIGHT + ",left = 590,top = 350');");
	}

// BB indsæt
function setHTML(felt,start,slut) 
	{
		var e = document.getElementById(felt);
		e.focus();
		startTxt = start;
		endTxt = slut;
		if(document.all)
			{
				Range = document.selection.createRange();
				Range.text = startTxt + Range.text + endTxt;
				Range.select();
			}
			else
				{
					cursorpos = e.selectionEnd+startTxt.length+endTxt.length;
					selectionTxt = e.value.substr(e.selectionStart, e.selectionEnd-e.selectionStart);
					selectionTxt = startTxt + selectionTxt + endTxt;
					e.value = e.value.substr(0, e.selectionStart) + selectionTxt + e.value.substr(e.selectionEnd);
					e.setSelectionRange(cursorpos, cursorpos);
				}
		e.focus();
	}

function point()
	{
		document.location.href='flipbillede.php';
	}

function flip()
	{
		document.location.href='flip.php';
	}

Ajax.PeriodicalUpdater = Class.create(Ajax.Base, {
  initialize: function($super, container, url, options) {
    $super(options);
    this.onComplete = this.options.onComplete;

    this.frequency = (this.options.frequency || 2);
    this.decay = (this.options.decay || 1);

    this.updater = { };
    this.container = container;
    this.url = url;

    this.start();
  },

  start: function() {
    this.options.onComplete = this.updateComplete.bind(this);
    this.onTimerEvent();
  },

  stop: function() {
    this.updater.options.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
  },

  updateComplete: function(response) {
    if (this.options.decay) {
      this.decay = (response.responseText == this.lastText ?
        this.decay * this.options.decay : 1);

      this.lastText = response.responseText;
    }
    this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency);
  },

  onTimerEvent: function() {
    this.updater = new Ajax.Updater(this.container, this.url, this.options);
  }
});
