if(typeof __i2rd_initted == 'undefined') {
  __i2rd_initted = true;
//note: incomplete impl.
if(!Array.prototype.push){Array.prototype.push=function(i){if(i){this[this.length]=i;}};}
//note: incomplete impl.
if(!Array.prototype.pop){
	Array.prototype.pop=function() {
	  if(this.length==0){return;}
      var i, n = this.length - 1;
	  i=this[n];
	  delete this[n];
      this.length = n;
	  return i;
	};
}
Array.prototype.pushAll=function(list){for(var h = 0, hb = list.length; h < hb; h++)this.push(list[h]);};
if(!String.prototype.trim) {String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g, "");};}
// dom:update special for backward compatibility
if(typeof __i2rd_domupdate_event == 'undefined') { 
	__i2rd_domupdate_event = "dom:update";
	__i2rd_domupdate_handlers = [];
	__i2rd_domupdate_fire = function(element, e) {
		var i, h, a = [];if(e) {a.push(e);}
		for(i=0;(h=__i2rd_domupdate_handlers[i]);i++){
			try {h.apply(element,a);}catch(e){}
        }
	};
}
//stubs
log4js={_log:function(msg,e){if(typeof console != 'undefined' && console.log){console.log(msg);if(e)console.log(e);}}};
log4js.logger={log:log4js._log,debug:log4js._log,info:log4js._log,warn:log4js._log,error:log4js._log};
if (typeof i2rd == 'undefined') {window.i2rd = {};} // expose

/**
 * Returns true if browser is Microsoft Internet Explorer 
 * and returns false for other browsers.
 * @see http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
 */
i2rd.isIE=!+'\v1'; 
i2rd.getConfigMap=function(el) {
	if (typeof el == 'string') el = document.getElementById(el);
	if (!el) return {};
	var e = el.childNodes, b = {}, n = 0, mx=e.length;
	for (; n<mx; n++) b[e[n].className] = e[n].innerHTML;
	return b;
};
i2rd.xmlToString=function(xml) {
    var str = '', ib, i=0, cn;
    if(typeof xml != 'string') {
    	cn = xml.childNodes;
        if(xml.xml) {
            for (ib=cn.length;i<ib;i++){str+=cn[i].xml;}
        } else {
            var xs = new XMLSerializer();
			for (ib=cn.length;i<ib;i++) {str+=xs.serializeToString(cn[i]);}
        }
    } else {str = xml;}
    return str;
};
i2rd.scriptRX=/<script[^>]*>([\S\s]*?)<\/script>/gim;
/** Returns an object with properties html and scripts. */
i2rd.stripScripts=function(h){
    return {
        html:h.replace(i2rd.scriptRX, ''),
        scripts:(function(){
        	try{i2rd.scriptRX.lastIndex=0;}catch(e){}
            var m=[],i,arr;
            while( (arr = i2rd.scriptRX.exec(h)) ){
                if(arr[1]){m[m.length]=arr[1].replace(/^\s*<!\[CDATA\[/, '').replace(/\]\]>\s*$/, '');}
            }
            return m;
        })(),
        addScripts:function(){
    		var e,t,i,s=this.scripts,h=document.getElementsByTagName("head")[0];
    		if(!s || s.length < 1)return;
			for(i=0;t=s[i]; i++) {
				e = document.createElement("script");
				e.setAttribute("type", "text/javascript");
				e.text = t;
				h.appendChild((s[i]=e));
			}
			setTimeout(function(){for(var i=0; i<s.length; i++)h.removeChild(s[i]);}, 30000);
    	}
    }; 
};
/**
 * Array/list copy.
 * @param s source.
 * @param sp source position.
 * @param d destination.
 * @return the destination.
 */
