/**
 * Javascript classes
 * 
 * @package		framework
 * @subpackage	base
 * @author		Roland Karle <rk@ateliervision.de>
 * @version 	1.0
 * @revision	$Id: classes.js 240 2007-11-09 17:49:43Z rk $
 * @since		25.10.2007
 */

// alias for document.
var d = document;

/**
 * AJAX base object
 *
 * @param	string	url
 * @param	object	options
 * @return	void
 */
ajax = function(url, options)
	{
	this.Url			= "";
	this.Method 		= "post";
	this.Parameter		= "";
	this.ContentType	= "application/x-www-form-urlencoded";
	this.Encoding		= "utf-8";
	this.Header			= Array();
	this.onSuccess		= function(){};
	this.onFailure		= function(){};
	if (isset(url))
		{
		this._init(url, options);	
		}
	}
	/**
 	 * AJAX base object
 	 *
 	 * @param	string	url
 	 * @param	object	options
 	 * @return	void
 	 */
	ajax.prototype._init = function(url, options)
		{
		this.Url = url;
		if (isset(options.method)) 		this.Method 		= options.method.toLowerCase();
		if (isset(options.parameter)) 	this.Parameter		= options.parameter;
		if (isset(options.encoding)) 	this.Encoding		= options.encoding;
		if (isset(options.contenttype))	this.ContentType	= options.contenttype;
		if (isset(options.onSuccess)) 	this.onSuccess 		= options.onSuccess;
		if (isset(options.onFailure)) 	this.onFailure		= options.onFailure;
		}
/**
 * AJAX request object
 *
 * @param	string	url
 * @param	object	options
 * @return	void
 */
ajax.request = function(url, options)
	{
	this._init(url, options);
	this.send();
	}
	/**
	 * extends ajax
	 */
	ajax.request.prototype = new ajax();
	/**
	 * Function getting called on change of the readyState:
	 * 
	 * 0 (not initialised)
     * 1 (loading)
     * 2 (loaded)
     * 3 (interactive)
     * 4 (completed)
     * 
     * @return 	void
	 */
	ajax.request.prototype.change = function()
		{
      	// Success
		if (this.response.readyState == 4 && (this.response.status <= 200 && this.response.status < 300))
			{
			this.onSuccess(this.response);
			}
		// Failure
		else if (this.response.readyState == 4 && (this.response.status > 200 && this.response.status >= 300))
			{
			this.onFailure(this.response);
			}
		}
	/**
	 * Sends the ajax request
	 * 
	 * @return	void
	 */
	ajax.request.prototype.send = function()
		{
		// Internet Explorer
		if (browser() == "ie")
			{
			try 
				{
                this.response = new ActiveXObject("Msxml2.XMLHTTP");
				}
			catch (e) 
				{
                try 
                	{
                    this.response = new ActiveXObject("Microsoft.XMLHTTP");
                	}
                catch (e) 
                	{
                		
                	}
				}	
			}
		// Other Browsers
		else
			{
			this.response = new XMLHttpRequest();
    		if (this.response.overrideMimeType) //Fix for Mozilla Browsers
    			{
                this.response.overrideMimeType('text/xml');
            	}
			}
		// Binds the current ajax.request object on the change function 
		// see also: http://www.prototypejs.org/api/function/bind
		this.response.onreadystatechange = this.change.bind(this);
		this.response.open(this.Method.toUpperCase(), this.Url, true);
		this.response.setRequestHeader("Content-type", this.ContentType);
		this.response.setRequestHeader("Content-length", this.Parameter.length);
		this.response.setRequestHeader("Connection", "close");
		this.response.send(this.Parameter);
		}
/**
 * Adds (or subtracts) a unit or the Date
 * 
 * Units:
 * "s" = seconds
 * "i" = minutes
 * "h" = hours
 * "d" = days
 * "w" = weeks	
 * "m" = months
 * "y" = years
 * 
 * @param	string	unit
 * @param	int		amount
 * @return	Date
 */
Date.prototype.add = function(unit, amount)
	{
	switch (unit)
		{
		case "y":
			var r = new Date(this.get("Y") + amount, this.get("n") - 1, this.get("j"), this.get("g"), this.get("i"), this.get("s"));
			break;
		case "m":
			var r = new Date(this.get("Y"), (this.get("n") - 1) + amount, this.get("j"), this.get("g"), this.get("i"), this.get("s"));
			break;
		case "w":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j") + (amount * 7), this.get("g"), this.get("i"), this.get("s"));
			break;
		case "d":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j") + amount, this.get("g") + amount, this.get("i"), this.get("s"));
			break;
		case "h":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g") + amount, this.get("i"), this.get("s"));
			break;
		case "i":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), this.get("i") + amount, this.get("s"));
			break;
		case "s":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), this.get("i"), this.get("s") + amount);
			break;
		}
	this.init(r.getTime());
	return r;
	}
/**
 * Ceils the Date by a unit 
 * 
 *  Units:
 * "s" = set seconds to 59
 * "i" = set seconds to 59
 * "h" = set seconds and minuted to 59
 * "d" = set time to 23:59:59
 * "w" = set the date to the last day of the week and time to 23:59:59
 * "m" = set the date to the last day of the month and time to 23:59:59
 * "y" = set date to 31.12. of the year and time to 23:59:59
 * 
 * @param	string	unit
 * @return	Date
 */
Date.prototype.ceil = function(unit)
	{
	switch (unit)
		{
		case "y":
			var r = new Date(this.get("Y"), 11, 31, 23, 59, 59);
			break;
		case "m":
			var r = new Date(this.get("Y"), (this.get("n") - 1), this.get("t"), 23, 59, 59);
			break;
		case "w":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j") + (7 - (this.get("N"))), 23, 59, 59);
			break;
		case "d":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), 23, 59, 59);
			break;
		case "h":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), 59, 59);
			break;
		case "i":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), this.get("i"), 59);
			break;
		case "s":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), this.get("i"), 59);
			break;
		}
	this.init(r.getTime());
	return r;
	}
