// Startzeit für den Countdown
var start=new Date();
start=Date.parse(start)/1000;
				
// CountDownFunktion
function CountDown(args){
	var now=new Date();
	now=Date.parse(now)/1000;
	
	delay = CountDown.arguments[0];
	var x=parseInt(delay-(now-start),10);
	if (document.form1) {document.form1.clock.value = x;}
	if (x > 0) {
		setTimeout("CountDown(delay)", 100);
	}
}

// nur wenn CountDown alleine verwendet wird
//var delay=0;
//delay=3;
//window.setTimeout('CountDown(delay)', 100);

// Hauptfunktion

function Start(URL, WIDTH, HEIGHT, WINNAME, BLNPOPUP, CLOSETIME) {

	if (BLNPOPUP) {
		windowprops = '';
		windowprops += 'left=50,';	// Position - X
		windowprops += 'top=50';	// Position - Y
		if (WIDTH != 0) windowprops += ', width=' + WIDTH;	// Weite
		if (HEIGHT != 0) windowprops += ', height=' + HEIGHT;	// Höhe
		windowprops += ', location=yes';
		windowprops += ', menubar=yes';
		windowprops += ', resizable=yes';
		windowprops += ', scrollbars=yes';
		windowprops += ', status=yes';
		windowprops += ', toolbar=yes';
				
		preview = window.open(URL, WINNAME, windowprops);
		
	} else {
		location.href = URL;
	}

	if (CLOSETIME) setTimeout("preview.close();", CLOSETIME*1000);
}

function doPopup(args) {

	// Aufruf:
	// doPopup(url, blnCountDown, blnPopup, width, height, winname, delay, closetime)
	// doPopup('http://www.erdgas.ch/601.html',1,1,0,0,'',3,0)  oder
	// doPopup('http://www.erdgas.ch/601.html')

	blnCountDown = 1;	// Soll der CountDown ausgeführt werden?
	if (doPopup.arguments.length > 1) blnCountDown = doPopup.arguments[1];
	
	blnPopup = 1;		// Soll die neue Seite als Popup oder als Redirect geöffnet werden
	if (doPopup.arguments.length > 2) blnPopup = doPopup.arguments[2];

	//url = "http://www.erdgas.ch/601.html";	// Zieladresse
	url = doPopup.arguments[0];
	
	//width = 267;  // Fensterbreite (nur Popup)
	width = 0;  // 0 = keine Breitenangabe
	if (doPopup.arguments.length > 3) width = doPopup.arguments[3];
	
	//height = 103; // Fensterhöhe (nur Popup)
	height = 0; // 0 = keine Höhenangabe
	if (doPopup.arguments.length > 4) height = doPopup.arguments[4];
	
	//winname = 'preview';	// Fenstername wird benötigt zum Schliessen des Fensters
	winname = '';	// keine Angabe erzeugt default name
	if (doPopup.arguments.length > 5) winname = doPopup.arguments[5];
	

	// Zeit in Sekunden bevor das Popup öffnet
	delay=3;
	if (doPopup.arguments.length > 6) delay = doPopup.arguments[6];

	// Zeit in Sekunden bis das Fenster wieder geschlossen wird
	// 0 = nicht schliessen
	closetime = 0;
	if (doPopup.arguments.length > 7) closetime = doPopup.arguments[7];

	
	if (blnCountDown) timerCountDown = setTimeout("CountDown(delay)", 100);
	
	timerStart = setTimeout("Start(url, width, height, winname, blnPopup, closetime)", delay*1000);
	
}

