
/* center Popup Images ----------------------------*/

var _DeBug = '0'; 		/* set to 1 if you want see the alert window every time */
	
		var _LINE = '---------------------------------------------------------------------------------------------------------\n<br>'; 
		var _POP_W =  document.images[0].width;
		var _POP_H =  document.images[0].height;
		var _ERROR_1 = '';
		var _ERROR_2 = '';
		var _MOVE_STATUS = true;
		var _DEBUGINFO = _LINE + 'Info: Debug is on \n<br>' + _LINE;
		var _BROWSER1 = 'navigator.appCodeName: [ '+ navigator.appCodeName + ' ]\n<br>'; 
		var _BROWSER2 = 'navigator.appName: [ '+ navigator.appName + ' ]\n<br>'; 
		var _BROWSER3 = 'navigator.appVersion: [ '+ navigator.appVersion + ' ]\n<br>'; 
		var _BROWSER4 = 'navigator.platform: [ '+ navigator.platform + ' ]\n<br>'; 
		var _BROWSER5 = 'navigator.userAgent: [ '+ navigator.userAgent + ' ]\n<br>'; 
		var _SCREEN = 'Screen width is: ' + screen.width + '\n<br>Screen height is: ' + screen.height + '\n<br>'; 
		var _IMAGE_W = 'Image width is: ' + _POP_W + '\n<br>';
		var _IMAGE_H = 'Image height is: ' + _POP_H + '\n<br>';
		var _MOVE = 'Move from left 0 to ' + ((screen.width / 2) - (_POP_W / 2)) + '\n<br> and from top 0 to ' +((screen.height /2) - (_POP_H / 2)+'\n<br>');
		var _MESSAGE = _LINE + 'so... i think, the window has to move \n'; 
		var _MAIL = 'If you see this debug-window ,\n<br>please copy the content of this,\n<br>paste in new E-Mail and send to mk@netbust.de.\n<br><br>thank\`s for help ! \n<br>regardin Matthias Karr\n<br>E-Mail <a href=\"mailto:mk@netbust.de\?Subject=Netstal-Popup\">mk@netbust.de</a><br>' + _LINE;
		
	if (_DeBug == '1') { _ErrorMessage ('','')};
	
	if 	((! document.images[0].width) | (! document.images[0].height)){ 
		if (! document.images[0].width){
			_ERROR_1 = _LINE + 'Error on --> '+ _IMAGE_W + '\n';
		}
		if (! document.images[0].height) {
			_ERROR_2 = _LINE + 'Error on --> '+ _IMAGE_H + '\n';
		}
	_MOVE_STATUS = false;
	_test_alert (_ERROR_1,_ERROR_2);
	}


/* ----------------------------------------------------------------------------- */	 
	 function _Set_Cookie (_CokName, _CokDays, _Content) {
		var _Ablauf = new Date();
		var _Zeit = _Ablauf.getTime() + (_CokDays * 24 * 60 * 60 * 1000);
		_Ablauf.setTime(_Zeit);
		_Ablauf = _Ablauf.toGMTString();
		document.cookie = _CokName +"=" + _Content + ";expires=" + _Ablauf;
  	}

/* test if alert was 1 time on and not older then 20 Days --------------------------------------------------- */
	function _test_alert (_ERROR_1, _ERROR_2) {
		var _CokName = 'pop_alert';
		var _CokDays = '20';  /* 5 tage lebenszeit des Cookies */
		var _Content = 'alert-off';
	
		if (document.cookie) {
			if (_read_cookie_name(_CokName) != _Content){ 
					_ErrorMessage( _ERROR_1, _ERROR_2) ;
			}
		_Set_Cookie (_CokName, _CokDays, _Content);
		}
	} 
/* ----------------------------------------------------------------------------- */
	
/* -- Beginn test Cookie --------------------------------------------------------------------------------- */
	
	function _read_cookie_offset (offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1)
        		endstr = document.cookie.length;
    		return unescape(document.cookie.substring(offset, endstr));
	}

	function _read_cookie_name (name) {
		var arg = name + "=";
    		var alen = arg.length;
    		var clen = document.cookie.length;
    		var i = 0;
		while (i < clen) {
        	var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return _read_cookie_offset (j);
        	i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
    	}
    	return null;
	}

/* -- End test Cookie--------------------------------------------------------------------------------- */

	if (_MOVE_STATUS){
			this.window.moveTo(((screen.width / 2) - (_POP_W / 2)),((screen.height /2) - (_POP_H / 2)));
	}
/* ------------------------------------------------------------------------------------------------------- */
	function _ErrorMessage (_ERROR_1,_ERROR_2) {
	
		var _Alert_Win=window.open("","_Alert_Win","height=400,width=550,left=2,top=50");
		with (_Alert_Win.document) {
			open();
				write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n');
				write('<html><head>\n');
				write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n');
				write('<link href="../fileadmin/css/main.css" rel="stylesheet" type="text/css">\n');
				write('<title>Debug Alert</title>\n');
				write('</head>\n');
		 		write('<body bgcolor="#ffffff" text="#535353" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><center>\n');
		 		write('<img src="no.gif" width="1" heght="1">');
	 			write ('<table><tr><td>\n');
				write(_DEBUGINFO + _MAIL + _BROWSER1 + _BROWSER2 + _BROWSER3 + _BROWSER4 + _BROWSER5 + _LINE + _SCREEN + _LINE + _IMAGE_W + _IMAGE_H + _ERROR_1 + _ERROR_2 + _MESSAGE + _MOVE + _LINE);
	 			write ('</center></td></tr></table>\n');
 				write ('</body></html>\n');
		 	close();
		 }
	}

/* End center Popup Images ---------------------------- */