/**
 * Calculates the differenze between two Date objects.
 * 
 * Units:
 * "s" = in seconds
 * "i" = in minutes
 * "h" = in hours
 * "d" = in days
 * "a" = as object with all unit values
 * 
 * @param	Date	from
 * @param	Date	to
 * @param	string	unit
 * @return	mixed
 */
Date.prototype.diff = function(from, to, unit)
	{
	var from 	= from.getTime() / 1000;
	var to 		= to.getTime() / 1000
	var r		= Math.ceil(to - from);
	switch(unit)
		{
		case "i":
			r = Math.ceil(r / 60);
			break;
		case "h":
			r = Math.ceil(r / 60 / 60);
			break;
		case "d":
			r = Math.ceil(r / 60 / 60 / 24);
			break;
		case "a":
			r = 
				{
				seconds:	r,
				minutes:	Math.ceil(r / 60),
				hours:		Math.ceil(r / 60 / 60),
				days:		Math.ceil(r / 60 / 60 / 24)
				};
			break;
		default:
			break;
		}
	return r;
	}
/**
 * Returns a value of the Date as number.
 * 
 * @param	string	unit	(see: Date.prototype.format)
 * @return	int
 */
Date.prototype.get = function(unit)
	{
	r = Number(this.format(unit));
	if (isNaN(r))
		{
		return 0;	
		}
	else
		{
		return r;
		}
	}
/**
 * Returns a Date object of the first day of the first week of the current year.
 * 
 * @return	Date
 */
Date.prototype.getFirstWeek = function()
	{
	var r = new Date(this.get("Y"), 0, 4);
	if (r.format("N") != 1)
		{
		r = new Date(this.get("Y"), 0, 4 - (r.get("N") - 1));
		}
	return r;
	}
/**
 * Floors the Date by a unit
 * 
 * Units:
 * "s" = set seconds to 0
 * "n" = set seconds to 0
 * "h" = set seconds and minutes to to 0
 * "d" = set time to 00:00:00
 * "w" = set date to the first day of the week and time to 00:00:00
 * "m" = set date to the first day of the month and time to 00:00:00
 * "y" = set date to 01.01. of the year and time to 00:00:00
 * 
 * <code>
 * var date = new Date(2001, 3, 7, 10, 15, 0); // sets Date to 07.04.2001 10:15:00
 * date.floor("d"); // sets Date to 07.04.2001 00:00:00
 * date.ceil("m"); 	// sets Date to 01.04.2001 00:00:00
 * </code>
 * 
 * @param	string	unit
 * @return	Date
 */
Date.prototype.floor = function(unit)
	{
	switch (unit)
		{
		case "y":
			var r = new Date(this.get("Y"), 0, 1, 0, 0, 0);
			break;
		case "m":
			var r = new Date(this.get("Y"), (this.get("n") - 1), 1, 0, 0, 0);
			break;
		case "w":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j") - (this.get("N") - 1), 0, 0, 0);
			break;
		case "d":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), 0, 0, 0);
			break;
		case "h":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), 0, 0);
			break;
		case "i":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), this.get("i"), 0);
			break;
		case "s":
			var r = new Date(this.get("Y"), this.get("n") - 1, this.get("j"), this.get("g"), this.get("i"), 0);
			break;
		}
	this.init(r.getTime());
	return r;
	}
/**
 * Sets the date and time of the Date object. This method supports several string inputs or a 
 * javascript timestamp.
 * 
 * Supported string formats are for date are DD.MM.YYYY, YYYY-MM-DD, DD-MM-YYYY, YYYY/MM/DD and  
 * DD/MM/YYYY.
 * Supported string formats are for time are HH:MM:SS and HH:MM. 
 * 
 * @param	mixed	v
 * @return 	Date
 */
Date.prototype.init = function(v)
	{
	var year 	= 0;
	var month 	= 0;
	var day		= 0;
	var hour	= 0;
	var minute	= 0;
	var second 	= 0;

	if (isNaN(v))
		{
		// DD.MM.YYYY
		var regexp = /([0-9]{2})\.([0-9]{2})\.([0-9]{4})/;
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			year 	= result[3];
			month 	= Number(result[2]) - 1;
			day		= result[1];
			}
		// YYYY-MM-DD
		var regexp = /([0-9]{4})-([0-9]{2})-([0-9]{2})/;
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			year 	= result[1];
			month 	= Number(result[2]) - 1;
			day		= result[3];
			}
		// DD-MM-YYYY
		var regexp = /([0-9]{2})-([0-9]{2})-([0-9]{4})/;
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			year 	= result[3];
			month 	= Number(result[2]) - 1;
			day		= result[1];
			}
		// YYYY/MM/DD
		var regexp = /([0-9]{4})\/([0-9]{2})\/([0-9]{2})/;
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			year 	= result[1];
			month 	= Number(result[2]) - 1;
			day		= result[3];
			}
		// DD/MM/YYYY
		var regexp = /([0-9]{2})\/([0-9]{2})\/([0-9]{4})/
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			year 	= result[3];
			month 	= Number(result[2]) - 1;
			day		= result[1];	
			}
		// HH:MM:SS
		var regexp = /([0-9]{2}):([0-9]{2}):([0-9]{2})/
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			hour 	= result[1];
			minute 	= result[2];
			second	= result[3];	
			}
		// HH:MM
		var regexp = /([0-9]{2}):([0-9]{2})/
		if (v.match(regexp))
			{
			var result 	= regexp.exec(v);
			hour 	= result[1];
			minute 	= result[2];
			}
		var ts = new Date(year, month, day, hour, minute, second).getTime();
		}
	else
		{
		var ts = v;
		}
	this.setTime(ts);
	return this;
	}
