function propertiesToString (obj, delimiter)
{
	if(!delimiter)
	{
		var delimiter = ";";
	}
	var ret;
	if(obj)
	{
		ret = "Object " + (obj.id||obj.name||"undefined") + " is [\n";
		
		for (var prop in obj)
		{
			
			if(obj[prop])
			{
			
		   		//if(obj[prop].toString().match(/\[object /))
		   		//{
		   			//ret += propertiesToString(obj[prop], delimiter+"   ");
		   		//}else{
			      ret += "  " + prop + ": " + obj[prop] + delimiter +"\n";
			      
		   		//}
	   		}
	   		
	   	}
	   	//window.status = "1";
	   	return ret + "]";
	}else{
		return "No Object";
	}
}

function extend(descendant, parent) {
	//Working
	//Credit to Troels Knak-Nielsen
	//http://www.kyberfabrikken.dk
	
    var sConstructor = parent.toString();//Get the parent constructor as a string
    var aMatch = sConstructor.match( /\s*function (.*)\(/ );//checks to make sure it's a function
    if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; }//adds the parent constructor to the descendent
    for (var m in parent.prototype) {
    	/*loops thru all of the parent class members
    	and adds them to the descendant class. brilliant*/
        descendant.prototype[m] = parent.prototype[m];
    }
}

function cast(descendant, parent, call_constructor) {
	/*This is a modified version of Troels Knak-Nielsen's extend.
	Instead of adding members of a parent class to an entire subclass,
	this function adds members of a parent class (parent) to a specific instance (descendent)*/
	if(call_constructor == null)
	{
		call_constructor = true;
	}
	if(descendant[parent])
	{
		var call_constructor = false;
	}else{
		var call_constructor = true;
	}
    var sConstructor = parent.toString();//Get the parent constructor as a string
    //debug(sConstructor);
    var aMatch = sConstructor.match( /\s*function (.*)\(/ );//checks to make sure it's a function
   
    if ( aMatch != null ) { descendant[aMatch[1]] = parent; }//adds the parent constructor to the descendent
    for (var m in parent.prototype) {
    	/*loops thru all of the parent members
    	and adds them to the descendant object. brilliant*/
    	if(!descendant[m])
    	{
        	descendant[m] = parent.prototype[m];
    	}
    }
    //alert(descendant.propertiesToString());
    if (call_constructor)
    {
		parent.call(descendant);//Call the parent constructor
	}
}

function getFromURL(url)
{
	var req = false;
	
	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest)
	{
		try
		{
			req = new XMLHttpRequest();
		} catch(e) {
			req = false;
        }
	// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				req = false;
			}
		}
	}
		
	if(req)
	{
		//alert(url);
		req.open("GET", url, false);
		req.send();
		
		if(req.status == 200)
		{
			try
			{
				return req.responseText;
			}catch(e){
				alert("src failed");
    		}
    	}else{
    		return req.status;
    	}
	}
}


function include(url, target)
{
	//check to see if it has been loaded
	var cur_inc = document.getElementById(url);

	if (cur_inc)
	{
		return false;
	}else{
			
		if (!target)
		{
			target = document.getElementsByTagName('head').item(0);
		}
			
		/*var incEle = document.createElement("SCRIPT");
		target.appendChild(incEle);
		incEle.id = url;
		incEle.language = "javascript";*/
		var script = getFromURL(url);
		try{
			//Yet another workaround for IE
			document.writeln("\n<script id='"+url+"' type='text/javascript'>\n"+script+"\n</script>\n");		
		}catch(e){
			alert("src failed");
    	}	
    	
	}
}