/*
 * Copyright (c) 2008 FIZON GmbH
 * All rights reserved.
 *
 * $Id: pget.js 1739 2008-08-04 07:50:26Z as $
 */
PGet = function(paras)
{
	this.paras = null;
	this.requestUrl = null;
	this.rawResult = null;
	this.lines = [];
	this.values = {};


	/**
	 * construct()
	 */
	this.construct = function(paras)
	{
		this.requestUrl = 'pget.php?';
		for (var key in paras)
			this.requestUrl += key+'='+escape(paras[key])+'&';

		if (! (this.rawResult = this.fetch()))
			return false;

		this.lines = this.rawResult.replace(/\n$/, '').split("\n");

		for (var i = 0; i < this.lines.length; i++) {
			var tmp = this.lines[i].split(':', 2);
			if (tmp.length == 2)
				this.values[tmp[0]] = tmp[1].replace(/\\n/g, "\n");
		}
	}


	/**
	 * fetch()
	 */
	this.fetch = function()
	{
		var result = PaJaH.GetResponseText(this.requestUrl);
		if (! result) {
			PPage.ShowError('PGet', 'es wurden keine Daten zu "'+this.requestUrl+'" empfangen');
			return false;
		}

		return result;
	}


	this.construct(paras);
}

