
if ( typeof red === "undefined" ){


	var red = new Function();
   
	red.prototype = {
						
		version : "0.1",
		
		path : '',
		
		setpath : function(path){
			red.prototype.path = path;
		
		},
				
		browser : null,
		
		browserversion : null,
		
		boxmodel : null,
		
		os : null,
						
		screenxy : null,
		
		availscreenxy : null,
						
		pagexy : function(){
			return [document.body.scrollWidth,document.body.scrollHeight];
		},
		
		viewportxy : function(){
			var doc = document.documentElement;
			return [self.innerWidth || (doc && doc.clientWidth) || document.body.clientWidth,
					self.innerHeight || (doc && doc.clientHeight) || document.body.clientHeight];
		},
		
		f_clientWidth : function() {
			return red.prototype.f_filterResults (
			window.innerWidth ? window.innerWidth : 0,
			document.documentElement ? document.documentElement.clientWidth : 0,
			document.body ? document.body.clientWidth : 0
			);
		},
		
		f_clientHeight : function() {
			return red.prototype.f_filterResults (
			window.innerHeight ? window.innerHeight : 0,
			document.documentElement ? document.documentElement.clientHeight : 0,
			document.body ? document.body.clientHeight : 0
			);
		},
		
		f_scrollLeft : function() {
			return red.prototype.f_filterResults (
			window.pageXOffset ? window.pageXOffset : 0,
			document.documentElement ? document.documentElement.scrollLeft : 0,
			document.body ? document.body.scrollLeft : 0
			);
		},
		
		f_scrollTop : function() {
			return red.prototype.f_filterResults (
			window.pageYOffset ? window.pageYOffset : 0,
			document.documentElement ? document.documentElement.scrollTop : 0,
			document.body ? document.body.scrollTop : 0
			);
		},
		
		f_filterResults : function(n_win, n_docel, n_body) {
			var n_result = n_win ? n_win : 0;
			if (n_docel && (!n_result || (n_result > n_docel)))
			n_result = n_docel;
			return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
		},
		
		is_array : function(object) {
			return object && object.constructor === Array;
		},		
		
		is_boolean: function(o) {
			return typeof o === 'boolean';
		},

		is_function: function(o) {
			return typeof o === 'function';
		},

		is_null: function(o) {
			return o === null;
		},

		is_number: function(o) {
			return typeof o === 'number' && isFinite(o);
		},

		is_object: function(o) {
			return (o && (typeof o === 'object' || red.prototype.is_function(o))) || false;
		},

		is_string: function(o) {
			return typeof o === 'string';
		},

		is_undefined: function(o) {
			return typeof o === 'undefined';
		},
		
		/**
		*   getType
		*   Use this when typeof returns 'Object'.
		*   @param mixed $obj The object to investigrate.
		*   @return string The object's constructor.
		*   @author Josh Zerin, Life Blue Media (http://www.lifeblue.com/)
		*   @author Special thanks to:
		*       - gits
		*       - iam_clint
		*       - volectricity
		*       - Purple
		*   http://www.thescripts.com/
		*/
		gettype : function($obj){
		    if( typeof $obj == 'undefined' ){
		        return 'undefined';
		    }
		        
		    if($obj === null){
		        return 'null';
		    }
		    
		    switch($obj.constructor){
		        case Array:
		            return 'Array';
		        case Boolean:
		            return 'Boolean';
		        case Date:
		            return 'Date';
		        case Error:
		            return 'Error';
		        case Function:
		            return 'Function';
		        case Number:
		            return 'Number';
		        case RegExp:
		            return 'RegExp';
		        case String:
		            return 'String';
		        default:
		      
				if( typeof($obj.nodeType) != 'undefined' ){
					return 'HTML ' + $obj.nodeName.toUpperCase() + ' Element';
				}
		        
				if($obj.toString){
					if($obj.toString().match('Event')){
						return 'Event';
					}
				}
				return 'Object';
		    }
		},
		 
		/**
		*
		*   print_r
		*   Similar to the PHP function of the same name, except it always returns its output (I never liked that about PHP's print_r()).
		*   @param mixed $content The variable you're trying to print_r.  Generally an object or array.
		*   @param bool $htmlEncode How to format the output:
		*       - true:     Use <br /> for line breaks, and &nbsp; for tabs.
		*       - false:    Use \n for line breaks and \t for tabs.
		*   @param string $basePrefix The base prefix that will be appended to all lines of output.  Very useful if you need your debug output to all line up (and something that REALLY bugs me about PHP's print_r()!).
		*   @param string $_prefix (internal)
		*   @return string A print_r()'ed string, similar in format to the PHP function of the same name (but with a few enhancements ~_^).
		*   @author Josh Zerin, Life Blue Media (http://www.lifeblue.com/)
		*   @author Special thanks to:
		*       - gits
		*       - iam_clint
		*       - volectricity
		*       - Purple
		*   http://www.thescripts.com/
		*/
		print_r : function($content, $htmlEncode, $basePrefix, $_prefix){
		    if( ! $_prefix ){
		        $_prefix = '';
		    }
		       
		    if( ! $basePrefix ){
		        $basePrefix =
		        (
		            // If $_prefix is defined, we'll just use that.
		            $_prefix
		                ? $_prefix
		                :
		                (
		                    // Otherwise, use a default.
		                    $htmlEncode
		                        ? '&nbsp;&nbsp;&nbsp;&nbsp;'
		                        : '\t'
		                )
		        );
		    }
		    var $newLine = ($htmlEncode ? '<br />' : '') + '\n';
		    
		    var $retVal = '';
		    var $blacklistDisplayType =
		    {
		        'null':         true,
		        'Array':        true,
		        'Object':       true,
		        'undefined':    true
		    }
		    var $myType = red.prototype.gettype($content);
		    var $subType = '';
		  
			if( $myType == 'Array' ){
		        // E.g., "Array:\n\t(\n"
		        $retVal += $myType + ':' + $newLine + $_prefix + '(' + $newLine;
		        var $close = $_prefix + ')' + $newLine;
		        $_prefix += $basePrefix;
		        
		        for( var $i = 0; $i < $content.length; ++$i ){
		            var $innerType = red.prototype.gettype($content[$i]);
		            
		            // E.g., "\t\t0 => (Number) "
		            $retVal += $_prefix + $i + ' => ' +
		            (
		                $blacklistDisplayType[$innerType]
		                    ? ''
		                    : ' (' + red.prototype.gettype($content[$i]) + ')'
		            ) + ' ';
		            
		            if(($innerType == 'Array') || ($innerType == 'Object')){
		                $retVal +=
		                    red.prototype.print_r
		                    (
		                        $content[$i],
		                        $htmlEncode,
		                        $basePrefix,
		                        $_prefix
		                    );
		            }
		            else
		            {
		                $retVal += $content[$i] + $newLine;
		            }
		        }
		        
		        // E.g., "\t)\n"
		        $retVal += $close;
		    }
		    else if( $myType == 'Object' ){
		        $retVal += $myType + ':' + $newLine + $_prefix + '(' + $newLine;
		        var $close = $_prefix + ')' + $newLine;
		        $_prefix += $basePrefix;
		            
		        for( $i in $content ){
		            var $innerType = red.prototype.gettype($content[$i]);
		            $retVal += $_prefix + $i + ' => ' +
		            (
		                $blacklistDisplayType[$innerType]
		                    ? ''
		                    : ' (' + red.prototype.gettype($content[$i]) + ')'
		            ) + ' ';
		            
		            if( ($innerType == 'Array') || ($innerType == 'Object') ){
		                $retVal +=
		                    red.prototype.print_r
		                    (
		                        $content[$i],
		                        $htmlEncode,
		                        $basePrefix,
		                        $_prefix
		                    );
		            }
		            else{
		                $retVal += $content[$i] + $newLine;
		            }
		        }
		        
		        $retVal += $close;
		    }
		    else{
		        $retVal += $content;
		    }
		    return $retVal;
		},
		
		randint : function (min,max){
			var div = (max - min) + 1
			var randNum = Math.random()
			for (var i = 0; i <= div - 1; i++){
				if (randNum >= i / div && randNum < (i+1) / div){return i + min};
			}
		},
		
		format : function(content){
			if(red.prototype.is_string(content)){
				return content;
			}
			else if(red.prototype.is_number(content)){
				return ''+content+'';
			}
			else if(red.prototype.is_function(content)){
				return content();
			}
			else if(red.prototype.is_object(content)){
				return content;
			}
			else if(red.prototype.is_array(content)){
				return red.prototype.print_r(content);
			}
			else if(red.prototype.is_boolean(content)){
				if(content){return '1';}
				else{return '0';}
			}
			else{
				return '';
			}
		},
		
		trim : function(str){
			return str.replace(/^\s*|\s*$/g,'');
		}
		
			
	
	};
	
	red.prototype.array = {
		
		/* hängt ein array an ein anderes, lässt keine doppelten werte zu, wenn doppelte = false */
		/* zuerst das array was angehängt werden soll */
		
		push : function(array,altarray,doppelte){
			if(doppelte == null){doppelte = false;}
			for(var i=0;i<array.length;i++){
				if(doppelte == false){
					if(!red.prototype.array.in_array(altarray,array[i])){
						altarray[altarray.length] = array[i];
					}
				}
				else{
					altarray[altarray.length] = array[i];
				}
			}
			return altarray;
		},
		
		/* löscht werte aus einem array in einem anderen */
		/* zuerst das array was gelöscht werden soll */
		
		remove : function(array,altarray){
			var neuarray = new Array();
			var j=0;
			for(var i=0;i<altarray.length;i++){
				if(!red.prototype.array.in_array(array,altarray[i])){
					neuarray[j] = altarray[i];
					j++;
				}
			}
			return neuarray;
		},		
				
		in_array : function(array,wert,key){
			if((array == null) || (!red.prototype.is_array(array)) || (!red.prototype.is_object(array))){
				return false;
			}
									
			for(var i=0;i<array.length;i++){
				if(key == null){	
					if(array[i] == wert){
						return array[i];
					}
				}
				else{
					if(array[i][key] == wert){
						return array[i];
					}
				}
			}
			return false;
		},
						
		foreach : function(f) {
			for(i=0; i < this.length; i++) f(this[i]);
		}
				
		
		
	};
	
}


