/**********************************
   	Diligenz Inc Scripting Object
**********************************/
var Common = {
	/**********************************
		General Helper Methods
	**********************************/
	tempValues: [], //this is a place to hold misc values
	mouseOverColor: '',
	selectedColor: '',
	defaultColor: '',
	expandable: true,
	isDebug: function(){
		if(this.tempValues['isDebug'] == null){
			this.tempValues['isDebug'] = false;
			
			if(Common.queryString.get('CurrentState').toLowerCase() == 'debug'){
				this.tempValues['isDebug'] = true;
			}
		}
		return this.tempValues['isDebug'];
	},
	
	isIE: function (){ return (document.all) ? true : false; },
	flip: function(fld,link,expText,defText){
		var itm = this.getElement(fld);

		if(this.expandable){
			if(itm.style.display == 'none'){
				this.show(itm);
				if(expText != null){ link.innerHTML = expText; }
			}else{ 
				this.hide(itm);
				if(defText != null){ link.innerHTML = defText; }
			}
		}
	},
	flipColor: function(e,fld,child){
		var itm = this.getElement(fld);
		var itmChild = (child) ? this.getElement(child) : null;
		if(itmChild != null){
			if(itmChild.style.display == 'none'){
				if(e.type == 'mouseover'){
					itm.style.backgroundColor=this.mouseOverColor;
				}else{
					itm.style.backgroundColor=this.defaultColor;
				}
			}else{
				if(e.type == 'mouseover'){
					itm.style.backgroundColor=this.mouseOverColor;
				}else{
					itm.style.backgroundColor=this.selectedColor;
				}						
			}
		}else{
			if(e.type == 'mouseover'){
				itm.style.backgroundColor=this.mouseOverColor;
			}else{
				itm.style.backgroundColor=this.defaultColor;
			}
		}
	},
	hide: function(fld){ var itm = this.getElement(fld); if(itm != null){ itm.style.display = 'none'; } },
	show: function(fld){ var itm = this.getElement(fld); if(itm != null){ itm.style.display = ''; } },
	visible: function(fld){
		var itm = this.getElement(fld);
		var isVisible = false;
		if(itm.style.display != 'none'){ isVisible=true; }
		if(itm.style.visible != 'hidden'){ isVisible=true; }
		return isVisible;
	},
	startsWith: function(str,startVal){
		if(str.length >= startVal.length){
			if(str.substring(0,startVal.length) == startVal){
				return true;
			}
		}
		
		return false;
	},
	getElement: function(val){
		switch(typeof val){
			case 'string':
				var ret;
								
				//find it on the page
				if(ret == null){ try{ ret = document.getElementById(val); }catch(e){ ret=null } }				
				if(ret == null){ try{ ret = document.getElementsByName(val)[0]; }catch(e){ ret=null } }
				
				return ret;
			default:
				return val;
		}
	},
	
	
	/**********************************
		String Helper Methods
	**********************************/
	string: {
		trim: function(s){ return s.replace(/^\s+/, '').replace(/\s+$/,''); },
		ltrim: function(s){ return s.replace(/^\s+/, ''); },
		rtrim: function(s){ return s.replace(/\s+$/,''); }
	},
	
	
	/**********************************
		Number Helper Methods
	**********************************/
	integer: {
		toMoney: function(val){
			var v = val.toFixed(2);var t = v.substring(0,v.indexOf('.'));if(t.length > 3){var c = 0;var n = '';var a = t.split('');for(i=(a.length-1);i>-1;i--){if(c == 3){n = ',' + n;c = 0;}n = a[i] + '' + n;c++;}t = n;}v = '$' + t + v.substring(v.indexOf('.'));return v;
		}
	},
	
	
	/**********************************
		Popup Helper Methods	
	**********************************/
	popup: {
		settings: {
			width: null,
			height: null,
			top: null,
			left: null,
			scollbars: true,
			resizable: true,
			locationbar: false,
			menubar: false,
			personalbar: false,
			statusbar: false,
			toolbar: false,
			returnReferece: false
			},
		reset: function(){
			//this is used to reset the values in the settings array
			this.settings = {
				width: null,
				height: null,
				top: null,
				left: null,
				scollbars: true,
				resizable: true,
				locationbar: false,
				menubar: false,
				personalbar: false,
				statusbar: false,
				toolbar: false,
				returnReferece: false
				};
		},
		
		normal: function(url,title,h,w){
			//check to see if height/width have been passed in
			if(h != null){ this.settings.height = h; } 
			if(w != null){ this.settings.width = w; }
			
			if(this.settings.height == null){ this.settings.height = window.screen.height-30; }
			if(this.settings.width == null){ this.settings.width = window.screen.width-30; }
			
			if(this.settings.top == null){ 
				this.settings.top = Math.floor((window.screen.height/2)-(this.settings.height/2)); 
			}
			if(this.settings.left == null){
				this.settings.left = Math.floor((window.screen.width/2)-(this.settings.width/2)); 
			}
			//alert ('rayban width ' + this.settings.width);
			if (this.settings.width> 1900)
			{
			 this.settings.width=(this.settings.width/2)-30;
			 //alert ('rayban width AFTER' + this.settings.width);
			}
			//create a string out of the settings
			var params;
			params='width=' + this.settings.width;
			params+=',height=' + this.settings.height;
			params+=',top=' + this.settings.top;
			params+=',left=' + this.settings.left;
			params+=',scollbars=' + this.settings.scollbars;
			params+=',resizable=' + this.settings.resizable;
			params+=',locationbar=' + this.settings.locationbar;
			params+=',menubar=' + this.settings.menubar;
			params+=',personalbar=' + this.settings.personalbar;
			params+=',statusbar=' + this.settings.statusbar;
			params+=',toolbar=' + this.settings.toolbar;
			//create the popup window
			var win = window.open(url,title,params);
			
			//reset any parameters that have been modified
			this.reset();
			
			//check to see if the reference to the window should be returned
			if(this.settings.returnReferece){
				return win;
			}else{
				return false;
			}
		},
		
		special: function(type,params){
			var win;	
			switch(type.toLowerCase()){
				case 'help':
					this.settings.width = 650;
					this.settings.height = 650;
					win = this.normal('HelpCenter/WebSolutionOverviewWeb.htm#' + params,'Help');
					break;
				case 'faq':
					this.settings.width = 500;
					this.settings.height = 500;
					win = this.normal('KnowledgebasePopup.aspx?FaqID=' + params,'Help');
					break;
				case 'newsletter':
					this.settings.width = 900;
					this.settings.height = 650;
					win = this.normal('/Newsletter/Newsletter.htm','Help');
					break;
				case 'newsletter:teaser':
					this.settings.width = 900;
					this.settings.height = 650;
					win = this.normal('/Newsletter/Teaser/Newsletter.htm','Help');
					break;
				case 'clipboard':
					this.settings.width = 750;
					this.settings.height = 650;
					win = this.normal('Clipboard.aspx','Clipboard');
					break;
				case 'issue':
					this.settings.width = 500;
					this.settings.height = 560;
					win = this.normal('ContactUsWindow.aspx?CreateBug=True','Submit Bug');
					break;
				case 'fullscreen':
				//alert("1234 - rayban")
					this.settings.top = 5;
					this.settings.left = 5;
					var url = params[0];
					var title = params[1];
					win = this.normal(url,title);
					break;		
			}
			
			//reset any parameters that have been modified
			this.reset();
			
			//return the reference to the window (or boolean value)
			return win
		}
	},
	
	
	/**********************************
		Radio/Checkbox Helper Methods
	**********************************/
	radio: {
		items: [],
		populateItems: function(group){
			//go thru the document and get all of the radio buttons with in this group
			if(group == null || this.items[group] != null){ 
				return;
			}
			
			this.items[group] = [];
			var all = Common.isIE ? document.all : document.getElementsByTagName('INPUT');
			
			for(i=0;i<all.length;i++){
				if(all[i].tagName.toLowerCase() == 'input' && all[i].type.toLowerCase() == 'radio' && all[i].name.toLowerCase() == group.toLowerCase()){
					this.items[group][this.items[group].length] = all[i].id;
				}
			}
		},
		
		getCheckedRadioControlForGetCounts: function () {
		    var all = Common.isIE ? document.all : document.getElementsByTagName('INPUT');
		    		  
		    for(i=0;i<all.length;i++) {
		        if(all[i].tagName.toLowerCase() == 'input' && all[i].type.toLowerCase() == 'radio' && all[i].id.indexOf('MyCenterBox_FilingInProcess_MainBox_View') > -1 && all[i].checked == true) {
		            return all[i];
		        }
		    }
		    return null;
		},
		
		getSelectedValue: function(group){
			this.populateItems(group);
			var isSelected = false;
			if(this.items[group] != null){
				for(i=0;i<this.items[group].length;i++){
					var fld = Common.getElement(this.items[group][i]);
					if(fld.checked){
						return fld.value;
					}
				}
			} else {
				return null;
			}
		},
		
		setSelectedValue: function(group,value){
			this.populateItems(group);
			if(this.items[group] != null){
				for(i=0;i<this.items[group].length;i++){
					if(this.items[group][i].value == value){
						this.items[group][i].checked = true;
					}else{
						this.items[group][i].checked = false;
					}
				}
			}
		}
	},
	
	checkboxes: {
		items: [],
		populateItems: function(group,firstFld,beginsWith){
			//if no groupname has been passed in, return nothing
			if(group == null){ return false; }
			
			//alert('Group: ' + group + '\nFirst Field: ' + firstFld + '\nStarts With: ' + beginsWith);
			
			//check to see if the items in the array are just strings
			//which will usually mean the IDs have been set.
			var allGood = false;
			if(this.items[group] != null && this.items[group].length > 0) {
				//if the first item is a string, then it's most likely
				//all populated with field id's and not references
				if((typeof this.items[group][0]) == 'string'){
					for(i=0; i<this.items[group].length; i++){
						var fld = Common.getElement(this.items[group][i]);
						if(fld != null){
							this.items[group][i] = fld;
							allGood = true;
						}
					}
				}else{
					//everythings all good
					allGood = true;
				}
			} else {				
				//go thru the document and get all of the
				//radio buttons with in this group
				this.items[group] = [];
				
				
				//get all of the elements on the page
				var all
				if(firstFld != null){
					var begin = Common.getElement(firstFld);
					all = begin.getElementsByTagName('INPUT');
				}else{
					all = document.getElementsByTagName('INPUT');
				}
				
				if(beginsWith == null){ beginsWith = group.toLowerCase(); }
				
				//parse thru the elements and get the ones that are needed
				for(i=0;i<all.length;i++){
					if(all[i].tagName.toLowerCase() == 'input' && all[i].type.toLowerCase() == 'checkbox' && Common.startsWith(all[i].id.toLowerCase(),beginsWith)){
						this.items[group][this.items[group].length] = all[i];
						allGood = true;
					}
					
					/*
					if(all[i].tagName.toLowerCase() == 'input' && all[i].type.toLowerCase() == 'checkbox'){
						alert(all[i].id + '\nBeginsWith:' + beginsWith + '\nIsMatch:' + Common.startsWith(all[i].id.toLowerCase(),beginsWith));
					}
					*/
				}
			}
			
			return allGood;
		},
		
		selectAll: function(group,firstFld,beginsWith){
			this.populateItems(group,firstFld,beginsWith);
			if(this.items[group] != null){
				for(i=0;i<this.items[group].length;i++){
					this.items[group][i].checked = true;
				}
			}
		},
		
		unselectAll: function(group,firstFld,beginsWith){
			this.populateItems(group,firstFld,beginsWith);
			if(this.items[group] != null){
				for(i=0;i<this.items[group].length;i++){
					this.items[group][i].checked = false;
				}
			}
		},
		
		getSelectedValues: function(group,start){
			var selected = this.getSelected(group,start);
			if(selected != null){
				var ret = [];
				for(i=0;i<selected.length;i++){
					ret[ret.length] = selected[i].value;
				}
				return ret;
			}else{
				return null;
			}
		},
		
		getSelected: function(group,start){
			this.populateItems(group,start);
			if(this.items[group] != null){
				var ret = [];
				for(i=0;i<this.items[group].length;i++){
					if(this.items[group][i].checked){
						ret[ret.length] = this.items[group][i];
					}
				}
				return ret;
			}
		}
	},
	
	/**********************************
		Drop Down Lists Helper Methods
	**********************************/
	dropDownList: {
		items: [],
		hideAll: function(flds){
			this.items['hidden'] = [];
			
			if(flds != null && flds.length > 0){
				for(var i=0;i<flds.length;i++){
					var fld = Common.getElement(flds[i]);
					this.items['hidden'][this.items['hidden'].length] = fld;
					fld.style.visibility = 'hidden';
				}
			}else{
				//get all of the SELECT elements on the page
				var all = document.getElementsByTagName('SELECT');
				
				//now set the visible style on all of them to hidden
				for(i=0;i<all.length;i++){
					this.items['hidden'][this.items['hidden'].length] = all[i];
					all[i].style.visibility = 'hidden';
				}
			}
		},
		showAll: function(){
			if(this.items['hidden']!=null){
				for(var i=0;i<this.items['hidden'].length;i++){
					try {
						var fld = Common.getElement(this.items['hidden'][i]);
						fld.style.visibility = 'visible';
					} catch(e){
						//eat the error message
					}
				}
				
				this.items['hidden'] = null;
			}
		},
		add: function(fld,name,id,selected){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			var optionName = new Option(name, id, false, selected);
			itm.options[itm.options.length] = optionName;
		},
		
		remove: function(fld,pos){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			if(pos == null && itm.selectedIndex > -1){ pos = itm.selectedIndex; }
			if(pos != null && pos < itm.options.length){
				itm.remove(pos);
				if(pos < itm.options.length && itm.options.length > 0){
					itm.options[pos].selected = true; 
				}else if(itm.options.length > 0){
					itm.options[itm.options.length-1].selected = true;
				}
			}
		},
		
		clear: function(fld){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			if(itm != null){ while(itm.options.length > 0){ itm.remove(0); } }
		},
		
		moveItemUp: function(fld){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			if(itm.selectedIndex > 0){
				this.moveItem(itm,itm.selectedIndex,itm.selectedIndex-1);
			}
		},
		
		moveItemDown: function(fld){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			if(itm.selectedIndex > -1 && itm.selectedIndex < (itm.options.length - 1)){
				this.moveItem(itm,itm.selectedIndex,itm.selectedIndex+1);
			}
		},
		
		moveItem: function(fld,posA,posB){
			var itm = Common.getElement(fld);
			try{
				if(itm.options[posA] != null && itm.options[posB] != null){
					var tmpTxt; var tmpVal;
					tmpTxt = itm.options[posA].text;
					tmpVal = itm.options[posA].value;
					itm.options[posA].text = itm.options[posB].text;
					itm.options[posA].value = itm.options[posB].value;
					itm.options[posB].text = tmpTxt;
					itm.options[posB].value = tmpVal;
					itm.options[posB].selected = true;
				}
			}catch(e){
				//eat the error up
			}
		},
		
		selectedValue: function(fld){
			var itm = this.selected(fld);
			if(itm == null){ return null; }
			return itm.value;
		},
		
		selectedText: function(fld){
			var itm = this.selected(fld);
			if(itm == null){ return null; }
			return itm.text;
		},
		
		selected: function(fld){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			return itm.options[itm.selectedIndex];
			
		},
		
		setSelectedText: function(fld,txt){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			
			var pos = -1;
			for (var i = 0; i < itm.options.length; i++){
				if(itm.options[i].text.toLowerCase() == txt.toLowerCase()){ pos = i; break; }
			}
			
			itm.selectedIndex = pos;
		},
		
		setSelectedValue: function(fld,val){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			
			var pos = -1;
			for (var i = 0; i < itm.options.length; i++){
				if(itm.options[i].value.toLowerCase() == val.toLowerCase()){ pos = i; break; }
			}
			
			itm.selectedIndex = pos;
		},
		
		toString: function(fld){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			var ret;
			for(i=0;i<itm.options.length;i++){
				if(ret != null){ ret += ','; }else{ ret = ''; }
				ret += "['" + itm.options[i].text + "','" + itm.options[i].value + "']";
			}
			return '[' + ret + ']';
		},
		
		parse: function(fld,txt){
			var itm = Common.getElement(fld);
			if(itm == null){ return null; }
			if(txt.length > 0){
				var a = eval(txt);
				for(i=0;i<a.length;i++){
					this.add(itm,a[i][0],a[i][1],false);
				}
			}
		}
	},
	
	/**********************************
		FileUpload Helper Methods
	**********************************/
	fileUpload: {
		items: [],
		create: function(parentId){		
			//get the reference to the container
			var container = Common.getElement(parentId);
			
			//this will put a border around each attachment
			//to give it seperation from the rest of the
			//other elements
			var boxDiv = document.createElement('div');
			
			//labels and description input
			var descHolder = document.createElement('div'); //used to add a line break
			var descTitle = document.createElement('span');
			var descInput = document.createElement('input');
			var attTitle = document.createElement('span');
			
			//elements used to create the fake file upload
			var outerDiv = document.createElement('div');
			var realInput = document.createElement('input');
			var innerDiv = document.createElement('div');
			var fakeInput = document.createElement('input');
			var brwseImg = document.createElement('img');
			
			//set the properties
			boxDiv.className = 'fileInputContainer';
			descTitle.className = 'fileInputTitles TextInput Span200';
			attTitle.className = 'fileInputTitles TextInput Span200';
			descInput.className = 'fakeInput'; //need it to be the same size as the fake input
			outerDiv.className = 'fileInputs';
			innerDiv.className = 'fakeFile';
			
			descTitle.innerHTML = 'Description';
			attTitle.innerHTML = 'Attachment';
			
			realInput.id = 'fileUp' + this.items.length;
			realInput.type = 'file';
			realInput.className = 'file';
			
			fakeInput.id = realInput.id + '_fake';
			fakeInput.type = 'text';
			fakeInput.className = 'fakeInput';
			fakeInput.disabled = true;
			
			fakeInput.id = realInput.id + '_btn';
			brwseImg.src='../images/browse_btn.gif';
			brwseImg.align = 'right';
			
			//add the events to sync up the values
			//of the fake and real input fields
			realInput.onchange = realInput.onmouseout = function() { Common.getElement(fakeInput.id).value = this.value; }
			
			//add the fields to the appropiate containers
			descHolder.appendChild(descTitle);
			descHolder.appendChild(descInput);
			boxDiv.appendChild(descHolder);
			
			boxDiv.appendChild(attTitle);
			innerDiv.appendChild(brwseImg);
			innerDiv.appendChild(fakeInput);
			outerDiv.appendChild(realInput);
			outerDiv.appendChild(innerDiv);
			boxDiv.appendChild(outerDiv);
			container.appendChild(boxDiv);
			
			//update the count
			this.items[this.items.length] = boxDiv;
		}
	},
	
	/**********************************
		CoolButton Helper Methods
	**********************************/
	coolButton: {
		buttonText: [],
		isClickable: true,
		click: function(id){
			var fld = Common.getElement(id);
			if(fld && fld.click){ fld.click(); }
			return false;
		},
		checkDefault: function(id,e){			
			if ((e.which != null && e.which == 13) || (e.keyCode != null && e.keyCode == 13)){
				setTimeout('Common.coolButton.click(\'' + id + '\')',100);
				return false;
			}else{
				return true;
			}
		},
		changeStatus: function(parentID,childID){
			if (this.isClickable) {
				var parentBtn = Common.getElement(parentID);
				if(parentBtn != null && parentBtn.innerHTML != 'Processing...') {
					buttonText[parentID] = parentBtn.innerHTML;
					parentBtn.innerHTML = 'Processing...';
					parentBtn.style.color = 'gray';
					parentBtn.style.cursor = 'wait';
					this.isClickable = false;
				}
				
				var childBtn = Common.getElement(otherID);
				if (childBtn != null && childBtn.innerHTML != 'Processing...') {
					buttonText[childID] = childBtn.innerHTML;
					childBtn.innerHTML = 'Processing...';
					childBtn.style.color = 'gray';
					childBtn.style.cursor = 'wait';
					this.isClickable = false;
				}
			}
			return this.isClickable;
		},
		
		resetStatus: function(id){
			var item = Common.getElement(id);
			if(item != null){
				if(this.buttonText[id] != null){
					item.innerHTML = this.buttonText[id];
				}
				item.style.color = '#000000';
				item.style.cursor = '';
				this.isClickable = true;
			}
		}
	},
	
	
	/**********************************
		Validation Helper Methods
	**********************************/
	validate: {
		isInteger: function(txt){ if(typeof txt == 'integer'){ return true; }else{ return false; } },
		isString: function(txt){ if(typeof txt == 'string'){ return true; }else{ return false; } },
		isBoolean: function(txt){ if(typeof txt == 'boolean'){ return true; }else{ return false; } }
	},
	
	
	/**********************************
		Encoding Helper Methods
	**********************************/
	encoding: {
		xmlChars: {
			//'"': '&qout;',
			'<': '&lt;',
			'>': '&gt;',
			'&': '&amp;'
		},
		
		xmlEncode: function(txt) {
			var updated = '';
			for(var i=0;i<txt.length;i++){
				var current = txt.substr(i,1);
				if(this.xmlChars[current] != null){
					updated += this.xmlChars[current];
				} else {
					updated += current;
				}
			}
			return updated;
		},
		
		xmlDecode: function(txt) {
			var updated = '';
			for(var i=0;i<txt.length;i++){
				var newVal = txt.substr(i,1);
				for(val in this.xmlChars){
					try {
						var sz = this.xmlChars[val].length;
						if(txt.substr(i,sz) == this.xmlChars[val]){
							i = i+(sz-1);
							newVal = val;
							break;
						}
					} catch(e){
						//eat the error message
					}
				}
				updated += newVal;
			}
			return updated;
		}
	},
	
	
	/**********************************
		QueryString Helper Methods
	**********************************/
	queryString: {
		items: [],
		length: 0,
		get: function(name){
			//populate the array, it if hasn't already
			if(this.length == 0 && document.location.search.length > 0){ this.parse(); }
			if(this.length > 0){
				if(this.items[name.toLowerCase()] == null){
					return '';
				} else {
					return this.items[name.toLowerCase()];
				}
			} else {
				return '';
			}
		},
		
		parse: function(){
			try{
				var q = document.location.search.substring(1);
				var p = q.split('&');
				this.length = p.length;
				for(i=0;i<p.length;i++){
					var n = p[i].substring(0,p[i].indexOf('='));
					var v = p[i].substring(p[i].indexOf('=')+1);
					this.items[n.toLowerCase()] = v; 
				}
			} catch(e){
				//eat the error message
			}
			return;
		}
	},
	
	
	/**********************************
		Jurisdictions Helper Methods
	**********************************/
	jurisdictions: {
			//container for all of the jurisdictions
			items: [],
			
			//create a string of the jurisdictions
			toString: function(){
				var ret;
				for(i=0;i<this.items.length;i++){
					if(ret != null){ ret += ','; }else{ ret = ''; }
					ret += "['" + this.items[i]['name'] + "'," + this.items[i]['id'] + "]";
				}
				return '[' + ret + ']';
			},
			
			//used to generate a blank item
			nothing: function(){
				var blank = [2];
				blank['id'] = -1;
				blank['name'] = '';
				return blank;
			},
			
			//populate the list of jurisdictions from the text that has been passed in
			parse: function (txt) {				
				this.items = eval(txt);
	    	},
			
			//searches the list of jurisdictions for the ID passed in
			getById: function(id) {
				//search for the jurisdiction with the id passed in
				if(this.items.length > 0){
					for(i=0;i<this.items.length;i++){
						if(this.items[i]['id'] == id){ return this.items[i]; }
					}
				}
				
				//if nothing is found, return a blank array
				return this.nothing();
			},
			
			//searches the list of jurisdictions for the Name passed in
			getByName: function(name) {
				//search for the jurisdiction with the name passed in
				if(this.items.length > 0){
					for(i=0;i<this.items.length;i++){
						if(this.items[i]['name'] == name){ return this.items[i]; }
					}
				}
				
				//if nothing is found, return a blank array
				return this.nothing();
			}
		},
	
	/**********************************
		Ajax Helper Methods
	**********************************/
	ajax: {
		counter: 0,
		processingPage: location.pathname,
		iframeCollection: [],
		parameterCollection: [],
		requestData: function(classname,method,params,callback){	
		
			var delim = '|||'; //this uses regex
			//create a new iframe to make the request with
			var fSize = '1';
			var fBorder = '0';
			var fScrolling = 'no';
			if(Common.isDebug()){ fSize = '500'; fBorder = '1'; fScrolling = 'yes'; }
			var iframe = document.createElement("iframe");
			iframe.setAttribute('id', 'ajaxRequest.' + this.counter);
			iframe.setAttribute('name', 'ajaxRequest.' + this.counter);
			iframe.setAttribute('scrolling', fScrolling);
			iframe.setAttribute('frameBorder', fBorder);
			iframe.setAttribute('height', fSize);
			iframe.setAttribute('width', fSize);
			iframe.setAttribute('src','');
			
			//check to see if a callback method name was set
			if(callback == null || callback.length == 0){ callback='AjaxCallback' }
			
			//go thru the params array and turn it into a delimted list
			var p = '';
			if(typeof params == 'string' || typeof params == 'number'){
				p = params;
			} else if(params != null) {
				for(i=0;i<params.length;i++){
					if(p.length>0){ p += delim; }
					p += params[i];
				}	
			}
			
			//set the source for the iframe
			iframe.src = this.processingPage + '?id=' + iframe.id + '&cb=' + callback + '&cn=' + classname + '&m=' + method + '&d=' + escape(delim);
			
			//add the iframe reference to the collection
			this.iframeCollection[iframe.id] = iframe;
			this.parameterCollection[iframe.id] = p;
			
			//add the iframe to the page
			document.body.appendChild(iframe);
			
			//add one to the counter, so that it doesn't 
			//conflict with any other requests on the page
			this.counter += 1;
			
			//return the id for the processing frame, this
			//will allow the calling procedure to keep track
			//of the data they are requesting
			return iframe.id;
		},
		
		getParameters: function(id){
			return this.parameterCollection[id];
		},
		
		processResponse: function(id,callback,retVal,ids){
			//remove the iframe from the page
			if(!Common.isDebug()){
				document.body.removeChild(this.iframeCollection[id]);
			}
			
			//escape the single quotes
			var quote = new RegExp("'","gi");
			var crlf = new RegExp("\n|\r","gi");
			retVal = retVal.replace(quote,"\\'");
			retVal = retVal.replace(crlf,"");

			var callit = '\'' + id + '\',\'' + retVal + '\'';
			if(ids != null){ callit += ',ids'; }

			//call the callback method provided
			eval(callback + '(' + callit + ')');
		},
		
		error: function(id){
			document.body.removeChild(this.iframeCollection[id]);
			if(Common.isIE()){
				location.href='ErrorPage.aspx?AjaxError=true';
			} else {
				setTimeout('Common.ajax.redirectError',10);
			}
		},
		
		redirectError: function(){
			location.href='ErrorPage.aspx?AjaxError=true';
		}
	}
}