/*
Thiago amaral soalheiro

Adekz.com

Copyright © 2006.

É expressamente proibida a copia parcial ou total de qualquer parte desse arquivo.

Versao 2.0 - 23/10/2006*/

function is_object(x){
	return (typeof(x)=="object");
}
function alerta(x){
	document.write(x);
}
function alerta2(x){
	document.getElementById('tar').value+=x;
}
function space(sn){
	var out="";
	for(var i=0; i<sn;i++) out+="&nbsp;";
	return out;
}
function Obj(){
	this.D = Array();
	this.Ds= Array();
	this.add= function (key, val){
		if (this.Ds[key]==1){
			this.addAsArray(key, val);	
		}else if (this.Ds[key]==2){
			this.addInArray(key, val);	
		}else{
			this.addVal(key, val);	
		}
	}
	this.addVal=function (key, val){
		this.D[key]=val;
		this.Ds[key]=1;
	}
	this.addAsArray=function (key, val){
		var A = new Array();
		A[0]=this.D[key];
		A[1]=val;
		this.D[key]=A;
		this.Ds[key]=2;
	}
	this.addInArray=function (key, val){
		this.D[key][this.D[key].length]=val;
	}

	this.existe= function (key){
		return (this.Ds[key]==1 || this.Ds[key]==2);
	}

	this.isArray=function (key){
		return (this.Ds[key]==2);
	}
	this.size=function (key){
		if (!this.existe(key)) return 0;
		if (!this.isArray(key)) return 1;
		return this.D[key].length;
	}
	
	this.get= function (key){
		if(!this.existe(key)) return null;
		return this.D[key];
	}

	this.getA= function (key){
		if(!this.existe(key)) return null;
		var el = this.D[key];
		if(!this.isArray(key)){
			return Array(el);
		}
		return this.D[key];
	}


	this.var_dump= function(sn){ 
		var out="";
		for(var key in this.D){
			out+=space(sn)+key+"=><br>";
			if (!this.isArray(key)){
				if (!is_object(this.D[key])){
					out += space(sn)+space(5)+this.D[key];  
				}else{
					out += this.D[key].var_dump(sn+10);
				}				
			}else{
				out+=space(sn)+space(5)+"{";
				for(var n in this.D[key]){ 
					out+="<br>";
					if (!is_object(this.D[key][n])){ 
						out += space(sn)+space(5)+this.D[key][n];
					}else{ 
						out += this.D[key][n].var_dump(sn+10);
					}
					out += "<br>";
				}
				out += space(sn)+space(5)+"}";
			}
			out+="<br>";
		}
		return out;
	}
}


function Map(){
	this.D = Array();
	this.set=function(key, val){
		this.D[key]=val;
	}
	this.get=function(key){
		return this.D[key];
	}
}