(function() {
	var n = navigator.userAgent.toLowerCase();

	var that = red.prototype;
	if (/msie/.test(n) && !/opera/.test(n)) {
		that.browser = "IE";
	} 
	else if (/safari/.test(n)) {
		that.browser = "Safari";
	} 
	else if (/firefox/.test(n)) {
		that.browser = "Firefox";
	} 
	else if (/!webkit|firefox/.test(n) && /mozilla/.test(n)) {
		that.browser = "Mozilla";
	} 
	else if (/netscape/.test(n)) {
		that.browser = "Netscape";
	} 
	else if (/opera/.test(n)) {
		that.browser = "Opera";
	} 
	else if (/khtml/.test(n)) {
		that.browser = "KHTML";
	} 
	else if (/webkit/.test(n)) {
		that.browser = "Webkit";
	}
	var p = navigator.platform.toLowerCase();

	if (/bsd/.test(p)) {
		that.os = "BSD";
	} 
	else if (/linux/.test(p)) {
		that.os = "Linux";
	} 
	else if (/mac/.test(p)) {
		that.os = "Mac";
	} 
	else if (/sunos/.test(p)) {
		that.os = "Solaris";
	} 
	else if (/win/.test(p)) {
		that.os = "Windows";
	}

	that.bv = navigator.appVersion; 
	that.ba = navigator.userAgent;
	that.bName = "";
	that.bNamePos = 0;
	if (that.browser == "IE") {
		that.vPos = that.ba.indexOf("MSIE");
		that.browserversion = parseFloat(that.ba.substring(that.vPos+5));
	} 
	else if (that.browser == "Opera") {
		that.vPos = that.ba.indexOf("Opera");
		that.browserversion = parseFloat(that.ba.substring(that.vPos+6));
	}
	else if (that.browser == "Safari") {
		that.tempBv = "";
		that.bNamePos = that.ba.lastIndexOf(' ') + 1;
		that.vPos = that.ba.lastIndexOf('/');
		that.tempBv = parseFloat(that.ba.substring(that.vPos + 1));
		if (that.tempBv < 86) {
			that.browserversion = 1;
		} 
		else if (that.tempBv > 99 && that.tempBv < 100.1) {
			that.browserversion = 1.1;
		} 
		else if (that.tempBv > 124 && that.tempBv < 126) {
			that.browserversion = 1.2;
		} 
		else if (that.tempBv > 311 && that.tempBv < 313) {
			that.browserversion = 1.3;
		} 
		else if (that.tempBv > 412 && that.tempBv < 500) {
			that.browserversion = 2;
		} 
		else if (that.tempBv > 500) {
			that.browserversion = 3;
		}
	} 
	else if ((that.bNamePos = that.ba.lastIndexOf(' ') + 1) < (that.vPos = that.ba.lastIndexOf('/'))) {
		that.browser = that.ba.substring(that.bNamePos, that.vPos);
		that.browserversion = parseFloat(that.ba.substring(that.vPos + 1));
	}
	that.boxmodel = "";
	that.browser != "IE" || document.compatMode == "CSS1Compat" ? that.boxmodel = true : that.boxmodel = false;
		
	that.screenxy 			= [screen.width,screen.height];
	that.availscreenxy 		= [screen.availWidth,screen.availHeight];
	
		
	
})();