/**
 * Format a date time value like the php command date
 * 
 * Year:
 * y	a two digit representation of a year (Examples: 99 or 03)
 * Y	a full numeric representation of a year, 4 digits (Examples: 1999 or 2003)
 * L	whether it's a leap year; 1 if it is a leap year, 0 otherwise.
 * 
 * Month:
 * m	numeric representation of a month, with leading zeros (01 through 12)
 * n 	numeric representation of a month, without leading zeros (1 through 12)
 * F	a full textual representation of a month, such as January or March (January through December)
 * M	a short textual representation of a month, three letters (Jan through Dec)
 * 
 * Day:
 * d	day of the month, 2 digits with leading zeros (01 to 31)
 * j	day of the month without leading zeros (1 to 31)
 * D	a textual representation of a day, three letters (Sun through Sat)
 * l 	(lowercase 'L') a full textual representation of the day of the week (Sunday through Saturday)
 * w	numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
 * N	ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
 * z	the day of the year (0 through 365)
 * S	english ordinal suffix for the day of the month, 2 characters (st, nd, rd or th)
 * t	number of days in the given month (28 through 31)
 * 
 * Hours:
 * g	12-hour format of an hour without leading zeros (1 through 12)
 * G	24-hour format of an hour without leading zeros (0 through 23)
 * h	12-hour format of an hour with leading zeros (01 through 12)
 * H	24-hour format of an hour with leading zeros (00 through 23)
 * 
 * Minutes/Seconds/...:
 * i	minutes with leading zeros (00 to 59)
 * s	seconds, with leading zeros (00 through 59)
 * u	milliseconds (Example: 54321)
 * 
 * Timezone:
 * O	difference to Greenwich time (GMT) in hours as string (Example: +0200)
 * P	difference to Greenwich time (GMT) with colon between hours and minutes (Example: +02:00)
 * Z	timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive (-43200 through 50400)
 
 * Other:
 * a	lowercase Ante meridiem and Post meridiem (am or pm) 
 * A	uppercase Ante meridiem and Post meridim (AM or PM)
 * c	ISO 8601 date (Example: 2004-02-12T15:19:21+00:00)
 * W	ISO-8601 week number of year, weeks starting on Monday (Example: 42 (the 42nd week in the year))
 * r	RFC 2822 formatted date	(Example: Thu, 21 Dec 2000 16:01:07 +0200)
 * U	seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
 * 
 * Unsupported are: 
 * o	ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
 * e	timezone identifier (Examples: UTC, GMT, Atlantic/Azores)
 * T	timezone abbreviation (Examples: EST, MDT ...)
 * 
 * @param	string	format
 * @return	string
 */
