function itemlist()
{
	this.items   = [];
}

itemlist.prototype.setItems = function(items)
{
	this.items = items;
}

itemlist.prototype.getById = function(itemid)
{
	for (var i=0; i < this.items.length; i++)
	{
		if (this.items[i].id == itemid)
			return this.items[i];
	}
	
	console.log('itemid #'+itemid+' could not be found.');
	
	return null;
}

itemlist.prototype.addItems = function(newitems)
{
	for(var tel=0; tel<newitems.length; tel++)
		this.items.push(newitems[tel]);
}

itemlist.prototype.addItem = function(item)
{
	this.items.push(item);
}




function getClone(obj)
{
	return eval(obj).toSource();
}



// prevent browsers without console support to bomb out
if (/*!useragent.isFirefox &&*/ typeof window.console == 'undefined')
{
	window.console = { log:     function(msg) { }
					, error:    function(msg) { }
					, warn:     function(msg) { } 
					, group:    function() { }
					, groupEnd: function() { }
					, info:     function(msg) { }
					};
}


/*
- FireFox 1+
- Opera 8+ (not tested in 7)
- Safari 2+ (not tested in 1)
- KDE 3.4 or greater
- Internet Explorer 5+ (not tested in IE 5.2 for Mac)
*/
function onContent(f){//(C)webreflection.blogspot.com
var a,b=navigator.userAgent,d=document,w=window,
c="__onContent__",e="addEventListener",o="opera",r="readyState",
s="<scr".concat("ipt defer src='//:' on",r,"change='if(this.",r,"==\"complete\"){this.parentNode.removeChild(this);",c,"()}'></scr","ipt>");
w[c]=(function(o){return function(){w[c]=function(){};for(a=arguments.callee;!a.done;a.done=1)f(o?o():o)}})(w[c]);
if(d[e])d[e]("DOMContentLoaded",w[c],false);
if(/WebKit|Khtml/i.test(b)||(w[o]&&parseInt(w[o].version())<9))
(function(){/loaded|complete/.test(d[r])?w[c]():setTimeout(arguments.callee,1)})();
else if(/MSIE/i.test(b))d.write(s);
}


function getDefined( varval, fallback )
{
	return typeof varval=='undefined' ? fallback : varval;
}


// Name		- SPCTrim
// Author	- Mark de Jong (SPeLLCoDER)
// Date		- 15 december 2005 ... fixed 12 juni 2008

function SPCTrim(myStr)
{
	if (myStr==null || myStr==undefined) return ''

	var tchars = { 9:true, 10:true, 32: true, 50:true } // 9=tab, 10= , 32=space, 50=

	var strlen = myStr.length;

	for (var rStart=0;rStart < strlen && tchars[myStr.charCodeAt(rStart)] == true;rStart++) { }
	for (var rEnd=strlen-1;rEnd>0 && tchars[myStr.charCodeAt(rEnd)] == true;rEnd--) { }

	if (rStart == strlen)
		return '';
	
	return myStr.substring(rStart,rEnd+1)
}

// http://blog.stevenlevithan.com/archives/faster-trim-javascript
function trim(str)
{
	var	str = str.replace(/^\s\s*/, ''),
		ws = /\s/,
		i = str.length;
	while (ws.test(str.charAt(--i)));
	return str.slice(0, i + 1);
}

/*
function SPC_LTrim(myStr) {
	if (myStr==null || myStr==undefined) return ''
	var tchars = { 9:true, 10:true, 50:true }
	while ( tchars[myStr.charCodeAt(0)] == true ) {
		myStr = myStr.substring(1, myStr.length)
	}
	return myStr
}
*/

function padnumber(number, length)
{
   var str = ''+number;

   while(str.length < length)
      str = '0'+str;

   return str;
}

function pad(number,length)
{
	var str = '' + number;
	while (str.length < length)
		str = '0' + str;
	return str;
}

function initialCap(text)
{
	return text.substr(0, 1).toUpperCase() + text.substr(1);
}


/* window.location
	.hash
	.host
	.hostname
	.href
	.pathname
	.port
	.protocol
	.search
	.target
*/

function parseCurrentURLArgs()
{
	if (window.location.search == '')
		return {};

	return parseURLArgs(window.location.search);
}

function parseURLArgs(argstring)
{
// alert(dbg(window.location, "\n"));
//	var argstring = window.location.search;
	var URLargs = argstring.substring(1).split("&");

	var args = {};

	for ( var paramCount = 0 ; paramCount < URLargs.length ; paramCount++ )
	{
		var argCombo = URLargs[ paramCount ].split("=");
		args[ unescape(argCombo[0]) ] = unescape(argCombo[1]);
	};

	return args;
//  alert(dbg(this.args, "\n"));
}

function GetPropList(myvar)
{	
	var txt = '';
	for (propname in myvar) {
		txt = txt + propname + ' = ' + myvar[propname] + "\n";
	}
	return txt;	
}

function debugdump(name, htmlvalue)
{
	var bla=document.getElementById("bla");
	if (!bla)
	{
		bla=document.createElement("div");
		bla.id="bla";
		bla.style.cssText="position: fixed; top: 15px; left: 15px; font-size: 20px; font-weight: bold; background-color: rgba(0,0,0,0.5); color: #FFFFFF; z-index: 99999; width: 40px; line-height: 29px; text-align: center;";
		document.body.appendChild(bla);
	}
	bla.innerHTML = htmlvalue;
}
