
<!-- //********************** File not found: TOR/View/Content/Sort *******************************// -->



<!-- //********************** File not found: TOR/View/Content/Filter *******************************// -->



<!-- //********************** File not found: TOR/Features *******************************// -->



<!-- //************************** BEGIN lib/functions ********************************// -->

<!--

function noop() {}
function returntrue() {return true;}
function returnfalse() {return false;}
dbg = function() { return false; }

function def(element) {
	return (element==undefined ? false : true);
}

function danb(element) {
	return ( (def(element)) && element!="" ? true : false );
}

function danf(element) {
	return ( (def(element)) && element!=false ? true : false );
}

function dant(element) {
	return ( (def(element)) && element==false ? true : false );
}

el = function(id) { return $(id); }
function $() {
	var a = arguments;
	if( a.length<1 ) return false;
	if( a.length==1 ) {
		var d = document.getElementById(a[0]);
		return (d==undefined?false:d);
	} 
	var r = [];
	for(var i=0;i<arguments.length;i++) {
		r[i]=document.getElementById(a[i]);
		if(r[i]==undefined)r[i]=false;
	}
	return r;
}

function isFunction( o ) {
	return (def(o) && typeof o == 'function');
}

function isString( o ) {
	return (def(o) && typeof o == 'string');
}

function isArray(testObject,force) {
    if 
	( 
		def(testObject) && 
		!(def(testObject.propertyIsEnumerable) && testObject.propertyIsEnumerable('length')) && 
		(typeof testObject === 'object') && 
		(typeof testObject.length === 'number')
	) { return true; }
	else { return false ; }
}
function isArray2( o ) {
  return ( !o || ( o.constructor && o.constructor.toString().indexOf("Array") == -1 ) ? false : true);
}

function isObject( o ){
	return (typeof(o) != 'undefined' && o != null && typeof(o) == 'object' && o.constructor == Object);
}

function foreach( arr, func ) {
	if( isArray( arr ) ) {
		foreachArray(arr,func);
	} else {
		foreachObject(arr,func);
	}
}

function foreachArray( a, f ) {
	if( !def(a) ) return dbg(f,'foreachArray sez, !a, but func');
	var l = a.length;
	if(l>0&&!def(a[l-1]))return dbg(f,'foreachArray Exception: is this in IE?  Calling this function');
	for(var i=0;i<l;i++) {
		f(i,a[i]);
	}
}

function foreachObject( o, f )
{
	if( !def(o) ) return dbg(f,'foreachObject sez, !o, but func');
	for(var x in o) {
		f(x,o[x]);
	}
}

function foreachNumber( n, f, sn )
{
	if( !def(n) || isNaN(n) ) return dbg(f,'foreachNumber sez, !n, but func or isNaN');
	if( !def(sn) ) sn = 0;
	for(var i=sn;i<n;i++) {
		f(i);
	}
}

var addEvent_counter = 1000;
function addEvent( element, type, func, eventName ){
	if(!element||!danb(type)||!isFunction(func))return false;
	if(!danb(eventName))eventName='event'+addEvent_counter++;
	if(type.indexOf('on')==0)type=type.substr(2);
	if(!element.events)element.events={};
	if(!element.events[type])element.events[type]={};
	element.events[type][eventName] = func;
	element['on'+type] = fireEvent.bind(this,element,type);
	return eventName;
}
function fireEvent( element, type, e ){
	var returnValue;
	for(var eventName in element.events[type]){
		returnValue = element.events[type][eventName](e);
	}
	return returnValue;
}
function removeEvent( element, type, eventName ){
	if(!element||!danb(type))return false;
	if(type.indexOf('on')==0)type=type.substr(2);
	if(!element.events||!element.events[type])return false;
	if( danb(eventName) ) {
		delete element.events[type][eventName];
	} else {
		element.events[type]={};
	}
	return true;
}

function addLoadEvent(func) {
	return addEvent( window, 'load', func );

  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}


var count=0;
function deepObjectIsEqual(o1,o2,maxdepth,depth)
{
	if( !def(maxdepth) ) maxdepth=3;
	if( !def(depth) ) depth=0;

	if( depth>=maxdepth ) return true;

	for(var x in o1) {
	
		if( !def(o2[x]) ) return false;
	
		if(o1[x]!=o2[x]) {
			return false;
		} else if( ( ( def(o1[x].length)&&def(o2[x].length)) || (typeof(o1[x])=='object'&&typeof(o2[x])=='object') ) && !(isFunction(o1[x]||isFunction(o2[x])) ) ) {
			if(!deepObjectIsEqual(o1[x],o2[x],maxdepth,depth+1))return false;
		}
	}
	for(var x in o2) {
		if( !def(o1[x]) ) return false;
	}
	return true;
}

function deepObjectIsEqual2(o1,o2,s)
{
	var eq=true;
	foreachObject(o1,function(n,v){
		if( eq ) {
			dbg( def(o2[n]),n );
			if( def(o2[n]) ) {
				if( def(v.length) || isObject(v) ) {
					eq=deepObjectIsEqual(n,o2[n]);
				} else if( v!=o2[n] ) {
					eq=false;
					return;
				}
			} else {
				dbg('so here');
				eq=false;
				dbg(eq,'equal');
				return;
			}
		}
	});
	if( !s && eq ) {
		eq = deepObjectIsEqual(o2,o1,1);
	}
	return eq;
}



function deepObjectCopy(dupeObj) {
	var retObj = new Object();
	if (dupeObj&&typeof(dupeObj) == 'object') {
		if (typeof(dupeObj.length) != 'undefined')
			var retObj = new Array();
		for (var objInd in dupeObj) {
			if (typeof(dupeObj[objInd]) == 'object') {
				retObj[objInd] = deepObjectCopy(dupeObj[objInd]);
			} else if (typeof(dupeObj[objInd]) == 'string') {
				retObj[objInd] = dupeObj[objInd];
			} else if (typeof(dupeObj[objInd]) == 'number') {
				retObj[objInd] = dupeObj[objInd];
			} else if (typeof(dupeObj[objInd]) == 'boolean') {
				((dupeObj[objInd] == true) ? retObj[objInd] = true : retObj[objInd] = false);
			}
		}
	}
	return retObj;
}


if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt )
  {
    var len = this.length;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

Array.prototype.pushAt = function( i, v ) {
	if( i>=0 ) {
		var indx = this.length;
		while(1) {
			if(indx==i)return this[indx] = v;
			this[indx] = this[--indx];
		}
	}
}

String.prototype.replaceAll = function( reg, withWhat ) {
	var count = 0;
	var s = this;
	while( s.match(reg) ) {
		if( count++>1000 ) {
			try{
				dbg('thrown exception: caught inf_loop ('+reg+' into '+withWhat+')');				
			}catch(e){}
			return s;
		}
		s = s.replace(reg,withWhat);
	}
	return s;
}



var $A = function(iterable) {
  if (!iterable) return [];
  if (iterable.toArray) {
    return iterable.toArray();
  } else {
    var results = [];
    for (var i = 0; i < iterable.length; i++)
      results.push(iterable[i]);
    return results;
  }
}


Function.prototype.bind = function() {
  var __method = this, args = $A(arguments), object = args.shift();
  return function() {
    return __method.apply(object, args.concat($A(arguments)));
  }
}


String.prototype.pad = function(w,n)
{

	var c = n-(''+this).length;
	var nv = this;
	for( ; c>0 ; c-- ){
		nv=w+nv;
	}
	return nv;
}


__rootCreate = crind = function(){
	var a=arguments,o=this;
	for(var i=0;i<a.length;i++) {
		if(o[a[i]]==undefined||!isObject(o[a[i]]))o[a[i]]={};
		o=o[a[i]];
	}
}




<!-- //*************************** END lib/functions *********************************// -->



<!-- //************************** BEGIN lib/php ********************************// -->

<!--




PHP = 
{
	trim: function( str, charList )
	{
		return PHP.ltrim( PHP.rtrim( str, charList ), charList );
	},
	
	ltrim: function( str, charList )
	{
		if( def(charList) ) {
			str = str.replace( new RegExp('^['+charList+']+') ,'');
		} else {
			str = str.replace( /^[\s\t\n\r\0\x0B]+/, '' );
		}
		return str;
	},
	
	rtrim: function( str, charList )
	{
		if( def(charList) ) {
			str = str.replace( new RegExp('['+charList+']+$') ,'');
		} else {
			str = str.replace( /^[\s\t\n\r\0\x0B]+/, '' );
		}
		return str;
	},
	
	in_array: function( needle, haystack )
	{
		var len = this.length;
		for ( var x = 0 ; x <= len ; x++ ) {
			if ( this[x] == obj ) return true;
		}
		return false;
	}
}




<!-- //*************************** END lib/php *********************************// -->



<!-- //************************** BEGIN lib/oo ********************************// -->

<!--



var OO =
{
	extend: function( extendThis, usingThis )
	{
		extendThis = extendThis || {};
		if( usingThis ) {
			if( isFunction(usingThis) ) {
				usingThis = new usingThis();
			} else if( def(OO.Class.Objects[usingThis]) ) {
				usingThis = OO.Class.instance(usingThis);
			} else {
				dbg(usingThis,'Extender not found for '+extendThis);
			}
		}
		for(var x in usingThis) {
			extendThis[x]=usingThis[x];
		}
		return extendThis;
	},
	
	Class:
	{
		Counter: 1000,
		
		Objects:
		{
			ClassPrototype: 
			{
				extenders:[],
				implementors:[],
				body: function( className )
				{
					this.getClassName = function() { return this.__CLASS__; }
					this.instanceOf = function( testClassName ) { return OO.Class.doesClassXExtendClassY( this.getClassName(), testClassName ); }
					this.__construct = function(){}
				}
			}
		},

		doesClassXExtendClassY: function( x, y )
		{
			if(x==y)return true;
			if(def(OO.Class.Objects[x])) {
				var m=false;
				foreachObject(OO.Class.Objects[x].extenders,function(n,v){
					if(v==y)m=true;
					if(!m&&def(OO.Class.Objects[v])){
						foreachObject(OO.Class.Objects[v].extenders,function(n2,v2){
							m=OO.Class.doesClassXExtendClassY(v2,y);
							if(m)return;
						});
					}
				});
				if(m)return true;
			}
			return false;
		},
		
		replaceVar: function( classFunction, privateOrProtected, replaceThis, withThis )
		{
			return classFunction.replaceAll('this.'+privateOrProtected+'_'+replaceThis,withThis).replaceAll('this.'+replaceThis,withThis);
		},
		
		define: function( className, classFunction )
		{
			var vars = {
				'private': {},
				'protected': {}
			};
			classFunction = new String(classFunction);
			var m = classFunction.match(/\bthis\.(protected|private)_([a-z_]+)\b/);
			var count = 0;
			while( m ) {
				var newVarName = 'this.vz'+OO.Class.Counter++;
				vars[ m[1] ][ m[2] ] = newVarName;
				if(0) {
					classFunction = classFunction.replaceAll(m[0],newVarName);
					classFunction = classFunction.replaceAll('this.'+m[2],newVarName);
				} else {
					classFunction = OO.Class.replaceVar( classFunction, m[1], m[2], newVarName );
				}
 				m = classFunction.match(/\bthis\.(protected|private)_([a-z_]+)\b/);
				if(count++>1000)return ('infite loop '+m[0]+' and '+newVarName);
			}
		
			
			var funcname = 'func'+OO.Class.Counter++;
			window.parent.eval('window["'+funcname+'"] = '+classFunction);
			classFunction = window[funcname];
			
			OO.Class.Objects[ className ] = 
			{
				vars: deepObjectCopy(vars),
				body: classFunction,
				extenders: [],
				implementors: []
			}
			
			return new ( function(className) {
				this.className = className;
				
				this.extend = function() {
					foreachArray($A(arguments),function(i,x){
						OO.Class.Objects[className].extenders.push( x );
						if( !isFunction(x) && def(OO.Class.Objects[x]) ) {
							foreachObject(OO.Class.Objects[x].vars.protected,function(n,v){
								OO.Class.Objects[className].vars.protected[n]=v;
								var funcname = 'func'+OO.Class.Counter++;
								var classFunction = OO.Class.replaceVar( new String(OO.Class.Objects[className].body),'protected',n,v);
								window.parent.eval('window["'+funcname+'"] = '+classFunction);
								OO.Class.Objects[className].body = window[funcname];
							});
						}
					});
				
				}
				
				this.implement = function() {
					foreachArray($A(arguments),function(i,x){
						OO.Class.Objects[className].implementors.push( x );
					});
				}
			} ) ( className );
		},

		
		instance: function()
		{
			var args = $A(arguments), className = args.shift();
			if( !def(OO.Class.Objects[className]) ) return dbg(className,'Class not found');
			var object = new OO.Class.Objects.ClassPrototype.body( className );
			foreachArray(OO.Class.Objects[className].extenders,function(i,x){
				object = OO.extend(object,x);
			});
			object = OO.extend(object,OO.Class.Objects[className].body);
			object.__construct.apply( object, args.concat($A(args)) );
			object.__CLASS__ = className;
			return object;
		}
	}
}




<!-- //*************************** END lib/oo *********************************// -->



<!-- //************************** BEGIN lib/user ********************************// -->

<!--

var User = 
{
	Browser: '',
	OS: '',
	Version: '',
	
	getBrowser: function()
	{
		return User.Browser;
	},
	
	getOS: function()
	{
		return User.OS;
	},
	
	getVersion: function()
	{
		return User.Version;
	},
	
	
	getInnerWidth: function() 
	{
		var x,y;
		if (self.innerHeight)
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body)
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}
		return [x,y];
	},
	
	getScrollOffset: function() 
	{
		var x,y;
		if (self.pageYOffset)
		{
			x = self.pageXOffset;
			y = self.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		
		{
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;
		}
		else if (document.body)
		{
			x = document.body.scrollLeft;
			y = document.body.scrollTop;
		}
		return [x,y];
	},
	
	getPageHeight2: function() 
	{
		var x,y;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2)
		{
			x = document.body.scrollWidth;
			y = document.body.scrollHeight;
		}
		else
		    
		{
			x = document.body.offsetWidth;
			y = document.body.offsetHeight;
		}
		return [x,y];
	},
	
	getPageHeight:function() 
	{
	
		var ph;
	
		if( window.innerHeight!=undefined && window.scrollMaxY!=undefined ) 
		{
			ph = [
				window.innerWidth + window.scrollMaxX,
				window.innerHeight + window.scrollMaxY
			];
		}
		else if( document.body.scrollHeight > document.body.offsetHeight )
		{
			ph = [
				document.body.scrollWidth,
				document.body.scrollHeight
			];
		}
		else
		{ 
			ph = [
				document.body.offsetWidth + document.body.offsetLeft, 
				document.body.offsetHeight + document.body.offsetTop 
			];
		}
		return ph;
	},	
	
	init: function()
	{
		if( def(this.inited) ) return;
		this.inited = 1;

		
		var BrowserDetect = function() 
		{
			this.searchString = function (data) 
			{
				for (var i=0;i<data.length;i++)	{
					var dataString = data[i].string;
					var dataProp = data[i].prop;
					this.versionSearchString = data[i].versionSearch || data[i].identity;
					if (dataString) {
						if (dataString.indexOf(data[i].subString) != -1)
							return data[i].identity;
					}
					else if (dataProp)
						return data[i].identity;
				}
			}
			this.searchVersion = function (dataString) 
			{
				var index = dataString.indexOf(this.versionSearchString);
				if (index == -1) return;
				return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
			}
			this.dataBrowser = 
			[
				{ 	string: navigator.userAgent,
					subString: "OmniWeb",
					versionSearch: "OmniWeb/",
					identity: "OmniWeb"
				},
				{
					string: navigator.vendor,
					subString: "Apple",
					identity: "Safari"
				},
				{
					prop: window.opera,
					identity: "Opera"
				},
				{
					string: navigator.vendor,
					subString: "iCab",
					identity: "iCab"
				},
				{
					string: navigator.vendor,
					subString: "KDE",
					identity: "Konqueror"
				},
				{
					string: navigator.userAgent,
					subString: "Firefox",
					identity: "Firefox"
				},
				{
					string: navigator.vendor,
					subString: "Camino",
					identity: "Camino"
				},
				{	
					string: navigator.userAgent,
					subString: "Netscape",
					identity: "Netscape"
				},
				{
					string: navigator.userAgent,
					subString: "MSIE",
					identity: "Explorer",
					versionSearch: "MSIE"
				},
				{
					string: navigator.userAgent,
					subString: "Gecko",
					identity: "Mozilla",
					versionSearch: "rv"
				},
				{ 	
					string: navigator.userAgent,
					subString: "Mozilla",
					identity: "Netscape",
					versionSearch: "Mozilla"
				}
			]
			this.dataOS = 
			[
				{
					string: navigator.platform,
					subString: "Win",
					identity: "Windows"
				},
				{
					string: navigator.platform,
					subString: "Mac",
					identity: "Mac"
				},
				{
					string: navigator.platform,
					subString: "Linux",
					identity: "Linux"
				}
			]
			this.init = function () 
			{
				this.b = this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
				this.v = this.version = this.searchVersion(navigator.userAgent)
					|| this.searchVersion(navigator.appVersion)
					|| "an unknown version";
				this.os = this.o = this.OS = this.searchString(this.dataOS) || "an unknown OS";
			}
			this.init();
		};
		var bd = new BrowserDetect();
		User.Browser = bd.b;
		User.isIE = ( User.Browser == 'Explorer' ? function() { return true; } : function() { return false; } );  
		User.OS= bd.o; 
		User.Version = bd.v; 
	}
}
User.init();




<!-- //*************************** END lib/user *********************************// -->



<!-- //************************** BEGIN lib/data/store/simple ********************************// -->

<!--



__rootCreate('Data','Store');

OO.extend(Data.Store,
{
	Simple: function( initialObjects )
	{
		this.values = {};
		
		this.set = function(n,v)
		{
			this.values[n] = v;
			return v;
		}
		
		this.get = function(n)
		{
			if( this.values[n]!=undefined ) {
				return this.values[n];
			} else {
				return false;
			}
		}
		
		this.getKey = function(v)
		{
			for(var x in this.values){
				if( this.values[x]==v ) {
					return x;
				}
			}
			return false;
		}
		
		this.getKeys = function(v)
		{
			var r = [];
			for(var x in this.values){
				r.push(x);
			}
			return r;
		}
		
		this.clear = function()
		{
			for(var x in this.values) {
				delete this.values[x];
			}
			this.values= {};
		}
		
		this.del = this.remove = function(n)
		{
			var r = '';
			if( this.values[n]!=undefined ) {
				r=this.values[n]
				delete this.values[n];
			}
			return r;
		}
		
		this.count = this.size = function()
		{
			var count = 0;
			for(var x in this.values) {
				count++;
			}
			return count;
		}
		
		this.getAssociativeArray = function()
		{
			var r = {};
			for(var x in this.values) {
				r[x] = this.values[x];
			}
			return r;
		}
		
		this.foreach = function( func ) 
		{
			return foreachObject( this.values, func );
		}
		
		this.__construct = function( initialObjects )
		{
			if( isObject(initialObjects) ) {
				for(var x in initialObjects) {
					this.set(x,initialObjects[x]);
				}
			}
			dbg('Use the OO.version');
		}
		
		this.__construct( initialObjects );
	}
});


OO.Class.define('Data_Store_Simple',function(){
	this.values = {};
	
	this.set = function(n,v)
	{
		this.values[n] = v;
		return v;
	}
	
	this.get = function(n)
	{
		if( this.values[n]!=undefined ) {
			return this.values[n];
		} else {
			return false;
		}
	}
	
	this.clear = function()
	{
		for(var x in this.values) {
			delete this.values[x];
		}
		this.values= {};
	}
	
	this.del = this.remove = function(n)
	{
		var r = '';
		if( this.values[n]!=undefined ) {
			r=this.values[n]
			delete this.values[n];
		}
		return r;
	}
	
	this.getKey = function(v)
	{
		for(var x in this.values){
			if( this.values[x]==v ) {
				return x;
			}
		}
		return false;
	}
	
	this.getKeys = function(v)
	{
		var r = [];
		for(var x in this.values){
			r.push(x);
		}
		return r;
	}
	
	this.count = this.size = function()
	{
		var count = 0;
		for(var x in this.values) {
			count++;
		}
		return count;
	}
	
	this.getAssociativeArray = function()
	{
		var r = {};
		for(var x in this.values) {
			r[x] = this.values[x];
		}
		return r;
	}
	
	this.foreach = function( func ) 
	{
		return foreachObject( this.values, func );
	}
	
	this.__construct = function( initialObjects )
	{
		if( isObject(initialObjects) ) {
			for(var x in initialObjects) {
				this.set(x,initialObjects[x]);
			}
		}
	}
});




<!-- //*************************** END lib/data/store/simple *********************************// -->



<!-- //************************** BEGIN lib/dom ********************************// -->

<!--






