
/*
	--------------------------------------------------------------------------------------------------------------
	@package:  Validation Tools
	@author:     Michael Walsh
	@date:        13-08-2006
	@version:    1.0
	--------------------------------------------------------------------------------------------------------------
	MSIE 5.5+
	Firefox 1.07+
	Netscape 7.0+
	Opera 8.0+
	--------------------------------------------------------------------------------------------------------------
*/

/*
	@method:   Form validation.
	@version:   1.0
*/
function validateForm(o)
{
	var oDiv = document.getElementById(o.hud.element), oForm = document[o.form.name], aErrors = [];
	for (var i=0; i < o.schema.length; i++)
	{
		var required = o.schema[i].required, value, re;
		switch (o.schema[i].type)
		{
			case "input":
			value = oForm[o.schema[i].field].value; break;
			case "radio":
			value = (oForm[o.schema[i].field].value!=undefined) ? oForm[o.schema[i].field].value : ''; break;
			case "select":
			value = Forms.Select.getSelectedValues(oForm[o.schema[i].field]); break;
			case "range":
			value = []; for (var j=o.schema[i].range[0]; j <= o.schema[i].range[1]; j++) { var name = o.schema[i].field+j; value[j-1] = oForm[name].value; } break;
			case "password":
			value = oForm[o.schema[i].field].value; break;
			case "classGroup":
			value = o.schema[i].field; break;
		}
		if (required&&!value.length) aErrors[aErrors.length] = [o.schema[i].field,o.schema[i].message.required];
		else if(o.schema[i].validation=='custom')
		{
			if (o.schema[i].range!=undefined)
			{
				for (var j=o.schema[i].range[0]; j <= o.schema[i].range[1]; j++)
				{
					var name = o.schema[i].field+j;
					var output = o.schema[i].custom.apply(this,[{id:name,index:j}]);
					if (!output.valid) for (var k=0; k < output.errors.length; k++) aErrors[aErrors.length] = output.errors[k];
				}
			} else { var output = o.schema[i].custom.apply(this,[{id:o.schema[i].field}]); if (!output.valid) for (var l=0; l < output.errors.length; l++) aErrors[aErrors.length] = output.errors[l]; }
		}
		else if(value.length)
		{
			var bFail=false;
			switch (o.schema[i].validation)
			{
				case "string":
					bRe=true;re = /./;
					break;
				case "email":
					bRe=true;re = /^[a-z\d._%-]+@[a-z\d.-_]+(\.[a-z]{2,4})$/;
					break;
				case "numeric":
					bRe=true;re = /^[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?$/;
					break;
				case "password":
					bRe=true;re = /./;
					break;
				case "date":
					var aDate=value.split("/"); var date = new Date(aDate[2],aDate[1]-1,aDate[0]); var bFail=(parseInt(aDate[2],10)!=date.getFullYear()||parseInt(aDate[1]-1,10)!=date.getMonth()||parseInt(aDate[0],10)!=date.getDate());
					break;
				case "unique":
					bFail = validateUnique(value);
					break;
			}
			if ((bRe&&!re.exec(value.toLowerCase()))||bFail) aErrors[aErrors.length] = [o.schema[i].field,o.schema[i].message.validation];
			else if (o.schema[i].maxlength&&(value.length>o.schema[i].maxlength)) aErrors[aErrors.length] = [o.schema[i].field,o.schema[i].message.maxlength];
		}
		if (o.schema[i].validation!='custom' && o.schema[i].validation!='unique') if (o.form.classes.valid!=null) oForm[o.schema[i].field].className = o.form.classes.valid;
	}
	if (aErrors.length) { var message = o.hud.message; for (var i=0; i < aErrors.length; i++) { message += aErrors[i][1]; if (aErrors[i][0]!=null) if (o.form.classes.error!=null && typeof(oForm[aErrors[i][0]]) != 'undefined') oForm[aErrors[i][0]].className = o.form.classes.error; } if (aErrors[0][0]!=null && typeof(oForm[aErrors[0][0]]) != 'undefined') oForm[aErrors[0][0]].focus(); oDiv.className = o.hud.classes.error; oDiv.innerHTML = message; if (typeof o.hud.onError == 'function') o.hud.onError.apply(this,[aErrors]); return false; }
	else { oDiv.className = o.hud.classes.valid; if (typeof o.hud.onValid == 'function') { eval(o.hud.onValid)(); } return true; }//o.hud.onValid.call();
};

// Add on form validation element for unique values within a group of elements
// Returns FALSE if validation has passed, true if there is an error
function validateUnique(sClassGroup) {
	// Get the base grouping for all elements matching the class group
	var aElements = getElementsByClass(sClassGroup);
	
	var nBaseGrouping = 0;
	var nThisGroup = 0;
	
	// Loop over collected elements
	for (i = 0; i < aElements.length; i++) {
		nBaseGrouping = aElements[i].getAttribute('nBaseGrouping');
		if(nBaseGrouping == nThisGroup) continue;
		
		var aValueList = new Array();
		
		for(j = 0; j < aElements.length; j++) {
			if(aElements[j].getAttribute('nBaseGrouping')!=nBaseGrouping) continue;
			if(aElements[j].value == '' || aElements[j].value == null) continue;
			// IE doesn't have an indexOf array function, make one
			if(!Array.indexOf){ Array.prototype.indexOf = function(obj){ for(var i=0; i<this.length; i++){ if(this[i]==obj){ return i;	} } return -1; } }			
			if(aValueList.indexOf(aElements[j].value) != -1) return true;
			aValueList.push(aElements[j].value);
		}
		nThisGroup = nBaseGrouping;
	}
	
	return false;
}

/*
	@method:   Global div display helpers.
	@version:   1.0
*/
function showMessage()
{
	_DOM.setStyle(oValidationConstruct.hud.element,"display","block");
	var a = (arguments.length) ? ((typeof arguments[0]=='number')? arguments[0] : arguments[0].length) : [''];
	var o = { height: { to: (a*15)+((_browser=='MSIE')?40:10) }, opacity: { to: 1 } };  
	var tween = new YAHOO.util.Anim(oValidationConstruct.hud.element, o, 1, YAHOO.util.Easing.backOut);
	window.location.hash="pagetop";
	tween.animate(); 
};
function hideMessage()
{
	var o = { height: { to: 0 }, opacity: { to: 0 } };  
	var tween = new YAHOO.util.Anim(oValidationConstruct.hud.element, o, ((_browser=='MSIE')?1:0.5), YAHOO.util.Easing.backIn);
	tween.animate();
	tween.onComplete.subscribe(function(){_DOM.setStyle(oValidationConstruct.hud.element,"display","none");})
};

/*
	--------------------------------------------------------------------------------------------------------------
	@package:  Form Toolkit
	@author:     Michael Walsh
	@date:        29-06-2006
	@version:    1.0
	--------------------------------------------------------------------------------------------------------------
	MSIE 5.0+
	Firefox 1.07+
	Netscape 6.0+
	Opera 7.0+
	--------------------------------------------------------------------------------------------------------------
*/

/*
	@method:   Form toolkit.
	@version:   1.0
*/
Forms = 
{
	_version:1.0,
	confirmAction:function(s,url)
	{
		if (confirm(s)) window.location = url; else return false;
	},
	confirmCheck:function(o,s)
	{
		if (!o.checked) return false;
		if (!confirm(s)) o.checked = false;
	},
	confirmUncheck:function(o,s)
	{
		if (o.checked) return false;
		if (!confirm(s)) o.checked = true;
	},
	collateForm:function(oForm)
	{
		var o = [], i = 0;
		do
		{
			var item = oForm[i], add = true;
			switch (item.type)
			{
				case 'checkbox': if (!item.checked) add = false; break;
				case 'radio': if (!item.checked) add = false; break;
			}
			if (add) o[o.length] = {id:oForm[i].id,value:Forms.urlEncode(oForm[i].value)}; i++;
		}
		while (oForm[i]);
		return o;
	},
	collateForm_wrx:function(oForm)
	{
		var o = [], i = 0;
		do
		{
			var item = oForm[i], aggregateValue = '', add = true;
			switch (item.type)
			{
				case 'checkbox': if (!item.checked) add = false; break;
				case 'radio': if (!item.checked) add = false; break;
				case 'select-multiple':
					for( var j = 0; j < item.options.length; j++ ) {
						if(item.options[j].selected == true) {
							if(!aggregateValue.length) {
								aggregateValue = item.options[j].value;
							}else{
								aggregateValue += ',' + item.options[j].value;
							}
						}
					}
					o[o.length] = {id:oForm[i].id,value:aggregateValue};
					add=false;
					break;
			}
			if (add) o[o.length] = {id:oForm[i].id,value:Forms.urlEncode(oForm[i].value)}; i++;
		}
		while (oForm[i]);
		return o;
	},
	submitToUrl:function(f,url)
	{
		var oForm = document.getElementById(f);
		oForm.action = url;
		oForm.submit();
	},
	submitWithValue:function(f,a,val)
	{
		var oForm = _DOM.get(f), oField = oForm[a];
		oField.value = val; oForm.submit();
	},
	urlEncode:function(s)
	{
		return escape(s).replace(/\+/g,"%2B").replace(/(\/)/g,"%2F");
	},
	wordsRemaining:function(id,text,count)
	{
		var oDest = get(id), oSource = get(text), remaining = (count-oSource.value.length);
		if (remaining<0) { oSource.value = oSource.value.substring(0, count); remaining = 0; }
		oDest.value = remaining;
	},
	disable:function(elementId) {
		document.getElementById(elementId).disabled = true;
	},
	enable:function(elementId) {
		document.getElementById(elementId).disabled = false;
	},
	Select:
	{
		_version:1.0,
		get:function(sId)
		{	
			return (document.getElementById) ? document.getElementById(sId) : document.all[sId];
		},
		getCount:function(sId)
		{
			var oSelect = this.get(sId);
			return oSelect.options.length;
		},
		getSelected:function(sId)
		{
			var oSelect = this.get(sId), aIndexs = [], j = 0;
			for (var i = 0; i < oSelect.options.length; i++) { if (oSelect.options[i].selected) { aIndexs[j] = i; j++; } }
			return aIndexs;
		},
		getSelectedValues:function(sId)
		{
			var oSelect = (typeof(sId)=='string')? this.get(sId) : sId;
			var aIndexs = []
			var value = '';
			for (var i = 0; i < oSelect.options.length; i++) { if (oSelect.options[i].selected) { value += oSelect.options[i].value; } }
			return value;
		},
		getSelectedText:function(sId)
		{
			var oSelect = this.get(sId), aIndexs = [], j = 0;
			for (var i = 0; i < oSelect.options.length; i++) { if (oSelect.options[i].selected) { aIndexs[j] = oSelect.options[i].text; j++; } }
			return aIndexs;
		},
		jumpUrlWithAttributes:function(o)
		{
			var qstring = '?';
			if (typeof o.query!='undefined') for (var i=0;i<o.query.length;i++) { if (typeof getQueryVariable(o.query[i])!='undefined') qstring += ((i==0)?'':'&')+o.query[i]+'='+getQueryVariable(o.query[i]); }
			if (typeof o.attributes!='undefined') for (var i=0;i<o.attributes.length;i++) qstring += ((i==0&&!o.query.length)?'':'&')+o.attributes[i];
			window.location = window.location.pathname+qstring;
		},
		selectAt:function(sId,n)
		{
			var oSelect = this.get(sId);
			if (oSelect == null || oSelect.options == null) return false;
			oSelect.options[n].selected = true;
		},
		selectAll:function(sId)
		{
			var oSelect = this.get(sId);
			if (oSelect == null || oSelect.options == null) return false;
			for (var i = 0; i < oSelect.options.length; i++) oSelect.options[i].selected = true;
		},
		selectByValue:function(sId,sValue)
		{
			var oSelect = this.get(sId);
			if (oSelect == null || oSelect.options == null) return false;
			for (var i = 0; i < oSelect.options.length; i++) if (oSelect.options[i].value == sValue) oSelect.options[i].selected = true;
		},
		deselectAll:function(sId)
		{
			var oSelect = this.get(sId);
			if (oSelect == null || oSelect.options == null) return false;
			for (var i = 0; i < oSelect.options.length; i++) oSelect.options[i].selected = false;
		},
		add:function(sId,sName,sValue)
		{
			var oSelect = this.get(sId), oOption = document.createElement("option");
			oOption.appendChild(document.createTextNode(sName,sValue));
			if (arguments.length == 3) oOption.setAttribute("value",sValue);
			oSelect.appendChild(oOption);
		},
		remove:function(sId,nIndex)
		{
			var oSelect = this.get(sId);
			oSelect.remove(nIndex);
		},
		purge:function(sId)
		{
			var oSelect = this.get(sId);
			for (var i = oSelect.options.length-1; i >= 0; i--) this.remove(sId,i);
		},
		copy:function(sId,sTarget,oConfig)
		{
			if (oConfig == null) var oConfig = {};
			var bMove = (oConfig.move) ? oConfig.move : false;
			var bTrim = (oConfig.trim) ? oConfig.trim : false;
			var oSelect = this.get(sId), oTarget = this.get(sTarget), nIndex = this.getSelected(sId)
			for (var i = 0; i < nIndex.length; i++) { var element = oSelect.options[nIndex[i]]; if (bMove) { oTarget.appendChild(element) } else { this.add(sTarget,  (bTrim) ? element.text.trim() : element.text, element.value); } } // element.disabled = true; element.selected = false;
		},
		extract:function(sId)
		{
			var oSelect = this.get(sId), nIndex = this.getSelected(sId);
			for (var i = nIndex.length-1; i >= 0; i--) { this.remove(sId,nIndex[i]); }
		},
		rationaliseFromQuery:function(aQueryObject)
		{
			var nColumns = aQueryObject.length;
			var nRecordCount = aQueryObject[0].length
			var aReturn = new Array();
			for(i = 0; i < nRecordCount; i++) {
				aReturn[i] = new Array(aQueryObject[0][i], aQueryObject[1][i]);
			}

			return aReturn;
		},
		populate:function(sId,aOptions,oConfig)
		{
			if (oConfig == null) var oConfig = {};
			var bClear = (oConfig.purge) ? oConfig.purge : false;
			var bTrim = (oConfig.trim) ? oConfig.trim : false;
			var oSelect = this.get(sId);
			if (bClear) this.purge(sId);
			for (var i = 0; i < aOptions.length; i++) {
				if (typeof aOptions[i]!='string' && typeof aOptions[i]!='number') this.add(sId, (bTrim) ? aOptions[i][1].trim() : aOptions[i][1], aOptions[i][0]);
				else this.add(sId, (bTrim) ? aOptions[i].trim() : aOptions[i], aOptions[i]);
			}
		},
		populateFromJson:function(elementId, optionArray, purge) {
			if(purge != null) this.purge(elementId);
			for(var idx = 0; idx < optionArray.length; idx++) {
				this.add(elementId, optionArray[idx].title, optionArray[idx].id);
			}
		},
		shiftUp:function (sId)
		{
			var oSelect = this.get(sId), nIndex = this.getSelected(sId);
			if (nIndex[0] == 0 || nIndex.length == 0 || nIndex.length > 1) return;
			var oOption = oSelect.options[nIndex[0]], oShiftOption = oSelect.options[nIndex[0]-1];
			oSelect.insertBefore(oOption, oShiftOption);
		},
		shiftDown:function (sId)
		{
			var oSelect = this.get(sId), nIndex = this.getSelected(sId);
			if (nIndex[0] == oSelect.options.length-1 || nIndex.length == 0 || nIndex.length > 1) return;
			var oOption = oSelect.options[nIndex[0]], oShiftOption = oSelect.options[nIndex[0]+1];
			oSelect.insertBefore(oShiftOption, oOption);
		}
	}
};

// Prototype get elements by class name utility
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\\\s)"+searchClass+"(\\\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

// CF style dump of a js object (debug tool)
dump=function(object, showTypes) {
	var dump='';var st=typeof showTypes=='undefined' ? true : showTypes;var winName='dumpWin';var browser=_dumpIdentifyBrowser();var w=760;var h=500;var leftPos=screen.width ?(screen.width-w)/ 2 : 0;var topPos=screen.height ?(screen.height-h)/ 2 : 0;var settings='height='+h+',width='+w+',top='+topPos+',left='+leftPos+',scrollbars=yes,menubar=yes,status=yes,resizable=yes';var title='Dump';var script='function tRow(s){t=s.parentNode.lastChild;tTarget(t, tSource(s));}function tTable(s){var switchToState=tSource(s);var table=s.parentNode.parentNode;for(var i=1;i < table.childNodes.length;i++){t=table.childNodes[i];if(t.style){tTarget(t, switchToState);}}}function tSource(s){if(s.style.fontStyle=="italic"||s.style.fontStyle==null){s.style.fontStyle="normal";s.title="click to collapse";return "open";}else{s.style.fontStyle="italic";s.title="click to expand";return "closed";}}function tTarget(t, switchToState){if(switchToState=="open"){t.style.display="";}else{t.style.display="none";}}';dump+=(/string|number|undefined|boolean/.test(typeof(object))||object==null)? object : recurse(object, typeof object);winName=window.open('', winName, settings);if(browser.indexOf('ie')!=-1||browser=='opera'||browser=='ie5mac'||browser=='safari'){winName.document.write('<html><head><title> '+title+' </title><script type="text/javascript">'+script+'</script><head>');winName.document.write('<body>'+dump+'</body></html>');}else{winName.document.body.innerHTML=dump;winName.document.title=title;var ffs=winName.document.createElement('script');ffs.setAttribute('type', 'text/javascript');ffs.appendChild(document.createTextNode(script));winName.document.getElementsByTagName('head')[0].appendChild(ffs);}winName.focus();function recurse(o, type){var i;var j=0;var r='';type=_dumpType(o);switch(type){case 'regexp':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>RegExp: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'date':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Date: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'function':var t=type;var a=o.toString().match(/^.*function.*?\((.*?)\)/im);var args=(a==null||typeof a[1]=='undefined'||a[1]=='')? 'none' : a[1];r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td colspan="2"'+_dumpStyles(t,'td-value')+'><table'+_dumpStyles('arguments','table')+'><tr><td'+_dumpStyles('arguments','td-key')+'><i>Arguments: </i></td><td'+_dumpStyles(type,'td-value')+'>'+args+'</td></tr><tr><td'+_dumpStyles('arguments','td-key')+'><i>Function: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o+'</td></tr></table>';j++;break;case 'domelement':var t=type;r+='<table'+_dumpStyles(t,'table')+'><tr><th colspan="2"'+_dumpStyles(t,'th')+'>'+t+'</th></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Name: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeName.toLowerCase()+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Type: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeType+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>Node Value: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.nodeValue+'</td></tr>';r+='<tr><td'+_dumpStyles(t,'td-key')+'><i>innerHTML: </i></td><td'+_dumpStyles(type,'td-value')+'>'+o.innerHTML+'</td></tr>';j++;break;}if(/object|array/.test(type)){for(i in o){var t=_dumpType(o[i]);if(j < 1){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+'</th></tr>';j++;}if(typeof o[i]=='object' && o[i]!=null){r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else if(typeof o[i]=='function'){r+='<tr><td'+_dumpStyles(type ,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+recurse(o[i], t)+'</td></tr>';}else{r+='<tr><td'+_dumpStyles(type,'td-key')+'>'+i+(st ? ' ['+t+']' : '')+'</td><td'+_dumpStyles(type,'td-value')+'>'+o[i]+'</td></tr>';}}}if(j==0){r+='<table'+_dumpStyles(type,'table')+'><tr><th colspan="2"'+_dumpStyles(type,'th')+'>'+type+' [empty]</th></tr>';}r+='</table>';return r;};};_dumpStyles=function(type, use){var r='';var table='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;cell-spacing:2px;';var th='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;text-align:left;color: white;padding: 5px;vertical-align :top;cursor:hand;cursor:pointer;';var td='font-size:xx-small;font-family:verdana,arial,helvetica,sans-serif;vertical-align:top;padding:3px;';var thScript='onClick="tTable(this);" title="click to collapse"';var tdScript='onClick="tRow(this);" title="click to collapse"';switch(type){case 'string':case 'number':case 'boolean':case 'undefined':case 'object':switch(use){case 'table':r=' style="'+table+'background-color:#0000cc;"';break;case 'th':r=' style="'+th+'background-color:#4444cc;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccddff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'array':switch(use){case 'table':r=' style="'+table+'background-color:#006600;"';break;case 'th':r=' style="'+th+'background-color:#009900;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#ccffcc;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'function':switch(use){case 'table':r=' style="'+table+'background-color:#aa4400;"';break;case 'th':r=' style="'+th+'background-color:#cc6600;"'+thScript;break;case 'td-key':r=' style="'+td+'background-color:#fff;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'arguments':switch(use){case 'table':r=' style="'+table+'background-color:#dddddd;cell-spacing:3;"';break;case 'td-key':r=' style="'+th+'background-color:#eeeeee;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;}break;case 'regexp':switch(use){case 'table':r=' style="'+table+'background-color:#CC0000;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FF0000;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FF5757;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'date':switch(use){case 'table':r=' style="'+table+'background-color:#663399;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#9966CC;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#B266FF;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;case 'domelement':switch(use){case 'table':r=' style="'+table+'background-color:#FFCC33;cell-spacing:3;"';break;case 'th':r=' style="'+th+'background-color:#FFD966;"'+thScript;break;case 'td-key':r=' style="'+th+'background-color:#FFF2CC;color:#000000;cursor:hand;cursor:pointer;"'+tdScript;break;case 'td-value':r=' style="'+td+'background-color:#fff;"';break;}break;}return r;};_dumpIdentifyBrowser=function(){var agent=navigator.userAgent.toLowerCase();if (typeof window.opera != 'undefined'){return 'opera';} else if (typeof document.all != 'undefined'){if (typeof document.getElementById != 'undefined'){var browser = agent.replace(/.*ms(ie[\/ ][^ $]+).*/, '$1').replace(/ /, '');if(typeof document.uniqueID != 'undefined') {if (browser.indexOf('5.5') != -1){return browser.replace(/(.*5\.5).*/, '$1');}else{return browser.replace(/(.*)\..*/, '$1');}}else{return 'ie5mac';}}}else if(typeof document.getElementById != 'undefined'){if (navigator.vendor.indexOf('Apple Computer, Inc.')!=-1) {return 'safari';}else if(agent.indexOf('gecko')!=-1) {return 'mozilla';}}return false;};_dumpType=function(obj){var t=typeof(obj);if(t=='function'){var f=obj.toString();if((/^\/.*\/[gi]??[gi]??$/).test(f)){return 'regexp';}else if((/^\[object.*\]$/i).test(f)){t='object'}}if(t !='object'){return t;}switch(obj){case null:return 'null';case window:return 'window';case document:return document;case window.event:return 'event';}if(window.event &&(event.type==obj.type)){return 'event';}var c=obj.constructor;if(c !=null){switch(c){case Array:t='array';break;case Date:return 'date';case RegExp:return 'regexp';case Object:t='object';break;case ReferenceError:return 'error';default:var sc=c.toString();var m=sc.match(/\s*function(.*)\(/);if(m !=null){return 'object';}}}var nt=obj.nodeType;if(nt !=null){switch(nt){case 1:if(obj.item==null){return 'domelement';}break;case 3:return 'string';}}if(obj.toString !=null){var ex=obj.toString();var am=ex.match(/^\[object(.*)\]$/i);if(am !=null){var am=am[1];switch(am.toLowerCase()){case 'event':return 'event';case 'nodelist':case 'htmlcollection':case 'elementarray':return 'array';case 'htmldocument':return 'htmldocument';}}}return t;};