Date.prototype.format = function(v)
	{
	var Months 			= ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	var Days			= ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
	var DaysInMonth 	= [null, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
	
	// mask the format string ("a" => "&a;")
	v = v.replace(/(\w{1})/g, "&$1;");
	
	// a	lowercase Ante meridiem and Post meridiem (am or pm) 
	if (v.search(/&a;/) != -1) v = v.replace(/&a;/g, (this.getHours() < 12) ? "am" : "pm");
	// A	uppercase Ante meridiem and Post meridim (AM or PM)
	if (v.search(/&A;/) != -1) v = v.replace(/&A;/g, (this.getHours() < 12) ? "AM" : "PM");
	// c	ISO 8601 date (Example: 2004-02-12T15:19:21+00:00)
	if (v.search(/&c;/) != -1)
		{
		// http://www.cl.cam.ac.uk/~mgk25/iso-time.html
		// ISO 8601 date (e.g.: "2004-02-12T15:19:21+00:00"), as per
		var r = this.format("Y-m-d") + "T" + this.format("H:i:sP");
		v = v.replace(/&c;/g, r);
		}
	// d	day of the month, 2 digits with leading zeros (01 to 31)
	if (v.search(/&d;/) != -1) v = v.replace(/&d;/g, (this.getDate() < 10) ? "0" + this.getDate() : this.getDate());
	// D	a textual representation of a day, three letters (Sun through Sat)
	if (v.search(/&D;/) != -1) v = v.replace(/&D;/g, Days[this.getDay()].substring(0,3));
	// F	a full textual representation of a month, such as January or March (January through December)
	if (v.search(/&F;/) != -1) v = v.replace(/&F;/g, Months[this.getMonth()]);
	// g	12-hour format of an hour without leading zeros (1 through 12)
	if (v.search(/&g;/) != -1) v = v.replace(/&g;/g, (this.getHours() <= 12) ? this.getHours() : this.getHours() - 12);
	// G	24-hour format of an hour without leading zeros (0 through 23)
	if (v.search(/&G;/) != -1) v = v.replace(/&G;/g, this.getHours());
	//  h	12-hour format of an hour with leading zeros (01 through 12)
	if (v.search(/&h;/) != -1)
		{
		var hour = this.getHours();
		hour = (hour <= 12) ? hour : hour - 12;
		hour = (hour >= 10) ? hour : "0" + hour;
		v = v.replace(/&h;/g, hour);
		}
	// H 	24-hour format of an hour with leading zeros (00 through 23)
	if (v.search(/&H;/) != -1) v = v.replace(/&H;/g, (this.getHours() >= 10) ? this.getHours() : "0" + this.getHours());
	// i	minutes with leading zeros (00 to 59) 
	if (v.search(/&i;/) != -1) v = v.replace(/&i;/g, (this.getMinutes() >= 10) ? this.getMinutes() : "0" + this.getMinutes());
	// I 	(capital i)	whether or not the date is in daylight saving time; 1 if Daylight Saving Time, 0 otherwise
	if (v.search(/&I;/) != -1) v = v.replace(/&I;/g, (new Date(this.get("Y"), 0, 1).getTimezoneOffset() == new Date().getTimezoneOffset() ? 0 : 1));
	// j	day of the month without leading zeros (1 to 31)
	if (v.search(/&j;/) != -1) v = v.replace(/&j;/g, this.getDate());
	// l 	(lowercase 'L') a full textual representation of the day of the week (Sunday through Saturday)
	if (v.search(/&l;/) != -1) v = v.replace(/&l;/g, Days[this.getDay()]);
	// L	whether it's a leap year; 1 if it is a leap year, 0 otherwise.
	if (v.search(/&L;/) != -1)
		{ 
        var year = this.get("Y");
        if ((year % 4 == 0 && year % 100 != 0) || (year % 4 == 0 && year % 100 == 0 && year % 400 == 0)) 
        	{
            v = v.replace(/&L;/g, 1);
        	}
        else 
        	{
            v = v.replace(/&L;/g, 0);
        	}
		}
	// m	numeric representation of a month, with leading zeros (01 through 12)
	if (v.search(/&m;/) != -1) v = v.replace(/&m;/g, (this.getMonth()+1 < 10) ? "0" + (this.getMonth()+1) : this.getMonth()+1);
	// M	a short textual representation of a month, three letters (Jan through Dec)
	if (v.search(/&M;/) != -1) v = v.replace(/&M;/g, Months[this.getMonth()].substring(0,3));
	// n	numeric representation of a month, without leading zeros (1 through 12)
	if (v.search(/&n;/) != -1) v = v.replace(/&n;/g, this.getMonth()+1);
	// N	ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
	if (v.search(/&N;/) != -1) v = v.replace(/&N;/g, (this.format("w") == 0 ? 7 : this.format("w")));
	// O	diffeence to Greenwich tie (GMT) in hours as string (Example: +0200)
	if (v.search(/&O;/) != -1)
    	{
        var h = String(Math.floor(Math.abs(this.getTimezoneOffset()) / 60));
        var m = String(Math.abs(this.getTimezoneOffset()) % 60);
        h.length == 1 ? h = "0" + h : 1;
        m.length == 1 ? m = "0" + m : 1;
        v = v.replace(/&O;/g, this.getTimezoneOffset() < 0 ? "+" + h + m : "-" + h + m);
    	}
    // P	Difference to Greenwich time (GMT) with colon between hours and minutes (Example: +02:00)
    if (v.search(/&P;/) != -1)
    	{
        var h = String(Math.floor(Math.abs(this.getTimezoneOffset()) / 60));
        var m = String(Math.abs(this.getTimezoneOffset()) % 60);
        h.length == 1 ? h = "0" + h : 1;
        m.length == 1 ? m = "0" + m : 1;
        v = v.replace(/&P;/g, this.getTimezoneOffset() < 0 ? "+" + h + ":" + m : "-"+ h + ":" + m);
    	}
    // r	RFC 2822 formatted date	(Example: Thu, 21 Dec 2000 16:01:07 +0200)
    if (v.search(/&r;/) != -1) v = v.replace(/&r/g, this.format("D, d M Y H:i:s O"));
	// s	seconds, with leading zeros (00 through 59)
	if (v.search(/&s;/) != -1) v = v.replace(/&s;/g, (this.getSeconds() >= 10) ? this.getSeconds() : "0" + this.getSeconds());
	// S	english ordinal suffix for the day of the month, 2 characters (st, nd, rd or th)
	if (v.search(/&S;/) != -1) 
		{
		switch (this.get("j"))
			{
			case 1:
				var r = "st";
				break;
			case 2:
				var r = "nd";
				break;
			case 3:
				var r = "rd";
				break;
			default:
				var r = "th";
				break;
			}
		v = v.replace(/&S;/g, r);
		}
	// t	number of days in the given month (28 through 31)
	if (v.search(/&t;/) != -1) v = v.replace(/&t;/g, (this.format("n") == 2 && this.format("L") == 1) ? 28 : DaysInMonth[this.format("n")]);
	// u	milliseconds (Example: 54321)
	if (v.search(/&u;/) != -1) v = v.replace(/&u;/g, (this.get("s") * 1000) + this.getMilliseconds());
	// U	seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
	if (v.search(/&U;/) != -1) v = v.replace(/&U;/g, Math.round(this.getTime() / 1000));
	// w	numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
	if (v.search(/&w;/) != -1) v = v.replace(/&w;/g, this.getDay());
	// W	ISO-8601 week number of year, weeks starting on Monday (Example: 42 (the 42nd week in the year))
	if (v.search(/&W;/) != -1) 
		{
		v = v.replace(/&W;/g, Math.floor(this.diff(this.getFirstWeek(), this.floor("d"), "d") / 7 ) + 1);
		} 
	// y	a two digit representation of a year	(Examples: 99 or 03)
	if (v.search(/&y;/) != -1) v = v.replace(/&y;/g, this.getFullYear().toString().substr(2,2));
	// Y	a full numeric representation of a year, 4 digits (Examples: 1999 or 2003)
	if (v.search(/&Y;/) != -1) v = v.replace(/&Y;/g, this.getFullYear());
	// z	the day of the year (0 through 365)
	if (v.search(/&z;/) != -1) v = v.replace(/&z;/g, Math.ceil((this - new Date(this.getFullYear(),0,1)) / 86400000)); 
	// Z	timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive (-43200 through 50400)
	if (v.search(/&Z;/) != -1) v = v.replace(/&Z;/g, (this.getTimezoneOffset () * -60)); 
	return v;
	}
/**
 * Sets a unit of the Date object
 * 
 * Units:
 * "s" = seconds of the minute
 * "i" = minutes of the hour
 * "h" = hours of the day
 * "d" = days of the month
 * "m" = months of the year
 * "y" = year
 * 
 * @param	string	unit
 * @param	value	int
 * @return	Date
 */
Date.prototype.set = function(unit, value)
	{
	switch (unit)
		{
		case "y":
			var r = new Date(value, this.get("m") - 1, this.get("d"), this.get("h"), this.get("i"), this.get("s"));
			break;
		case "m":
			var r = new Date(this.get("Y"), value - 1, this.get("d"), this.get("h"), this.get("i"), this.get("s"));
			break;
		case "d":
			var r = new Date(this.get("Y"), this.get("m") - 1, value, this.get("h"), this.get("i"), this.get("s"));
			break;
		case "h":
			var r = new Date(this.get("Y"), this.get("m") - 1, this.get("d"), value, this.get("i"), this.get("s"));
			break;
		case "i":
			var r = new Date(this.get("Y"), this.get("m") - 1, this.get("d"), this.get("h"), value, this.get("s"));
			break;
		case "s":
			var r = new Date(this.get("Y"), this.get("m") - 1, this.get("d"), this.get("h"), this.get("i"), value);
			break;
		}
	this.init(r.getTime());
	return r;
	}
/**
 * Dialog
 */
function dialog(title, body, options)
	{
	this.Id			= new guid();
	this.Body		= body;
	this.Options 	= options;
	this.Layer		= null;
	var ele 		= null;
	this.Layer = d.createElement("DIV");
	this.Layer.setAttribute("id", this.Id);
	this.Layer.setAttribute("class", "dialog_layer");
	if (isset(title) && title != "")
		{
		ele = d.createElement("DIV");
		ele.setAttribute("class", "header");
		ele.appendChild(document.createTextNode(title));
		this.Layer.appendChild(ele);
		}
	if (isset(body) && body != "")
		{
		ele = d.createElement("P");
		ele.appendChild(document.createTextNode(body));
		this.Layer.appendChild(ele);
		}
	ele = d.createElement("P");
	ele.appendChild(document.createTextNode(" "));
	this.Layer.appendChild(ele);
	ele = d.createElement("P");
	ele.appendChild(document.createTextNode(" "));
	this.Layer.appendChild(ele);
	
	var default_onclick = "d.body.removeChild(d.getElementById('" + this.Id + "')); d.body.removeChild(d.getElementById('ov" + this.Id + "'))";
	var seperator = false;	
	if (isset(this.Options.yes))
		{
		ele = d.createElement("A");
		if (isset(this.Options.target) && this.Options.target != "")
			{
			ele.setAttribute("href", "#");
			ele.setAttribute("onclick", "new ajax.request('" + this.Options.yes + "',{onSuccess: function(r) {document.getElementById('" + this.Options.target + "').innerHTML = r.responseText;}});" + default_onclick);
			}
		else
			{
			ele.setAttribute("href", this.Options.yes);	
			}
		ele.appendChild(document.createTextNode("Ja"));
		this.Layer.appendChild(ele);
		seperator = true;
		}

	if (isset(this.Options.no))
		{
		if (seperator)
			{
			ele = d.createElement("SPAN");
			ele.appendChild(document.createTextNode(" | "));
			this.Layer.appendChild(ele);
			}
		
		ele = d.createElement("A");
		if (isset(this.Options.target) && this.Options.target != "")
			{
			ele.setAttribute("href", "#");
			ele.setAttribute("onclick", "void new ajax.request('" + this.Options.no + "',{onSuccess: function(r) {document.getElementById('" + this.Options.target + "').innerHTML = r.responseText;}});" + default_onclick);
			}
		else
			{
			ele.setAttribute("href", this.Options.no);	
			}
		ele.appendChild(document.createTextNode("Nein"));
		this.Layer.appendChild(ele);
		}
		
	if (isset(this.Options.cancel))
		{
		if (seperator)
			{
			ele = d.createElement("SPAN");
			ele.appendChild(document.createTextNode(" | "));
			this.Layer.appendChild(ele);
			}
		ele = d.createElement("A");
		ele.setAttribute("href", "#");
		ele.setAttribute("onclick", default_onclick);
		ele.appendChild(document.createTextNode("Abbrechen"));
		this.Layer.appendChild(ele);
		}
	ele = d.createElement("P");
	ele.appendChild(document.createTextNode(" "));
	this.Layer.appendChild(ele);
	
	d.body.appendChild(this.Layer);
	
	// Option: position
	if (isset(this.Options.position))
		{
		switch(this.Options.position)
			{
			case "center":
				new e(this.Id).center();
				break;
			case "mouse":
				new e(this.Id).position(mouse.PosX, mouse.PosY);
				break;
			}
		}
	// Option: overlay
	if (isset(this.Options.overlay) && this.Options.overlay)
		{
		ele = d.createElement("DIV");
		ele.setAttribute("id", "ov" + this.Id);
		ele.setAttribute("class", "dialog_overlay");
		d.body.appendChild(ele);
		var height = (all.Height > mouse.WindowY) ? all.Height : mouse.WindowY;
		height += mouse.ScrolledY; 
		var width = (all.Width > mouse.WindowX) ? all.Width : mouse.WindowX;
		width += mouse.ScrolledX;
		var ov = new e("ov" + this.Id);
		ov.resize(width, height);
		}
	}

/**
 * Base HTML element object
 *
 * @param	string	v	Id of the element
 * @return	bool
 */
function e(v)
	{
	this.Height		= 0;
	this.Width		= 0;
	this.PosX		= 0;
	this.PosY		= 0;
	this._init(v);
	}
	/**
	 * Initialises the html element
	 *
	 * @return 	void
	 */
	e.prototype._init = function(v)
		{
		this.Element = document.getElementById(v);
		if (isset(this.Element))
			{
			this.Id 	= this.Element.id;
			this.Name 	= this.Element.name;
			this.Type	= this.Element.tagName.toLowerCase();
			this.dimension();
			this.position();
			}
		}
	/**
	 * Centers the element on the page or within a other html element
	 *
	 * @return 	bool
	 */
	e.prototype.center = function(center_on)
		{
		if (isset(center_on))
			{
			var container = new e(center_on);
			var pos_left 	= container.PosX + ((container.Width - this.Width) / 2); 
			var pos_top 	= container.PosY + ((container.Height - this.Height) / 2);
			}
		else
			{
			var pos_left = ((mouse.WindowX - this.Width) / 2) + mouse.ScrolledX;
			var pos_top = ((mouse.WindowY - this.Height) / 2) + mouse.ScrolledY;
			}
		if (this.Element)
			{
			return this.position(pos_left, pos_top);	
			}
		else
			{
			return false;
			}
		}
	/**
	 * Returns or set the dimension of the element
	 * 
	 * @return	array 
	 */
	e.prototype.dimension = function(width, height)
		{
		if (isset(this.Element))
			{
			// set dimensions 
			if (isset(width) && isset(height))
				{
				this.Element.style.width 	= width + "px";
				this.Element.style.height 	= height + "px";
				this.Width 					= width;
				this.Height 				= height;
				return true;
				}
			// return dimension
			else
				{
				
				if (browser() != "ie" && (this.style("display") == "none" || this.style("display") == ""))
					{
				    var visibility 					= this.Element.style.visibility;
				    var position 					= this.Element.style.position;
				    var display 					= this.Element.style.display;
				    this.Element.style.visibility 	= "hidden";
				    this.Element.style.position 	= "absolute";
				    this.Element.style.display 		= "block";
				    this.Width 						= this.Element.clientWidth;
				    this.Height 					= this.Element.clientHeight;
				    this.Element.style.display 		= visibility;
				    this.Element.style.position 	= position;
				    this.Element.style.visibility 	= display;
					}
				else
					{
					this.Width	= this.Element.clientWidth;
			    	this.Height = this.Element.clientHeight;
					}
				return [this.Width, this.Height];
				}
			}
		else
			{
			this.Width 	= 0;
			this.Height = 0;
			return false;
			}
		}
	/**
	 *  Disable this element
	 */
	 e.prototype.disable = function()
	 	{
	 	if (this.Element && isset(this.Element.disabled))
	 		{
	 		this.Element.disabled = true;
	 		return true;
	 		}
	 	else
	 		{
	 		return false;
	 		}
	 	}
	/**
	 * Enable this element
	 * 
	 * @return 	bool
	 */
	 e.prototype.enable = function()
	 	{
	 	if (this.Element && isset(this.Element.disabled))
	 		{
	 		this.Element.disabled = false;
	 		return true;
	 		}
	 	else
	 		{
	 		return false;
	 		}
	 	}
	/**
	 * Hide element
	 *
	 * @return 	bool
	 */
	e.prototype.hide = function()
		{
		if (isset(this.Element))
			{
			this.Element.style.visibility	= "hidden";
			this.Element.style.display		= "none";
			return true;
			}
		else
			{
			return false;
			}
		}
	/**
 	 * Sets the opacity of an element
 	 *
 	 * @param	int		v	opacity
 	 * @return 	bool
 	 */
	e.prototype.opacity = function(v)
		{
		if (isset(this.Element))
			{
			this.Element.style.opacity = (v == 1 || v === '') ? '' : (v < 0.00001) ? 0 : v;
			return true;
			}
		else
			{
			return false;
			}
		}
	/**
 	 * Sets or returns the absolute position of an element
 	 *
 	 * @param	int	left
 	 * @param	int	top
 	 * @return 	bool
 	 */
	e.prototype.position = function(left, top)
		{
		if (this.Element)
			{
			// get position
			if (isset(left) && isset(top))
				{
				this.Element.style.left = left + "px";
				this.Element.style.top	= top + "px";
				this.PosX	= left;
			    this.PosY	= top;
				return true;					
				}
			// return position
			else
				{
				var left 	= 0;
				var top 	= 0;
				var obj 	= this.Element;
				if (obj.offsetParent) 
					{
					left	= obj.offsetLeft;
					top 	= obj.offsetTop;
					while (obj = obj.offsetParent) 
						{
						left	+= obj.offsetLeft;
						top		+= obj.offsetTop;
						}
					}
			    this.PosX	= left;
			    this.PosY	= top;
				return [this.PosX, this.PosY];
				}
			}
		else
			{
			return false;
			}
		}
	/**
 	 * Replace the content of an element
 	 *
 	 * @param	string	v
 	 * @return bool
 	 */
	e.prototype.replace = function(v)
		{
		if (this.Element && isset(v))
			{
			this.Element.innerHTML = v;
			return true;				
			}
		else
			{
			return false;
			}
		}
	/**
 	 * Resize an element
 	 *
 	 * @param	int		x
 	 * @param	int 	y
 	 * @return bool
 	 */
	e.prototype.resize = function(width, height)
		{
		return this.dimension(width, height);
		}
	/**
 	 * Show element
 	 *
 	 * @return 	bool
 	 */
	e.prototype.show = function()
		{
		if (isset(this.Element))
			{
			this.Element.style.visibility	= "visible";
			this.Element.style.display		= "block";
			return true;
			}
		else
			{
			return false;
			}
		}
	/**
	 * Sets or return a style of the element
	 * 
	 * @param	string	i	Style attribute of the element
	 * @param	string	v	Value of the style attribute
	 * @return	mixed
	 */
	e.prototype.style = function(i, v)
		{
		if (isset(this.Element) && isset(i))
			{
			// get style property
			if (!isset(v))
				{
				return this.Element.style[i];
				}
			// set style property
			else
				{
				this.Element.style[i] = v;
				return true;
				}
			}
		}
	/**
 	 * Toggle the visibility of the element
 	 *
 	 * @return	bool
 	 */
	e.prototype.toggle = function()
		{
		if (this.Element)
			{
			switch (this.Element.style.visibility)
				{
				case "":
				case "visible":
					return this.hide();
					break;
				case "hidden":
					return this.show();
					break;
				}
			return true;
			}
		return false;
		}
	/**
 	 * Update the content of the element
 	 *
 	 * @return	bool
 	 */
	e.prototype.update = function(v)
		{
		if (isset(this.Element) && isset(this.Element.innerHTML))
			{
			this.Element.innerHTML = v; 
			return true;
			}
		return false;
		}
/**
 * Input HTML element object
 *
 * @param	string	v	Id of the element
 * @return	void
 */
e.checkbox = function(v)
	{
	this._init(v);
	this.Value		= this.Element.value;
	this.Checked	= this.Element.checked;
	}
	/**
	 * extends e
	 */
	e.checkbox.prototype = new e();
	/**
	 * Checks the checkbox
	 */
	e.checkbox.prototype.check = function()
		{
		this.Element.checked = true;
		this.Checked = true;
		}
	/**
	 * Unchecks the checkbox
	 */
	e.checkbox.prototype.uncheck = function()
		{
		this.Element.checked = false;
		this.Checked = false;
		}
/**
 * Form HTML element object
 *
 * @param	string	v	Id of the element
 * @return	void
 */
e.form = function(v)
	{
	this._init(v);
	this.Count 	= this.Element.length;
	this.Fields = Array();
	this.Post	= "";
	for (i = 0; i <= this.Element.length -1; i++)
		{
		var skip = false;		
		var ele = this.Element.elements[i];
		switch (ele.tagName)
			{
			case "INPUT":
				switch (ele.type)
					{
					case "checkbox":
						this.Fields[i] = new e.checkbox(ele.id);
					case "radio":
						//
						break;
					case "button":
						skip = true;
						break;
					default:
						this.Fields[i] = new e.input(ele.id);
						break;
					}
				break;
			case "SELECT":
				this.Fields[i] = new e.select(ele.id);
				break;
			default:
				break;
			}
		if (!skip)
			{
			if (this.Post != "") this.Post += "&"; 
			if (isset(this.Fields[i].Checked) && !this.Fields[i].Checked)
				{
				this.Post += this.Fields[i].Name + "=";
				}
			else
				{
				this.Post += this.Fields[i].Name + "=" + encodeURI(this.Fields[i].Value);
				}
			}
		}
	}
	/**
	 * extends e
	 */
	e.form.prototype = new e();
		
	
/**
 * Input HTML element object
 *
 * @param	string	v	Id of the element
 * @return	void
 */
e.input = function(v)
	{
	this._init(v);
	this.Value		= this.Element.value;
	}
	/**
	 * extends e
	 */
	e.input.prototype = new e();
	/**
 	 * Sets the value of the input element
 	 *
 	 * @param	string	v	value
 	 * @return	mixed
 	 */
	e.input.prototype.value = function(v)
		{
		if (isset(this.Element) && isset(v))
			{
			this.Element.value 	= v;
			this.Value 			= v;
			return true;
			}
		else if (isset(this.Element.value) && !isset(v))
			{
			return this.Element.value;
			}
		else
			{
			return false;
			}
		}
/**
 * Select HTML element object
 *
 * @param	string	v	Id of the select element
 * @return	bool
 */
e.select = function(v)
	{
	this._init(v);
	this.Options 	= this.Element.options;
	this.Count		= this.Element.options.length;
	this.Index		= this.Element.selectedIndex;
	this.Value		= this.Options[this.Index].value;
	this.Text		= this.Options[this.Index].text;
	}
	/**
	 * extends e
	 */
	e.select.prototype = new e();
	/**
	 * Adds a option to the select element
	 * 
	 * @param	string	text		Text of the new option
	 * @param	mixed	value		Value of the new option
	 * @param	bool	selected	Is the new option selected
	 * @param	bool	is_default	Is the new option default selected
	 * @return	int					Index of the new option
	 */
	e.select.prototype.add = function(text, value, selected, is_default)
		{
		if (isset(this.Element) && isset(text) && isset(value))
			{
			var i = (this.Count == 0) ? 0 : this.Count;
			if (!isset(is_default)) is_default = false;
			if (!isset(selected)) selected = false;
			this.Options[i] = new Option(text, value, is_default, selected);
			this.Count++;
			return i;
			}
		else
			{
			return false;
			}
		}
	/**
	 * Clears all options of the select element
	 * 
	 * @return	bool
	 */
	e.select.prototype.clear = function ()
	 	{
	 	if (isset(this.Element))
	 		{
	 		this.Element.options.length = 0;
	 		this.Count = 0;
	 		return true;
	 		}
	 	else
	 		{
	 		return false;
	 		}
	 	}
	/**
	 * Removes a option of the select element
	 * 
	 * @param	int		i 		Index of the option	
	 * @return	bool
	 */
	e.select.prototype.remove = function (i)
	 	{
	 	if (isset(this.Element) && isset(this.Options[i]))
	 		{
	 		this.Options[i] = null;
	 		this.Count--;
	 		return true;
	 		}
	 	else
	 		{
	 		return false;
	 		}
	 	}
	/**
	 * Selects a option of the select element
	 * 
	 * @param	int		i 		Index of the option	
	 * @return	bool
	 */
	e.select.prototype.select = function (i)
	 	{
	 	if (isset(this.Element) && isset(this.Options[i]))
	 		{
	 		this.Options[i].selected = true;
	 		return true;
	 		}
	 	else
	 		{
	 		return false;
	 		}
	 	}
/**
 * 
 */
Function.prototype.bind = function()
	{
  	var __method 	= this;
  	var object 		= arguments[0];
  	return function()
  		{
    	return __method.apply(object);
  		}
	}
/**
 * Creates a pseudo random guid
 *
 * @return	string
 */
guid = function()
	{
	this.Seed 	= "";
	this.id 	= this.create();
	}
	/**
	 * Return the guid
	 *
	 * @return 	string
	 */
	guid.prototype.valueOf = function()
		{
		return this.id;
		}
	/**
	 * Return the guid 
	 *
	 * @return 	string
	 */
	guid.prototype.toString = function()
		{
		return this.id;
		}
	/**
	 * Creates the guid
	 *
	 * @return 	string
	 */
	guid.prototype.create = function()
		{
		if (isset(mouse.Seed))
			{
			this.Seed = mouse.Seed;			
			}
		else
			{
			this.Seed = rand(0,Math.pow(8,8)*16);
			}
		return this.token(4) + this.token(4) + 
			"-" + this.token(4) + 
			"-" + this.token(4) + 
			"-" + this.token(4) + 
			"-" + this.token(4) + this.token(4) + this.token(4);
		}
	/**
	 * Randomises the current seed and returns a hex token
	 *
	 * @return 	string
	 */	
	guid.prototype.token = function(amount)
		{
		seed = this.Seed ^ rand(0,Math.pow(10, this.Seed.length));
		seed = dec_hex(seed);
		//r = seed.substr(0,amount);
		r = seed.substring(seed.length-(amount+1),seed.length-1);
		return r;
		}

/**
 * Validation object
 * 
 * <code>
 * var is_valid = new validate
 * 		(
 * 		new e.input('myinput'),
 * 		new Array
 * 			(
 * 			new validate.min(10), 
 * 			new validate,max(12)
 * 			)
 * 		).validate();
 * </code>
 * 
 * @param	element		e
 * @param	array		validations
 * @return	bool
 */
validate = function (e, validations)
	{
	this.Element 		= e;
	this.Validations 	= validations;
	this.Valid 			= true;
	}
	validate.prototype.validate = function()
		{
		if (isset(this.Element.Value))
			{
			for(var i in this.Validations) 
				{
				if (!this.Validations[i].validate(this.Element.Value))
					{
					this.Valid = false;
					}
				}
			}
		else
			{
			this.Valid = false;
			}
		return this.Valid;
		}
/**
 * Validate datetime 
 * 
 * @return	bool
 */
validate.date = function(format)
	{
	this.Format = format;
	this.RegExp = new Array();
	this.RegExp[1] = /^\d{2}\.\d{2}.\d{4}$/;
	this.RegExp[2] = /^\d{2}\.\d{2}.\d{4} \d{2}:\d{2}$/;
	this.RegExp[3] = /^\d{2}\.\d{2}.\d{4} \d{2}:\d{2}:\d{2}$/;
	}
	validate.date.prototype.validate = function(v)
		{
		var regexp =  this.RegExp[this.Format];
		if (isset(v) && regexp.test(v))
			{
			return true;
			}
		else
			{
			return false;
			}
		}
/**
 * Validate is email 
 * 
 * @return	bool
 */
validate.email = function(v) { }
	validate.email.prototype.validate = function(v)
		{
		var regexp = /^\w[\w|\.|\-]+@\w[\w|\.|\-]+\.[a-zA-Z]{2,4}$/;
		if (isset(v) && regexp.test(v))
			{
			return true;
			}
		else
			{
			return false;
			}
		}
/**
 * Validate maximum lenght 
 * 
 * @param	int		v
 * @return	bool
 */
validate.max = function(v)
	{
	this.Max = v;
	}
	validate.max.prototype.validate = function(v)
		{
		if (isset(v) && v.length <= this.Max)
			{
			return true;
			}
		else
			{
			return false;
			}
		}
/**
 * Validate minimum lenght 
 * 
 * @param	int		v
 * @return	bool
 */
validate.min = function(v)
	{
	this.Min = v;
	}
	validate.min.prototype.validate = function(v)
		{
		if (isset(v) && v.length >= this.Min)
			{
			return true;
			}
		else
			{
			return false;
			}
		}
/**
 * Mouse object
 *
 * Deliveres current mouse position and page offset
 */
function mouse(x)
	{
	this.PosX 		= 0;
	this.PosY 		= 0;
	this.ScrolledX 	= 0;
	this.ScrolledY 	= 0;
	this.WindowX	= 0;
	this.WindowY	= 0;
	this.Seed		= Math.round(new Date().getTime() / 1000);
	}
	/**
	 * Updates the mouse position and page offset
	 * 
	 * @param	event	e
	 * @return 	void
	 */
	mouse.prototype.update = function(e)
		{
		// get current mouse position
		if(document.all ? true : false)
			{
			this.PosX = event.clientX;
			this.PosY = event.clientY;
			}
		else
			{
			this.PosX = e.pageX;
			this.PosY = e.pageY;
			}
		// get page scrolling
		if (self.pageYOffset)
			{
	   		this.ScrolledX = self.pageXOffset;
	   		this.ScrolledY = self.pageYOffset;
	   		}
		else if (document.documentElement && document.documentElement.scrollTop)
			{
	   		this.ScrolledX = document.documentElement.scrollLeft;
	   		this.ScrolledY = document.documentElement.scrollTop;
	   		}
		else if (document.body)
			{
	   		this.ScrolledX = document.body.scrollLeft;
	   		this.ScrolledY = document.body.scrollTop;
	   		}
	   	// get window size
  		if( typeof( window.innerWidth ) == 'number' )
  			{
    		//Non-IE
    		this.WindowX = window.innerWidth;
    		this.WindowY = window.innerHeight;
  			}
  		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  			{
    		//IE 6+ in 'standards compliant mode'
    		this.WindowX = document.documentElement.clientWidth;
    		this.WindowY = document.documentElement.clientHeight;
  			}
  		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  			{
    		//IE 4 compatible
    		this.WindowX = document.body.clientWidth;
    		this.WindowY = document.body.clientHeight;
  			}
  		//this.Seed = this.Seed ^ (new Date().getTime() / 1000) & (this.PosX * this.PosY * rand(256*4, 256*8)) & rand(0,this.Seed);
  		var seed = this.Seed ^ this.PosX * this.PosY * rand(256*4, 256*8);
  		
  		seed = seed.toString();
  		if (seed.length > 8)
  			{
  			seed = seed.substring(seed.length-9, seed.length-1);
  			}
  		else if (seed.length < 8)
  			{
  			for (i = 0; i <= 8 - seed.lenght; i++)
  				{
  				seed = "0" + seed;
  				}
  			}
  		this.Seed = seed;
		}
/**
 * Requester object
 *
 * Representation of the php requester class
 */
function requester()
	{
	this.Action 	= 1;
	this.Target 	= 0;
	this.Type 		= 0;
	this.Ref		= 0;
	this.Category 	= 0;
	this.Index		= 0;
	this.Count		= 0;
	this.Profile	= "";
	this.Option 	= 0;
	this.Search		= "";
	}
	requester.prototype.reset = function()
		{
		this.Action 	= 1;
		this.Target 	= 0;
		this.Type 		= 0;
		this.Ref		= 0;
		this.Category 	= 0;
		this.Index		= 0;
		this.Count		= 0;
		this.Profile	= "";
		this.Option 	= 0;
		this.Search		= "";
		}
	requester.prototype.create = function()
		{
		this.reset();
		var query_string = window.location.href.substring((window.location.href.indexOf('?') + 1));
		var params = query_string.split("&");
		for(var i = 0; i < params.length; i++)
			{
			var tmp = params[i].split("=");
			switch (tmp[0])
				{
				case "a":
					this.Action 	= tmp[1];
					break;
				case "t":
					this.Target 	= tmp[1];
					break;
				case "y":
					this.Type 		= tmp[1];
					break;
				case "r":
					this.Ref		= tmp[1];
					break;
				case "c":
					this.Category	= tmp[1];
					break;
				case "i":
					this.Index		 = tmp[1];
					break;
				case "n":
					this.Count		 = tmp[1];
					break;
				case "p":
					this.Profile	 = tmp[1];
					break;
				case "s":
					this.Search		 = tmp[1];
					break;
				case "o":
					this.option		 = tmp[1];
					break;
				}
			}
		}
	requester.prototype.url = function()
		{
		return "?a=" + this.Action + "&t=" + this.Target + "&y=" + this.Type + "&r=" + this.Ref + "&c=" + this.Category + "&i=" + this.Index + "&n=" + this.Count + "&p=" + this.Profile + "&o=" + this.Option + "&s=" + this.Search;
		}