var	DOM = 
{
	Objects:
	{
	},
	
	Class:
	{
		AddRemoveObject: function()
		{
			this.addList = OO.Class.instance('Data_Store_Simple');
			this.removeList = OO.Class.instance('Data_Store_Simple');
			
			this.to = function( element )
			{
				if( !element || !element.className ) return dbg('DOM.Class.AddRemoveObject sez, !element');

				var classArray = element.className.split(/\s+/);
				var classes = new OO.Class.instance('Data_Store_Simple');
				foreachArray( classArray, function(i,v){
					classes.set(v,true);
				});
				foreachArray( this.addList.getKeys(), function(i,v){
					classes.set(v,true);
				});
				foreachArray( this.removeList.getKeys(), function(i,v){
					classes.remove(v,true);
				});
				element.className = classes.getKeys().join(" ");
			}
		},
		
		add: function()
		{
			var o = new DOM.Class.AddRemoveObject();
			for(var i=0;i<arguments.length;i++) {
				o.addList.set( arguments[i], true );
			}
			return o;
		},
		
		remove: function()
		{
			var o = new DOM.Class.AddRemoveObject();
			for(var i=0;i<arguments.length;i++) {
				o.removeList.set( arguments[i], true );
			}
			return o;
		},
		
		hide: function( className )
		{
		},
		
		matching: function( className, parent, tagName )
		{
			var regex = new RegExp( '(^|\s+)'+className+'(\s+|$)' );
			if( !def(parent) || parent=='body' ) parent=DOM.getBody();
			var elements = parent.getElementsByTagName( tagName );
			var r = [], m;
			foreachArray( elements, function(i,n){
				if( danb(n.className) ) {
					m = n.className.match(regex);
					if( m ) {
						m.splice(1,1);
						m.splice(m.length-1,1);
						r.push({
							match: deepObjectCopy(m),
							element: n
						});
					}
				}
			});
			return r;
		} 
	},
	
	Radio:
	{
		get2: function( form, name )
		{
			return DOM.find({
				parent:form,
				tagName:'input',
				attribute:'name',
				string:name,
				elementOnly:true
			});
		},
		
		get: function( form, name )
		{
			var matching = false, radios = DOM.find({
				parent:form,
				tagName:'input',
				attribute:'type',
				string:'radio',
				elementOnly:true
			});
			
			if( radios ) {
				foreachArray( radios, function(i,radio){
					if( radio.name == name ) {
						if( !def(matching.length) ) {
							matching = [];
						}
						matching.push(radio);
					}
				});
			}
			
			return matching;
		},
		
	
		getSelectedIndex: function( formOrRadioArray, name )
		{
			var arr = false;
			if( danb(name) ) {
				arr = DOM.Radio.get( formOrRadioArray, name );
			} else {
				arr = formOrRadioArray;
			}
			var selectedIndex = -1;
			if( arr ){
				foreachArray( arr, function(i,radio){
					if( radio.checked ) {
						selectedIndex = i;
						return;
					}
				}); 
			}
			return selectedIndex;
		},
		
	
		getSelectedValue: function( formOrRadioArray, name )
		{
			var arr = false;
			if( danb(name) ) {
				arr = DOM.Radio.get( formOrRadioArray, name );
			} else {
				arr = formOrRadioArray;
			}
			var selectedValue = false;
			if( arr ){
				foreachArray( arr, function(i,radio){
					if( radio.checked ) {
						selectedValue = radio.value;
						return;
					}
				}); 
			}
			return selectedValue;
		},
		
	
		setSelectedIndex: function( index, formOrRadioArray, name )
		{
			var arr = false;
			if( danb(name) ) {
				arr = DOM.Radio.get( formOrRadioArray, name );
			} else {
				arr = formOrRadioArray;
			}
			var success = false;
			if( arr ){
				foreachArray( arr, function(i,radio){
					if( i==index ) {
						radio.checked = true;
						success = true;
					} else {
						radio.checked = false;
					}
				}); 
			}
			return success;
		},
		
	
		addEvent: function( type, func, formOrRadioArray, name )
		{
			var arr = false;
			if( danb(name) ) {
				arr = DOM.Radio.get( formOrRadioArray, name );
			} else {
				arr = formOrRadioArray;
			}
			if( arr ) {
				foreachArray( arr, function(i,radio){
					addEvent( radio, type, func );
				});
				return true;
			} else {
				return false;
			}
		}
	},
		
	getContainingId2: function( element, regex ) 
	{
		var m;
		while( def(element) && def(element.id) ) {
			m = element.id.match(regex);
			if( m ) {
				return m;
			}
			element = element.parentNode;
		}
		return false;
	},
	
	reverseFind: function(o)
	{
		if(!def(o.element))return false;
		if(danb(o.attr))o.attribute=o.attr;
		if(o.attribute=='class')o.attribute='className';
		if(danb(o.tag))o.tagName=o.tag;
		if(!danb(o.tagName))o.tagName='*';
		if(!def(o.elementOnly))o.elementOnly=false;
		
		var n = o.element;
		var regex = false;
		var string = false;
		
		if( danb(o.regex) ) regex = new RegExp( '(^|\\s+)'+o.regex+'(\\s+|$)' );
		else if( danb(o.string) ) string = o.string;
		
		var m = false;
		
		while( def(n) ) {
			if( regex ) { 
				m = n[ o.attribute ].match( regex );
				if( m ) {
					m.splice(1,1);
					m.splice(m.length-1,1);
					if( o.elementOnly ) {
						return n; 
					} else {
						return {
							match: deepObjectCopy(m),
							element: n
						};
					}
				}
			} else if( string ) {
				m = (new String( n[ o.attribute ] )).indexOf(string);
				if( m>=0 ) {
					if( o.elementOnly ) {
						return n;
					} else {
						return {
							index: m,
							element: n
						};
					}
				}
			}
			n = n.parentNode;
		}
		return false;
	},

	/*
		DOM.find({
		
			string: 'string to match'
			  OR
			regex: 'regex pattern'
			
		
			parent: DOM.get('elment')
			attribute: 'className'
			tagName: 'div' 	
			elementOnly: true||false
								
		}); 
	*/	
	find: function(o)
	{
		if(!def(o.parent)||o.parent=='body')o.parent=DOM.getBody();
		if(danb(o.attr))o.attribute=o.attr;
		if(o.attribute=='class')o.attribute='className';
		if(danb(o.tag))o.tagName=o.tag;
		if(!danb(o.tagName))o.tagName='*';
		if(!def(o.elementOnly))o.elementOnly=false;
		
		var regex = false;
		var string = false;
		
		if( danb(o.regex) ) regex = new RegExp( '(^|\\s+)'+o.regex+'(\\s+|$)' );
		else if( danb(o.string) ) string = o.string;

	
		var elements = o.parent.getElementsByTagName( o.tagName );
		var r = [], m, n, i;
		for(i=0;i<elements.length;i++) {
			n=elements[i];
			if( danb(o.attribute) ) {
				if( danb( n[ o.attribute ] ) ) {
					if( regex ) { 
						m = n[ o.attribute ].match( regex );
						if( m ) {
							m.splice(1,1);
							m.splice(m.length-1,1);
							if( o.elementOnly ) {
								r.push(n);
							} else {
								r.push({
									match: deepObjectCopy(m),
									element: n
								});
							}
						}
					} else if( string ) {
						m = (new String( n[ o.attribute ] )).indexOf(string);
						if( m>=0 ) {
							if( o.elementOnly ) {
								r.push(n);
							} else {
								r.push({
									index: m,
									element: n
								});
							}
						}
					}
				}
			} else {
				if( o.elementOnly ) {
					r.push( n );
				} else {
					r.push({
						element: n
					});
				}
			}
		}
	
		return r;
	},
	
	findFirst: function(o)
	{
		var elements = DOM.find(o), element = false;
		if( elements && def(elements.length) && elements.length > 0 ) {
			if( def(elements[0].element) ) {
				element = elements[0].element;
			} else {
				element = elements[0];
			}
		}
		return element;
	},
	
	getBody: function()
	{
		return document.getElementsByTagName('body')[0];
	},
		
	register: function( niceName, html ) 
	{
		var element;
		if( isString( html ) ) {
			element = $( html );
		} else {
			element = html;
		}
		DOM.Objects[ niceName ] = element;
		if( !def(element) ) element=false;
		return element;
	},
	
	get: function( niceName )
	{
		if( niceName=='body' ){
			return DOM.getBody();
		} else if( def(DOM.Objects[ niceName ]) ) {
			return DOM.Objects[ niceName ];
		}
		return $( niceName );
		
		
		if( 1 || !def(DOM.Objects[ niceName ]) ) {
			DOM.Objects[ niceName ] = $( niceName );
		
		}
		return DOM.Objects[ niceName ];
	},
			
	getElement: function( element ) {
		if( !def(element) || !element ) {
			return false;
		} else if( isString( element ) ) {
			return DOM.get( element );
		} else if ( def(element.nodeName) ) {
			return element;
		}
		return false;
	},
	
	className: function( className, elementType )
	{
		if( !def(elementType) ) var elementType = '*';
		var elements = DOM.getElementsByClassName(document,elementType,className);
		
		elements.hide = function()
		{
			for(var i=0;i<this.length;i++) {
				DOM.hide( this[i] );
			}
		}
		
		return elements;
	},
	
	hideClass: function( className, elementType )
	{
		if( !def(elementType) ) var elementType = '*';
		var elements = DOM.getElementsByClassName(document,elementType,className);
		for(var i=0;i<elements.length;i++) {
			DOM.hide( elements[i] );
		}
	},
	
	/*
		Written by Jonathan Snook, http://www.snook.ca/jonathan
		Add-ons by Robert Nyman, http://www.robertnyman.com
	*/
	getElementsByClassName: function(oElm, strTagName, strClassName)
	{
		if( oElm=='body' ) oElm=document.getElementsByTagName('body');
		var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
		var arrReturnElements = new Array();
		strClassName = strClassName.replace(/\-/g, "\\-");
		var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
		var oElement;
		for(var i=0; i<arrElements.length; i++){
			oElement = arrElements[i];
			if(oRegExp.test(oElement.className)){
				arrReturnElements.push(oElement);
			}
		}
		return (arrReturnElements)
	},
	
	getElementsByClassName2: function(theClass,d,c) 
	{
		if(!document.hasChildNodes) return false;
		if(!c) var c = new Array();
		if(!d) var d = document.body;
		if(d.nodeType == 1 && d.className.match("^" + theClass + "$")) {
			c.push(d);
		}
		if(d.hasChildNodes()) {
			for(var i = 0; i < d.childNodes.length; i++) {
				DOM.getElementsByClassName(theClass,d.childNodes[i],c);

			}
			return c;
		} else {
			return c;
		}
	},

	removeAllChildren: function( element ) 
	{
		element = DOM.getElement( element );
		if( !def(element) || !def(element.childNodes) ) return;
		while( element.childNodes.length>0 ) {
			element.removeChild( element.childNodes[0] );
		}
	},

		
	insertAfter: function(newChild, refChild) 
	{ 
		refChild.parentNode.insertBefore(newChild,refChild.nextSibling); 
	},
	
	insertBefore: function(newChild, refChild) 
	{ 
		refChild.parentNode.insertBefore(newChild,refChild); 
	},
	
	insert: function( element ) 
	{
		return new ( function(element) {
			this.element = element;
			
			this.before = function( refElement ) {
				refElement = DOM.getElement( refElement );
				if( !refElement ) return false;

				refElement.parentNode.insertBefore( this.element, refElement ); 
				
				return true;
			}
			
			this.after = function( refElement ) {
				refElement = DOM.getElement( refElement );
				if( !refElement ) return false;
				
				refElement.parentNode.insertBefore( this.element, refElement.nextSibling ); 
				
				return true;
			}

		
			this.first = function( refElement ) {
				refElement = DOM.getElement( refElement );
				if( !refElement ) return false;
				
				if( refElement.hasChildNodes ) {
				
					refElement.insertBefore( this.element, refElement.childNodes[0] );
				} else {
					refElement.appendChild( this.element );
				}
				
				return true;
			}
			
			this.inside = this.into = function( refElement ) {
				refElement = DOM.getElement( refElement );
				if( !refElement ) return false;
				
				refElement.appendChild( this.element );
				
				return true;
			}
		} ) ( element );
	},
	
	remove: function( element )
	{
		element = DOM.getElement( element );
		if( !element || !element.parentNode ) return false;
		element.parentNode.removeChild( element );
		return true;
	},
	
	del: function( element )
	{
		return DOM.remove( element );
	},
	
	ElementDisplayTypes: 
	{
		'TBODY':'table-row-group',
		'TR':'table-row',
		'TABLE':'table',
		'LI':'list-item',
		'A':'inline', 
		'SPAN':'inline' 
	},
	
	hide: function( element )
	{
		element = DOM.getElement( element );
		if( !element || !def(element.style) ) return false;
		element.style.visibility="hidden";
		element.style.display='none';
		return true;
	},
	
	softhide: function( element )
	{
		element = DOM.getElement( element );
		if( !element || !def(element.style) ) return false;
		element.style.visibility="hidden";
		return true;
	},
	
	show: function( element, display )
	{
		element = DOM.getElement( element );
		if( !element || !def(element.style) ) return false;
	
		if(display==undefined) {
		
			if( def(DOM.ElementDisplayTypes[element.nodeName]) ) {
			
				display = '';
				display = DOM.ElementDisplayTypes[element.nodeName];
			} else {
				display='block';
			}
		
		}

		element.style.visibility="visible";
		element.style.display=display;
		return true;
	},
	
	findPos: function(obj) 
	{
	
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			while (true) {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
				if(!obj.offsetParent)
				  break;
				obj = obj.offsetParent;
			}
		} 
		
		return [curleft,curtop];
	},
	
	getStyle: function(x,styleProp) 
	{
		
		if (x.currentStyle) {
			styleProp=styleProp.replace(/-([a-z])/g, function(t,a){return a.toUpperCase()} );
			return x.currentStyle[styleProp];
		} else if (window.getComputedStyle) {
			return document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
		}
	},
	
	getBoundary: function( element )
	{
		element = DOM.getElement( element );
		
		var boundary = [0,0,0,0];
		
		if( element && def(element.style) ) {
			var pos = DOM.findPos( element );
			boundary[0] = pos[0];
			boundary[1] = pos[1];
			boundary[2] = pos[0]+DOM.getRealWidth(element);
			boundary[3] = pos[1]+DOM.getRealHeight(element);
		}
		
		return boundary;
	},
	
	doesXcontainY: function( outerX, innerY )
	{
	
		return ( innerY[0]>=outerX[0] && innerY[2]<=outerX[2] && innerY[1]>=outerX[1] && innerY[3]<=outerX[3] );	
	},
	
	getRealWidth: function(el) 
	{
		el = DOM.getElement(el);
		return el.offsetWidth+parseInt(0+DOM.getStyle(el,'margin-left'),10)+parseInt(0+DOM.getStyle(el,'margin-right'),10);
	},
	
	getRealHeight: function(el) 
	{
		el = DOM.getElement(el);
		return el.offsetHeight+parseInt(0+DOM.getStyle(el,'margin-top'),10)+parseInt(0+DOM.getStyle(el,'margin-bottom'),10);
	},
	
	getDims: function(el) 
	{
		el = DOM.getElement(el);
		return [ DOM.getRealWidth(el), DOM.getRealHeight(el) ];
	},
		
	getContainingID: function( element, regex ) 
	{
		var m = false;
		while( def(element) && def(element.id) ) {
			var m = element.id.match(regex);
			if( m ) {
				return m;
			}
			element = element.parentNode;
		}
		return m;
	},
		

	getContainingId: function( element, regex ) 
	{
		var m;
		while( def(element) && def(element.id) ) {
			m = element.id.match(regex);
			if( m ) {
				return m;
			}
			element = element.parentNode;
		}
		return false;
	},
	
	getContaining: function( element, regex )
	{
	},
	
	nextSibling: function( element )
	{
		var sibling = element.nextSibling;
		while( sibling ) {
			if( sibling.nodeName != '#text' ) return sibling;
			sibling = sibling.nextSibling;
		}
		return false;
	},
	
	previousSibling: function( element )
	{
		var sibling = element.previousSibling;
		while( sibling ) {
			if( sibling.nodeName != '#text' ) return sibling;
			sibling = sibling.previousSibling;
		}
		return false;
	},
	
	create: function( obj, parent, recursive )
	{
		parent = DOM.getElement(parent);
		
		if( def(obj.className) ) obj['class'] = obj.className;
		
		if( !def(recursive) ) this.vars = {};
		var d;
		if( def(obj.t) ) {
			obj.t = obj.t.toLowerCase();
		
			var isInput = (obj.t=='input'||obj.t=='option'||obj.t=='textarea');
			if( User.isIE() && isInput ) {
				var inputstring = "<"+obj.t;
				if( def(obj.name) ) {	inputstring+=" name=\""+obj.name+"\"";	}
				if( def(obj.value) ) { inputstring+=" value=\""+obj.value+"\"";	}
				if( def(obj.type) ) { inputstring+=" type=\""+obj.type+"\"";	}
				inputstring+=">";
				d = document.createElement( inputstring );
			} else {
				d = document.createElement( obj.t );
			}
			for(var objx in obj) {
				if( objx=='t' || ( User.isIE() && isInput && (objx=='name' || objx=='value' || objx=='type') ) ) {
				
				} else if( objx=='style' ) {
					DOM.stylize( d, obj[objx] );
				} else if( objx=='options' ) {
					for(var obji=0;obji<obj[objx].length;obji++) {
						if(def(obj[objx][obji]['el'])){
							d.appendChild(obj[objx][obji].el);
						} else if(def(obj[objx][obji]['element'])){
							d.appendChild(obj[objx][obji].element);
						} else {
							obj[objx][obji]['t'] = 'option';
							DOM.create(obj[objx][obji], d, 1 );
						}
					}
				} else if( objx=='kids' ) {
					for(var obji=0;obji<obj[objx].length;obji++) {
						if(def(obj[objx][obji]['el'])){
							d.appendChild(obj[objx][obji].el);
						} else if(def(obj[objx][obji]['element'])){
							d.appendChild(obj[objx][obji].element);
						} else {
							DOM.create( obj[objx][obji], d, 1 );
						}
					}
				} else if( objx=='text' ) {
					d.appendChild( document.createTextNode( obj[objx] ) );

				} else if( objx.indexOf('on') == 0 ) {
					if( typeof obj[objx] == 'string' ) {
						var old = obj[objx];
						d[objx] = function() { try{eval(old)}catch(e){dbg(e)} } 
					} else {
						d[objx] = obj[objx];
					}
				} else if( objx=='variable' ) {
					this.vars[ obj[objx] ] = d;
				} else {
					d.setAttribute( objx, obj[objx] );
				}
			}
		} else if( def(obj.text) ) {
			d = document.createTextNode( obj.text );
			if( def(obj.variable) ) {
				this.vars[ obj['variable'] ] = d;
			}
		}
		if( def(d) && parent ) {
			try {
				parent.appendChild( d );
			} catch(e) {
				foreachObject(e,function(n,v){dbg(v,n);});
			} 
		}
		if( !def(recursive) ) {
			if( def(d.nodeName) && d.nodeName!='#text' ) {
				if( !def(d.vars) ) {
					d['vars'] = {}; 
				}
				for(var x in this.vars) {
					d.vars[x] = this.vars[x];
				}
			}
		}
		return d;
	},

	crel: function(type,id,parent,styles) 
	{
	
		/*
			return creTree({
				t:type,
				id:id,
				href:( def(styles.href) ? styles.href : undefined ),
				style:styles
			}, parent );
		
		*/
		var d = document.createElement(type);
	
	
	
		d.style.visibility='hidden';
	
		if(parent!=undefined&&parent=='body') {
			parent = document.getElementsByTagName('body')[0];
		}
		
		if(id!=undefined) {
			d.id = id;
		}
		
		if(parent!=undefined && parent.appendChild)parent.appendChild(d);
		
		d.style.visibility='visible';
		
		if(styles!=undefined){
		
		
		
		
			if( type.toLowerCase()=='a' && def(styles['href']) ) {
				d.setAttribute('href',styles['href']);
			}
			DOM.stylize(d,styles);
		}
		return d;
	},
	
	stylize: function(element,styles) 
	{
		element = DOM.getElement( element );
		if( !element ) return;
		for(var x in styles) {
			if(x=='className'||x=='src'){
				element[x]=styles[x];
			} else if(x=='colSpan'||x=='href') {
				element.setAttribute(x,styles[x]);
			} else if(x=='cursor') {
				DOM.setCursor(element,styles[x])
			} else if(x=='opacity') {
				DOM.setOpacity( element, styles[x] );
			} else if(x=='text') {
				element.appendChild( document.createTextNode(styles[x]) );
			} else if( x.indexOf('on') == 0 ) {
				element[x] = styles[x];
			} else {
				try{
				element.style[x] = styles[x];
				}catch(e) { alert('DOM.stylize ('+x+' == '+styles[x]+') '+e); }
			}
		}
	},
	
	setCursor: function (el,cursor) 
	{
		if(el==undefined)return;
		try{
			el.style.cursor=cursor;
		} catch(e) {
			try{
				el.style.cursor='default';
			}catch(f) {
			
			}
		}
	},
	
	setOpacity: function(el,n) 
	{
		if(el==""||el==undefined||el.style==undefined)return;
		el.style.filter = "alpha(opacity="+n+")";
		el.style.opacity=''+(n/100);
	}
	
};
DOM['creTree'] = DOM.create; 




<!-- //*************************** END lib/dom *********************************// -->



<!-- //************************** BEGIN lib/eventobject ********************************// -->

<!--



EventObject = function(e) {
	if(!e) var e = window.event;

  
	this.evnt = e;
	this.mouseCoords;
	this.target;
	this.mouseWheel;
	this.keyCode;
	this.keyCodeChar;
	
	var me = this;
	
	this.getTarget = function() {
		if( def(me.target) ) return me.target;
		var targ;
		if(me.evnt.target) targ = me.evnt.target;
		else if(me.evnt.srcElement) targ = me.evnt.srcElement;
		if(targ.nodeType == 3)
		    targ = targ.parentNode;
		me.target = targ;
		return me.target;
	}
	
	this.getMouseWheel = function() {
		if( def(me.mouseWheel) ) return me.mouseWheel;

		var mpos=this.getMouseCoords();
		var d=0;
		if(mme.evnt.evnt.wheelDelta) {
			d=(me.evnt.wheelDelta>0)?1:-1;
			if(window.opera)
				d=-d;
		} else if(me.evnt.detail) {
			d=(me.evnt.delta>0)?-1:1;
		}
		if(me.evnt.preventDefault)
			me.evnt.preventDefault();
		me.evnt.returnValue=true;
		
		me.mouseWheel = d;
		return me.mouseWheel;
	}	

	this.getMouseCoords = function() {
		if( def(me.mouseCoords) ) return me.mouseCoords;

		var evmposx=0;
		var evmposy=0;
		if(me.evnt.pageX||me.evnt.pageY) {
			evmposx=me.evnt.pageX;
			evmposy=me.evnt.pageY;
		}
		else if(me.evnt.clientX||me.evnt.clientY) {
			evmposx=me.evnt.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
			evmposy=me.evnt.clientY+document.body.scrollTop+document.documentElement.scrollTop;
		}
		
		me.mouseCoords = [evmposx,evmposy];
		return me.mouseCoords;
	}
	
	this.getKeyCode = function() {
		if( def(me.keyCode) ) return me.keyCode;
	
	
		me.keyCode = me.evnt.charCode || me.evnt.keyCode;
	
		if(User.getBrowser()=='Safari'&&User.getOS()=='Mac'){
		
			if(me.keyCode==63233)me.keyCode=40;
			else if(me.keyCode==63232)me.keyCode=38;
			else if(me.keyCode==63276)me.keyCode=33;
			else if(me.keyCode==63277)me.keyCode=34;
		}
		return me.keyCode;
	}
	
	this.preventDefault = function() {
		if(me.evnt.preventDefault)me.evnt.preventDefault();
		else if(window.event)window.event.returnValue=false;
	}
	
	this.stopPropagation = function() {
		if(me.evnt.stopPropagation)me.evnt.stopPropagation();
		else if(window.event)window.event.cancelBubble=true;
	}

	this.stopprop = function() {
		me.preventDefault();
		me.stopPropagation();
		return false;
	}
}



<!-- //*************************** END lib/eventobject *********************************// -->



<!-- //************************** BEGIN lib/dropdown/item ********************************// -->

<!--



OO.Class.define('Dropdown_Item',function(){
	this.element;
	this.rootElement;
	this.classNames = {
		inactive: [], 
		normal: []
	};
	
	this.actionElements = {};
	this.activeActions = {};
	
	this.isActive = function( actionName )
	{
		if( def( this.activeActions[ actionName ] ) ) {
			return this.activeActions[ actionName ];
		}
		return false;
	}
	
	this.activate = function( actionName )
	{
	
		if( def( this.actionElements[ actionName ] ) ) {
			DOM.show( this.actionElements[ actionName ] );
			this.activeActions[ actionName ] = true;
		}

		this.applyClassNames();
	}
	
	this.deactivate = function( actionName )
	{
		if( def(actionName) ) {
			if( def( this.actionElements[ actionName ] ) ) {
				DOM.hide( this.actionElements[ actionName ] );
				this.activeActions[ actionName ] = false;
			}
		} else {
			foreachObject(this.activeActions,function(actionName, isActive){
				if( def( this.actionElements[ actionName ] ) ) {
					DOM.hide( this.actionElements[ actionName ] );
					this.activeActions[ actionName ] = false;
				}
			}.bind(this));
		}

		this.applyClassNames();
	}
	
	this.getRootElement = function()
	{
		return this.rootElement;
	}
	
	this.setRootElement = function(n)
	{
		this.rootElement = n;
	}
	
	this.getElement = function()
	{
		return this.element;
	}
	
	this.setElement = function(n)
	{
		this.element = n;
	}
	
	this.applyClassNames = function()
	{
		var className = '';
		className = this.classNames.normal.join(' ');
		
		var inactive = true;
		foreachObject(this.activeActions,function(actionName,isActive){
			if( isActive ) {
				inactive = false;
				foreachArray(this.classNames.inactive,function(i0,v0){
					className+=' '+v0+actionName;
					
				}.bind(this));
			}
		}.bind(this));
		
		if( inactive ) {
			foreachArray(this.classNames.inactive,function(i0,v0){
				className+=' '+v0+'inactive';
			}.bind(this));
		}
		
	
		this.element.className = className;  
	}
	
	this.init = function()
	{
		if( !def(this.rootElement) || !def(this.element) ) return dbg(this.rootElement+' and '+this.element,'root element or element !def in dropdown_item');
		
	
		var itemElements = DOM.find({
			regex: this.element.id + '_(.+)',
			parent: this.rootElement,
			attribute: 'id'
		});
		
		foreachArray(itemElements,function(i,v){
			if( def(v.match) ) {
				this.actionElements[ v.match[1] ] = v.element;
			}
			
		}.bind(this));
		
		var classNames = this.element.className.split(/\s+/);
		if( def(classNames.length) ) {
			foreach(classNames,function(i,v){
				var m = v.match(/(.+_)inactive/);
				if( m && danb(m[1]) ) {
					this.classNames.inactive.push( m[1] );
				} else {
					this.classNames.normal.push( v );
				}
			}.bind(this));
		}
		
		this.applyClassNames();
	}
	
	this.__construct = function(o)
	{
		if( def(o) ) {
			if( def(o.root) ) {
				this.setRootElement(o.root.element);
			}
			this.setElement(o.element);
		}
		
		this.init();
	}	
});




<!-- //*************************** END lib/dropdown/item *********************************// -->



<!-- //************************** BEGIN lib/dropdown ********************************// -->

<!--






OO.Class.define('Dropdown',function(){
	this.mouseoutTimeout = 350;
	this.rootElement;
	this.rootName;
	
	this.timeouts = {
		mouseout: []
	};
	
	this.items = [];
	
	this.setMouseOutTimeOut = function(n)
	{
		this.mouseoutTimeout = n;
	}
	
	this.setRootName = function(n)
	{
		this.rootName = n;
	}
	
	this.setRootElement = function(n)
	{
		this.rootElement = n;
	}
	
	this.item_onMouseOver = function( index )
	{
		clearTimeout( this.timeouts.mouseout[index] );

		foreachArray(this.items,function(i,item){
			if( i == index ) {
				item.activate('hover');
			} else {
				item.deactivate('hover');
			}
		}.bind(this));
	}	
	
	this.item_onMouseOut = function( index )
	{
		clearTimeout( this.timeouts.mouseout[index] );
		
		this.timeouts.mouseout[index] = setTimeout(
			function() {
				this.items[ index ].deactivate('hover');
			}.bind(this),
			
			this.mouseoutTimeout
		);
	}
		
	this.document_onClick = function(e)
	{
		clearTimeout( this.timeouts.mouseout[index] );

		if(def(this.oldDocumentOnClick)) this.oldDocumentOnClick(e);
		
		var eo = new EventObject(e);
		var id = DOM.getContainingID( eo.getTarget(), this.rootName + '_item(\\d+)' );
		var index = -1;

		if( def(id) ) {
			id = id[0];

			foreachArray(this.items,function(i,item){
				if( item.getElement().id == id ) {
					index = i;
					return;
				}
			}.bind(this));
		}

		this.onclick( index );
		
	
	}
	
	this.onclick = function( index )
	{
		foreachArray(this.items,function(i,item){
			if( i==index ) {
				if( item.isActive('click') ) {
					item.deactivate('click');
				} else {
					item.activate('click');
				}
			} else {
				item.deactivate('click');
			}
		}.bind(this));
	}
	
	this.init = function()
	{
		if( !def(this.rootElement) && !def(this.rootElement.getElementsByTagName) ) {
			this.rootElement = document;
		}
		
		if( !danb(this.rootName) ) return dbg('Root name not given.');
		
		var itemElements = DOM.find({
			regex: this.rootName + '_item(\\d+)',
			parent: this.rootElement,
			attribute: 'id'
		});
		
		foreachArray(itemElements,function(i,v){
			var item = OO.Class.instance('Dropdown_Item',{element:v.element,root:{element:this.rootElement}});

		
		
			v.element.onmouseover = this.item_onMouseOver.bind(this, i);
			v.element.onmouseout = this.item_onMouseOut.bind(this, i);

			this.items.push( item );
			
		}.bind(this));
		
		this.oldDocumentOnClick = document.onclick;
		document.onclick = this.document_onClick.bind(this);
	}
	
	this.__construct = function(o)
	{
		if( def(o) ) {
			if( def(o.root) ) {
				this.setRootName(o.root.name);
				this.setRootElement(o.root.element);
			}
		}
	}	
});




<!-- //*************************** END lib/dropdown *********************************// -->



<!-- //************************** BEGIN lib/dropdown/auto ********************************// -->

<!--





__rootCreate('Dropdown');

Dropdown.Auto =
{
	init: function()
	{
		var menus = DOM.find({
			regex: 'dropdownmenu_(.+)',
			attribute: 'id'
		});
		
		dbg(menus);
		
		foreachArray(menus, function(i,menu){
			var dropdown = OO.Class.instance('Dropdown',{root:{element:menu.element,name:menu.match[1]}});
			dropdown.init();
		});		
	}
};

addLoadEvent( Dropdown.Auto.init ) ;




<!-- //*************************** END lib/dropdown/auto *********************************// -->



<!-- //************************** BEGIN lib/funcup ********************************// -->

<!--