i2rd.acopy=function(s,sp,d){
	var i=sp;
	for(;i<s.length;i++)d.push(s[i]);
	return d;
}
i2rd._dl='dom:loaded';
i2rd.w3cevt=!!document.addEventListener;
i2rd.ieevt=!!document.attachEvent;
// Simple event handling helpers http://dean.edwards.name/weblog/2005/10/add-event/
i2rd.addEvent=function(el, type, handler) {
	if(type == __i2rd_domupdate_event) {
		__i2rd_domupdate_handlers.push(handler);
	} else if(type == i2rd._dl && i2rd.rdy) { 
		handler.call(el, i2rd.createEvent('HTMLEvents', i2rd._dl,false,false));
	} else if(i2rd.w3cevt) {
		el.addEventListener(type, handler, false);
	} else {
		if (!handler.$$guid){handler.$$guid=i2rd.addEvent_guid++;}
		if (!el.events){el.events={};}
		var handlers = el.events[type];
		if (!handlers) {
			handlers = el.events[type] = {};
			if (el["on" + type]) {
				handlers[0] = el["on" + type];
			}
		}
		handlers[handler.$$guid] = handler;
		el["on" + type] = i2rd.handleEvent;
	}
};
i2rd.createEvent=function(module,type){//fyi opera/ie won't let you leave out args
	var d=document,a=i2rd.acopy(arguments,2,[type]); 
	if(i2rd.w3cevt){
		d = d.createEvent(module);
		d['init'+module.replace(/(HTML)?([A-Z][a-z]*vent)s?/, '$2')].apply(d, a);
		return d;
	}else if(i2rd.ieevt){
		d=d.createEventObject();
		d.type=type;
		i2rd.fixEvent(d);
		return d;
	}else{return {type:type};}
};
i2rd.createMouseEvent=function(type,p){
	p = p || {};
	return i2rd.createEvent('MouseEvents',type,p.canBubble||true,p.cancelable||true,p.view||window,p.detail||1,p.screenX||0,p.screenY||0,p.clientX||0,p.clientY||0,p.ctrlKey||false,p.altKey||false,p.shiftKey||false,p.metaKey||false,p.button||0,p.relatedTarget||null);
};
i2rd.fireEvent=function(el, evt){
	var a=i2rd.acopy(arguments,2,['HTMLEvents', evt]);
	if(typeof evt == 'string') {
		if(arguments.length==2)a=a.concat([false,false]);
		evt=i2rd.createEvent.apply(this, a);
	}
	if(i2rd.w3cevt)el.dispatchEvent(evt);
	else if(evt.cancelBubble === false) {
		// It's important that evt.type doesn't start w/ 'on'
		try{el.fireEvent('on'+evt.type, evt);}catch(e){i2rd.handleEvent.call(el,evt);/*non-standard event*/}
	} else i2rd.handleEvent.call(el,evt);
};
i2rd.removeEvent=function(el, type, handler) {
	if(type==__i2rd_domupdate_event) {
		var hl=[];
		for(i=0;(h=__i2rd_domupdate_handlers[i]);i++){if(h!==handler){hl.push(h);}}
		__i2rd_domupdate_handlers=hl;
	} else if (i2rd.w3cevt) {
		el.removeEventListener(type, handler, false);
	} else {
		if (el.events && el.events[type]) {
			delete el.events[type][handler.$$guid];
		}
	}
};
// a counter used to create unique IDs
i2rd.addEvent_guid=1;
// Internal event methods follow.
i2rd.handleEvent=function(event) {
	if(!this.events)return;
	var i, hl, rv = true;
	event = event || i2rd.fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
	hl = this.events[event.type];
	for(i in hl){if(hl[i].call(this,event)==false){rv = false;}}
	return rv;
};
i2rd.fixEvent=function(event) {
	event.preventDefault = i2rd.fixEvent_preventDefault;
	event.stopPropagation = i2rd.fixEvent_stopPropagation;
	return event;
};
i2rd.fixEvent_preventDefault=function() {this.returnValue = false;};
i2rd.fixEvent_stopPropagation=function() {this.cancelBubble = true;};
i2rd.rdy=document.readyState=='complete';
i2rd.DOMCL=function(){
	if(i2rd.rdy)return;
	if(i2rd.w3cevt) {
		i2rd.rdy=true;
		document.removeEventListener("DOMContentLoaded", i2rd.DOMCL, false);
		window.removeEventListener("load", i2rd.DOMCL, false);
	} else if(i2rd.ieevt) {
		if(document.readyState === "complete"){
			i2rd.rdy=true;
			document.detachEvent("onreadystatechange", i2rd.DOMCL);
			window.detachEvent("onload", i2rd.DOMCL);
		}
	}
	i2rd.fireEvent(document, i2rd._dl);
};
if(i2rd.w3cevt){
	document.addEventListener("DOMContentLoaded", i2rd.DOMCL, false);
	window.addEventListener("load", i2rd.DOMCL, false);
}else if(i2rd.ieevt){
	document.attachEvent("onreadystatechange", i2rd.DOMCL);
	window.attachEvent("onload", i2rd.DOMCL);
}
i2rd.getAjaxTransport=function() {
    try { return new XMLHttpRequest(); } catch(e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
	return null;
};
i2rd.bind=function(m, caller) {
	var a=i2rd.acopy(arguments,2,[]),_m=m,obj=caller;
	return function() {
		_m.apply(obj, i2rd.acopy(arguments,0,a));
	};
};
i2rd.bindAsEventListener=function(m, caller) {
	var a =i2rd.acopy(arguments,2,[]), _m=m,obj=caller;
	return function(evt) {
			i2rd.acopy(arguments,0,a)
			_m.apply(obj, [evt || window.event].concat(a));
		};
};
i2rd.eventElement=function(evt) {
	evt = evt || window.event;
	return (evt.target || evt.srcElement);
};
i2rd.getInnerText=function(el) {
	if (typeof el=="string"){return el;}
	var cn,i,str="",children=el.childNodes;
	for(i=0;(cn=children[i]);i++) {
		switch (cn.nodeType) {
			case 1: str += i2rd.getInnerText(cn); break;
			case 3:
			case 4:  str += cn.nodeValue; break;
		}
	}
	return str;
};
i2rd._p={x:0,y:0};
i2rd._mt=false;
i2rd.coord=function(e) {
	var x=0,y=0;
	e=e||window.event;
	if (e.pageX||e.pageY) { x = evt.pageX; y = evt.pageY;} 
	else if (e.clientX||e.clientY){
        var d=document,b=d.body,de=d.documentElement;
		x = evt.clientX + de.scrollLeft + b.scrollLeft;
	    y = evt.clientY + de.scrollTop + b.scrollLeft;
	}
	return i2rd._p={x:x,y:y};
};
i2rd.getMouseCoord=function(e) {
	if(!i2rd._mt) {
		i2rd._mt = true;
        if( (e = e || window.event)) {i2rd.coord(e);}
		i2rd.addEvent(document, 'mousemove', i2rd.coord);
        setTimeout(function(){i2rd._mt=false;i2rd.removeEvent(document, 'mousemove', i2rd.coord);}, 
            60000);
	}
    return i2rd._p;
};
i2rd.addClassName=function(el,cn){
  var cn = cn.trim();
  if (!i2rd.hasClassName(el,cn))
    el.className = ((el.className || '') + ' ' + cn).trim();
};
i2rd.removeClassName=function(el,cn){
  if (!i2rd.hasClassName(el,cn)) return;
  el.className = (el.className || '').replace(RegExp("(^|\\s+)" + cn.trim() + "(\\s+|$)",'g'), ' ').trim();
};
i2rd.hasClassName=function(el,cn){
  var cur = (el.className || '');
  return cur == cn || (RegExp("(^|\\s+)"+cn+"(\\s+|$)").test(cur));
};
/** Gets the value of the specified cookie.
 * @param name  Name of the desired cookie.
 * @return Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
i2rd.getCookie=function (name) {
	var i=0,c,cn=name+"=",ca=document.cookie.split(';');
	for(;c=ca[i];i++) {
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(cn) == 0) return c.substring(cn.length,c.length);
	}
	return null;
};
/**
 * Sets a Cookie with the given name and value.
 * @param name    Name of the cookie
 * @param value   Value of the cookie
 * @param expires (Optional)  Expiration date of the cookie (default: end of current session)
 * @param path (Optional) Path where the cookie is valid (default: path of calling document)
 * @param domain (Optional) Domain where the cookie is valid
 *              (default: domain of calling document)
 * @param secure (Optional) Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
i2rd.setCookie=function (name, value, expires, path, domain, secure) {
    document.cookie=name+"="+escape(value)+
        ((expires)?"; expires="+expires.toGMTString():"")+
        ((path)?"; path="+path : "")+
        ((domain)?"; domain="+domain:"")+
        ((secure)?"; secure" : "");
};
/**
* Delete a Cookie with the given name.
* @param name the name of the cookie.
* @param path optional path of the cookie.
*/
i2rd.deleteCookie=function(name, path, domain) {
    document.cookie=name+"; expires=Thu, 01-Jan-1970 00:00:01 GMT" + ((path)?"; path="+path:"") + ((domain)?"; domain="+domain:"");
};
// http://developer.mozilla.org/en/docs/DOM:window.open
i2rd.owfDefault={
    menubar : false,
    location : false,
    toolbar : false,
    scrollbars : true,
    statusbar : false
    /* ,dependent : null, dialog : null,  resizable : null */
};
/**
 * Open a new window.
 * @param {Object} url the URL of the window.
 * @param {Object} name the optional name of the window.
 * @param {Object} dim the optional dimensions of the window. Must have x and y prop.
 * @param {Object} features the optional features. Map of feature => boolean || null. See owfDefault.
 * @param {Object} pbMesg the optional popup blocked message.
 * @param {Event} evt optional event. 
 */
i2rd.openWindow=function(url, name, dim, features, pbMesg, evt) {
    name = name || '_blank';
    features = features || i2rd.owfDefault;
    pbMesg = pbMesg || 'Please disable any popup blockers for this site.';
    var fstr = '';
    for(var key in features) {
        var val = i2rd.getOWFeature(features, key);
        if(val!=null) {//NULL check, undefined/false means something else
            fstr +=','+key+'='+(val?'yes':'no');
        } 
    }
    if(dim) {
        if(dim.x && dim.x > 0){dim.x+=30;fstr+=',width='+dim.x;}
        if(dim.y && dim.y > 0){dim.y+=50;fstr+=',height='+dim.y;}
    }
    if(fstr.length > 0) {fstr = fstr.substring(1);}
    var nw = window.open(url, name, fstr);
    if(name != '_top' && name != '_parent' && name != '_self') {
        if(nw.opener != window) { // Should be nw == null ?
            alert(pbMesg);
        }
    }
    try {
        nw.focus();
        if(dim && dim.x && dim.y){
            if(dim.x > 0 && dim.y > 0){
                nw.resizeTo(dim.x, dim.y); // Only resize if both dimensions are known
            }
        }
    }catch(e){}
    evt = evt || window.event;
    if(evt){
        if(evt.preventDefault) {
        	evt.preventDefault();
        	evt.stopPropagation();
    	}
        else {
        	evt.cancelBubble = true;
        	evt.returnValue = false;
    	}
    }
    return false;   
};
i2rd.getOWFeature=function(m, prop) {
    var val=m[prop];
    if(typeof val == 'undefined' ||  val==null){return null;}
    else{return !!val;}
};
/**
 * Iterate over the array and apply the passed function to each of the
 * individual items.
 * <p>
 * An optional filter may be passed as the third parameter which will only apply
 * the function to elements for which the filter returns true (or an object
 * which evaluates to true).
 * 
 * @param array The array or array-like object to iterate over.
 * @param fn(index,el,count) The function to apply to the matching elements. 'this' refers to the
 *          element.
 * @param filter(index,el,count) An optional filter to limit the elements the function applies to.
 *          'this' refers to the element.
 */
i2rd.each = function(array, fn, filter) {
  var ct = 0, all = (typeof filter !== 'function');
  for ( var i = 0, mx = array.length; i < mx; i++) {
    var el = array[i];
    if (all || filter.call(el, i, el, ct)) {
      fn.call(el, i, el, ct++);
    }
  }
};
i2rd.serialize=function(form){
	var t,e,i,s=[];
	for(i=0; e=form.elements[i]; i++){
		t=e.type;
		if(e.serializeValue) e.serializeValue(form, s, e.name, e.value);
		else if(e.name && !e.disabled && t != 'submit' && t != 'file') {
			switch(e.nodeName.toLowerCase()){
				case 'input':
					switch(t){
						case 'checkbox':
						case 'radio':
							if(e.checked)i2rd.serializeValue(form, s, e.name, e.value); 
							break;
						case 'button':break;
						default: i2rd.serializeValue(form, s, e.name, e.value); break;
					}
					break;
				case 'select':
					for(var o,j=0; o=e.options[j];j++) if(o.selected) i2rd.serializeValue(form, s, e.name, o.value);
					break;
				case 'button':break;
				default:i2rd.serializeValue(form, s, e.name, e.value); break;
			}
		}
	}
	return s.join('&');
};
/**
 * Serialize a form element.
 * @param f form.
 * @param s serialized value "$name=$value" list.
 * @param n the form element name.
 * @param v the form element value.
 */
i2rd.serializeValue=function(f, s, n,v){
	if(n && v!=null){s.push(encodeURIComponent(n) + '=' + encodeURIComponent(v));}
};

// Setup the 'focus' listener and 'auto-submit' for appropriate form elements
i2rd._lf=null;
i2rd.focusListener=function(evt) {
    var el=i2rd.eventElement(evt);
	if(i2rd._lf){i2rd.removeClassName(i2rd._lf, "focused");}
	i2rd.lastFocus=el;
	i2rd.addClassName(el, "focused");
};
i2rd.addEvent(window, 'load', function(){
	var i=0,j,e,f,el,fl=document.forms;
	if(!fl)return;
	for(;f=fl[i];i++){
		el=f.elements;
		for(j=0;e=el[j];j++){
            if(e.type == 'hidden')continue;
            i2rd.addEvent(e,'focus',i2rd.focusListener);
			if(e.nodeName.toLowerCase() == 'select' && i2rd.hasClassName(e, 'autosubmitselect'))
                e.onchange=function(evt){this.form.submit();};
		}
	}
});

} // End conditional eval.