function FunctionFromMarkup( d ) {
	var mapper = {};
	var vars = {};

	this.getCreTreeObject = function( d, depth ) {
		if(!def(d)) return {};
		if(!def(depth)) var depth=0;
		var map = {
			replacers: [],
			kids: []
		};
		if( d.nodeType==3 ) {
			var o = {
				text: d.nodeValue 
			}
			
		
			var ma = d.nodeValue.match(/%([a-zA-Z0-9_]+)%/);
			if( ma ) {
				vars[ ma[1] ] = 1;
			
				map.replacers.push('text');
			}
			
			return [ o, map ];
			
		} else {
			var o = {
				t:d.tagName,
				kids:[]
			};
		}
		
		if( def(d.attributes) ) {
			for(var i=0;i<d.attributes.length;i++) {
				var at = d.attributes[i];
				var nn = at.nodeName;
	
				if( nn == 'style' ) {
					if( !def(o['style']) ) o['style'] = {};
					var styles;
					if( User.getBrowser()=='Safari' ) {
						styles = {};
						for(var j=0;j<d.style.length;j++) {
						
						
							styles[ d.style[j].replace(/-([a-z])/, function(m1,m2){return m2.toUpperCase()}) ] = d.style.getPropertyValue( d.style[j] );
						}
					} else {
						styles = d.style;
					}
					for(var x in styles) {
					
						if( (!(depth==0 && x=='display' && styles[x]=='none')) && danb(styles[x]) && ! x.match(/^(len|parent|accel|css|get|set|remove|\d|item|isprop)/i) ) { 
							o.style[x] = styles[x];
	
							var ma = x.match(/%([a-zA-Z0-9_]+)%/);
							if( ma ) {
								vars[ ma[1] ] = 1;
								map.replacers.push('style.'+x);
							}
						}
					}
				
					
				} else if( at.nodeValue ) {
					var nv = ''+d.attributes[i].nodeValue;
					try {
						if( nv.match ) {
							var ma = nv.match(/%([a-zA-Z0-9_]+)%/);
							if( ma || nn!='id' ) {
								o[d.attributes[i].nodeName] = nv;
								if( nn == 'class' ) {
									o['className'] = nv;
								}
								if( ma ) {
									vars[ ma[1] ] = 1;
									map.replacers.push(nn);
									if( nn=='class') {
										map.replacers.push('className');
									}
								}
							}
						}
					} catch(e) { dbg(e,'lib/funcup: Exception'); }
				} 
			}
		}
		
		for(var i=0;i<d.childNodes.length;i++) {
			var kids = this.getCreTreeObject(d.childNodes[i],depth+1);
			map.kids.push( kids[1] );
			o.kids.push( kids[0] );
		}
		return [ o, map ];
	}

	__construct = function( d ) {
		var kids = this.getCreTreeObject( d );
		var matches = [];
		for(var x in vars) {
			matches.push(x);
		}
		return new FunctionFromMarkup_Species( kids[0], kids[1], matches );
	}
	
	return __construct(d);
}

FunctionFromMarkup_Species = function( creTreeObject, mapper, matches ) {
	this.creTreeObject = creTreeObject;
	this.mapper = mapper;
	this.matches = matches;
	
	this.getMatches = function() {
		return this.matches;
	}
	
	this.getInstance = function() {
		return new FunctionFromMarkup_Particular( deepObjectCopy(this.creTreeObject), this.mapper, this.matches );
	}
}

FunctionFromMarkup_Particular = function( creTreeObject, mapper, matches ) {
	this.creTreeObject = this.originalcreTreeObject = creTreeObject;
	this.mapper = mapper;
	this.replaces = {};
	this.needsRender = 1;
	this.matches = matches;
	
	this.getMatches = function() {
		return this.matches;
	}
	
	this.replace = function( from, to ) {
		this.replaces[from] = to;
		this.needsRender = 1;
	}
	
	this.replaceAll = function( cre, arr ) {
		for(var i=0;i<arr.length;i++) {
			for(var x in this.replaces) {
			
				var m = x.match(/^style\.(.+)/);
				if( m ) {
					if( cre['style'] && cre['style'][ m[1] ] ) {
						cre['style'][ m[1] ] = cre['style'][ m[1] ].replace( '%'+x+'%', this.replaces[x] ); 
					}
				} else {
					if( cre[ arr[i] ] ) {
						cre[ arr[i] ] = cre[ arr[i] ].replace( '%'+x+'%', this.replaces[x] );
					}
				}
			}
		}
		return cre;
	}
	
	this.recurse = function( cre, map ) {
		if( map.replacers ) {
			cre = this.replaceAll( cre, map.replacers );
		}
		if( map.kids && cre.kids ) {
		
			for(var i=0;i<cre.kids.length;i++) {
			
				if( cre.kids[i] && map.kids[i] ) {
					cre.kids[i] = this.recurse( cre.kids[i], map.kids[i] );
				}
			}
		}
		return cre;
	}
	
	this.render = function(  ) {
		this.creTreeObject = this.originalcreTreeObject;
		this.creTreeObject = this.recurse( this.creTreeObject, this.mapper );
		this.needsRender = 0;
	}
	
	this.render2 = function() {
		for(var x in this.replaces) {
		
		
			for(var y in this.domObject.vars) {
				this.domObject.vars[y].nodeValue = this.domObject.vars[y].nodeValue.replace( '%'+x+'%', this.replaces[x] );
			}
		}
		this.needsRender = 0;
	}
	
	this.getDomObject = this.getDomObj = function() {
		if( this.needsRender ) this.render( );
		var domObject = DOM.creTree( this.creTreeObject );
		return domObject;
	}
}






<!-- //*************************** END lib/funcup *********************************// -->



<!-- //************************** BEGIN lib/ptypes ********************************// -->

<!--




var	PTypes = 
{
	Objects:
	{
	},
	
	register: function( niceName, htmlId ) 
	{
		var element = $( htmlId );
		if( element ) {
			PTypes.Objects[ niceName ] = FunctionFromMarkup( element );
		}
		DOM.Objects[ niceName ] = element;
		return true;
	},
	
	get: function( niceName )
	{
		if( !def(PTypes.Objects[ niceName ]) ) {
			if( $( niceName ) ) {
				PTypes.register( niceName, niceName );
			} else {
				return false;
			}
			if( !def(PTypes.Objects[ niceName ]) ) {
				return false;
			}
		}
		return PTypes.Objects[ niceName ].getInstance();
	}
};




<!-- //*************************** END lib/ptypes *********************************// -->


<!-- //************************** BEGIN lib/observer ********************************// -->

<!--




Observer = function() 
{
	this.observers = [];
	
	this.attach = function( obj ) 
	{
		this.observers.push( obj );
	}
	
	this.detach = function( obj ) 
	{
		for(var i=0;i<this.observers.length;i++) {
			if( this.observers[i] == obj ) {
				return this.observers[i].splice( i, 1 );
			}
		}
	}
	
	this.notify = function( arg ) 
	{
		for(var i=0;i<this.observers.length;i++) {
			this.observers[i].update( arg );
		}
	}
	
	this.update = function( args )
	{
	}
}


OO.Class.define('Observer',function() {
	this.private_observers = [];
	
	this.attach = function( obj ) 
	{
		this.observers.push( obj );
	}
	
	this.detach = function( obj ) 
	{
		for(var i=0;i<this.observers.length;i++) {
			if( this.observers[i] == obj ) {
				return this.observers.splice( i, 1 );
			}
		}
		return false;
	}
	
	this.notify = function( arg ) 
	{
	
		for(var i=0;i<this.observers.length;i++) {
			if( !def(this.observers[i].update) ) dbg('Observer does not have update method');
			else this.observers[i].update( arg );
		}
	}
	
	this.update = function()
	{
	}
});




<!-- //*************************** END lib/observer *********************************// -->



<!-- //************************** BEGIN lib/pagination/control ********************************// -->

<!--




OO.Class.define('Pagination_Control',function(){
	this.dataCount=0;
	this.lastPage=0;
	this.perPage=0;
	this.currentPage=0;
	
	this.getLastPage = function() { return this.lastPage; }

	this.setCurrentPage = function(r) {
		this.currentPage=r; 
	}
	this.getCurrentPage = function() { return this.currentPage; }

	this.getDataCount = function() { return this.dataCount; }
	this.setDataCount = function(r) { 
		this.dataCount=r; 
		this.recalculate();
	}

	this.getPerPage = function() { return this.perPage; }
	this.setPerPage = function(r) { 
		this.perPage=r; 
		this.recalculate();
	}
	
	this.gotoPage = function(p)
	{
		if( p<0 ) {
			this.currentPage = 0;
		} else if( p>this.lastPage ) {
			this.currentPage = this.lastPage;
		} else {
			this.currentPage = p;
		}
		
		this.notify( this );

		return true;
	}
	
	this.gotoFirstPage = function()
	{
		return this.gotoPage(0);
	}
	
	this.gotoLastPage = function()
	{
		return this.gotoPage( this.lastPage );
	}
	
	this.prevPage = this.previousPage = function()
	{
		return this.gotoPage( this.currentPage-1 );
	}
	
	this.nextPage = function()
	{
		return this.gotoPage( this.currentPage+1 );
	}
	
	this.hasPrevPage = this.hasPreviousPage = function()
	{
		return ( this.currentPage > 0 );
	}
	
	this.hasNextPage = function()
	{
		return ( this.currentPage < this.lastPage );
	}
	
	this.getStartingOffset = function()
	{
		return this.currentPage*this.perPage;
	}
	
	this.getEndingOffset = function()
	{
		return this.currentPage*(this.perPage)+this.perPage;
	}
	
	this.getDataIndices = function()
	{
		var arr = [], i;
		for( i=this.getStartingOffset(); i<this.dataCount && i<this.getEndingOffset(); i++ ) {
			arr.push( i ); 
		}
		return arr;
	}
	
	this.protected_recalculate = function()
	{
	
		try { 
			this.lastPage = parseInt( (this.dataCount-1)/(this.perPage) , 10 );
			if( this.lastPage < 0 ) this.lastPage=0;

		} catch(e) { this.lastPage=0; }
		
		this.gotoPage( this.currentPage );
	}
	
	this.dbg = function()
	{
		dbg( this.perPage, 'pp' );
		dbg( this.lastPage, 'last page' );
		dbg( this.dataCount, 'dataCount' );
		dbg( this.currentPage, 'currentPage' );
		dbg( this.getDataIndices(), 'dataIndices' );
	}
	
	this.__construct = function( o ) 
	{
		if( def(o) ) {
			if( def(o.perPage) ) this.setPerPage( o.perPage );
			if( def(o.dataCount) ) this.setDataCount( o.dataCount );
			if( def(o.curPage) ) o.currentPage = o.curPage;
			if( def(o.currentPage) ) this.setCurrentPage( o.currentPage );
		}
	}
}).extend('Observer');




<!-- //*************************** END lib/pagination/control *********************************// -->



<!-- //************************** BEGIN lib/web/cookie ********************************// -->

<!--



__rootCreate('Web');

OO.extend(Web,
{
		
	Cookie:
	{
		get: function(n)
		{
			var nEQ = n + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nEQ) == 0) return c.substring(nEQ.length,c.length);
			}
			return false;
		},
		
		set: function(n,v,d)
		{
			if (d) {
				var date = new Date();
				date.setTime(date.getTime()+(d*24*60*60*1000));
				var ex = "; expires="+date.toGMTString();
			}
			else var ex= "";
			document.cookie = n+"="+v+ex+"; path=/";
		},
		
		remove: function(n)
		{
			Web.Cookie.set(n,"",-1);
		},
		
		del: function(n)
		{
			Web.Cookie.remove(n);
		}
	}
});




<!-- //*************************** END lib/web/cookie *********************************// -->


<!-- //************************** BEGIN lib/data/json ********************************// -->

<!--



__rootCreate('Data');

OO.extend(Data,
{
	Json:
	{
		serialize: function( o ) 
		{
			var r='';
			if( isString(o) ) {
				r='"'+o.replaceAll(/([^\/])\"/,"&quot;")+'"';
			} else {
				var t='';
				if( isArray(o) ) {
					t='a';
					r+='[';
				} else if( isObject(o) ) {
					t='o';
					r+='{';
				}
				
				if(t!='') {
					var i=0;
					foreachObject(o,function(n,v){
						if(i++>0)r+=',';
						if(t=='o') {
							dbg(v,n);
							r+=Data.Json.serialize(n)+':';
						}
						r+=Data.Json.serialize(v);
					});
				}
				
				if(t=='a') {
					r+=']';
				} else if(t=='o') {
					r+='}';
				}
			}
			return r;
		}
	}
});




<!-- //*************************** END lib/data/json *********************************// -->



<!-- //************************** BEGIN lib/data/store/class ********************************// -->

<!--




OO.Class.define('Data_Store_Class',function(){
	this.classes = {};
	
	this.set = function(className,n,v)
	{
		if( !def(this.classes[className]) ) {
			this.classes[className] = OO.Class.instance('Data_Store_Simple');
		}
		this.classes[className].set(n,v);
	}
	
	this.get = function(className,n)
	{
		if( def(this.classes[className]) ) {
			return this.classes[className].get(n);
		} else {
			return false;
		}
	}
	
	this.clear = function(className)
	{
		if( def(this.classes[className]) ) {
			this.classes[className].clear();
		}
	}
	
	this.del = this.remove = function(className,n)
	{
		if( def(this.classes[className]) ) {
			return this.classes[className].del(n);
		}
		return false;
	}
	
	this.getKey = function(className,v)
	{
		if( def(this.classes[className]) ) {
			return this.classes[className].getKey(v);
		}
		return false;
	}
	
	this.getKeys = function(className,v)
	{
		if( def(this.classes[className]) ) {
			return this.classes[className].getKeys(v);
		}
		return [];
	}
	
	this.count = this.size = function(className)
	{
		if( def(this.classes[className]) ) {
			return this.classes[className].count();
		} 
		return 0;
	}
	
	this.getAssociativeArray = function(className)
	{
		if( def(this.classes[className]) ) {
			return this.classes[className].getAssociativeArray();
		}
		return {};
	}
	
	this.__construct = function( initialObjects )
	{
		if( def(initialObjects) ) {
			dbg('Not implemeneted in Data Store Class');
		}
	}
	
});




<!-- //*************************** END lib/data/store/class *********************************// -->



<!-- //************************** BEGIN lib/data/store ********************************// -->

<!--







<!-- //*************************** END lib/data/store *********************************// -->



<!-- //************************** BEGIN lib/data ********************************// -->

<!--







<!-- //*************************** END lib/data *********************************// -->



<!-- //************************** BEGIN lib/web/url ********************************// -->

<!--




__rootCreate('Web');

OO.extend(Web,
{
	Url:
	{
    Utf8: {
			 encode : function (string) {
	        string = string.replace(/\r\n/g,"\n");
	        var utftext = "";
	        for (var n = 0; n < string.length; n++) {
	            var c = string.charCodeAt(n);
	            if (c < 128) {
	                utftext += String.fromCharCode(c);
	            }
	            else if((c > 127) && (c < 2048)) {
	                utftext += String.fromCharCode((c >> 6) | 192);
	                utftext += String.fromCharCode((c & 63) | 128);
	            }
	            else {
	                utftext += String.fromCharCode((c >> 12) | 224);
	                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
	                utftext += String.fromCharCode((c & 63) | 128);
	            }
	        }
	        return utftext;
	      },
	      
				decode : function (utftext) {
				  var string = "";
				  var i = 0;
				  var c = c1 = c2 = 0;
				  while ( i < utftext.length ) {
				      c = utftext.charCodeAt(i);
				      if (c < 128) {
				          string += String.fromCharCode(c);
				          i++;
				      }
				      else if((c > 191) && (c < 224)) {
				          c2 = utftext.charCodeAt(i+1);
				          string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				          i += 2;
				      }
				      else {
				          c2 = utftext.charCodeAt(i+1);
				          c3 = utftext.charCodeAt(i+2);
				          string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				          i += 3;
				      }
				  }
				  return string;
				}
    },
		
		getScriptName: function(url)
		{
			if( !danb(url) ) var url = location.href;
			var m = url.match('^([^#\?]+)');
			if ( m ) {
				return m[1];
			}
			return '';
		},
		
		getHostName: function(url)
		{
			if( !danb(url) ) var url = location.href;
			var m = url.match('^(https?:\/\/[^\/]+)');
			if ( m ) {
				return m[1];
			}
			return '';
		},
		
		isValid: function(url)
		{
			 var regex = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
			 return regex.test(url);
		},
		
		encode: function( url )
		{
			return escape( url );
		},
		
		decode: function( url )
		{
			return unescape( url );
		},
		
		serialize: function( data )
		{
			var str = '';
			if( def(data) ) {
				var count=0;
				for(var x in data)
				{
					str+=( count++>0 ? '&' : '' )+Web.Url.encode(x)+'='+Web.Url.encode(data[x]);
				}
			}
			return str;
		},
		
		Wrapper: function( baseUrl, initialArgs )
		{
			OO.extend( this, 'Data_Store_Simple' );
			
			this.url = '';
			if( 0 ) {
				this.data = new Data.Store.Simple();
				
				this.get = function(n) { return this.data.get(n); }
				this.set = function(n,v) { return this.data.set(n,v); }
				this.del = function(n) { return this.data.del(n); }
				this.remove = function(n) { return this.data.remove(n); }
				this.clear = function() { return this.data.clear(); }
			}
			
			this.setUrl = function(url)
			{
				this.clear();
				if( !def(url) ) {
					return this.url = '';
				}
				var m = url.match(/(.+)\?([^#]+)?/);
				if( m ) {
					this.url = m[1];
					if( def(m[2]) ) {
						var params = m[2].split(/&/);
						for(var i=0;i<params.length;i++) {
							var nv = params[i].split(/=/);
							if( def(nv[0]) ) {
								this.set( nv[0], ( def(nv[1]) ? nv[1] : '' ) );
							} else {
								this.set( params[i], '' );
							}
						}
					}
				} else {
					return this.url = url;
				}
			
			}
			
			this.getUrl = function()
			{
				return this.url;
			}
			
			this.build = function()
			{
				var url = this.url;
				var data = this.getAssociativeArray();
				
				if( !this.url.match(/\?/) && this.count() > 0 ) {
					url += '?'; 
				}
				url += Web.Url.serialize( data );
				return url;
			}
			
			this.__construct = function( baseUrl, initialArgs )
			{
				if( def(baseUrl) ) {
					this.setUrl( baseUrl );
				}
				if( def(initialArgs) ) {
					for(var x in initialArgs)
					{
						this.set( x, initialArgs[x] );
					}
				}
			}
			
			this.__construct( baseUrl, initialArgs );
		}
	}
});




<!-- //*************************** END lib/web/url *********************************// -->



<!-- //************************** BEGIN lib/web/hashcookie ********************************// -->

<!--




__rootCreate('Web');

OO.extend(Web,
{
	HashCookie:
	{
		decode: function( n )
		{
			return Web.Url.decode( n.replace(/__/g,'%') );
		},
		
		encode: function( n )
		{
			return Web.Url.encode( n ).replace(/\%/g,'__'); 
		},
		
		/**
		 * @private
		 **/		 		
		getArr: function()
		{
			var m = location.href.match(/#(.+)/);
			var arr = {};
			if( m ) {
				var nvs = m[1].split(/\&/);
				for(var i=0;i<nvs.length;i++) {
					m = nvs[i].split(/=/);
					if( m ) {
						if( !def(m[1]) ) m[1] = '';
						arr[ Web.HashCookie.decode(m[0]) ] = Web.HashCookie.decode(m[1]);
					}
				}
			}
			return arr;
		},

		/**
		 * @private
		 **/		 		
		setArr: function( arr )
		{
			var arrStr = '',i=0,url;
			var i=0;
			for(var x in arr) {
			
				arrStr+=(i++!=0?'&':'')+Web.HashCookie.encode(x)+'='+Web.HashCookie.encode(arr[x]);
			}
			var url;
			var m = location.href.match(/(.+)#/);
			if( m ) {
				url = m[1]+'#'+arrStr;
			} else {
				url = location.href+'#'+arrStr;
			}
			location.href = url;
		},
		
		get: function(n)
		{	
			var r = false;
			var arr = Web.HashCookie.getArr();
			if( def(arr[n]) ) {
				r = arr[n];
			} 
			return r;
		},
		
		set: function(n,v)
		{
			var arr = Web.HashCookie.getArr();
			arr[ n ] = v;
			Web.HashCookie.setArr( arr );
			return v;
		},
		
		remove: function(n)
		{
			var v = false;
			var arr = Web.HashCookie.getArr();
			if( def(arr[n] ) ) {
				v = arr[n];
				delete arr[n];
			}
			Web.HashCookie.setArr( arr );
			return v;
		},
		
		del: function(n)
		{
			Web.HashCookie.remove(n);
		}
	}
});




<!-- //*************************** END lib/web/hashcookie *********************************// -->



<!-- //************************** BEGIN lib/animation ********************************// -->

<!--




/**
 * Animation is a general object for animating elements on the screen.
 * There are only a few basic animation types that are currently in place.  The idea is that more can be added in the future.<br />
 * For example, a fade:
 * <pre>
 * 	new Animation({
 * 		el:div('boxy'),
 * 		type:'fade',
 * 		waittime:5,
 * 		by:3,
 * 		start:100,
 * 		end:0
 * 	});
 * </pre>
 * 	OR, a move:
 * <pre>
 * 	new Animation({
 * 		el:div('boxy'),
 * 		type:'move',
 * 		waittime:5,
 * 		by:[Animation.prototype.smooth,Animation.prototype.smooth],	
 * 		end:[0,500]
 * 	});
 * 	</pre>
 * 	Note the inclusion of Animation.prototype.smooth in the 'by' field of the previous example.  More "movement types" could be defined by the user (quadratic, boomerang, etc.), but 'smooth' is the only pre-defined one.  
 * @constructor
 * @param {anim} AnimationObject An object containing information about the type of animation to create.  A little tweaking between the 'by' and 'waittime' will probably be required for things to look nice and smooth.<br /><br />
 * {<br /> 
 * 		&nbsp;&nbsp;&nbsp;&nbsp;<strong>el</strong>: the element to move around<br />
 * 		&nbsp;&nbsp;&nbsp;&nbsp;<strong>type</strong>: currently one of 'move', 'resize', or 'fade'<br />
 * 		&nbsp;&nbsp;&nbsp;&nbsp;<strong>waittime</strong>: the number of milliseconds to wait in between frames (where a 'frame')<br />
 * 		&nbsp;&nbsp;&nbsp;&nbsp;<strong>by</strong>: every frame, the current value (coordinate/size/opacity) is incremented by this amount, until the final value is reached (types 'move' and 'resize' take an array -- for x and y values, respectively; 'fade' takes an integer -- for opacity amount).<br />
 * 		&nbsp;&nbsp;&nbsp;&nbsp;<strong>start</strong>: the starting value for the coordinate/size/opacity (types 'move' and 'resize' take an array -- for x and y values, respectively; 'fade' takes an integer -- for opacity amount).  If no 'start' is defined, then it will use the value(s) that the element has when starting (e.g., it's current x/y coordinates).<br />
 * 		&nbsp;&nbsp;&nbsp;&nbsp;<strong>end</strong>: the final value for coordinate/size/opacity (types 'move' and 'resize' take an array -- for x and y values, respectively; 'fade' takes an integer -- for opacity amount).<br />
 * }<br /> 
 */   
Animation = function( anim ) {
	/**
	 * @private
	 */	 	
	this.__by = 10;
	/**
	 * @private
	 */	 	
	this.__waittime = 5;

	/**
	 * @private
	 */	 	
	var me = this;
	
	/**
	 * @private
	 */	 	
	this.animations = {
		move: 
			{
				beginfunction:
					function(me) {
						if( !def(me.start) ) {
							me.start = DOM.findPos( me.el );
						}
						me.cur = [ me.start[0], me.start[1] ];
						me.el.style.position= 'absolute';
						
						me.animations[ me.type ].modfunctions[0]( me );
						me.animations[ me.type ].modfunctions[1]( me );x
					},
				modfunctions: 
					[
						function(me) { me.el.style.left= me.cur[0]+'px'; },
						function(me) { me.el.style.top= me.cur[1]+'px'; }
					]
			},
		resize: 
			{
				beginfunction:
					function(me) {
						if( !def(me.start) ) {
							me.start = [ me.el.offsetWidth, me.el.offsetHeight ];
						}
						me.cur = [ me.start[0], me.start[1] ];
						
						me.animations[ me.type ].modfunctions[0]( me );
						me.animations[ me.type ].modfunctions[1]( me );
					},
				modfunctions: 
				[
						function(me) { me.el.style.width= me.cur[0]+'px'; },
						function(me) { me.el.style.height= me.cur[1]+'px'; }
					]
			},
		fade: 
			{
				beginfunction:
					function(me) {
						if( !def(me.start) ) {
							me.start = [100];
						}
						me.cur = [ me.start[0] ];
						
						me.animations[ me.type ].modfunctions[0]( me );
					},
				modfunctions: 
					[
						function(me) { me.el.style.filter="alpha(opacity="+me.cur[0]+")";me.el.style.opacity=me.cur[0]/100; }
					]
			}
	};

	/**
	 * Checks to see if the animation is complete or not.
	 * @returns {bool} True if complete, false if not complete.
	 */	 	 		
	this.isComplete = function() {
		return !def(me.el);
	}	
	
	/**
	 * Cancels the current animation.
	 */	 	
	this.cancel = function() {
		if( def(me.timeout) ) clearTimeout( me.timeout );
		me.el = undefined;
		if( def(me.oncomplete) ) { me.oncomplete( me ); }
	}
	
	/**
	 * @private
	 */	 	
	this.pattern = function() {
		if(!def(me.el) || !def(me.end)) {
			return;
		}
		
	
		if(!def(me.cur)) {
			me.cur = [0,0];
			
		
			if( me.animations[ me.type ].modfunctions.length == 1 ) {
				if( !def(me.by) ) {
					me.by = [me.__by];
				} else {
					me.by = [me.by];
				}
				if( def(me.start) ) {
					me.start = [me.start];
				}
				me.end = [me.end];
			
		
			} else {
				if( !def(me.by) ) {
					me.by = [];
					for(var i=0;i<me.animations[ me.type ].modfunctions.length;i++) {
						me.by[i] = me.__by;
					}
				} else {
					for(var i=0;i<me.animations[ me.type ].modfunctions.length;i++) {
						if( !def(me.by[i]) ) {
							me.by[i] = me.__by;
						}
					}
				}
			}
			
		
			if( !def(me.waittime) ) {
				me.waittime = me.__waittime;
			}
			
			for(var i=0;i<me.animations[ me.type ].modfunctions.length;i++) {
				if( def(me.by) && def(me.by[i]) && typeof me.by[i]!='function' ) me.by[i] = parseInt( me.by[i], 10 );
				if(def(me.start)&&def(me.start[i]))me.start[i] = parseInt( me.start[i], 10 );
				if(def(me.end)&&def(me.end[i]))me.end[i] = parseInt( me.end[i], 10 );
			}

		
			me.animations[ me.type ].beginfunction( me );

			for(var i=0;i<me.animations[ me.type ].modfunctions.length;i++) {
				if( (typeof me.by[i] != 'function') && ( (me.start[i] < me.end[i] && me.by[i]<0) || (me.start[i] > me.end[i] && me.by[i]>0) ) ) {
					me.by[i]*=-1;
				}
			}
		}

	
		var dc = 0;		
		for(var i=0;i<me.animations[ me.type ].modfunctions.length;i++) {
			
			if( (me.start[i] <= me.end[i] && me.cur[i] >= me.end[i]) || (me.start[i] >= me.end[i] && me.cur[i] <= me.end[i]) ) {
				me.cur[i] = me.end[i];
				dc++;
				
			
				me.animations[ me.type ].modfunctions[i]( me );

			} else {
				
			
				me.animations[ me.type ].modfunctions[i]( me );

				if(typeof me.by[i] == 'function') {
					me.cur[i]+=me.by[i]( me, i );
				} else {
					me.cur[i]+=me.by[i];
				}
			}
		}

		if( dc!=me.animations[ me.type ].modfunctions.length ) {
			me.timeout = setTimeout( function() { me.pattern(); }, me.waittime );
			
	
		} else {
			if( def(me.oncomplete) ) {
				me.oncomplete( me );
			}
			me.el = undefined;
		}
		
	}

	for(var x in anim) {
		this[x] = anim[x];
	}
	if( danb(this['type']) ) {
		this.pattern();
	}
}

/**
 * A pre-defined "movement type".  See the Animation constructor for more animation.  
 * @extends Animation
 */ 
Animation.prototype.smooth = function( me, i ) {
	var tot = 10;
	var mod = 3;
	var perc = Math.abs( (me.cur[i]-me.start[i]) / (me.cur[i]-me.end[i]) );
	var ret = tot-parseInt( ( Math.log(tot) * perc ) / mod, 10 );

	if(ret<2) {
		ret=2;
		me.waittime/=2;
		if(me.waittime<1) me.waittime=1;
	}
	if( me.start[i]>me.end[i] ) {
		ret*=-1;
	}
	return ret;
}




<!-- //*************************** END lib/animation *********************************// -->



<!-- //************************** BEGIN lib/popupwindow ********************************// -->

<!--






PopupWindow = function() {
	this.id = "";
	this.zIndex = 999;
	this.opacity = 50; 

	this.root = {};
	this.baseDiv = {};
	this.shade = {};
	this.content = {};
	
	this.redrawOnResize = true;

	this.old_onclick;
	this.old_onresize;
	this.old_onscroll;
	
	this.fades = true;
	
	this.preventClicks = false;

	var me = this;
	
	this.setFades = function( bool )
	{
		me.fades = bool;
	}
	
	this.setRoot = function(root) {
		if(root=='body')root=document.getElementsByTagName('BODY')[0];
		me.root['el'] = root;
	}
	
	this.setID = this.setId = function(i) {
		me.id = i;
	}
	
	this.setContent = function(c) {
		me.content['el'] = c;	
	}
	
	this.setOpacity = function(o) {
		me.opacity = o;
	}
	
	this.setZIndex = function(z) {
		me.zIndex = z;
	}
	
	this.setRedrawOnResize = function(d) {
		me.redrawOnResize = d;
	}
	
	this.setPreventClicks = function(d) {
		me.preventClicks = d;
	}
	
	this.close = function() {
		if( def(me.shade.el) && def(me.shade.el.parentNode) ) {
			me.shade.el.parentNode.removeChild( me.shade.el );
			me.shade.el = undefined;
		}
		if( def(me.content.el) && def(me.content.el.parentNode) ) {
			me.content.el.parentNode.removeChild( me.content.el );
		}
		if( def(me.baseDiv.el) && def(me.baseDiv.el.parentNode) ) {
			me.baseDiv.el.parentNode.removeChild( me.baseDiv.el );
		}

		return false;
	}
	
	this.redraw = function() {
		var ph = User.getPageHeight();
		var iw = User.getInnerWidth();
		var sc = User.getScrollOffset();
		
	
	
		
		if( iw[0] > ph[0] ) ph[0] = iw[0];
		if( iw[1] > ph[1] ) ph[1] = iw[1];

	
		
		var correction = [0,0];
		if( User.getBrowser()=='Firefox' || (User.getBrowser()=='Safari'&&User.getOS()=='Windows') ) {
			if( ph[0]>iw[0] ) correction[1]=-16; 
			if( ph[1]>iw[1] ) correction[0]=-16;
		}
		
	

		DOM.stylize( me.shade.el,
			{
				left:'0px',
				top:'0px',
				width:sc[0]+ph[0]+correction[0]+'px',
				height:sc[1]+ph[1]+correction[1]+'px'
			}
		);

		me.content['w'] = me.content.el.offsetWidth;
		me.content['h'] = me.content.el.offsetHeight;

		DOM.stylize( me.content.el,
			{
				left: parseInt( sc[0] + iw[0]/2 - me.content.w/2 , 10) + 'px',
				top: parseInt( sc[1] + iw[1]/2 - me.content.h/2 , 10) + 'px'
			}
		);
		dbg(me.content.el.style.top,'me.content.el top');
	}
	
	this.init = function() {
		if(!def(me.content)) return;

		if( !def(me.root.el) ) {
			me.root.el = document.getElementsByTagName('body')[0];
		}
		
		me.baseDiv['el'] = DOM.crel('div', me.id, me.root.el,
			{
				className:'popupwindow',
				position:'absolute',
				width:'0px',
				height:'0px',
				backgroundColor:'#f00',
				zIndex:me.zIndex
			}
		);

		if( me.preventClicks ) {
			me.baseDiv.el.onclick = function(e) {
				var eo = new EventObject(e);
				return eo.stopprop();
			}
		}
		
		var pos = DOM.findPos( me.baseDiv.el );
		DOM.stylize( me.baseDiv.el,
			{
				left: -pos[0]+'px',
				top: -pos[1]+'px'
			}
		);
		DOM.stylize( me.baseDiv.el,
			{
				left: '0px',
				top: '0px'
			}
		);
		
		me.shade['el'] = DOM.crel('div', '', me.baseDiv.el,
			{
				backgroundColor:'#000',
				opacity:0,
				className:'shade',
				position:'absolute',
				zIndex:me.zIndex+1
			}
		);

		if( me.fades ){
			var fade = new Animation(
				{
					oncomplete:function() { DOM.show( me.content.el ); },
					el:me.shade.el,
					type:'fade',
					waittime:0,
					start:0,
					end:me.opacity,
					by:17
				}
			);
		} else {
			DOM.setOpacity( me.shade.el, me.opacity );
		}
		
		me.baseDiv.el.appendChild( me.content.el );
		
		DOM.stylize( me.content.el,
			{
				visibility:'hidden',	
				position:'absolute',
				zIndex:me.zIndex+2
			}
		);
		
		me.content['w'] = me.content.el.offsetWidth;
		me.content['h'] = me.content.el.offsetHeight;

		if( me.fades ) {		
		
			DOM.stylize( me.content.el,
				{
					visibility:'hidden'
				}
			);
		} else {
			DOM.show( me.content.el );
		}
		
		if( me.redrawOnResize ) {
			var old = window.onresize;
			window.onresize= function() {
				me.redraw();
				if(def(old))old();
			}
		}
		
		me.redraw();
	}
}




<!-- //*************************** END lib/popupwindow *********************************// -->



<!-- //************************** BEGIN TOR/Button ********************************// -->

<!--

var TOR_Button =
{	
	focus: function( button )
	{
		try {
			button.focus();
		} catch(e) { dbg(e,'Button.focus'); }
	},
	
	create: function( caption, linkProperties )
	{
		if( !def(url) ) {
			var url = '#'; 
		}
		var creTreeObject = 
		{
			t:'a',
			kids:
			[
				{
					t:'span',
					kids:[
						{t:'span',kids:[{text:caption}]}
					]
				}
			]
		}
		if( def(linkProperties) ) {
			for(var x in linkProperties) {
				creTreeObject[x] = linkProperties[x];
			}
		} 
		if( !def(creTreeObject['href']) ) {
			creTreeObject['href'] = 'javascript:void(0)';
		}
		return DOM.creTree( creTreeObject );
	},
	
	create2: function( caption, linkProperties )
	{
		if( !def(url) ) {
			var url = '#'; 
		}
		var creTreeObject = 
		{
			t:'span',
			kids:
			[
				{
					t:'a',
					kids:
					[
						{
							t:'span',
							kids:[
								{t:'span',kids:[{text:caption}]}
							]
						}
					]
				},
				{t:'br'},
				{t:'br'}
			]
		}
		if( def(linkProperties) ) {
			for(var x in linkProperties) {
				creTreeObject.kids[0][x] = linkProperties[x];
				dbg( creTreeObject.kids[0][x],x );
			}
		} else {
			creTreeObject.kids[0]['href'] = 'javascript:void(0)';
		}
		return DOM.creTree( creTreeObject );
	}
};




<!-- //*************************** END TOR/Button *********************************// -->



<!-- //************************** BEGIN TOR/Popup ********************************// -->

<!--





var TOR_Popup =
{
	UsingDefault: false,
	
	bindDeleteLinks: function()
	{
		return alert('not imple');
		
		var imgs = document.getElementsByTagName('img');
		var a;
		for(var i=0;i<imgs.length;i++) {
			if( imgs[i].src.match(/(icons\/minus.gif|buttons\/delete.gif)/) && imgs[i].parentNode && imgs[i].parentNode.nodeName.toLowerCase()=='a' ) {
				dbg( imgs[i].src, 'Found delete image '+i);
				a = imgs[i].parentNode;
				var href = ( def(a.href) ? a.href : a );
				a.href = 'javascript:void(0)';
				a.onclick = TOR_Popup.confirm.bind( this, TOR_Strings[ TOR_User.Command.getLanguage() ]['sure_continue'], href, noop, TOR_Strings[ TOR_User.Command.getLanguage() ]['confirm_removal'] );
			}
		}
	
	},
	
	getObject: function()
	{
		var popup = new PopupWindow();
		popup.setFades( 0 );
		return popup;
	},
	
	generic: function( popupwindow, title, message, buttons, id )
	{
		if( !danb(id) ) id = 'tor_popup';
		
		var outtercontent = DOM.creTree({
			t:'div',
			id:id,
			kids:[
				{
					t:'div',
					style:{className:'popupwindow_header'},
					kids:[
						{text:title}
					]
				},
				{
					t:'div',
					style:{className:'popupwindow_content'},
					variable:'content'
				},
				{
					t:'div',
					style:{className:'popupwindow_footer'},
					variable:'footer'
				}
			]
		});

		var defaultBtn = 0;
		for(var i=0;i<buttons.length;i++) {
			buttons[i].btn = TOR_Button.create(
				buttons[i].caption,
				buttons[i].properties 
			);
			buttons[i].btn.setAttribute('tabIndex',i+2);
			outtercontent.vars.footer.appendChild( buttons[i].btn );
			if( def(buttons[i].isDefault) && buttons[i].isDefault ) {
				buttons[i].btn.setAttribute('tabIndex',1);
				defaultBtn = i;
			}
		}
		
		DOM.creTree({t:'br'},outtercontent.vars.footer);
	

		if( def(message.nodeType) ) {
			outtercontent.vars.content.appendChild( message );
		} else {
			outtercontent.vars.content.innerHTML = message;
		}
		
		popupwindow.setContent( outtercontent );
		
		popupwindow.init();

		if( buttons.length>0 ) {
			setTimeout(
				function(){
					TOR_Button.focus( buttons[defaultBtn].btn );
				},
				250
			);			
		}
		
		return false;
	},
	
	confirm: function( message, okFunction, cancelFunction, title )
	{
		if( TOR_Popup.UsingDefault ) {
			if( confirm( message ) ) {
				if( isFunction( okFunction ) ) {
					return okFunction();
				} else {
					return true;
				}
			} else {
				if( isFunction( cancelFunction ) ) {
					return cancelFunction();
				} else {
					return false;
				}
			}
		}
		
		if( !def(title) ) {
			title = TOR_Strings[ TOR_User.Command.getLanguage() ]['alert_box'];
		}

		var w = TOR_Popup.getObject();	
		TOR_Popup.generic( w, title, message,
			[
				{
					caption:TOR_Strings[ TOR_User.Command.getLanguage() ]['popup_ok'], 
					properties: {
						href:( isFunction( okFunction ) ? 'javascript:void(0)' : okFunction ),
						onclick: ( isFunction( okFunction ) ? function() { if(def(okFunction)){okFunction();}w.close(); } : noop ),
						style:{className:'btn update'} 
					}
				},
				{
					caption:TOR_Strings[ TOR_User.Command.getLanguage() ]['popup_cancel'], 
					properties: {
						href:'javascript:void(0)',
						onclick: function() { if(danb(cancelFunction)){cancelFunction();}w.close(); },
						style:{className:'btn cancel'} 
					},
					isDefault:true
				}
			] 
		);
			
	},
	
	alert: function( message, title )
	{
		if( TOR_Popup.UsingDefault ) {
			return alert(message);
		}
		
		if( !def(title) ) {
			title = TOR_Strings[ TOR_User.Command.getLanguage() ]['alert_box'];
		}
	
		var w = TOR_Popup.getObject();	
		TOR_Popup.generic( w, title, message, 
			[
				{
					caption:TOR_Strings[ TOR_User.Command.getLanguage() ]['popup_close'], 
					properties: {
						href:'javascript:void(0)',
						onclick: w.close,
						style:{className:'btn update'} 
					}
				}
			] 
		);
	}
}








<!-- //*************************** END TOR/Popup *********************************// -->




<!-- //************************** BEGIN TOR/Strings ********************************// -->

<!--

var TOR_Strings =
{
	'en':
	{
		'confirm_approve_content': 'Are you sure you want to approve this content?',
		'must_be_an_admin': 'Must be an admin',
		'search_input_value': 'Search',
		'Search': 'Search',
		'share_this_entry':'Share This Entry',
		'Tag': 'Tag',
		'Category': 'Category',
		'User': 'User',
		'Loading': 'Loading...',
		'popup_close_window': 'Close Window',
		'popup_ok': 'OK',
		'popup_close': 'Close',
		'popup_cancel': 'Cancel',
		'popup_email_to_a_friend': 'Email to a friend',
		'sure_continue': 'Are you sure you want to continue?',
		'confirm_removal': 'Confirm Removal',
		'confirm_box': 'Confirm',
		'alert_box': 'Alert',
		'must_be_logged_in': 'You must be logged in to do this.',
		'must_be_logged_in_to_rate_content': 'You must be logged in to rate content.'
	},
	
	'fr': // TODO
	{
		'confirm_approve_content': String.fromCharCode('202') + 'tes vous certain de vouloir approuver ce contenu?',
		'must_be_an_admin': String.fromCharCode('202') + 'tes vous certain de vouloir approuver ce contenu?',
		'search_input_value': 'Chercher',
		'Search': 'Chercher',
		'Tag': 'Mot-cl' + String.fromCharCode('233'),
		'share_this_entry':'Partagez cette soumission',
		'Category': 'Cat' + String.fromCharCode('233') + 'gorie',
		'User': '...',
		'popup_close_window': 'Fermer la fen' + String.fromCharCode('234') + 'tre',
		'popup_ok': 'OK',
		'popup_close': 'Fermer',
		'popup_cancel': 'Annuler',
		'popup_email_to_a_friend': 'Envoyer un courriel ' + String.fromCharCode('224') + ' un ami',
		'sure_continue': String.fromCharCode('202') + 'tes vous certain de vouloir continuer?',
		'confirm_removal': 'Confirmer votre retrait',
		'alert_box': 'Alerte', 
		'must_be_logged_in': 'Vous devez ' + String.fromCharCode('234') + 'tre connect' + String.fromCharCode('233') + ' pour continuer', 
		'must_be_logged_in_to_rate_content': 'Vous devez ' + String.fromCharCode('234') + 'tre connect' + String.fromCharCode('233') + ' pour ' + String.fromCharCode('233') + 'valuer le contenu',
		'Loading': 'T' + String.fromCharCode('233') + 'l' + String.fromCharCode('233') + 'chargement...'
	}
};




<!-- //*************************** END TOR/Strings *********************************// -->



<!-- //************************** BEGIN TOR/User ********************************// -->

<!--





var TOR_User =
{
	Objects:
	{
		UserId: false,
		UserName: false
	},
	
	Command:
	{
		getUserId: function()
		{
			return TOR_User.Objects.UserId;
		},
		
		getUserName: function()
		{
			return TOR_User.Objects.UserName;
		},
		
		getLanguage: function()
		{
			if( location.href.match(/espaceorange\.ca/) ) {
				return 'fr';
			}
			return 'en';
		},
		
		isAdmin: function()
		{
			return false;
		},
		
		setupLoggedIn: function( userSpan )
		{
			TOR_User.Objects.UserName = userSpan.childNodes[0].nodeValue;
			var m = userSpan.className.match(/(admin)?id(\d+)/);
			if( m ) {
				TOR_User.Objects.UserId = m[2];
				if(danb(m[1]))TOR_User.Command.isAdmin=function(){return true};
			}
		},
		
		setupNotLoggedIn: function( loginForm, loginLink )
		{
			DOM.register('loginForm','user_login_form');
			DOM.register('loginLink','user_login_link');
			DOM.register('loginUsername','user_login_username');
			DOM.register('loginPassword','user_login_password');
			
			DOM.get('loginUsername').onfocus = DOM.get('loginPassword').onfocus = function(){ this.select() };
		},
		
		init: function()
		{
			var userSpan = $('userId');
			if( userSpan ) {
				TOR_User.Command.setupLoggedIn( userSpan );
			} else {
				TOR_User.Command.setupNotLoggedIn(  );
			}
		}
	},
	
	View:
	{
		showLogin : function()
		{
			var facebookLogin = DOM.get('facebook_li');
			var link = DOM.get('loginLink');
			var form = DOM.get('loginForm');
			
			DOM.hide(facebookLogin);
			DOM.show(form);
			DOM.hide(link);

			try{
				var fieldset = ( DOM.find({parent:form,tag:'fieldset'}) )[0].element;
				var anim = new Animation({
					oncomplete:function()
					{ 
						form['username'].select();
						form['username'].focus(); 
					},
		            el:fieldset,
		            type:'fade',
		            waittime:0,
		            start:0,
		            end:100,
		            by:15
				});

				DOM.stylize( form.parentNode, {className:'listFirst'} );
			} catch(e) {dbg(e,'exccc'); }
		}
	}
} 

addLoadEvent( TOR_User.Command.init );





<!-- //*************************** END TOR/User *********************************// -->



<!-- //************************** BEGIN lib/data/objectwatcher ********************************// -->

<!--





OO.Class.define('Data_ObjectWatcher',function(){
	this.counter = 0;
	this.classes = {};
	
	
	this.find = function( className, id )
	{
		var r = false;
		if( def( this.classes[className] ) ) {
			r = deepObjectCopy( this.classes[className].data.get(id) );
		}
		return r;
	}
	
	this.findAll = function( className )
	{
		var r = false;
		if( def( this.classes[className] ) ) {
			r = deepObjectCopy( this.classes[className].data.getAssociativeArray() );
		}
		return r;
	}
	
	this.save = function( className, object )
	{
		if( !def(className) || !def(object) || !def(object.id) ) return dbg(className + ' and '+object + ' and '+object.id, 'Data_ObjectWatcher save, !def');
		var original = false;
		if( !def(this.classes[className]) ) {
			this.classes[className] = {};
		}
		if( !object.id ) {
			object.id = 'newObject'+this.counter++;
		}
		if( !def(this.classes[className].data) ) {
			this.classes[className].data = OO.Class.instance('Data_Store_Simple');
			
		} else {
			original = this.classes[className].data.get(object.id);
		}
		this.classes[className].data.set( object.id, object );
		
	
		if( this.isDifferent( original, object ) ) {
			this.notify( className, object );
		}
	}
	
	this.remove = this.del = function( className, object )
	{
		if( !def(className) || !def(object) || !danb(object.id) || !def(this.classes[className]) || !def(this.classes[className].data) ) return dbg(className + ' and '+object + ' and '+object.id+ ' and '+this.classes[className]+ ' and '+this.classes[className].data, 'Data_ObjectWatcher remove2, !def');
		this.classes[className].data.remove( object.id ); 

		this.notify( className, object );
	}
	
	this.isDifferent = function(o1, o2)
	{
	
		return true;
	}
	
	
	this.attach = function( className, object, observer )
	{
		if( !def(className) || !def(object) || !danb(object.id) ) return dbg(className + ' and '+object + ' and '+object.id, 'Data_observer attach, !def');
		if( !def(this.classes[className]) ) {
			this.classes[className] = {};
		}
		if( !def(this.classes[className].observers) ) {
			this.classes[className].observers = {};
		}
		if( !def(this.classes[className].observers[object.id]) ) {
			this.classes[className].observers[object.id] = new Observer();
		}
		this.classes[className].observers[object.id].attach( observer );
	}
	
	this.detach = function( className, object )
	{
		if( !def(className) || !def(object) || !danb(object.id) || !def(this.classes[className]) || !def(this.classes[className].observers) || !def(this.classes[className].observers[object.id]) ) return dbg(className + ' and '+object + ' and '+object.id+ ' and '+this.classes[className]+ ' and '+this.classes[className].observers+ ' and '+this.classes[className].observers[object.id], 'Data_observer detach, !def');
		this.classes[className].observers[object.id].detach( observer ); 
	}
	
	this.notify = function( className, object )
	{
		if( 
			!def(className) || 
			!def(object) || 
			!danb(object.id) || 
			!def(this.classes[className]) || 
			!def(this.classes[className].observers) || 
			!def(this.classes[className].observers[object.id]) 
		) return dbg(
			className + ' and '+
			object + ' and '+
			object.id+ ' and '+
			this.classes[className]+ ' and &quot;observers&quot;', 'Data_observer notify, !def');
		this.classes[className].observers[ object.id ].notify( object );
	}
});





<!-- //*************************** END lib/data/objectwatcher *********************************// -->



<!-- //************************** BEGIN lib/data/objectwatcher/callbacks ********************************// -->

<!--



OO.Class.define('Data_ObjectWatcher_Callbacks',function(){
	OO.extend(this,'Data_ObjectWatcher');
	
	this.client;

	this.getClient = function(c)
	{
		return this.client;
	}
		
	this.setClient = function(c)
	{
		this.client = c;
	}

	this.__find = this.find;
	this.__findAll = this.findAll;
	this.__save = this.save;
	this.__remove = this.__del = this.remove;
	
	this.restClientObjectCounter = 0;
	this.getRestClientObject = function( o )
	{
		var rco = {
			restClientObjectId: this.restClientObjectCounter++ 
		};
		if( def(o.className) ) rco.className = o.className;
		if( def(o.id) ) rco.id= o.id;
		if( def(o.object) ) {
			rco.object= o.object;
			if( def(o.object.id) ) rco.id = o.object.id;
		}
		if( def(o.options) ) {
			rco.options = o.options;
			if( def(o.options.onSuccess) ) rco.onSuccess = o.options.onSuccess;
			if( def(o.options.onError) ) rco.onError = o.options.onError;
		} else {
			rco.options = {};
			rco.onSuccess = noop;
			rco.onError = noop;
		}
		return rco;
	}
	
	this.find = function( className, id, options ) {
		var o = this.__find(className,id);
		if( !o ) {
			var rco = this.getRestClientObject({className:className,id:id,options:options});
			this.client.retrieve( rco );
		} else {
			if( def(options.onSuccess) ) {
				options.onSuccess( o ) ;
			}
		}
	}
	
	this.findAll = function( className, options ) {
		var rco = this.getRestClientObject({className:className,options:options});
		this.client.retrieveAll( rco );
	}
	
	this.save = function( className, object, options ) {
		var rco = this.getRestClientObject({className:className,object:object,options:options});

	
		if( def(object.id) ) {
		
			this.client.store( rco );
			
	
		} else {
			this.client.create( rco );
		}
	}
	
	this.remove = this.del = function( className, object, options ) {
		var rco = this.getRestClientObject({className:className,object:object,options:options});

	
		this.client.remove( rco );
	}
	
	this.__construct = function(c)
	{
		this.setClient(c);
	}
	
});




<!-- //*************************** END lib/data/objectwatcher/callbacks *********************************// -->


<!-- //************************** BEGIN lib/web/mime ********************************// -->

<!--




__rootCreate('Web');

OO.extend(Web,{
	Mime:
	{
		DefaultType: 'text/plain',
		
		Types: OO.Class.instance(
			'Data_Store_Simple',
			{
				'application/x-www-form-urlencoded':'formdata',
				'application/xml':'xml',
				'application/javascript':'js',
				'text/plain':'txt',
				'text/html':'html'
			}
		),
	 
		old: function( contentType )
		{
			if( contentType=='application/xml' ) {
				return 'xml';
			} else if( contentType=='text/x-json'||contentType=='text/javascript'||contentType=='application/javascript' ) {
				return 'js';
			} else if( contentType=='plain/text' ) {
				return 'text';
			} else if( contentType=='text/html' ) {
				return 'html';
			}
			return 'unknown';
		},
		
		byExtension: function( extension )
		{
			var contentType = Web.Mime.Types.getKey( extension );
			if( !contentType ) contentType = Web.Mime.DefaultType;
			return contentType;
		},
		
		byContentType: function( contentType )
		{
			var extension = Web.Mime.Types.get( contentType );
			if( !extension ) extension = Web.Mime.Types.get( Web.Mime.DefaultType );
			return extension;
		}
	}
});




<!-- //*************************** END lib/web/mime *********************************// -->



<!-- //************************** BEGIN lib/ajax/common ********************************// -->

<!--




__rootCreate('Ajax','Common');

OO.extend(Ajax.Common,
{
	getXMLHttpRequest: function()
	{
		try { return new XMLHttpRequest(); }
		catch(error) {
			try{ return new ActiveXObject("Microsoft.XMLHTTP"); }
			catch(error) { return false; }
		}
		return false;
	},
	
	serializeData: function( data )
	{
		return '';
		
		var s;
		if( isString( data ) ) {
			s = data.toString();
		} else if( isArray( data ) ) {
			dbg(' not imple');
		} else if( isObject( data ) ) {
			foreachObject(data,function(n,v){
				
			});
		} else if( def(data.toString) ) {
			s = data.toString();
		} else {
			s = '';
		}
		return s;
	}
});	



<!-- //*************************** END lib/ajax/common *********************************// -->



<!-- //************************** BEGIN lib/web/http ********************************// -->

<!--



__rootCreate('Web');

OO.extend(Web,
{
	Http:
	{
		Code:
		{
			HTTP_CONTINUE: 100,
			HTTP_SWITCHING_PROTOCOLS: 101,
	
			HTTP_OK: 200,
			HTTP_CREATED: 201,
			HTTP_ACCEPTED: 202,
			HTTP_NON_AUTHORITATIVE_INFORMATION: 203,
			HTTP_NO_CONTENT: 204,
			HTTP_RESET_CONTENT: 205,
			HTTP_PARTIAL_CONTENT: 206,
	
			HTTP_MULTIPLE_CHOICES: 300,
			HTTP_MOVED_PERMANENTLY: 301,
			HTTP_FOUND: 302,
			HTTP_SEE_OTHER: 303,
			HTTP_NOT_MODIFIED: 304,
			HTTP_USE_PROXY: 305,
			HTTP_TEMPORARY_REDIRECT: 307,
	
			HTTP_BAD_REQUEST: 400,
			HTTP_UNAUTHORIZED: 401,
			HTTP_PAYMENT_REQUIRED: 402,
			HTTP_FORBIDDEN: 403,
			HTTP_NOT_FOUND: 404,
			HTTP_METHOD_NOT_ALLOWED: 405,
			HTTP_NOT_ACCEPTABLE: 406,
			HTTP_PROXY_AUTHENTICATON_REQUIRED: 407,
			HTTP_REQUEST_TIMEOUT: 408,
			HTTP_CONFLICT: 409,
			HTTP_GONE: 410,
			HTTP_LENGTH_REQUIRED: 411,
			HTTP_PRECONDITION_FAILED: 412,
			HTTP_REQUEST_ENTITY_TOO_LARGE: 413,
			HTTP_REQUEST_URI_TOO_LONG: 414,
			HTTP_UNSUPPORTED_MEDIA_TYPE: 415,
			HTTP_REQUESTED_RANGE_NOT_SATISFIED: 416,
			HTTP_EXPECTATION_FAILED: 417,
	
			HTTP_INTERNAL_SERVER_ERROR: 500,
			HTTP_NOT_IMPLEMENTED: 501,
			HTTP_BAD_GATEWAY: 502,
			HTTP_SERVICE_UNAVAILABLE: 503,
			HTTP_GATEWAY_TIMEOUT: 504,
			HTTP_VERSION_NOT_SUPPORTED: 505
		},
		
		Message:
		{
			100: "Continue",
			101: "Switching Protocols",
			200: "OK",
			201: "Created",
			202: "Accepted",
			203: "Non-Authoritative Information",
			204: "No Content",
			205: "Reset Content",
			206: "Partial Content",
			300: "Multiple Choices",
			301: "Moved Permanently",
			302: "Found",
			303: "See Other",
			304: "Not Modified",
			305: "Use Proxy",
			307: "Temporary Redirect",
			400: "Bad Request",
			401: "Unauthorized",
			402: "Payment Required",
			403: "Forbidden",
			404: "Not found",
			405: "Method not allowed",
			406: "Not acceptable",
			407: "Proxy Authenticaton Required",
			408: "Request Timeout",
			409: "Conflict",
			410: "Gone",
			411: "Length Required",
			412: "Precondition Failed",
			413: "Request entity too large",
			414: "Request-URI too long",
			415: "Unsupported Media Type",
			416: "Requested Range Not Satisfied",
			417: "Expectation Failed",
			500: "Internal Server Error",
			501: "Not Implemented",
			502: "Bad Gateway",
			503: "Service Unavailable",
			504: "Gateway Timeout",
			505: "HTTP Version not supported"
		},
		
		Group:
		{
			INFORMATION: 1,
			SUCCESS: 2,
			REDIRECT: 3,
			CLIENTERROR: 4,
			SERVERERROR: 5
		}
	}
});




<!-- //*************************** END lib/web/http *********************************// -->


<!-- //************************** BEGIN lib/web/email ********************************// -->

<!--



__rootCreate('Web');

OO.extend(Web,
{
	Email:
	{
		isValid: function(email)
		{
		    var regex = /^((([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+(\.([a-z]|[0-9]|!|#|$|%|&|'|\*|\+|\-|\/|=|\?|\^|_|`|\{|\||\}|~)+)*)@((((([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.))*([a-z]|[0-9])([a-z]|[0-9]|\-){0,61}([a-z]|[0-9])\.)[\w]{2,4}|(((([0-9]){1,3}\.){3}([0-9]){1,3}))|(\[((([0-9]){1,3}\.){3}([0-9]){1,3})\])))$/i
		    return regex.test(email);
		}
	}
});




<!-- //*************************** END lib/web/email *********************************// -->



<!-- //************************** BEGIN lib/web ********************************// -->

<!--











<!-- //*************************** END lib/web *********************************// -->



<!-- //************************** BEGIN lib/ajax/response/status ********************************// -->

<!--




OO.Class.define('Ajax_Response_Status',
	function( code )
	{
		this.private_code;
		this.private_codeGroup;
		this.private_error;
		
		this.getCode = function()
		{
			return this.code;
		}
		
		this.getMessage = function()
		{
			return ( def(Web.Http.Message[ this.code ] ) ? Web.Http.Message[ this.code ] : 'An unknown error has occured.' ); 
		}
		
		this.isSuccess = function()
		{
			return ( this.codeGroup == Web.Http.Group.SUCCESS );
		}
		
		this.isInformation = function()
		{
			return ( this.codeGroup == Web.Http.Group.INFORMATION );
		}
		
		this.isRedirect = function()
		{
			return ( this.codeGroup == Web.Http.Group.REDIRECT );
		}
		
		this.isClientError = function()
		{
			return ( this.codeGroup == Web.Http.Group.CLIENTERROR );
		}
		
		this.isServerError = function()
		{
			return ( this.codeGroup == Web.Http.Group.SERVERERROR );
		}
		
		this.isError = function()
		{
			return this.error;
		}
		
		this.__construct = function( code ) {
		
			this.code = code;
			this.codeGroup = new String(code).charAt(0);
			this.error = 
			( 				
				( this.codeGroup != Web.Http.Group.INFORMATION ) && 
				( this.codeGroup != Web.Http.Group.REDIRECT ) && 
				( this.codeGroup != Web.Http.Group.SUCCESS )
			);
		}
	}
);




<!-- //*************************** END lib/ajax/response/status *********************************// -->



<!-- //************************** BEGIN lib/ajax/response ********************************// -->

<!--







OO.Class.define('Ajax_Response',
	function( xmlhttprequest )
	{
		this.private_xmlhttprequest;
		this.private_responseHeaders;
		this.private_extension;
		this.private_status;
		
		this.get = function() 
		{
			if( this.isXml() ) {
				return this.xmlhttprequest.responseXML;
			} else if( this.isJson() ) {
				if( danb(this.xmlhttprequest.responseText) ) {
					return eval( '('+this.xmlhttprequest.responseText+')' );
				} else {
					return false;
				}
			} else {
				return this.xmlhttprequest.responseText;
			}
		}		
		
		this.getXml = function()
		{
			return this.xmlhttprequest.responseXML;
		}
		
		this.getText = function()
		{
			return this.xmlhttprequest.responseText;
		}
		
		this.isXml = function()
		{
			return( this.extension=='xml' );
		}
		
		this.isJson = function()
		{
			return( this.extension=='js' );
		}
		
		this.isText = function()
		{
			return( this.extension=='text' );
		}
		
		this.isHtml = function()
		{
			return( this.extension=='html' );
		}
		
		this.getStatus = function()
		{
			return this.status;
		}
		
		this.getResponseHeader = function( n ) 
		{
			return this.responseHeaders.get( n );
		}
		
		this.getLanguage = function()
		{
			return this.responseHeaders.get('Content-Language');
		}
		
		this.getExtension = function()
		{
			return this.extension;
		}
		
		this.__construct = function( xmlhttprequest )
		{
			this.xmlhttprequest = xmlhttprequest;
			var responseHeaders = this.xmlhttprequest.getAllResponseHeaders().split(/\r|\n/);
			var ds = OO.Class.instance('Data_Store_Simple');
			foreachArray( responseHeaders, function(i,v2){
				if( danb(v2) && !isFunction(v2) ) {
					var m = v2.split(": ");
					if( m && m.length>1 ) {
						ds.set(m[0],m[1]);
					}
				}
			});
			this.responseHeaders = ds;
			this.extension = Web.Mime.byContentType( this.responseHeaders.get('Content-Type') );
			var status = this.xmlhttprequest.status; 
			if( this.xmlhttprequest.status==1223 ) {
				status=204;
			}
			this.status = OO.Class.instance('Ajax_Response_Status', status);
		}
	}
);




<!-- //*************************** END lib/ajax/response *********************************// -->



<!-- //************************** BEGIN lib/ajax/base ********************************// -->

<!--









OO.Class.define('Ajax_Base',
	function(action,func)
	{
		this.protected_onCompleteFunction;
		this.protected_onReadyStateChangeFunction;
		this.protected_action;
		this.protected_method;
		this.protected_asynchronous;
		this.protected_username;
		this.protected_password;
		this.protected_postParams;
		this.protected_postData;
		this.protected_contentType;
		this.protected_completed;
		
		this.response; 
		
		this.isCompleted = function() { return this.completed; }
		this.setCompleted = function(b) { this.completed = b; }
		
		this.getFunction = function() { return this.onCompleteFunction; }
		this.setFunction = function(o) { this.onCompleteFunction = o; }
		
		this.getAction = function() { return this.action; }
		this.setAction = this.setUrl = this.setURL = this.setPath = function(o) { 
			delete this.action; 
			this.action= new Web.Url.Wrapper(o); 
		}
		
		this.getMethod = function() { return this.method; }
		this.setMethod = function(o) { this.method=o.toLowerCase(); }
		
		this.getAsynchronous = this.getAsync = function() { return this.asynchronous; }
		this.setAsynchronous = this.setAsync = function(o) { this.asynchronous= o; }
		
		this.protected_getUsername = function() { return this.username; }
		this.setUsername = function(o) { this.username= o; }
		
		this.protected_getPassword = function() { return this.password; }
		this.setPassword = function(o) { this.password= o; }
		
		this.getResponse = function() { return ( def(this.response) ? this.response : false ); }

		this.get = function() { this.method = 'get'; this.request(); }
		this.post = function() { this.method = 'post'; this.request(); }
		this.put = function() { this.method = 'put'; this.request(); }
		this.del = function() { this.method = 'delete'; this.request(); }
	
		this.setGetParam = this.setParam = this.setQueryParam = function( p, q ) {
			if( danb(p) ) {
				this.action.set( p, q );
			}
		}
		
		this.setPostParam = function( p, q ) {
			if( isArray(p) ) {
				foreachObject(p,function(n,v){
					this.postParams.set(n,v);
				});
			} else if( danb(p) ) {
				this.postParams.set(p,q);
			}
		}
		
		this.getContentType = function() { return this.contentType; }
		this.setContentType = function(o) { this.contentType= o; }
		
		this.getPostData= function() { return this.postData; }
		this.setPostData= function(o) { this.postData = o; }
	
		/**
		 * Cancels the request in progress.
		 */	 
		this.cancel = function() {
			if( def(me.request) ) {
				me.request.abort();
			}
		}
		
		this.request = function() 
		{
			if( !danb(this.action.getUrl()) )return;
			
			this.setCompleted( false );
			
			
			if( def(this.xmlhttprequest) ) {
				if( def(this.xmlhttprequest.readyState) && this.xmlhttprequest.readyState != 0 && this.xmlhttprequest.readyState != 4 ) {
					this.xmlhttprequest.abort();
				}
				this.xmlhttprequest = null;
				this.xmlhttprequest = undefined;
			}
			
			this.xmlhttprequest = Ajax.Common.getXMLHttpRequest();

		
			this.setupOnReadyStateChangeFunction();
		
			
			this.xmlhttprequest.onreadystatechange = this.onReadyStateChangeFunction;

			var url = this.action.build();
			if(0){
			url = '/api/v1/videos/tags/Qu%58bec.js';
			url = '/api/v1/videos/tags/Qu%E9bec.js';
			url = '/api/v1/videos/tags/Québec.js';
			url = '/api/v1/videos/tags/Qu%C3%E9bec.js';
		
			}
			dbg('method: '+this.method+ ', action: '+url+', async: '+this.asynchronous+', u/p: '+this.username+'/'+this.password);
			this.xmlhttprequest.open( this.method, url, this.asynchronous, this.username, this.password );
			this.xmlhttprequest.setRequestHeader('Content-Type', this.contentType );
		
			
			var data = null;
			if( this.method=='post' || this.method=='put' ) {
				if( def(this.postData) ) {
					data = this.postData;
				} else {
					if( this.contentType == Web.Mime.byExtension('formdata') ) {
						data = Web.Url.serialize(this.postParams.getAssociativeArray());
					} else if( this.contentType == Web.Mime.byExtension('js') ) {
						data = Data.Json.serialize(this.postParams.getAssociativeArray());
					}
				}
				dbg(data,'post/put data');
			} 
			
			this.xmlhttprequest.send( data );
			
		
			if( def(this.onReadyStateChangeFunction) ) {
				this.onReadyStateChangeFunction();
			}
		
			setTimeout( 
				function() {
					this.onReadyStateChangeFunction();
				}.bind(this), 1000
			);
		}
		
		this.setupOnChangeFunction = function() {
			alert('Child should have redefined.');
		}
		
		this.__construct = function(func,action)
		{
			this.onCompleteFunction = func;
			this.action = new Web.Url.Wrapper( action );

			this.asynchronous = true;
			this.username = '';
			this.password = '';
			this.postParams = OO.Class.instance('Data_Store_Simple');
			this.postData = null;
			this.contentType = Web.Mime.byExtension('formdata');
			this.completed = false;
 		}
	}
);




<!-- //*************************** END lib/ajax/base *********************************// -->



<!-- //************************** BEGIN lib/ajax/rest ********************************// -->

<!--




OO.Class.define('Ajax_Rest',
	function(action,func)
	{
		this.setupOnReadyStateChangeFunction = function()
		{
			this.onReadyStateChangeFunction = function() {
				this.readyStateChangeFunctionTryCount=0;
				try{
					if
					( 
						def(this.xmlhttprequest) && 
						this.xmlhttprequest.readyState==4 && 
						def(this.xmlhttprequest.status) &&
						!this.isCompleted() 
					)
					{
						this.setCompleted( true );

						this.response = OO.Class.instance('Ajax_Response', this.xmlhttprequest );
							
						this.xmlhttprequest = null;
						this.xmlhttprequest = undefined;

						if( def(this.onCompleteFunction) ) {
							this.onCompleteFunction(this);
						}

					} else {
						if( def(this.onReadyStateChangeFunction) ) {
							if( !this.isCompleted() ) {
								setTimeout( this.onReadyStateChangeFunction.bind(this) , 50 );
							}
						}
					}
				} catch(e) {
					try{
						if(dbg&&def(dbg))dbg(e,'REST Exceptio');
						if( this.readyStateChangeFunctionTryCount++<20 ) {
							this.onReadyStateChangeFunction();
						}
					} catch(e) {}
				} 
			}
		}
	}
).extend('Ajax_Base');




<!-- //*************************** END lib/ajax/rest *********************************// -->



<!-- //************************** BEGIN TOR/RestClient ********************************// -->

<!--

OO.Class.define('TOR_RestClient',function(){
	this.classResourceMapper;
	this.ajax = {};
	this.data;
	
	this.getUrl = function( className, options )
	{
		var url = '/api/v1/'+this.classResourceMapper.get( className );
		var lang = TOR_User.Command.getLanguage();

		if( def(options) ) {
			if( danb(options.id) ) {
				if( className.match(/^Content_/) ) {
					url = '/api/v1/'+this.classResourceMapper.get( 'Content_Abstract' );
				}
			
				url+='/'+options.id;
			}
			if( danb(options.user) ) url+='/users/'+options.user;
			if( danb(options.category) ) url+='/categories/'+options.category;
			if( danb(options.tag) ) url+='/tags/'+options.tag;
		}
		if( className!='Rating_Content' ) {
			if( lang=='fr' ) {
				url+='.fr.js';
			} else {
				url+='.js';
			}
		}
		if( def(options) && danb(options.search) ) {
			//url+='?search=' + ( options.search.match(/\&/) ? Web.Url.encode(options.search) : options.search );
			url+='?search=' + options.search; 
		}
		if( className=='RidingByPostalCode' ) {
			url += '?lang='+lang;
		}

		return url; 
	}
	
	this.getObject = function( className, options )
	{
		var s = '';
		if( className=='Rating_Content' ) {
			if( def(options.userId) && def(options.contentId) && def(options.rating) ) {
				// {"Content":{"id":"1"},"User":{"id":"1"},"Rating":"2"}
				s = '{"Content":{"id":"'+options.contentId+'"},"User":{"id":"'+options.userId+'"},"Rating":"'+options.rating+'"}';
			}
		} else if ( className=='Approve_Content' ) {
			if( def(options.userId) && def(options.contentId) ) {
				s = '{"Content":{"id":"'+options.contentId+'"},"User":{"id":"'+options.userId+'"}}';
			}
		}
		return s;
	}
	
	this.getKey = function( className )
	{
		if( className == 'RidingByPostalCode' ) {
			// force it to not find a key
			return 'xxx';
		} 
		return 'id';
	}
	
	this.retrieve = function( o )
	{
		try {
			var data = this.data.get( o.className, o.id );
			if( data ) {
				if( def(o.onSuccess) ) {
					dbg('using cached');
					o.onSuccess( data );
				}

			} else {
				var url = this.getUrl( o.className, {id:o.id} );
				if( !def( this.ajax[ url ] ) ) {
					this.ajax[ url ] = OO.Class.instance('Ajax_Rest');
				}
				this.ajax[ url ].setAction( url ); 
				this.ajax[ url ].setFunction( this.onComplete.bind(this) );
				this.ajax[ url ].originalParams = o;
				this.ajax[ url ].get();
			}
			
		} catch(e) { dbg(e,'Rexception retrieve'); }
	}
	
	this.retrieveAll = function( o )
	{
		try {
			var url = this.getUrl(o.className,{tag:o.options.tag,user:o.options.user,category:o.options.categoryId,search:o.options.search});
			if( !def( this.ajax[ url ] ) ) {
				this.ajax[ url ] = OO.Class.instance('Ajax_Rest');
			}
			
			this.ajax[ url ].setAction( url );
			this.ajax[ url ].setFunction( this.onCompleteRetrieveAll.bind(this) );
			this.ajax[ url ].originalParams = o;
			
			if( o.className!='Content_Popular' ) {
				if( def(o.options.sort) ) {
					switch (o.options.sort) {
						case 'date':
							o.options.sort = 'datePosted';
							break;
						case 'rating':
							o.options.sort = 'rating';
							break;
						case 'title':
							o.options.sort = 'title';
							break;
					}
					this.ajax[ url ].setParam( 'column', o.options.sort );
				}
				if( def(o.options.direction) ) {
					this.ajax[ url ].setParam( 'direction', o.options.direction );
				}
			}
			this.ajax[ url ].setParam( 'noFeatures', 1 );
			this.ajax[ url ].setParam( 'lang', TOR_User.Command.getLanguage() );
			
			if( def(o.options.offset) ) this.ajax[ url ].setParam( 'offset', o.options.offset );
			if( def(o.options.limit) ) this.ajax[ url ].setParam( 'limit', o.options.limit );
			if( def(o.options.search) ) this.ajax[ url ].setParam( 'search', Web.Url.decode(o.options.search) );

			this.ajax[ url ].get();
			
		} catch(e) { dbg(e,'Rexception retrieveAll'); }
	}
	
	this.store = function( o )
	{
		try {
			var url = this.getUrl( o.className, {id:o.id} );
			if( !def( this.ajax[ url ] ) ) {
				this.ajax[ url ] = OO.Class.instance('Ajax_Rest');
			}
			this.ajax[ url ].setAction( url ); 
			this.ajax[ url ].setFunction( this.onComplete.bind(this) );
			this.ajax[ url ].originalParams = o;
			this.ajax[ url ].setContentType( Web.Mime.byExtension('js') );
			this.ajax[ url ].put();
			
		} catch(e) { dbg(e,'Rexception store'); }
	}
	
	this.create = function( o ) 
	{
		try {
			var url = this.getUrl( o.className );
			if( !def( this.ajax[ url ] ) ) {
				this.ajax[ url ] = OO.Class.instance('Ajax_Rest');
			}
			var object = this.getObject( o.className, o );
			this.ajax[ url ].setPostData( object ); 
			this.ajax[ url ].setAction( url );
			this.ajax[ url ].setFunction( this.onComplete.bind(this) );
			this.ajax[ url ].originalParams = o;
			this.ajax[ url ].setContentType( Web.Mime.byExtension('js') );
			this.ajax[ url ].post();
			
		} catch(e) { dbg(e,'Rexception create'); }
	}
	
	this.remove = function( o )
	{
		try {
			var url = this.getUrl( o.className, {id:o.id} );
			if( !def( this.ajax[ url ] ) ) {
				this.ajax[ url ] = OO.Class.instance('Ajax_Rest');
			}
			this.ajax[ url ].setAction( url ); 
			this.ajax[ url ].setFunction( this.onComplete.bind(this) );
			this.ajax[ url ].originalParams = o;
			this.ajax[ url ].del();
			
		} catch(e) { dbg(e,'Rexception remove'); }
	}
	
	this.onCompleteRetrieveAll = function( ajaxObject )
	{
		var status = ajaxObject.getResponse().getStatus();
		// if no objects were found, then call the success function with an empty array
		if
		( 
			(status.getCode()==Web.Http.Code.HTTP_NOT_FOUND || status.getCode()==Web.Http.Code.HTTP_NO_CONTENT ) && 
			ajaxObject.originalParams && def( ajaxObject.originalParams.onSuccess ) 
		) {
			ajaxObject.originalParams.onSuccess( [] );
			
		} else {
			this.onComplete( ajaxObject );
		}
	}
	
	this.onComplete = function( ajaxObject ) 
	{
		//dbg( ajaxObject.originalParams, 'in onComplete: ajaxObject.origianParms' );
		if( ajaxObject.originalParams ) {
			var status = ajaxObject.getResponse().getStatus();
			if( status.isSuccess() && def( ajaxObject.originalParams.onSuccess ) ) {
				
				var data = ajaxObject.getResponse().get();
				data.collectionLength = ajaxObject.getResponse().getResponseHeader('X-Orangeroom-Collection-Length');
				if( !def(data.collectionLength) ) data.collectionLength=0;
				var className = ajaxObject.originalParams.className;
				if( danb(className) ) {
					var key = this.getKey( className ); // almost always id
					if( isArray(data) ) {
						foreachArray(data,function(i,v){
							if( def(v[key]) ) {
								this.data.set( className, v[key], v );
							} 
						}.bind(this));

					} else if( def(data[key]) ) {
						this.data.set( className, data[key], data );
						
					// for those like postal code
					} else if( def(ajaxObject.originalParams.id) ) {
						this.data.set( className, ajaxObject.originalParams.id, data );
					}
				}
				
				ajaxObject.originalParams.onSuccess( data );
				
			} else if( status.isError() ) {
				if( def( ajaxObject.originalParams.onError ) ) {
					ajaxObject.originalParams.onError( status, ajaxObject.originalParams );
				}
			}
		}
	}
	
	this.__construct = function()
	{
		this.data = OO.Class.instance('Data_Store_Class');
		
		this.classResourceMapper = OO.Class.instance(
			'Data_Store_Simple',
			{
				'Content_Categories': 'categories',
				'Approve_Content': 'content/approve',
				'Content_Approvals': 'content/awaiting-approval',
				'Content_Search': 'content',
				'RidingByPostalCode': 'ridings/postal-code',
				'Rating_Content': 'content/rate',
				'Content_Popular': 'ranked/content',
				'Content_Abstract': 'content',
				'Content_Videos': 'videos',
				'Content_Photos': 'photos',
				'Content_News': 'articles',
				'Content_Facebook': 'apps',
				'Content_Tools': 'tools'
			}
		);
	}
});

<!-- //*************************** END TOR/RestClient *********************************// -->



<!-- //************************** BEGIN TOR/ObjectWatcher ********************************// -->

<!--





var ObjectWatcher = OO.Class.instance('Data_ObjectWatcher_Callbacks');
ObjectWatcher.setClient( OO.Class.instance('TOR_RestClient') );




<!-- //*************************** END TOR/ObjectWatcher *********************************// -->



<!-- //************************** BEGIN lib/view ********************************// -->

<!--





OO.Class.define('View',function(){
	this.protected_element;
	this.protected_data;
	this.protected_parent;
	this.protected_leftSibling;
	this.protected_rightSibling;
	this.protected_options;
	this.protected_autoViewId = true;
	this.pTypeName = '';
	this.pTypeReplacers = {};
	
	this.setViewId = function( id )
	{
		if( def(this.element) && def(newData.id) ) { 
			this.element.id = 'View_'+this.getClassName()+'_'+id;
		}
	}
	
	this.getData = function() { return this.data; }
	this.setData = function(o) {
		this.preSetData(o); 
		this.data = o; 
		this.postSetData(); 
	}
	
	this.getAutoViewId = function() { return this.autoViewId; }
	this.setAutoViewId = function(o) { this.autoViewId = o; }
	
	this.getElement = function() { return this.element; }
	this.setElement = function(o) { this.element= o; }
	
	this.getParent = function() { return this.parent; }
	this.setParent = function(o) { this.parent = o; }
	
	this.getLeftSibling = function() { return this.leftSibling; }
	this.setLeftSibling = function(o) { this.leftSibling = o; }
	
	this.getRightSibling = function() { return this.rightSibling; }
	this.setRightSibling = function(o) { this.rightSibling = o; }
	
	this.update = function( newData )
	{
		this.preUpdate( newData );
		
		if( !def(newData) ) {
			this.preClear();
			this.setData( newData );
			this.clear();
			this.postClear();
			
		} else if( !def(this.element) || !def(this.data) ) {
			this.preDraw();
			this.setData( newData );
			this.draw();
			this.postDraw();
			
		} else {
			this.preRedraw();
			this.setData( newData );
			this.redraw();
			this.postRedraw();
		}

		if( this.autoViewId ) {
			this.setViewId( newData.id );
		}
		
		this.postUpdate();
	}
	
	this.destroy = function()
	{
		this.removeElement();
		this.update = noop;
		this.notify = noop;
	}
	
	this.removeElement = function()
	{
		if( def(this.element) && def(this.element.parentNode) ) {
			DOM.remove( this.element );
		}
		this.element = undefined;
	}
	
	this.clear = function()
	{
		DOM.hide( this.element );
	}
	
	this.hide = function()
	{
		DOM.hide( this.element );
	}
	
	this.show = function()
	{
		DOM.show( this.element );
	}
	
	this.draw = function()
	{
		this.renderElement();
		if( def(this.element) ) {
			if( def(this.parent) ) {
				DOM.insert( this.element ).inside( this.parent );
				DOM.show( this.element );
			} else if ( def(this.leftSibling) ) {
				DOM.insert( this.element ).after( this.leftSibling );
			} else if ( def(this.rightSibling) ) {
				DOM.insert( this.element ).before( this.rightSibling );
			}
		} else if( !def(this.parent) && !def(this.leftSibling) && !def(this.rightSibling) ) {
			dbg('No element, parent or siblings.','View '+this.getClassName());
		}
	}
	
	this.redraw = function()
	{
		if( def(this.parent) || def(this.leftSibling) || def(this.rightSibling) ) {
			var oldElement = this.element;
			this.renderElement();
			if( def(this.element) && def(oldElement) ) {
				DOM.insert( this.element ).after( oldElement );
			}
			DOM.remove( oldElement );
		} else {
			this.renderElement();
		}
	}

	this.renderElement = this.__renderElement = function()
	{
		if( danb(this.pTypeName) ) {
			var ptype = PTypes.get(this.pTypeName);

			foreachObject( this.pTypeReplacers, function( htmlName, replaceWith ){
				if( isFunction(replaceWith) ) {
					replaceWith = replaceWith(this.data,this);
				}
				if( !def(replaceWith) ) replaceWith='';
				ptype.replace( htmlName, replaceWith );
				
			}.bind(this));
			
			this.element = ptype.getDomObject();
		}
	}
	
	this.__construct = function(o)
	{
		if( !def(o) ) return;
		
		this.options = o;
		
		if( def(o.parent) ) this.setParent(o.parent);
		if( def(o.leftSibling) ) this.setLeftSibling(o.leftSibling);
		if( def(o.rightSibling) ) this.setRightSibling(o.rightSibling);
		if( def(o.element) ) this.setElement(o.element);
		if( def(o.pTypeName) ) this.pTypeName = o.pTypeName;
		if( def(o.pTypeReplacers) ) this.pTypeReplacers = o.pTypeReplacers;
		if( def(o.autoViewId) ) this.autoViewId = o.autoViewId;

		this.initialize( o );

		if( def(o.data) ) {
			this.update(o.data);
		}
	}

	this.initialize = noop;
	this.preSetData = noop;
	this.postSetData = noop;
	this.preUpdate = noop;
	this.postUpdate = noop;
	this.preClear = noop;
	this.postClear = noop;
	this.preDraw = noop;
	this.postDraw = noop;
	this.preRedraw = noop;
	this.postRedraw = noop;
	
}).extend('Observer');




<!-- //*************************** END lib/view *********************************// -->



<!-- //************************** BEGIN TOR/View ********************************// -->

<!--




OO.Class.define('TOR_View',function(){
	this.contentType;
	
	this.getContentType = function() { return this.contentType; }
	this.setContentType = function(c) { this.contentType=c; }

	this.updateCategory = function( cats )
	{
		try{ 
			if( def(cats) ) {
				foreachArray(cats,function(i,cat){
					Content.Objects.Categories.set( cat.id, cat.name );
				});
			}
		} catch(e) { dbg( e, 'update category exception')}
	}
	
	this.postDraw = function()
	{
		this.postRedraw();
	}

	this.showLoading = function()
	{
		DOM.removeAllChildren( this.element );
		DOM.create(
			{
				t:'tr',
				kids:
				[
					{
						t:'td',
						style:
						{
							className:'content_loading'
						},
						kids:
						[
						   {t:'img',src:'http://imgs1.orangeroom.ca/imgs/common/ajax-loader.gif'},
						   {text:TOR_Strings[ TOR_User.Command.getLanguage() ]['Loading']}
						]
					}
				]
			},
			this.element
		);
	}
	
	this.initialize = function()
	{
		this.showLoading();
		this.__initialize();
	}
	
	this.error = function( status, originalParams ) 
	{
		dbg( status, 'error status' );
		dbg( status.getCode(), 'error status code' );
		dbg( originalParams, 'error original params' );
	}
	this.__initialize = noop;
	
}).extend('View');




<!-- //*************************** END TOR/View *********************************// -->



<!-- //************************** BEGIN TOR/View/Content/Entry ********************************// -->

<!--








OO.Class.define('TOR_View_Content_Entry',function(){
	this.renderVideo = function()
	{
		var ptype = PTypes.get( 'contentEntryVideos' );
		ptype.replace('YOU_TUBE_URL',this.data.youTube.url);
		return ptype;
	}

	this.renderPhoto = function()
	{
		var ptype = PTypes.get( 'contentEntryPhotos' );
		ptype.replace('IMG_SRC',this.data.file);
		return ptype;
	}

	this.renderNews= function()
	{
		var ptype = PTypes.get( 'contentEntryNews' );
		ptype.replace('IMG_SRC',this.data.image);
		ptype.replace('URL',this.data.link);
		return ptype;
	}

	this.renderApps = function()
	{
		var ptype = PTypes.get( 'contentEntryApps' );
		ptype.replace('IMG_SRC',this.data.image);
		ptype.replace('HREF',this.data.link);
		return ptype;
	}

	this.renderTools = function()
	{
		var ptype = PTypes.get( 'contentEntryTools' );
		ptype.replace('CODE_SNIPPET',this.data.codeSnippet);
		ptype.replace('IMG_SRC',this.data.image);
		return ptype;
	}
	 
	this.renderElement = function()
	{
		this.updateCategory( this.data.categories );
		
		var ptype;
		switch ( this.data.classKey ) {
			case 'Video':
				ptype = this.renderVideo();
				break;
			case 'Photo':
				ptype = this.renderPhoto();
				break;
			case 'Article':
				ptype = this.renderNews();
				break;
			case 'FacebookApp':
				ptype = this.renderApps();
				break;
			case 'BloggingTool':
				ptype = this.renderTools();
				break;
		}
		
		if( !def(ptype) ) return dbg('didnt get a good ptype');
		
		ptype.replace('ID',this.data.id);
		ptype.replace('TITLE', Data.Transform.unquote( this.data.title ) );
		ptype.replace('DESCRIPTION', Data.Transform.unquote( this.data.body ) );

		ptype.replace('RANKING',this.data.rating.weighted);
		ptype.replace('RATING_COUNT',this.data.rating.count);
		ptype.replace('POSTED_BY', Data.Transform.unquote( this.data.postedBy.username ) );
		ptype.replace('DATE_POSTED',this.data.datePosted);

		ptype.replace('CONTENT_TYPE', Content.Command.getPathByClassKey( this.data.classKey ) );
		ptype.replace('UPLOAD_CONTENT_PATH', Content.Command.getUploadPathByClassKey( this.data.classKey ) );

		var href = Web.Url.getScriptName().replaceAll(/[0-9\/]+$/,'');
		ptype.replace('HREF_TO_THIS_PAGE', Web.Url.encode(href+'/'+this.data.id) );
		
		this.element = ptype.getDomObject();
		this.element.id = 'view_' + this.data.classKey + this.data.id;
	}
	
	this.showThanks = function( rank )
	{
		DOM.hide('stars_block'+this.data.id);
		DOM.show('thanks_block'+this.data.id);
		var stars = $('thanks_content_stars'+this.data.id);
		if( stars ) {
			stars.style.width = ( Math.round(rank)*20 )+'%'; 
		}
	}
	
	this.error = function( status, originalParams ) 
	{
		DOM.show('contentEntryError');
		DOM.hide( 'contentEntryLoading') ;
	}
	
	this.postRedraw = function()
	{
		var stars = $('content_stars'+this.data.id);
		if( stars ) {
			rating=0;
			if( this.data.rating.average ) rating = parseInt( ( this.data.rating.average / 5 ) * 100, 10 );
			stars.style.width = rating+'%'; 
		}
		DOM.hide( 'contentEntryLoading') ;

		var rank = Web.Cookie.get('entry' + this.data.id);
		if( rank != false && parseInt( rank, 10 )>0 && parseInt(rank,10)<=5 ) {
			this.showThanks(rank);
		}
				
		if( TOR_User.Command.isAdmin() ) {
			DOM.show('content_entry_admin'+this.data.id);

			if( ! this.data.isApproved ) {
				DOM.show('content_entry_admin_approve'+this.data.id);
			}
		}
		
		var taglist = $('content_entry_tags_taglist'+this.data.id);
		if( taglist ) {
			hasTags=false;
			foreachArray( this.data.tags, function(i0,v0){
				DOM.create({
					t:'span',
					kids:[
						{
							t:'a',
							href:'javascript:void(0)',
							onclick:Content.List.View.show.bind(this,{tag:v0.name}),
							kids:[{text:v0.name}]						
						},
						{ text: ' | ' }						
					]
				}, taglist);
				hasTags=true;
			});
			if(hasTags){
				DOM.show(taglist);
			}
		}
	}
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/Entry *********************************// -->



<!-- //************************** BEGIN lib/data/transform ********************************// -->

<!--

__rootCreate('Data');

Data.Transform = 
{
	quote: function( s )
	{
		if( !danb(s) ) return '';
		return s.replaceAll(/([^\\])('|"|`)/,'$1\\$2');
	},
	
	unquote: function( s )
	{
		if( !danb(s) ) return '';
		return s.replaceAll(/\\('|"|`)/,'$1').replaceAll(/&quot;/,'"');
	},
	
	characterCap: function( s, c, append )
	{
		if( s.length<=c ) return s;
		return s.substring( 0, c ) + append;
	}
};




<!-- //*************************** END lib/data/transform *********************************// -->



<!-- //************************** BEGIN lib/fileserver/client/action ********************************// -->

<!--

FileServer_Client_Action = function( client ) {
    this.STATUS_UNPROCESSED = 0;
    this.STATUS_SUCCESS = 1;
    this.STATUS_FAILURE = 2;
    this.STATUS_COMMUNICATION_ERROR = 3;
     
    this.status = this.STATUS_UNPROCESSED;
    this.message = '';
    this.client;
    
    this.getClient = function() {
        return this.client;
    }

    this.getStatus = function() {
        return this.status;
    }

    this.isSuccess = function() {
        return this.status == this.STATUS_SUCCESS;
    }
    
    this.isFailure = function() {
        return this.status == this.STATUS_FAILURE;
    }
    
    this.isCommunicationError = function() {
        return this.status == this.STATUS_COMMUNICATION_ERROR;
    }

    this.getMessage = function() {
        return this.message;
    }

    this.process = function() {}

    this.__construct = function( client ) {
        this.client = client;
    }
    this.__construct( client );
}



<!-- //*************************** END lib/fileserver/client/action *********************************// -->



<!-- //************************** BEGIN lib/fileserver/client/action/link ********************************// -->

<!--




FileServer_Client_Action_Link = function( client, id, options ) 
{	
	this.action = new FileServer_Client_Action( client );
    this.id;
    this.options;

	 
    this.STATUS_UNPROCESSED = this.action.STATUS_UNPROCESSED;
    this.STATUS_SUCCESS = this.action.STATUS_SUCCESS;
    this.STATUS_FAILURE = this.action.STATUS_FAILURE;
    this.STATUS_COMMUNICATION_ERROR = this.action.STATUS_COMMUNICATION_ERROR;
    this.status = this.action.status;
    this.message = this.action.message;
    this.client = this.action.client;
    
    this.getClient = this.action.getClient;
    this.isSuccess = this.action.isSuccess;
    this.isFailure = this.action.isFailure;
    this.isCommunicationError = this.action.isCommunicationError;
	this.getMessage = this.action.getMessage;
	
    
    this.process = function() {
        return this.toString();
    }

    this.toString = function() {
        var link = PHP.rtrim(this.getClient().getServerUrl(), '/') + '/';
        link += PHP.rtrim(this.getClient().getApplicationId(), '/') + '/';
        link += this.id;
        if(def(this.options)) {
            for(var x in this.options) {
                link += '/' + x + '/' + this.options[x];
            }
        }
        return link;
    }

    this.getContent = function() {
        return this.content;
    }

    this.__construct = function(client, id, options) {
       
        this.id = id;
        this.options = options;
    }
    this.__construct( client, id, options );
}



<!-- //*************************** END lib/fileserver/client/action/link *********************************// -->


<!-- //************************** BEGIN lib/fileserver/client ********************************// -->

<!--






FileServer_Client = function( serverUrl, applicationId ) 
{
    this.serverUrl;
    this.applicationKey;
    this.applicationId;

    this.setApplicationKey = function(applicationKey) {
        this.applicationKey = applicationKey;
    }
    
    this.getApplicationKey = function() {
        return this.applicationKey;
    }
    
    this.setApplicationId = function(applicationId) {
        this.applicationId = applicationId;
    }
    
    this.getApplicationId = function() {
        return this.applicationId;
    }
    
    this.setServerUrl = function(serverUrl) {
        return this.serverUrl = serverUrl;
    }
    
    this.getServerUrl = function() {
        return this.serverUrl;
    }
    
    this.getStoreActionInstance = function(fileName, fileType, filePath, id) {
    	if( id == undefined) id = '';
        return new FileServer_Client_Action_Store(this, fileName, fileType, filePath, id);
    }

    this.getRemoveActionInstance = function(id) {
        return new FileServer_Client_Action_Remove(this, id);
    }

    this.getRetrieveActionInstance = function(id) {
        return new FileServer_Client_Action_Retrieve(this, id);
    }
    
    this.getLink = function(id, options) {
        link = new FileServer_Client_Action_Link(this, id, options);
        return link.toString();
    }


	this.__construct = function( serverUrl, applicationId )
	{
		this.setServerUrl( serverUrl );
        this.setApplicationId(applicationId);
        this.setApplicationKey('');
	}
	this.__construct( serverUrl, applicationId );
}



<!-- //*************************** END lib/fileserver/client *********************************// -->



<!-- //************************** BEGIN TOR/FileServer ********************************// -->

<!--



var TOR_FileServer_Config = 
{
	ApplicationId: 'testapp',
	ApplicationKey: 'testkey',
	ServerUrl: 'http://fileserver.offshootinc.com/file'
}

var TOR_FileServer =
{
	Client: new FileServer_Client( TOR_FileServer_Config.ServerUrl, TOR_FileServer_Config.ApplicationId ),
	
	setKey: function()
	{
		if( def(this.inited) ) return;
		this.inited = true;
		TOR_FileServer.Client.setApplicationKey(TOR_FileServer_Config.ApplicationKey);
	},
	
	getLink: function( fileId, options )
	{
		return TOR_FileServer.Client.getLink( fileId, options );
	}
}



<!-- //*************************** END TOR/FileServer *********************************// -->



<!-- //************************** BEGIN TOR/View/Content/List/Filter ********************************// -->

<!--






OO.Class.define('TOR_View_Content_List_Filter',function(){
	this.filters =
	{
		search: TOR_Strings[ TOR_User.Command.getLanguage() ]['Search'],
		tag: TOR_Strings[ TOR_User.Command.getLanguage() ]['Tag'],
		categoryName: TOR_Strings[ TOR_User.Command.getLanguage() ]['Category'],
		user: TOR_Strings[ TOR_User.Command.getLanguage() ]['User']
	};

	this.filterIds =
	{
		search: 'Search',
		tag: 'Tag',
		categoryName: 'Category',
		user: 'User'
	};
	
	this.renderElement = function()
	{
		var filterCount = 0, filterId;
		foreachObject( this.filters, function( n, v ) {
			filterId = this.filterIds[ n ];
			if( danb( this.data[n] ) ) {
				DOM.removeAllChildren('listFilter'+filterId);
				DOM.create({text:this.data[n]},'listFilter'+filterId);
				DOM.show('parentListFilter'+filterId);
				filterCount++;
			} else {
				DOM.hide('parentListFilter'+filterId);
			}
			
		}.bind(this));

		if( filterCount>0 ) {					
			this.show();
		} else {
			this.hide();
		}
	}
	
	this.show = function()
	{
		DOM.show('parentListFilter');
	}
	
	this.hide = function()
	{
		DOM.hide('parentListFilter');
	}
	
	this.showLoading = noop;
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/List/Filter *********************************// -->


<!-- //************************** BEGIN TOR/View/Content/List/Pagination ********************************// -->

<!--






OO.Class.define('TOR_View_Content_List_Pagination',function(){
	this.container;
	
	this.hide = function()
	{
		DOM.hide( this.container );
	}
	
	this.show = function()
	{
		DOM.show( this.container );
	}
	
	this.enable = function(n)
	{
		DOM.show(n);
		DOM.hide(n+'Disabled');
	}
	
	this.disable = function(n)
	{
		DOM.hide(n);
		DOM.show(n+'Disabled');
	}
	
	this.renderElement = function()
	{
		if( !def(this.data.instanceOf) || ! this.data.instanceOf('Pagination_Control') ) return false;
		
		if( this.data.getDataCount() < 1 ) {
			return this.hide();
		}
		
		this.show();

		var firstPage = 0;		
		var currentPage = this.data.getCurrentPage();
		var lastPage = this.data.getLastPage();
		
		if( currentPage > 0 ) {
			this.enable( 'firstPage' );
		} else {
			this.disable( 'firstPage' );
		}
		
		if( this.data.hasPrevPage() ) {
			this.enable( 'prevPage' );
		} else {
			this.disable( 'prevPage' );
		}
		
		firstPage = currentPage-3;
		if( firstPage<2 ) firstPage = 0;
		lastPage = firstPage+6;
		var actualLastPage = this.data.getLastPage();
		if( lastPage>actualLastPage-2 ) lastPage=actualLastPage;
		
		if( firstPage>0 ) DOM.show('pagesBefore');
		else DOM.hide('pagesBefore');
		
		if( lastPage!=actualLastPage ) DOM.show('pagesAfter');
		else DOM.hide('pagesAfter');
		
		var ptype;
		DOM.removeAllChildren( 'parentPaginationNumbers' );		
		for(var i=firstPage;i<=lastPage;i++) {
			if( i==currentPage ) {
				ptype=PTypes.get('paginationNumberDisabled');
			} else {
				ptype=PTypes.get('paginationNumber');
			}
			
			ptype.replace('NICE_NUMBER',i+1);
			ptype.replace('NUMBER',i);
			
			DOM.get('parentPaginationNumbers').appendChild( ptype.getDomObject() );
		}
		
		if( this.data.hasNextPage() ) {
			this.enable( 'nextPage' );
		} else {
			this.disable( 'nextPage' );
		}

		if( currentPage < lastPage ) {
			this.enable( 'lastPage' );
		} else {
			this.disable( 'lastPage' );
		}
		
		this.show();
	}
	
	this.initialize = function( o )
	{
		if( !def(o.container) ) return dbg('Cannot open this.container in '+this.getClassName());
		this.container = o.container;
	}
	
	this.showLoading = noop;
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/List/Pagination *********************************// -->



<!-- //************************** BEGIN TOR/View/Content/List/Sort ********************************// -->

<!--






OO.Class.define('TOR_View_Content_List_Sort',function(){
	this.hide = function()
	{
		DOM.hide('sort');
	}
	
	this.show = function()
	{
		if( this.data.className != 'Content_Popular' ) {
			DOM.show('sort');
		} else {
			dbg('not showing because its content popular');
		}
	}
	
	this.renderElement = function()
	{
		if( !def(this.data) || !def(this.data.sort) )return;

		var element,bindObject,sorters = {
			'date': 'desc',
			'rating': 'desc',
			'title': 'asc'
		};
		
		foreachObject( sorters, function(v,dir){
			element = DOM.get('sort_by_'+v);
			
			bindObject = {};
			bindObject.sort = v;
			bindObject.direction = dir;
			
			if( this.data.sort==v ) {
				DOM.stylize( element, {className:'currentSort'} );
				if( this.data.direction=='asc' ) {
					DOM.show(v+'_asc');
					DOM.hide(v+'_desc');
					bindObject.direction = 'desc';
				} else {
					DOM.hide(v+'_asc');
					DOM.show(v+'_desc');
					bindObject.direction = 'asc';
				}
			} else {
				DOM.stylize( element, {className:''} );
				DOM.hide(v+'_asc');
				DOM.hide(v+'_desc');
			}

			element.onclick = Content.List.View.show.bind( this, bindObject );
		}.bind(this));
	}
	
	this.showLoading = noop;
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/List/Sort *********************************// -->



<!-- //************************** BEGIN TOR/View/Content/List/Search ********************************// -->

<!--






OO.Class.define('TOR_View_Content_List_Search',function(){
	this.renderElement = function()
	{
		if( !danb( this.data.search ) ) {
			DOM.show('contentListNoSearch');
			this.hide();
		} else { 
			var query = DOM.get('searchBoxQuery');
			DOM.removeAllChildren(query);
			DOM.create({text:this.data.search},query);
			this.show();
		}
	}
	
	this.show = function()
	{
		DOM.show('searchBox');
	}
	
	this.hide = function()
	{
		DOM.hide('searchBox');
	}
	
	this.showLoading = noop;
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/List/Search *********************************// -->



<!-- //************************** BEGIN TOR/View/Content/List ********************************// -->

<!--














OO.Class.define('TOR_View_Content_List',function(){
	this.renderElement = function()
	{
		DOM.removeAllChildren( this.element );
		var row,tags;
		if( def(this.data) && def(this.data.length) && this.data.length>0 ) {
			foreachArray( this.data, function(i,v){
				this.updateCategory( v.categories );

				var row;
				if( v.classKey == 'Article' ) {
					row = PTypes.get('contentListRowNewsEntry');
				} else {
					row = PTypes.get('contentListRowEntry');
				}

				row.replace('ID',v.id);
				row.replace('TITLE', Data.Transform.unquote( v.title ) );
				row.replace('BODY', Data.Transform.characterCap( Data.Transform.unquote( v.body ), 150, '...' ) );
				row.replace('CONTENT_TYPE', v.classKey );
				row.replace('CONTENT_TYPE_LC', v.classKey.toLowerCase() );

				if( v.classKey == 'Video' ) {
					row.replace('IMG_SRC',v.youTube.image);
					
				} else {
				
					row.replace('IMG_SRC', v.image );
				}

				row.replace('RATING_COUNT',v.rating.count);
				row.replace('POSTED_BY', Data.Transform.unquote( v.postedBy.username ) );
				row.replace('DATE_POSTED',v.datePosted);

				this.element.appendChild( row.getDomObject() );
				
				if( ! v.isApproved ) {
					var admin = PTypes.get('contentListRowAdmin');

					admin.replace('ID',v.id);
					admin.replace('UPLOAD_CONTENT_PATH', Content.Command.getUploadPathByClassKey( v.classKey ) );

					this.element.appendChild( admin.getDomObject() );
				}

				var tags = PTypes.get('contentListRowTags');
				
				tags.replace('ID',v.id);
				tags.replace('HREF_TO_THIS_PAGE', Web.Url.encode(Web.Url.getScriptName()+'/'+v.id) );

				this.element.appendChild( tags.getDomObject() );
	
			}.bind(this));

			Content.List.Objects.Elements.Sort.show();

		} else {
			var ptype = PTypes.get('contentListNoMedia');
			
			this.element.appendChild( ptype.getDomObject() );

			Content.List.Objects.Elements.Sort.hide();
		}
	}
	
	this.postRedraw = function()
	{
		var taglist,hasTags,stars,rating;
		foreachArray( this.data, function(i,v){
		
			stars = $('content_stars'+v.id);
			if( stars ) {
				rating=0;
				if( v.rating.average ) rating = parseInt( ( v.rating.average / 5 ) * 100, 10 );
				stars.style.width = rating+'%'; 
			}
			
			taglist = $('content_list_row_tags_taglist'+v.id);
			if( taglist ) {
				hasTags=false;
				foreachArray( v.tags, function(i0,v0){
					DOM.create({
						t:'span',
						kids:[
							{
								t:'a',
								href:'javascript:void(0)',
								onclick:Content.List.View.show.bind(this,{tag:v0.name}),
								kids:[{text:v0.name}]						
							},
							{ text: ' | ' }						
						]
					}, taglist);
					hasTags=true;
				});
				if(hasTags){
					DOM.show(taglist);
				}
			}
		}.bind(this));
	}
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/List *********************************// -->



<!-- //************************** BEGIN TOR/View/Content/PhotoFeed ********************************// -->

<!--









OO.Class.define('TOR_View_Content_PhotoFeed',function(){
	this.renderElement = function()
	{
		DOM.removeAllChildren( this.element );
		var thumb;
		if( def(this.data) && def(this.data.length) && this.data.length>0 ) {
			foreachArray( this.data, function(i,v){
				thumb = PTypes.get('photoThumb');

				thumb.replace('ID',v.id);

				if( 0 ) {					
				
					v.image = '/imgs/common/pic_youtube.gif';
					v.image = 'http://orangeroom.ca.localhost/imgs/common/picfeature.gif';
					v.image = '/imgs/common/highestviewed.png';
				}
				thumb.replace('IMG_SRC', v.image );
				
				if( i==0 ) {
				
				
					DOM.stylize( $('photofeed'), {backgroundImage:'url('+v.image+')'} );
				}

				this.element.appendChild( thumb.getDomObject() );
	
			}.bind(this));
		}
	}
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Content/PhotoFeed *********************************// -->



<!-- //************************** BEGIN TOR/Content ********************************// -->

<!--






















var debug=500;
var debug_height=400;
var Content =
{
	Objects:
	{
		'lastUrl': '',
		'defaultContentClassName': 'Content_Videos',
		
		'contentClassNames':
		{
			'approvals': 'Content_Approvals',
			'search': 'Content_Search',
			'popular': 'Content_Popular',
			'content': 'Content_Abstract',
			'videos': 'Content_Videos',
			'news': 'Content_News',
			'facebook': 'Content_Facebook',
			'tools': 'Content_Tools',
			'photos': 'Content_Photos'
		},
		
		Categories: OO.Class.instance('Data_Store_Simple')
	},
	Command: 
	{
		init: function()
		{
			DOM.register('pageContentEntry','page_content_entry');
			DOM.register('pageContentList','page_content_list');

			Content.PhotoFeed.Command.init();

			Content.Search.Command.init();
			Content.Entry.Command.init();
			Content.List.Command.init();

			Content.View.init();
		},
		
		getPathByClassKey : function( classKey ) 
		{
			var path = false;
			if( danb(classKey) ) {
				switch( classKey ) {
					case 'Video': 
						path= 'videos';
						break; 
						
					case 'Photo':
						path= 'photos';
						break;
					
					case 'Article':
						path= 'news';
						break;
					
					case 'BloggingTool':
						path= 'tools';
						break;
					
					case 'FacebookApp':
						path= 'facebook';
						break;
				}
			}
			return path;
		},
		
		getUploadPathByClassKey : function( classKey ) 
		{
			var path = false;
			if( danb(classKey) ) {
				switch( classKey ) {
					case 'Video': 
						path= 'videos';
						break; 
						
					case 'Photo':
						path= 'photos';
						break;
					
					case 'Article':
						path= 'articles';
						break;
					
					case 'BloggingTool':
						path= 'tools';
						break;
					
					case 'FacebookApp':
						path= 'apps';
						break;
				}
			}
			return path;
		},
		
		getContentTypeFromLocation: function()
		{
			var m = location.pathname.match(/\/(admin\/)?([^\/\.]+)/);
			if( m ) {
				return m[2];
			}
			return false;
		},
		
		getContentIdFromLocation: function()
		{
			var regex = new RegExp("^\/"+Content.Command.getContentTypeFromLocation()+"\/(\\d+)");
			var m = location.pathname.match( regex );
			if( m ) {
				var id = parseInt( m[1] );
				if( def(id ) ) {
					return id;
				}
			}
			return false;
		}
	},
	
	View:
	{
		init: function()
		{
				
			if( !DOM.get('contentList') ) {
				return dbg('Not a content page');
			}
			
			Content.View.update();
		},
		
		update: function()
		{
			if( Content.Objects['lastUrl'] != location.href ) {
				dbg('Updating...','URL Change');

			
				var force = 1;
				
			
				var page = Web.HashCookie.get('page');
				if( ( danb(page) && ( page!='entry' && page!='list' ) ) ) {
					page='list';
				} 
				
				var contentType = Content.Command.getContentTypeFromLocation();
				var contentClassName = Content.Objects.contentClassNames[ contentType ];
				
				var entryId = false;
				if( !page ) {
					entryId = Content.Command.getContentIdFromLocation();
					if( entryId ) {
						page = 'entry';
					} else {
						page = 'list';
					}
				} else if( page=='entry' ) {
					entryId = Web.HashCookie.get('id');
					if( entryId ) entryId=parseInt(entryId,10);
					if( !def(entryId) || isNaN(entryId) || entryId==0 ) {
						entryId = false;
						page = 'list';
					}
				}
					
				var o = {};

				var search = Web.HashCookie.get('search');
				if( danb(search) ) {
					o.search = search;
				} else {
					o.search = Content.Search.Command.getQuery();
				}

				var user = Web.HashCookie.get('user');
				if( danb(user) ) {
					o.user = user;
				}
					
				var sort = Web.HashCookie.get('sort');
				if( danb(sort) ) {
					o.sort = sort;
				}
				var direction = Web.HashCookie.get('direction');
				if( danb(direction) ) {
					o.direction = direction;
				}
				var pageNumber = parseInt( Web.HashCookie.get('pageNumber') , 10 );
				if( danb(pageNumber) && !isNaN(pageNumber) ) {
					o.pageNumber = pageNumber;
				} else {
					o.pageNumber = 0;
				}
				var tag = Web.HashCookie.get('tag');
				if( def(tag) ) {
					o.tag = tag;
				} else {
					o.tag = '';
				}

				var categoryId;
				if( Web.HashCookie.get('categoryId') ) {
					categoryId = parseInt( Web.HashCookie.get('categoryId'), 10 );
				}
				var categoryName = Web.HashCookie.get('categoryName');
				if( danb(categoryName) && danb(categoryId) ) {
					Content.Objects.Categories.set( categoryId, categoryName );
					o.categoryName = categoryName;
					o.categoryId = categoryId;
				} else {
					o.categoryId = '';
					o.categoryName = '';
				}
				
				var user = Web.HashCookie.get('user');
				if( def(user) ) {
					o.user = user;
				} else {
					o.user = '';
				}
				
				if( page=='entry' && entryId ) {
					Content.List.View.show( o );
					Content.Entry.View.show( entryId, force );
					
				} else {
					Content.List.View.show( o, force );
				}

				Content.Objects['lastUrl'] = location.href;
			}
			
		
			setTimeout( Content.View.update.bind(this,0) , 500 );
		}
	},
	
	PhotoFeed: 
	{
		Objects: {
		},
		
		Command: 
		{
			init: function()
			{
				PTypes.register('photoThumb','ptype_photo_feed_thumb');

				DOM.register('photoFeedList','main_photo_list');
				
				if( !DOM.get('photoFeedList') ) {
					return dbg('Not a photo feed page');
				}

				var cpo = Content.PhotoFeed.Objects;
				cpo.className = Content.Objects.contentClassNames[ 'photos' ];

				cpo.PhotoFeed = OO.Class.instance(
					'TOR_View_Content_PhotoFeed',
					{
						element: DOM.get('photoFeedList'),
						pTypeName: 'photoThumb'		
					}
				);
				
				cpo.Controller = OO.Class.instance(
					'Pagination_Control',
					{
						perPage: 6
					}
				);
				
				Content.PhotoFeed.View.show();
			},
			
			getLimit: function()
			{
				return Content.PhotoFeed.Objects.Controller.getPerPage();
			},
			
			getOffset: function()
			{
				return Content.PhotoFeed.Objects.Controller.getStartingOffset();
			},
			
			setDataCount: function( dataCount )
			{
				if( !def(dataCount) ) dataCount = 0;
				return Content.PhotoFeed.Objects.Controller.setDataCount( dataCount );
			},

			setDataCount2: function( dataCount )
			{
				if( !def(dataCount) ) dataCount = 0;
				Content.PhotoFeed.Objects.Controller.setDataCount( dataCount );
				Content.Pagination.View.show();				
			},
			
			firstPage: function()
			{
				Content.PhotoFeed.Command.gotoPage('f');
			},
			
			prevPage: function()
			{
				Content.PhotoFeed.Command.gotoPage('p');
			},
			
			nextPage: function()
			{
				Content.PhotoFeed.Command.gotoPage('n');
			},
			
			lastPage: function()
			{
				Content.PhotoFeed.Command.gotoPage('l');
			},
			
			gotoPage: function(p)
			{
				if( !def( p ) ) return false;
				
				var controller = Content.PhotoFeed.Objects.Controller;
				var currentPage = controller.getCurrentPage();
				
				switch(p) {
					case 'f': 
						controller.gotoFirstPage();
						break;
					case 'p':
						controller.prevPage();
						break; 
					case 'n':
						controller.nextPage();
						break; 
					case 'l':
						controller.gotoLastPage();
						break; 
					default:
						controller.gotoPage( parseInt( p, 10 ) );
						break;
				}
				
				if( currentPage != controller.getCurrentPage() ) {
					Content.PhotoFeed.View.show();
				}
			}
		},
		
		View:
		{
			show: function()
			{
				var cpo = Content.PhotoFeed.Objects;
				
				var pageNumber = cpo.Controller.getCurrentPage()

				cpo['limit'] = Content.PhotoFeed.Command.getLimit();
				cpo['offset'] = Content.PhotoFeed.Command.getOffset();
				
				cpo.onSuccess = Content.PhotoFeed.View.receivedData.bind(this);
				ObjectWatcher.findAll( cpo.className, cpo );
			},
			
			receivedData: function( data )
			{
				Content.PhotoFeed.Objects.data = data;
				Content.PhotoFeed.Command.setDataCount( data.collectionLength );
				Content.PhotoFeed.Objects.PhotoFeed.update( data );
			},
			
			init: function()
			{
			}
		}
	},
	
	Entry:
	{
		Objects:
		{
			Elements: {}
		},
		
		Command:
		{
			rank: function(id,rank)
			{
				var userId = TOR_User.Command.getUserId();
				if( !userId ) {
				
					userId = 0; 
				}
				var entry = Content.Entry.Command.getEntry();
				if( !def(entry) || !def(entry.id) ) return dbg('!def getEntry()');
				
				Web.Cookie.set('entry' + entry.id, rank)
				
				var client = ObjectWatcher.getClient();
				client.create({
					className:'Rating_Content',
					rating: rank,
					userId: userId,
					contentId: entry.id
				});
				
				Content.Entry.Objects.Elements.Entry.showThanks(rank);
			},
			
			share: function()
			{
				
				var entry = Content.Entry.Command.getEntry(); 
				if( !def(entry) || !def(entry.classKey) )return dbg('invalid entry or classKey');
				
				var path = Content.Command.getPathByClassKey( entry.classKey );
				if( !path ) return dbg(path,'!def path');

				var ptype = PTypes.get('shareEntry');
				var url = Web.Url.getHostName()+'/'+path+'/'+entry.id;
				ptype.replace('ID',entry.id);
				ptype.replace('URL',url);
				
				var w = TOR_Popup.getObject();	
				TOR_Popup.generic( w, TOR_Strings[ TOR_User.Command.getLanguage() ]['share_this_entry'], ptype.getDomObject(),
					[
						{
							caption:TOR_Strings[ TOR_User.Command.getLanguage() ]['popup_close_window'], 
							properties: {
								href: 'javascript:void(0)',
								onclick: function() { w.close(); },
								style:{className:'btn update'} 
							}
						},
						{
							caption:TOR_Strings[ TOR_User.Command.getLanguage() ]['popup_email_to_a_friend'], 
							properties: {
								href:'javascript:void(0)',
								onclick: function() { location.href="mailto:?body="+url },
								style:{className:'btn cancel'} 
							}
						}
					] 
				);
				
				setTimeout(
					function() {
						var input = $('share_entry_input'+entry.id);
						if( input ) {
							input.focus();
							input.select();
						}
					}
				, 600 );
			},
			
			getEntry: function()
			{
				return Content.Entry.Objects.Elements.Entry.getData();
			},
			
			init: function()
			{
				PTypes.register('contentEntryVideos','ptype_content_entry_videos');
				PTypes.register('contentEntryPhotos','ptype_content_entry_photos');
				PTypes.register('contentEntryNews','ptype_content_entry_news');
				PTypes.register('contentEntryApps','ptype_content_entry_apps');
				PTypes.register('contentEntryTools','ptype_content_entry_tools');
				PTypes.register('shareEntry','ptype_share_entry');
				
				DOM.register('contentEntry','content_entry');
				DOM.register('contentEntryError','content_entry_error');
				DOM.register('contentEntryLoading','content_entry_loading');
				DOM.register('contentEntryAdmin','content_entry_admin');
				DOM.register('contentEntryAdminApprove','content_entry_admin_approve');
				
				if( !DOM.get('pageContentEntry') ) {
					return dbg('Not a content entry page');
				}

				Content.Entry.Objects.Elements.Entry = OO.Class.instance(
					'TOR_View_Content_Entry',
					{
						parent: DOM.get('contentEntry')
					}
				);
				
				var co = Content.Objects;
				var ceo = Content.Entry.Objects;

				ceo.contentType = Content.Command.getContentTypeFromLocation();
				if( !ceo.contentType ) return dbg('Content type could not be found.');
				
			
				
				ceo.className = co.contentClassNames[ ceo.contentType ];
				if( !danb(ceo.className) ) ceo.className = co.defaultClassName;
			}
		},
		
		View:
		{
			init: function()
			{
			},
			
			hide: function()
			{
				DOM.hide( 'pageContentEntry' );
			},
			
			show: function( id, force )
			{
				id = parseInt( id, 10 );
				if( !id ) return;
				
				Web.HashCookie.set('page','entry');
				Web.HashCookie.set('id',id);
				
				if( !def(force) || !force ) return;

				var ceo = Content.Entry.Objects;

				ceo.Elements.Entry.showLoading();				
				Content.List.View.hide();
				DOM.show( 'pageContentEntry' );

				if( def(force) && force==1 ) {
					ObjectWatcher.find( 
						ceo.className, 
						id, 
						{
							onSuccess:ceo.Elements.Entry.update.bind( ceo.Elements.Entry ),
							onError:ceo.Elements.Entry.error.bind( ceo.Elements.Entry )
						} 
					);
				}
			}
		}
	},
	
	List:
	{
		Objects: 
		{
			'Elements': {},
			
			'defaultSort': 
			{
				'approvals': 'date',
				'search': 'rating',
				'popular': 'ranking',
				'content': 'date',
				'videos': 'date',
				'news': 'date',
				'facebook': 'date',
				'tools': 'date',
				'photos': 'date'
			},
			
			'defaultDirection': 
			{
				'approvals': 'desc',
				'search': 'desc',
				'popular': 'desc',
				'content': 'desc',
				'videos': 'desc',
				'news': 'desc',
				'facebook': 'desc',
				'tools': 'desc',
				'photos': 'desc'
			}
		},
		
		Command:
		{
			getEntryIndex: function( entryId ) 
			{
				var list = Content.List.Command.getList();
				var indx = -1;
				foreachArray( list, function(i,v) {
					if( v.id == entryId ) return ( indx=i );
				});
				return indx;
			},
			
			getList: function()
			{
				return Content.List.Objects.Elements.List.getData();
			},
			
			init: function()
			{
				PTypes.register('contentListNoMedia','ptype_content_list_no_media');
				PTypes.register('contentListRowEntry','ptype_content_list_row');
				PTypes.register('contentListRowAdmin','ptype_content_list_row_admin');
				PTypes.register('contentListRowNewsEntry','ptype_content_list_row_news');
				PTypes.register('contentListRowTags','ptype_content_list_row_tags');
				DOM.register('contentList','content_list');

								
				DOM.register('parentListFilter','parent_list_filter');
				DOM.register('parentListFilterTag','list_filter_tag');
				DOM.register('parentListFilterCategory','list_filter_category');
				DOM.register('parentListFilterUser','list_filter_user');
				DOM.register('parentListFilterSearch','list_filter_search');
				DOM.register('listFilterTag','list_filter_tag_name');
				DOM.register('listFilterCategory','list_filter_category_name');
				DOM.register('listFilterUser','list_filter_user_name');
				DOM.register('listFilterSearch','list_filter_search_name');
				
				
				DOM.register('sortNormal','sort_normal');
				DOM.register('sortPopular','sort_popular');

				if( !DOM.get('contentList') ) {
					return dbg('Not a content page');
				}
				
				Content.Pagination.Command.init();
				

				Content.List.Objects.Elements.List = OO.Class.instance(
					'TOR_View_Content_List',
					{
						element: DOM.get('contentList'),		
						autoViewId: false		
					}
				);

				Content.List.Objects.Elements.Sort = OO.Class.instance(
					'TOR_View_Content_List_Sort',
					{
						element: DOM.get('sort_view'),
						autoViewId: false		
					}
				);

				Content.List.Objects.Elements.Filter = OO.Class.instance(
					'TOR_View_Content_List_Filter',
					{
						pTypeName: 'listFilter',
						autoViewId: false		
					}
				);

				var co = Content.Objects;
				var clo = Content.List.Objects;

				clo.contentType = Content.Command.getContentTypeFromLocation();
				if( !clo.contentType ) return dbg('Content type could not be found.');
				
				clo.className = co.contentClassNames[ clo.contentType ];
				if( !danb(clo.className) ) clo.className = co.defaultClassName;
			}
		},
		
		View: 
		{
			hide: function()
			{
				DOM.hide( 'pageContentList' );
			},
			
			show: function( n, force )
			{
				Content.Entry.View.hide();
				DOM.show( 'pageContentList' );

				var clo = Content.List.Objects;
				
				if( def(n) ) {
					if( !def(n.pageNumber) )n.pageNumber=0;
					
					Content.Pagination.Command.setPageNumber( n.pageNumber );
					 
					if( def(n.sort) ) clo.sort = n.sort;
					if( def(n.search) ) clo.search = n.search;
					if( def(n.direction) ) clo.direction = n.direction;

					if( def(n.tag) ) {
						clo.tag = n.tag;
					}
					if( def(n.user) ) {
						clo.user = n.user;
					}
					if( def(n.categoryName) && def(n.categoryId) ) {
						clo.categoryName = n.categoryName;
						clo.categoryId = n.categoryId;
					}
				}
				
				if( !def(clo.search) ) clo.search = '';
				if( def(clo.sort) && clo.sort=='datePosted' ) clo.sort = 'date';
				if( !def(clo.sort) || ( clo.sort!='rating' && clo.sort!='date' && clo.sort!='title' ) ) clo.sort = Content.List.Objects.defaultSort[ clo.contentType ];
				if( !def(clo.direction) || ( clo.direction!='asc' && clo.direction!='desc' ) ) clo.direction = Content.List.Objects.defaultDirection[ clo.contentType ];
				if( !danb(clo.tag) ) clo.tag = '';
				if( !danb(clo.user) ) clo.user = '';
				if( !danb(clo.categoryName) || !danb(clo.categoryId) ) { 
					clo.categoryName = '';
					clo.categoryId = '';
				}
				
				var previousHref = location.href;
				Web.HashCookie.set('page','list');
				Web.HashCookie.set('sort',clo.sort);
				Web.HashCookie.set('direction',clo.direction);
				Web.HashCookie.set('pageNumber',Content.Pagination.Command.getPageNumber());
				Web.HashCookie.set('tag',clo.tag);
				Web.HashCookie.set('user',clo.user);
				Web.HashCookie.set('categoryName',clo.categoryName);
				Web.HashCookie.set('categoryId',clo.categoryId);
				Web.HashCookie.set('search',clo.search);
				if( location.href!=previousHref ) {
					clo.Elements.List.showLoading();
					Content.Pagination.View.hide();
					clo.Elements.Filter.hide();
				}

				if( !def(force) || !force ) return;

				clo.Elements.Sort.update( clo );
				
				clo['limit'] = Content.Pagination.Command.getLimit();
				clo['offset'] = Content.Pagination.Command.getOffset();
				
				if( def(force) && force==1 ) {
					clo.onSuccess = Content.List.View.receivedData.bind(this);
					ObjectWatcher.findAll( clo.className, clo );
				}
			},
			
			receivedData: function( data ) 
			{
				Content.List.Objects.data = data;
				Content.List.Objects.Elements.List.update( data );
				Content.Pagination.Command.setDataCount( data.collectionLength );

				var clo = Content.List.Objects;
				if( danb(clo.categoryId) ) {
					clo.categoryName = Content.Objects.Categories.get( clo.categoryId );
				}
				clo.Elements.Filter.update( clo );
			}
		}
	},
	
	Pagination:
	{
		Objects:
		{
			PerPage: 5
		},
		
		Command:
		{
			getPageNumber: function()
			{
				return Content.Pagination.Objects.Controller.getCurrentPage();
			},

			setPageNumber: function( n )
			{
				if( !def(n) || isNaN(n) ) return dbg('n is undef');
				Content.Pagination.Objects.Controller.setCurrentPage( n );
			},
			
			getLimit: function()
			{
				return Content.Pagination.Objects.Controller.getPerPage();
			},
			
			getOffset: function()
			{
				return Content.Pagination.Objects.Controller.getStartingOffset();
			},
			
			getLastPageNumber : function()
			{
				return Content.Pagination.Objects.Controller.getLastPage();
			},
			
			init: function()
			{
				
				DOM.register('parentPagination','content_list_pagination');
				DOM.register('parentPaginationNumbers','parent_content_list_pagination_numbers');

				DOM.register('firstPage','pagination_first_page');
				DOM.register('firstPageDisabled','pagination_first_page_disabled');
				DOM.register('prevPage','pagination_prev_page');
				DOM.register('prevPageDisabled','pagination_prev_page_disabled');
				DOM.register('nextPage','pagination_next_page');
				DOM.register('nextPageDisabled','pagination_next_page_disabled');
				DOM.register('lastPage','pagination_last_page');
				DOM.register('lastPageDisabled','pagination_last_page_disabled');
				
				DOM.register('pagesBefore','pagination_ellipsis_before');
				DOM.register('pagesAfter','pagination_ellipsis_after');
				
				PTypes.register('paginationNumber','ptype_content_list_pagination_number');
				PTypes.register('paginationNumberDisabled','ptype_content_list_pagination_number_disabled');

				var currentPage = Web.HashCookie.get('pageNumber');
				
				Content.Pagination.Objects.Controller = OO.Class.instance(
					'Pagination_Control',
					{
						perPage: Content.Pagination.Objects.PerPage,
						currentPage: currentPage
					}
				);

				Content.Pagination.Objects.Pagination = OO.Class.instance(
					'TOR_View_Content_List_Pagination',
					{
						container: DOM.get('parentPagination'),
						parent: DOM.get('parentPaginationNumbers'),
						pTypeName: 'paginationNumber',
						autoViewId: false		
					}
				);
			},

			setDataCount: function( dataCount )
			{
				if( !def(dataCount) ) dataCount = 0;
				Content.Pagination.Objects.Controller.setDataCount( dataCount );
				Content.Pagination.View.show();				
			},
			
			firstPage: function()
			{
				Content.Pagination.Command.gotoPage('f');
			},
			
			prevPage: function()
			{
				Content.Pagination.Command.gotoPage('p');
			},
			
			nextPage: function()
			{
				Content.Pagination.Command.gotoPage('n');
			},
			
			lastPage: function()
			{
				Content.Pagination.Command.gotoPage('l');
			},
			
			gotoPage: function(p)
			{
				if( !def( p ) ) return false;
				
				var controller = Content.Pagination.Objects.Controller;
				var currentPage = controller.getCurrentPage();
				
				switch(p) {
					case 'f': 
						controller.gotoFirstPage();
						break;
					case 'p':
						controller.prevPage();
						break; 
					case 'n':
						controller.nextPage();
						break; 
					case 'l':
						controller.gotoLastPage();
						break; 
					default:
						controller.gotoPage( parseInt( p, 10 ) );
						break;
				}

				window.scrollTo(0,10);
				
				if( currentPage != controller.getCurrentPage() ) {
					Content.List.View.show({pageNumber:Content.Pagination.Objects.Controller.getCurrentPage()});
				}
			}
		},
		
		View:
		{
			hide: function()
			{
				Content.Pagination.Objects.Pagination.hide();
			},
			
			show: function()
			{	
				Content.Pagination.Objects.Pagination.update( Content.Pagination.Objects.Controller );
			}
		}
	},
	
	Search:
	{
		Command:
		{
			init: function()
			{
				DOM.register('searchInput','search_input');
				DOM.register('searchForm','search_form');
				
				var search = DOM.get('searchInput');
				var searchForm = DOM.get('searchForm');
				if( !search || !searchForm ) return dbg(search + ' and '+searchForm, 'Search not on this page');
				
				if( search.value == '' ) {
					search.value = TOR_Strings[ TOR_User.Command.getLanguage() ]['search_input_value'];
				}
				
				search.onfocus = function() {
					if( search.value == TOR_Strings[ TOR_User.Command.getLanguage() ]['search_input_value'] ) {
						search.value = '';
					} 
				}
				
				search.onblur = function() {
					if( search.value == '' ) {
						search.value = TOR_Strings[ TOR_User.Command.getLanguage() ]['search_input_value'];
					}
				}
				
				searchForm.onsubmit = function() {
					if( search.value == '' ) return false;
					if( Content.Search.Command.getQuery() != '' ) {
						var force = 0;
						if( Content.Search.Command.getQuery() == Content.List.Objects.search ) {
							force=1;
						}
						Content.List.View.show({search:search.value,sort:'reset'},force);
						return false;
					} 
				}
			},
			
			getQuery: function()
			{
				if( def(Content.List.Objects.search) ) {
					return Content.List.Objects.search;
				}
				var query = '';
				if( DOM.get('search_param_input') ) {
					query = DOM.get('search_param_input').value;
				}
				return query;
			}
		},
		
		View:
		{
			init: function()
			{
			}
		}
	},
	
	Approve:
	{
		Command:
		{
			approve: function( contentId, callback )
			{
				if( !def(callback) ) callback = false;
				
				var userId = TOR_User.Command.getUserId();
				if( !TOR_User.Command.isAdmin() ) {
					return TOR_Popup.alert( TOR_Strings[ TOR_User.Command.getLanguage() ]['must_be_an_admin'] , TOR_Strings[ TOR_User.Command.getLanguage() ]['alert_box'] ); 
				}
				
				TOR_Popup.confirm(
					TOR_Strings[ TOR_User.Command.getLanguage() ]['confirm_approve_content'],
					Content.Approve.Command.approveActually.bind( this, contentId, userId, callback ),
					noop, 
					TOR_Strings[ TOR_User.Command.getLanguage() ]['confirm_box']
				);
			},
			
			approveActually: function( contentId, userId, callback )
			{
				if( !callback || !def(callback) ) {
					callback = Content.List.View.show.bind(this,{pageNumber:0},1);
				}
				var client = ObjectWatcher.getClient();
				client.create(
					{
						className:'Approve_Content',
						userId: userId,
						contentId: contentId,
						onSuccess: callback
					}
				);
			}
		}
	}
};

addLoadEvent( Content.Command.init );




<!-- //*************************** END TOR/Content *********************************// -->



<!-- //************************** BEGIN lib/event/timer ********************************// -->

<!--



__rootCreate('Event');
Event.Timer = 
{
	Objects: {},
	
	create: function( name, func, ms )
	{
		if( !danb(name) || !def(func) || !def(ms) ) return dbg('couldnt create timer');
		Event.Timer.cancel( name );
		Event.Timer.Objects[ name ] = setTimeout( func, ms );
	},
	
	cancel: function( name )
	{
		if( !danb(name) ) return;
		if( def(Event.Timer.Objects[ name ]) ) {
			clearTimeout( Event.Timer.Objects[ name ] );
		}
	}
}



<!-- //*************************** END lib/event/timer *********************************// -->



<!-- //************************** BEGIN lib/form/validator ********************************// -->

<!--

OO.Class.define('Form_Validator',function(){
	this.element;
	this.options;
	
	this.getElement = function(){ return this.element; }
	this.setElement = function(e){ this.element = e; }
	
	this.hasErrors = function( validator )
	{
		return false;
	}
	
	this.__construct = function( options )
	{
		if( !def(options) ) var options={};
		this.options = options;

		if( def(this.options.element) ) {
			this.element = this.options.element;
		} 

		this.initialize( options );
	}
	
	this.submitSuccessful = noop;
	this.focus = noop;
	this.initialize = noop;
});




<!-- //*************************** END lib/form/validator *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator ********************************// -->

<!--



				
OO.Class.define('TOR_Form_Validator',function(){
	this.clearError = function( name )
	{
		if( !def(name) ) name = this.element.name;
		DOM.hide( 'error_text_' + name );
	}
	
	this.displayError = function( name )
	{
		if( !def(name) ) var name = this.element.name;
		DOM.show( 'error_text_' + name );
	}
	
	this.focus = function( element )
	{
		if( !def(element) ) var element = this.element;
		if( def(element.select) ) element.select();
		if( def(element.focus) ) element.focus();
	}
	
	this.initialize = function()
	{
		if( def(this.element) ) {
		
		}
	}
	
}).extend('Form_Validator');




<!-- //*************************** END TOR/Form/Validator *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator/Required ********************************// -->

<!--



OO.Class.define('TOR_Form_Validator_Required',function(){
	this.hasErrors = function()
	{
		if( !danb(this.element.value) ) {
			this.displayError();
			return true;
		} else {
			this.clearError();
			return false;
		} 
	}
	
}).extend('TOR_Form_Validator');

OO.Class.define('TOR_Form_Validator_Checked',function(){
	this.hasErrors = function()
	{
		if( this.element.checked != true ) {
			this.displayError();
			return true;
		} else {
			this.clearError();
			return false;
		} 
	}
	
}).extend('TOR_Form_Validator');




<!-- //*************************** END TOR/Form/Validator/Required *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator/File ********************************// -->

<!--



OO.Class.define('TOR_Form_Validator_File',function(){
	this.hasErrors = function()
	{
		if( !danb(this.element.value) ) {
			this.displayError();
			return true;
		} else {
			this.clearError();
			return false;
		} 
	}

}).extend('TOR_Form_Validator_Required');




<!-- //*************************** END TOR/Form/Validator/File *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator/Url ********************************// -->

<!--





OO.Class.define('TOR_Form_Validator_Url',function(){
	this.hasErrors = function()
	{
		if( !danb(this.element.value) ) {
			this.displayError();
			return true;
		} else if ( Web.Url.isValid( 'http://'+this.element.value ) ) {
			this.element.value = 'http://'+this.element.value;
			this.clearError();
			return false;
		} else if ( !Web.Url.isValid( this.element.value ) ) {
			this.displayError();
			return true;
		} else {
			this.clearError();
			return false;
		} 
	}
	
}).extend('TOR_Form_Validator');




<!-- //*************************** END TOR/Form/Validator/Url *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator/YouTubeUrl ********************************// -->

<!--



OO.Class.define('TOR_Form_Validator_YouTubeUrl',function(){
	this.isUrlValid = function()
	{
		var youTubeId = false;
		
	
		var m = this.element.value.match(/^([_\-a-zA-Z0-9]{8,})$/);
		if( m ) {
			youTubeId = m[1];
		}
		
		if( !youTubeId ) {
		
			m = this.element.value.match(/(youtube.([a-z]+)\/watch\?)?v=([_\-a-zA-Z0-9]{8,})/);
			if( m ) {
				youTubeId = m[3];
			}
		}

		if( !youTubeId ) {
		
			m = this.element.value.match(/youtube.([a-z]+)\/v\/([_\-a-zA-Z0-9]{8,})/);
			if( m ) {
				youTubeId = m[2];
			}
		}

		if( youTubeId ) {
			this.element.value = 'http://www.youtube.com/watch?v='+youTubeId;
			return true;
		}
		
		return false;
	}
	
	this.hasErrors = function()
	{
		if( !danb(this.element.value) ) {
			this.displayError();
			return true;
		
		} else if( ! this.isUrlValid() ) {
			this.displayError();
			return true;
			
		} else {
			this.clearError();
			return false;
		} 
	}
	
}).extend('TOR_Form_Validator');




<!-- //*************************** END TOR/Form/Validator/YouTubeUrl *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator/Tags ********************************// -->

<!--



OO.Class.define('TOR_Form_Validator_Tags',function(){
}).extend('TOR_Form_Validator_Required');




<!-- //*************************** END TOR/Form/Validator/Tags *********************************// -->


<!-- //************************** BEGIN TOR/Form/Validator/Email ********************************// -->

<!--



OO.Class.define('TOR_Form_Validator_Email',function(){
	this.hasErrors = function()
	{
		if( !danb(this.element.value) ) {
			this.displayError();
			return true;
		} else if( !Web.Email.isValid(this.element.value) ) {
			this.displayError();
			return true;
		} else {
			this.clearError();
			return false;
		} 
	}
	
}).extend('TOR_Form_Validator');




<!-- //*************************** END TOR/Form/Validator/Email *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validator/PasswordWithConfirm ********************************// -->

<!--





OO.Class.define('TOR_Form_Validator_PasswordWithConfirm',function(){
	this.elementConfirm;

	this.hasErrors = function()
	{
		return( this.passwordHasErrors() || this.passwordConfirmHasErrors() );
	}
	
	this.passwordHasErrors = function() 
	{
		var editUserId = DOM.get('editUserId').value;

	
		if( danb(editUserId) ) {
			if( this.element.value.length>0 && this.element.value.length<6 ) {
				this.displayError();
				return true;
			} 
		
	
		} else {
			if( !danb(this.element.value) || this.element.value.length<6 ) {
				this.displayError();
				return true;
			} 
		}
		 
	
		
		this.clearError();
		return false;
	}
	
	this.passwordConfirmHasErrors = function() 
	{
		this.clearError( this.elementConfirm.name );
		this.clearError( this.elementConfirm.name+'_match' );

		var editUserId = DOM.get('editUserId').value;
		
	
		if( danb(editUserId) ) {
			if( this.element.value != this.elementConfirm.value ) {
				this.displayError( this.elementConfirm.name+'_match' );
				return true;
			}

	
		} else {
		
			if( !danb(this.elementConfirm.value) ) {
				this.displayError( this.elementConfirm.name );
				return true;
				
			} else if( this.element.value != this.elementConfirm.value ) {
				this.displayError( this.elementConfirm.name+'_match' );
				return true;
			}
		}
		
		return false;
	}
	
	this.initialize = function()
	{
		if( def(this.options.element_confirm) ) {
			this.elementConfirm = this.options.element_confirm;
			this.elementConfirm.onblur = this.passwordConfirmHasErrors.bind(this);
		}

		if( def(this.element) ) {
			this.element.onblur = this.passwordHasErrors.bind(this);
		}

		this.focus = function() 
		{
			if( this.passwordHasErrors() ) {
				this.element.select();
				this.element.focus();
			} else if( this.passwordConfirmHasErrors() ) {
				this.elementConfirm.select();
				this.elementConfirm.focus();
			}
		}
	}
	
}).extend('TOR_Form_Validator');




<!-- //*************************** END TOR/Form/Validator/PasswordWithConfirm *********************************// -->



<!-- //************************** BEGIN lib/address/postalcode ********************************// -->

<!--

__rootCreate('Address','PostalCode');

Address.PostalCode = 
{
	isValid: function( pc ) 
	{
		pc = Address.PostalCode.getValidCharacters( pc );
		if( pc.match(/^([A-Z][0-9]){3}$/) ) {
			return true;
		} 
		return false;
	},
	
	getValidCharacters: function( pc )
	{
		return pc.toUpperCase().replaceAll(/[^A-Z0-9]+/,'');
	}
};




<!-- //*************************** END lib/address/postalcode *********************************// -->


<!-- //************************** BEGIN TOR/Form/Validator/PostalCode ********************************// -->

<!--





OO.Class.define('TOR_Form_Validator_PostalCode',function(){
	this.hasErrors = function()
	{
		if( !danb(this.element.value) ) {
			this.displayError();
			return true;
		} else if( !Address.PostalCode.isValid( this.element.value ) ) {
			this.displayError();
			return true;
		} else {
			this.clearError();
			return false;
		} 
	}

	this.submitSuccessful = function()
	{
		this.setValidPostalCode();
	}
	
	this.setValidPostalCode = function()
	{
		this.element.value = this.getValidPostalCode();
	}
	
	this.getValidPostalCode = function()
	{
		try{
			var validChars = Address.PostalCode.getValidCharacters( this.element.value );
			return validChars.substr(0,3) + ' ' + validChars.substr(3,3);
		} catch(e){
			dbg(e,'in getvalidpostalcode');
		} 
		return '';
	}
	
	this.getValue = function()
	{
		return this.element.value;
	}
	
}).extend('TOR_Form_Validator');




<!-- //*************************** END TOR/Form/Validator/PostalCode *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validators ********************************// -->

<!--














<!-- //*************************** END TOR/Form/Validators *********************************// -->



<!-- //************************** BEGIN lib/form/validation ********************************// -->

<!--



/*

Version history:

v1: 
- base model; allows you to instantiate Form_Validation, and attach to it various
   Form_Validator's, which has three key methods:
    - this.hasErrors: a method to return true/false as to whether its element contains
       errors
    - this.displayError/this.clearError: this gets called when the element is told to
	   display its error, along with a custom error message (if applicable) 

v2:
- modified to allow for versioning
- onFieldError (in the validator class) and onError (in the validation class) receive
    and array of the erring fields, rather than just an error field count

*/

OO.Class.define('Form_Validation',function(){
	this.options = {};
	this.form;
	this.fields = [];
	this.fieldNames = {};
	this.version = 1;
	
	this.getOptions = function() { return this.options; }
	this.getOption = function(n) { return this.options[n]; }
	this.setOption = function(n,v)
	{
		this.options[n] = v;
	}
	
	this.getVersion = function() { return this.version; }
	this.setVersion = function( v )
	{
		this.version = v;
	}
	
	this.getForm = function() { return this.form; }
	this.setForm = function(x) 
	{ 
		this.form = x;
		if( def(this.options.bindSubmit) && this.options.bindSubmit==true ) {
			this.form.onsubmit = this.onSubmit.bind(this);
		
		} 
	}
	
	this.add = function( field, fieldName )
	{
		var index = this.fields.length; 
		this.fields[ index ] = field;
		
		if( danb(name) ) {
			this.fieldNames[ fieldName ] = index;
		}
	}
	
	this.remove = function( fieldName ) 
	{
		if( danb( fieldName ) && def(this.fieldNames[ fieldName ]) ) {
			var index = this.fieldNames[ fieldName ];
			
			this.fields.splice( index, 1 );
			
			delete this.fieldNames[ fieldName ];
		}
	}
	
	this.clear = function()
	{
		this.fields = [];
	}
	
	this.onSubmit = function()
	{
		return this.isValid();
	}
	
	this.isValid = function()
	{
		var errorFields = [];
		var firstToError;

		foreachArray( this.fields, function(i,field) {

			if( field.hasErrors() ) {
				
				if( !def(firstToError) ) firstToError=i;
				
				errorFields.push( field );
				
				this.onFieldError( field, ( this.version==1 ? errorFields.length : errorFields ) );
			}
			
		}.bind(this));
	
		if( danf(this.options.focusOnError) && def(firstToError) ) this.fields[ firstToError ].focus();
		
		if( errorFields.length>0 ) {
			var response = this.onError( ( this.version==1 ? errorFields.length : errorFields ) );
			if( def(response) ) {
				return response;
			} 
			return false;
		} else {
			var response = this.onSuccess(); 

			foreach( this.fields, function(i,field){
				field.submitSuccessful();
			});

			if( def(response) ) {
				return response;
			}

			return true;
		}
	}
	
	this.focus = function( which )
	{
		try{
			if( def(which) && def(this.fields[which]) && def(this.fields[which].focus) ) {
				this.fields[which].focus();
			}
		} catch(e) { dbg(e,'Exception (which '+ which+')'); }
	}
	
	this.onFieldError = noop;
	this.onError = noop;
	this.onSuccess = noop;
	this.initialize = noop;
	
	this.__construct = function( options )
	{
		if( def(options) ) {
			this.options = options;
		} else {
			this.options = {};
		}

		if( !def(this.options.bindSubmit) ) this.options.bindSubmit=true;
		if( !def(this.options.focusOnError) ) this.options.focusOnError=true

		if( def(this.options.form) ) this.setForm( this.options.form );
	
		this.initialize( this.options );
	}
	
});




<!-- //*************************** END lib/form/validation *********************************// -->



<!-- //************************** BEGIN TOR/Form/Validation ********************************// -->

<!--





OO.Class.define('TOR_Form_Validation',function(){
	this.onError = function( errorCount )
	{
		DOM.show( 'feedback' );
	}
	
	this.onSuccess = function()
	{
		DOM.hide( 'feedback' );
	}
	
	this.initialize = function()
	{
		DOM.register('feedback','feedback');
	}
	
}).extend('Form_Validation');




<!-- //*************************** END TOR/Form/Validation *********************************// -->



<!-- //************************** BEGIN TOR/Upload ********************************// -->

<!--







var TOR_Upload =
{
	Objects:
	{
		UploadForm: false
	},
	
	Command:
	{
		init: function()
		{
			DOM.register('uploadForm','upload_form');
			
			var uploadForm = DOM.get('uploadForm');

			if( !uploadForm ) return dbg('Not an upload form');
			
			TOR_Upload.Objects.UploadForm = uploadForm;

			TOR_Upload.Command.initValidation( uploadForm );
			TOR_Upload.Command.initSubcategory( uploadForm );
		},
		
		initValidation: function( uploadForm )
		{
			if( uploadForm && def(uploadForm['content_type']) && danb(uploadForm['content_type'].value) ) {
				switch (uploadForm['content_type'].value) {
					case 'features': 
						TOR_Upload.Features.Command.init( uploadForm );
						break;
					case 'video': 
						TOR_Upload.Video.Command.init( uploadForm );
						break;
					case 'photo': 
						TOR_Upload.Photo.Command.init( uploadForm );
						break;
					case 'news': 
						TOR_Upload.News.Command.init( uploadForm );
						break;
					case 'facebookapplication': 
						TOR_Upload.FacebookApplication.Command.init( uploadForm );
						break;
					case 'bloggingtool': 
						TOR_Upload.BloggingTool.Command.init( uploadForm );
						break;
					default:
						break;
				}
			}
		},
		
		initSubcategory: function( uploadForm )
		{
			DOM.register('categorySelect','category_select');
			DOM.register('subcategorySelect','subcategory_select');
			DOM.register('subcategoryBlock','subcategory');

			var initialSubCategory = parseInt( DOM.get('initial_subcategory_id').value , 10 );
			if( !danb(initialSubCategory) || isNaN(initialSubCategory) ) initialSubCategory = 0; 
			
			var category = DOM.get('categorySelect');
			category.onchange = TOR_Upload.Command.changeSubCategory.bind(this,0);
		
			TOR_Upload.Command.changeSubCategory( initialSubCategory ); 

			if( !category ) return dbg(category , 'category, in initSubcateogry'); 
			
			ObjectWatcher.findAll('Content_Categories',
				{
					onSuccess: function( data ) { TOR_Upload.Objects.Categories = data; },
					onError: function() { TOR_Upload.Objects.Categories = {}; dbg('contnet_categories onerror was called!'); }
				}
			);
		},
		
		getSubCategories: function( categoryId )
		{
			var subcategories = [];
			foreachArray( TOR_Upload.Objects.Categories, function(i,category){
				if( categoryId == category.id ) {
					subcategories = category.children;
				}
			});
			return subcategories;
		},
		
		hideSubCategories: function()
		{
			var subcategory = DOM.get('subcategorySelect'); 
			var subcategoryBlock = DOM.get('subcategoryBlock');
			subcategory.selectedIndex = 0;
			DOM.hide( subcategoryBlock );
		},
		
		showSubCategories: function( index )
		{
			if( !def(index) ) var index = 0;
			
			var subcategory = DOM.get('subcategorySelect'); 
			var subcategoryBlock = DOM.get('subcategoryBlock');
			
			if( index>=subcategory.options.length ) index = subcategory.options.length-1; 
			subcategory.selectedIndex = index;
			DOM.show( subcategoryBlock );
		},
		
		changeSubCategory: function( forcedIndex )
		{

			var category = DOM.get('categorySelect'); 
			var subcategory = DOM.get('subcategorySelect');
			
			if( !def(TOR_Upload.Objects.Categories) ) return Event.Timer.create( 'wait_for_categories', TOR_Upload.Command.changeSubCategory.bind(this,forcedIndex), 500 );

			var categoryId = category.options[ category.selectedIndex ].value;

			if( !danb( categoryId ) ) {
				return TOR_Upload.Command.hideSubCategories();
			}
			
			var subcategories = TOR_Upload.Command.getSubCategories( categoryId );
			
			var toDelete = [];
			foreachArray( subcategory.options, function(i,option){
				if( i>0 )toDelete.push(option);
			}); 
			foreachArray( toDelete, function(i,option){
				DOM.remove( option );
			});

			if( subcategories.length<1 ) {
				return TOR_Upload.Command.hideSubCategories();
			}

			foreachArray( subcategories, function(i,sub){
				DOM.create({
					t:'option',
					value:sub.id,
					kids:[
						{text:sub.name}
					]
				}, subcategory );
			});
			
			TOR_Upload.Command.showSubCategories( forcedIndex );  
		}		
	},
	
	Common:
	{
		Command:
		{
			init: function( form, validators )
			{
				var validation = OO.Class.instance('TOR_Form_Validation');
	
				validation.setForm( form );
				
				foreachArray( validators, function( i, v ) {
					validation.add( v );
				});
				
				validation.focus(0);
			}
		}
	},
	
	Features:
	{
		Command:
		{
			init: function( form )
			{
				TOR_Upload.Common.Command.init( 
					form,
					[
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']})
					]
				);
			}
		},
		
		View:
		{
			preview: function()
			{
				var featureType = TOR_Upload.Objects.UploadForm['feature_type'];
				var selectedFeature = -1;
				foreachArray( featureType, function(i,feature){
					if( feature.checked ) {
						selectedFeature = i;
						return;
					}
				});
				if( selectedFeature<0 ) return dbg('no feature type selected')
			
				var width = 0, height = 0, defaultHeight = 450;
				switch( selectedFeature ) {
					case 0:
						width=600;
						height=defaultHeight;
						break;
					case 1:
						width=180;
						height=250;
						break;
					case 2:
						width=280;
						height=defaultHeight;
						break;
				}
				
				if( width<1 || height<1 ) return dbg('seleected feature type is not valid');
				
				var preview = DOM.create({
					t:'div',
					className:'previewWindow',
					style:{
						width:width+'px',
						height:height+'px',
						border:'solid black 1px',
						overflow:'auto'
					}
				});
				
				var title = DOM.get('feature_type_text'+(selectedFeature+1) ).innerHTML;
				title = title.replace(/^\(/,'').replace(/\)$/,'')
				
				var w = TOR_Popup.getObject();
				TOR_Popup.generic( w, title, preview,
					[
						{
							caption:TOR_Strings[ TOR_User.Command.getLanguage() ]['popup_close_window'], 
							properties: {
								href: 'javascript:void(0)',
								onclick: function() { w.close(); },
								style:{className:'btn update'} 
							}
						}
					],
					'tor_popup_preview' 
				);
				
				var popup = $('tor_popup_preview');
				foreach( popup.childNodes, function(i,childNode){
					childNode.style.width=(width+10)+'px';
				});
				w.redraw();
				
				preview.innerHTML = TOR_Upload.Objects.UploadForm['body'].value; 
			},
			
			clear: function()
			{
				TOR_Upload.Objects.UploadForm['body'].value = '';
			}
		}
	},

	Video:
	{
		Command:
		{
			init: function( form ) 
			{
			
				TOR_Upload.Common.Command.init( 
					form,
					[
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_YouTubeUrl',{element:form['you_tube_id']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']}),
						OO.Class.instance('TOR_Form_Validator_Tags',{element:form['tags']})
					]
				);
			}
		}
	},

	Photo:
	{
		Command:
		{
			init: function( form ) 
			{
				var validators;
				if( $('photo_id') && $('photo_id').value!='' ) {
					validators = [
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']}),
						OO.Class.instance('TOR_Form_Validator_Tags',{element:form['tags']})
					];
				} else {
					validators = [
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_File',{element:form['image']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']}),
						OO.Class.instance('TOR_Form_Validator_Tags',{element:form['tags']})
					];
				}
				
				TOR_Upload.Common.Command.init( 
					form,
					validators
				);
			}
		}
	},

	News:
	{
		Command:
		{
			init: function( form ) 
			{
				TOR_Upload.Common.Command.init( 
					form,
					[
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']}),
						OO.Class.instance('TOR_Form_Validator_Url',{element:form['link']}),
						OO.Class.instance('TOR_Form_Validator_Tags',{element:form['tags']})
					]
				);
			}
		}
	},

	FacebookApplication:
	{
		Command:
		{
			init: function( form ) 
			{
				TOR_Upload.Common.Command.init( 
					form,
					[
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']}),
						OO.Class.instance('TOR_Form_Validator_File',{element:form['image']}),
						OO.Class.instance('TOR_Form_Validator_Url',{element:form['link']}),
						OO.Class.instance('TOR_Form_Validator_Tags',{element:form['tags']})
					]
				);
			}
		}
	},

	BloggingTool:
	{
		Command:
		{
			init: function( form ) 
			{
				TOR_Upload.Common.Command.init( 
					form,
					[
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['title']}),
						OO.Class.instance('TOR_Form_Validator_Required',{element:form['body']}),
					
						OO.Class.instance('TOR_Form_Validator_Tags',{element:form['tags']})
					]
				);
			}
		}
	},
	
	t:
	{
	}	
};

addLoadEvent( TOR_Upload.Command.init );




<!-- //*************************** END TOR/Upload *********************************// -->



<!-- //************************** BEGIN lib/number ********************************// -->

<!--

Number = 
{
	getRandom: function( low, high )
	{
		return low+Math.floor(Math.random()*(high-low+1));
	}
}



<!-- //*************************** END lib/number *********************************// -->



<!-- //************************** BEGIN TOR/View/Join/PostalCode ********************************// -->

<!--







OO.Class.define('TOR_View_Join_PostalCode',function(){
	this.renderElement = function()
	{
		DOM.hide('riding_box_error');
		
		var name = DOM.get('riding_name');
		DOM.removeAllChildren(name);
		DOM.create({text:this.data.name},name);
		
		DOM.show('riding_box');
	}
	
	this.hide = function()
	{
		DOM.hide('riding_box');
		DOM.hide('riding_box_error');
	}
	
	this.showLoading = noop;
	
	this.error = function( status, originalParams )
	{
		DOM.hide('riding_box');

		var name = DOM.get('postal_code');
		DOM.removeAllChildren(name);
		DOM.create({text:originalParams.id},name);

		DOM.show('riding_box_error');
	}
	
}).extend('TOR_View');




<!-- //*************************** END TOR/View/Join/PostalCode *********************************// -->



<!-- //************************** BEGIN TOR/View/Join ********************************// -->

<!--






<!-- //*************************** END TOR/View/Join *********************************// -->



<!-- //************************** BEGIN TOR/Join ********************************// -->

<!--



var TOR_Join = 
{	
	Objects:
	{
		Elements: 
		{
		}
	},
	
	Command:
	{
		checkPostalCode: function()
		{
			if( def(TOR_Join.Objects.PostalCodeTimeout) ) clearTimeout( TOR_Join.Objects.PostalCodeTimeout );
			if( ! TOR_Join.Objects.Elements.PostalCodeValidator.hasErrors() ) {
				TOR_Join.Objects.PostalCodeTimeout = setTimeout( 
					function()
					{
						if( !TOR_Join.Objects.Elements.PostalCodeValidator.hasErrors() ) {
							TOR_Join.Objects.Elements.PostalCode.hide();
							ObjectWatcher.find( 
								'RidingByPostalCode', 
								TOR_Join.Objects.Elements.PostalCodeValidator.getValidPostalCode(),
								{ 
									onSuccess: function( o ) 
									{
										if( !TOR_Join.Objects.Elements.PostalCodeValidator.hasErrors() ) {
											TOR_Join.Objects.Elements.PostalCode.update( o );
										}
									},
									onError: TOR_Join.Objects.Elements.PostalCode.error.bind( TOR_Join.Objects.Elements.PostalCode )
								} 
							);
						}
					}, 
					500 
				);
			} else {
				TOR_Join.Objects.Elements.PostalCode.hide();
			}
		},
		
		init: function()
		{
			isJoin = isModify = false;
			if (form = DOM.get('join_form')) {
				isJoin = true;
			}
			else if (form = DOM.get('modify_user_form')) {
				isModify = true;
			}
			if( !form ) return dbg('Not a join / edit user form');
			
			DOM.register('editUserId','edit_user_id');
			
			var validation = OO.Class.instance('TOR_Form_Validation');

			validation.setForm( form );
			
			validation.add( OO.Class.instance('TOR_Form_Validator_Required',{element:form['first_name']}) );
			validation.add( OO.Class.instance('TOR_Form_Validator_Required',{element:form['last_name']}) );
			
			if (isJoin) {
				validation.add( OO.Class.instance('TOR_Form_Validator_Email',{element:form['email']}) );
				validation.add( OO.Class.instance('TOR_Form_Validator_Required',{element:form['username_']}) );
			}
			validation.add( OO.Class.instance('TOR_Form_Validator_PasswordWithConfirm',{element:form['password_'],element_confirm:form['confirm_password']}) );

			TOR_Join.Objects.Elements.PostalCodeValidator = OO.Class.instance('TOR_Form_Validator_PostalCode',{element:form['postal_code']});
			validation.add( TOR_Join.Objects.Elements.PostalCodeValidator );						
			validation.focus(0);
			form['postal_code'].onkeyup = form['postal_code'].onblur = TOR_Join.Command.checkPostalCode;			

			TOR_Join.Objects.Elements.PostalCode = OO.Class.instance('TOR_View_Join_PostalCode',{element:form['postal_code']});			
			if( form['postal_code'].value!='' ) {
				TOR_Join.Command.checkPostalCode();
			}

		
		
		
		
		

			if (isJoin) {
				validation.add( OO.Class.instance('TOR_Form_Validator_Checked',{element:form['t_and_c']}) );
			}
			
			return;
			
			form['first_name'].value='e';
			form['last_name'].value='e';
			form['email'].value='ee@see.com';
			form['username_'].value='e';
			form['password_'].value='dafsdfadse';
			form['confirm_password'].value='dafsdfadse';
		}
	}
}

addLoadEvent( TOR_Join.Command.init );




<!-- //*************************** END TOR/Join *********************************// -->

