/* begin util.js */
/* Generic Base Object */
function GenObj() {}
GenObj.prototype.setProp = function(prop,value) { this[prop] = value; }
GenObj.prototype.getProp = function(prop) { return this[prop]; }

function get(id) { return document.getElementById(id); }
function getByTagName(tag) { return document.getElementsByTagName(tag); }
function getByClassName(clsName) {
    var retVal = new Array();
    var elements = document.getElementsByTagName("*");
    for(var i = 0;i < elements.length;i++){
        if(elements[i].className.indexOf(" ") >= 0){
            var classes = elements[i].className.split(" ");
            for(var j = 0;j < classes.length;j++){
                if(classes[j] == clsName)
                    retVal.push(elements[i]);
            }
        }
        else if(elements[i].className == clsName)
            retVal.push(elements[i]);
    }
    return retVal;
}
function exists(o) { if((o!=null)&&(o!="null")&&(o!=undefined)) { return true; } else { return false; } }
function getInnerHTML(id) { return document.getElementById(id).innerHTML; }
function setInnerHTML(id, d) { var e = get(id); if (e != null) { e.innerHTML = d; } }
function getClassName(id) { return document.getElementById(id).className; }
function setClassName(id, c) {  var e = get(id);if (e != null) { e.className = c; } }
function getStyleAttr(id,p) { var e = get(id);if(e != null) { return e.style[p]; } }
function setStyleAttr(id,p,v) { var e = get(id);if(e != null) { e.style[p] = v; } }
function changeCLS(id,cls) { setClassName(id,cls); }
function formatURL(url){ var formattedURL = unescape(url);window.location = formattedURL;}

function show(id) { var e = get(id);if (e != null) { if(arguments.length>1) { setStyleAttr(id,"display",arguments[1]); } else { setStyleAttr(id,'display','block'); } } }
function hide(id) { var e = get(id); if (e != null) { if(arguments.length>1) { setStyleAttr(id,"display",arguments[1]); } else { setStyleAttr(id,'display','none'); } } }

function showInline(id) { show(id,"inline"); }
function hideInline(id) { hide(id,"hidden"); }
function displayInline(id) { show(id,"inline"); }
function hideInline(id) { hide(id,"hidden"); }
function toggle(id) {
	if(get(id)!=null)
	{
		switch(getStyleAttr(id,"display"))
		{
			case "block":
				hide(id);
				break;
			case "inline":
				hideInline(id);
				break;
			case "none":
				show(id);
				break;
			case "hidden":
				displayInline(id);
				break;
			default:
				show(id);
				hide(id);
				break;
		}
	}
}
function showDiv(id) { show(id); }
function hideDiv(id) { hide(id); }
function elementHide(id) { document.getElementById(id).style.visibility='hidden'; }
function elementShow(id) { document.getElementById(id).style.visibility='visible'; }

function getContextPath() {
	var URIBegin = window.location.href.lastIndexOf('.delta.com') + 10;
	var URIEnd = (window.location.href.lastIndexOf('?') > URIBegin) ? window.location.href.lastIndexOf('?') : window.location.href.length;
	var URI = window.location.href.substring(URIBegin, URIEnd);
	var pageArray = URI.split("/");
	if(pageArray.length > 1 && pageArray[1] != "index.jsp") {
		return pageArray[1];
	} else {
		return "home";
	}
}

function getPosition(e) {
	e = e || window.event;
	var cursor = {x:0, y:0};
	if (e.pageX || e.pageY) {
		cursor.x = e.pageX;
		cursor.y = e.pageY + 15;
		//Minus 115 to offset size of header in global.jsp file
	} else {
		cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
		cursor.y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop + 15;
		//Minus 115 to offset size of header in global.jsp file
	}
	return cursor;
 }
function getElementXAndYPos(element) {
	var curLeft = 0, curTop = 0;
	if(element.offsetParent) {
		while (element.offsetParent) {
			curLeft += element.offsetLeft
			curTop += element.offsetTop
			element = element.offsetParent;
		}
	} else if(element.x) {
		curLeft = element.x;
		curTop = element.y;
	} else {}
	return {x:curLeft, y:curTop};
}

var BrowserLanguageSettings = {
	languageSettings : null, languageCollection : [], languageCollectionCount : 0,
	acceptedLanguageDelimiter : ",", acceptedLanguageQualityIndicator : ";", localeLanguageDelimiter : "-",
	defaults : { browserAccept : "en-us", locale : "us", language : "en" },
	findPreferencesStruct : { browserAccept : 0, language : 1, locale : 2 },
	getLocaleByLanguage : function(languageCode) {
		for (var i=0, j=LanguageOptions.length; i<j; i++) {
			if (LanguageOptions[i].getProp("language_code").toLowerCase() === trimString(languageCode).toLowerCase()) {
				return LanguageOptions[i].getProp("default_country");
			}
		}
		return languageCode;
	},
	parseAcceptedLanguage : function(languagePreference) {
		var splitPreference = languagePreference.split(this.acceptedLanguageQualityIndicator);
		var preferredLanguage = splitPreference.length > 0 ? splitPreference[0] : null;
		if (exists(preferredLanguage)) {
			var preferredLanguageSplit = preferredLanguage.split(this.localeLanguageDelimiter);
			var localeCode = null, languageCode = null;
			switch (preferredLanguageSplit.length) {
				case 2:
					localeCode = preferredLanguageSplit[1];
				case 1:
					languageCode = preferredLanguageSplit[0];
					localeCode = exists(localeCode) ? localeCode : this.getLocaleByLanguage(languageCode);
					break;
			}
			return { browserAccept : languageCode + this.localeLanguageDelimiter + localeCode, language : languageCode, locale : localeCode };
		}
		return null;
	},
	isLanguageSupported : function(languageCode) {
		for (var i=0, j=LanguageOptions.length; i<j; i++) {
			if (trimString(LanguageOptions[i].getProp("language_code")).toLowerCase() === trimString(languageCode).toLowerCase()) {
				return true;
			}
		}
		return false;
	},
	getSupportedPreferenceFromCollection : function() {
		for (var i=0; i<this.languageCollectionCount; i++) {
			var currentPreference = this.parseAcceptedLanguage(this.languageCollection[i]);
			if (exists(currentPreference)) {
				if (this.isLanguageSupported(currentPreference.language)) {
					return currentPreference;
				}
			}
		}
		return this.defaults;
	},
	getPreferenceItem : function(structChoice) {
		switch (structChoice) {
			case this.findPreferencesStruct.browserAccept:
				return this.getSupportedPreferenceFromCollection().browserAccept;
			case this.findPreferencesStruct.language:
				return this.getSupportedPreferenceFromCollection().language;
			case this.findPreferencesStruct.locale:
				return this.getSupportedPreferenceFromCollection().locale;
			default:
				return null;
		}
	},
	init : function(browserAcceptLanguage) {
		this.languageSettings = browserAcceptLanguage;
		this.languageCollection = this.languageSettings.split(this.acceptedLanguageDelimiter);
		this.languageCollectionCount = this.languageCollection.length;
	}
};

/* moved from preferences.js for use with fpe engine */
function getPrefs(){
	var pref=getCookie("pref");
	if ( !exists(pref) && typeof(BrowserLanguageSettings) === "object" && typeof(BrowserLanguageSettings.getPreferenceItem) === "function") { 
		pref = BrowserLanguageSettings.getPreferenceItem(BrowserLanguageSettings.findPreferencesStruct.browserAccept);
	}
	if (!exists(pref)) { 
		pref = getDefault(window.location.toString().match("//[^.]*").toString().split("//")[1]); 
	}
	if (arguments.length==1) { return pref.split("-")[1]; }
	else if(arguments.length==2)
	{
		var rtnString = "lang=" + pref.split("-")[0] + ";";
		rtnString += "loc=" + pref.split("-")[1] + ";";
		return rtnString;
	}
	else { return pref; }
}
function getLang() { return getPrefs().split("-")[0]; }
function getLoc() { return getPrefs().split("-")[1]; }
function showHoverContent(event,w,h,elm,source,scrolling,offX,offY,iFrameId,ignoreXAxis) {
	if(hoverNumber == 0){
		var cursor = getPosition(event);
		var element = get(elm);
		iFrameId = arguments[8] ? iFrameId : "pwm_iframe";	
		//iFrame constructor		
		ifrm = document.createElement("IFRAME");
		ifrm.setAttribute("src", source);
		ifrm.setAttribute("id", iFrameId);
		ifrm.setAttribute("scrolling", scrolling);
		ifrm.style.width = w +"px";
		ifrm.style.height = h +"px";
		element.appendChild(ifrm);
		element.style.display='block';
		element.style.width = w + "px";
		element.style.height = h + "px";
		if((ignoreXAxis != null) && (ignoreXAxis)) {
			element.style.left = offX + "px"; 
		}
		else {
			element.style.left = cursor.x + offX + "px";
		}
		element.style.top = cursor.y + offY + "px";
		hoverNumber = 1;
	} else {
		return;
	}
}
function hideHoverContent(event,elm){
	var element = document.getElementById(elm);
	element.style.display = "none";
	if(element.hasChildNodes()){
		while (element.childNodes.length >= 1){
		element.removeChild(element.firstChild);
		}
	}
	hoverNumber = 0;
	
}
function showDebugMsg(msg) {
	try { console.log(msg); } catch(err) {
		var curHtml = (getInnerHTML("debug") != "" ) ? curHTML + "<hr />" : msg;
		setInnerHTML("debug",curHtml);
		if(getStyleAttr("debug","display") != "block") {
			setStyleAttr("debug","width","200px");
			setStyleAttr("debug","height","250px");
			setStyleAttr("debug","padding","5px");
			setStyleAttr("debug","backgroundColor","#eee");
			setStyleAttr("debug","position","absolute");
			setStyleAttr("debug","top","0");
			setStyleAttr("debug","right","0");
			setStyleAttr("debug","overflow","auto");
			setStyleAttr("debug","display","block");
		}
	}
}

function addScriptTag(src) {
	var replaceStr = "_dyn" + numAddedScripts + "_";
	numAddedScripts++;
	var id = src.replace(/\./,replaceStr);
	//alert(id);
	if(!get(id)) {
		var s= document.createElement('script');
		s.type= 'text/javascript';
		s.onload= helper; /* good browsers */
		s.onreadystatechange= function () { if (this.readyState == 'complete' || this.readyState == 'loaded') { helper(); }} /* ie */
		s.src= src; s.id = id;
		s.setAttribute('src',src); s.setAttribute('id',id);
		document.getElementsByTagName('head')[0].appendChild(s);
	}
	else {
		// script is already added to the page
	}
}
function helper() { return true; }

function strCompare(a,b) { if(a.toLowerCase()==b.toLowerCase()) { return true; }  else { return false;  } }
function stripHTML(str) { return str.replace(/\<.+?\>/g, ""); }
function trimString (str) { str = this != window? this : str; return str.replace(/^\s+/g, '').replace(/\s+$/g, '');}

/* use with EXTREME caution */
function addEvent(elm, evType, fn, useCapture)
{
	if(elm.addEventListener){ elm.addEventListener(evType, fn, useCapture); return true; }
	else if(elm.attachEvent){ var r = elm.attachEvent('on' + evType, fn); return r; }
	else { elm['on' + evType] = fn; }
}

function formatTo(base, precision, quantity) {
	var a = roundTo(base, precision);
	//alert(a + "x" + quantity); 
	var b = a * quantity;
	 	b = roundTo(b,2);
	var s = b.toString();
	
	var decimalIndex = s.indexOf(".");
	if(precision > 0 && decimalIndex < 0){
		decimalIndex = s.length;
		s += '.';
	}
	while (decimalIndex + precision + 1 > s.length){
		s += '0';
	}
	return s;
}
function roundTo(base, precision) {
  var m = Math.pow(10, precision);
  var a = Math.round(base * m) / m;
  return a;
}



/* -------------------- functions found online -------------------- */
// copyright Stephen Chapman 24th March 2006, 10th February 2007
// permission to use this function is granted provided
// that this copyright notice is retained intact
//javascript.about.com/library/blnumfmt.htm
function formatNumber(num,dec,thou,pnt,curr1,curr2,n1,n2) { var x = Math.round(num * Math.pow(10,dec));if (x >= 0) n1=n2='';var y = (''+Math.abs(x)).split('');var z = y.length - dec; if (z<0) z--; for(var i = z; i < 0; i++) y.unshift('0');y.splice(z, 0, pnt); while (z > 3) {z-=3; y.splice(z,0,thou);}var r = curr1+n1+y.join('')+n2+curr2;return r;}

function isComplete() {pageLoaded = true; }

addEvent(window,"load",isComplete,false);
var numAddedScripts = 0;
var pageLoaded = false;
var hoverNumber = 0; /* hoverNumber controls number of rollover popups with a limit of 1 */

function conCatTool() {
	var _self = this;
	this.conCatValue = [];
	this.currentIndex = 0;
	this.disableHTMLTranslationStartTag = "\n<!-- mp_trans_disable_start -->\n";
	this.disableHTMLTranslationEndTag = "\n<!-- mp_trans_disable_end -->\n";
	this.conCat = function(value, disableTranslation) {
		disableTranslation = arguments[1] ? disableTranslation : false;
		_self.conCatValue[_self.currentIndex] = (disableTranslation ? _self.disableHTMLTranslationStartTag : "") + value + (disableTranslation ? _self.disableHTMLTranslationEndTag : "");
		_self.currentIndex ++;
	};
	this.toString = function(doClear, joinValue) {
		var returnValue = _self.conCatValue.join( (exists(joinValue) ? joinValue : "\n") );
		if(exists(doClear) && doClear) {
			_self.clear();
		}
		return returnValue;
	};
	this.clear = function() {
		_self.conCatValue.length = 0;
		_self.currentIndex = 0;
	};
}

var mp_util = {
	startMPTag : "\n<!-- ",
	endMPTag : " -->\n",
	equals : "=",
	quote : "\"",
	emptyString : "",
	disableStart : "mp_trans_disable_start",
	disableEnd : "mp_trans_disable_end",
	partialStart : "mp_trans_partial_start",
	partialEnd : "mp_trans_partial_end",
	enableStart : "mp_trans_enable_start",
	enableEnd : "mp_trans_enable_end",
	removeStart : "mp_trans_remove_start",
	removeEnd : "mp_trans_remove_start",
	addStart : "mp_trans_add ",
	nestedDisableStart : "mp_trans_disable_start --]>",
	nestedDisableEnd : "mp_trans_disable_end --]>",
	transJSStartTag : "mp_trans_textjs_start",
	transJSEndTag : "mp_trans_textjs_start",
	navDisableStart : "mp_trans_navdisable_start",
	navDisableEnd : "mp_trans_navdisable_end",
	enableTransURLJSStart : "mp_trans_urljs_enable_start",
	endableTransURLJSEnd : "mp_trans_urljs_enable_end",
	disableTransURLJSStart : "mp_trans_urljs_disbale_start",
	disableTransURLJSEnd : "mp_trans_urljs_disbale_end",
	processDisableStart : "mp_trans_process_disable_start",
	processDisableEnd : "mp_trans_process_disable_end",
	translate : "mp_trans_translate=\"",
	schedule : "mp_trans_schedule=\"",
	addLanguages : function(languages) {
		return exists(languages) ? this.equals + this.quote + languages + this.quote : this.emptyString;
	},
	returnContent : function(content) {
		return exists(content) ? content : this.emptyString;
	},
	returnDisableStartTag : function(languages) {
		return this.startMPTag + this.disableStart + this.addLanguages(languages) + this.endMPTag;
	},
	returnDisableEndTag : function() {
		return this.startMPTag + this.disableEnd + this.endMPTag;
	},
	doDisable : function(content, languages) {
		return this.returnDisableStartTag(languages) + this.returnContent(content) + this.returnDisableEndTag();
	},
	returnStartPartialTag : function(languages) {
		return this.startMPTag + this.partialStart + this.addLanguages(languages) + this.endMPTag;
	},
	returnEndPartialTag : function() {
		return this.startMPTag + this.partialEnd + this.endMPTag;
	},
	doPartial : function(content, languages) {
		return this.returnStartPartialTag(languages) + this.returnContent(content) + this.returnEndPartialTag();
	},
	returnEnableStartTag : function(languages) {
		return this.startMPTag + this.enableStart + this.addLanguages(languages) + this.endMPTag;
	},
	returnEnableEndTag : function() {
		return this.startMPTag + this.enableEnd + this.endMPTag;
	},
	doEnable : function(content, languages) {
		return this.returnEnableStartTag(languages) + this.returnContent(content) + this.returnEnableEndTag();
	},
	returnRemoveStartTag : function(languages) {
		return this.startMPTag + this.removeStart + this.addLanguages(languages) + this.endMPTag;
	},
	returnRemoveEndTag : function() {
		return this.startMPTag + this.removeEnd + this.endMPTag;
	},
	doRemove : function(content, languages) {
		return this.returnRemoveStartTag(languages) + this.returnContent(content) + this.returnRemoveEndTag();
	},
	add : function(content, languages, nestedContent) {
		return this.startMPTag + this.addStart + this.addLanguages(languages) + this.returnContent(content) + this.nestedDisable(nestedContent) + this.endMPTag;
	},
	nestedDisable : function(content) {
		return exists(content) ? this.startMPTag + this.nestedDisableStart + content + this.startMPTag + this.nestedDisableEnd : this.emptyString;
	},
	disableNav : function(content) {
		return this.startMPTag + this.navDisableStart + this.endMPTag + this.returnContent(content) + this.startMPTag + this.navDisableEnd + this.endMPTag;
	},
	enableTransURLJS : function(content) {
		return this.startMPTag + this.enableTransURLJSStart + this.endMPTag + this.returnContent(content) + this.startMPTag + this.endableTransURLJSEnd + this.endMPTag;
	},
	disableTransURLJS : function(content) {
		return this.startMPTag + this.disableTransURLJSStart + this.endMPTag + this.returnContent(content) + this.startMPTag + this.disableTransURLJSEnd + this.endMPTag;
	},
	processDisable : function(content) {
		return this.startMPTag + this.processDisableStart + this.endMPTag + this.returnContent(content) + this.startMPTag + this.processDisableEnd + this.endMPTag;
	},
	translateTag : function(isDoTranslate) {
		return this.startMPTag + this.translate + isDoTranslate + this.quote + this.endMPTag;
	},
	scheduleTag : function(isDoSchedule) {
		return this.startMPTag + this.schedule + isDoSchedule + this.quote + this.endMPTag;
	}
};

var jsObjectArraySortUtil = {
	sortProperty : null,
	doSort : function(one, two) {
		if (exists(jsObjectArraySortUtil.sortProperty)) {
			var valueOne = one[jsObjectArraySortUtil.sortProperty];
			var valueTwo = two[jsObjectArraySortUtil.sortProperty];
			if (exists(valueOne) && exists(valueTwo)) {
				if (typeof(valueOne) === "string" && typeof(valueTwo) === "string") {
					valueOne = valueOne.toLowerCase();
					valueTwo = valueTwo.toLowerCase();
				}
				if (valueOne < valueTwo) {
					return -1;
				} else if (valueOne > valueTwo) {
					return 1; 
				} else {
					return 0;
				} 
			}
		}
		return 0;
	}
}

function collapseTable(elemId){
	if(elemId != null && elemId != ""){
		if(elemId.indexOf('_') > -1){
			elemId = elemId.split('_')[1];
		}
		setClassName(elemId + "_table_control", "display_ctl_closed");
		hide(elemId + "_table_container");		
	} else {
		return;
	}
}
function expandTable(elemId){
	if(elemId != null && elemId != ""){
		if(elemId.indexOf('_') > -1){
			elemId = elemId.split('_')[1];
		}
		setClassName(elemId + "_table_control", "display_ctl_open");
		show(elemId + "_table_container");
	} else {
		return;
	}
}

function iFrameUtility() {
	this.name = null;
	this.id = null;
	this.tagReference = null;
	this.documentBody = null;
	this.tagReferenceForForms = null;
	this.tagReferenceForJS = null;
	this.useContentDocument = null;
	this.timeoutId = null;
	this.isInitialized = false;
	this.isParentToChild = true;
	this.iframePadding = 20;
	this.childObjectToSet = null;
}
iFrameUtility.prototype.init = function(Definition) {
	this.name = Definition.name;
	this.id = Definition.id;
	this.isParentToChild = Definition.isParentToChild;
	this.setTagReferences(Definition.id);
	this.childObjectToSet = Definition.childObjectToSet;
	this.timeoutId = Definition.timeoutId;
};
iFrameUtility.prototype.setTagReferences = function(Reference) {
	if (Reference !== this.tagReference) {
		if (this.isParentToChild) {
			this.tagReference = typeof(Reference) === "object" ? Reference : get(Reference);
		} else {
			this.tagReference = typeof(Reference) === "object" ? Reference : window.parent.get(Reference);
		}
	}
	if (exists(this.tagReference)) {
		try {
			this.useContentDocument = exists(this.tagReference.contentDocument);
			this.documentBody = !this.useContentDocument ? this.tagReference.Document.body : this.tagReference.contentDocument.body;
			this.tagReferenceForForms = !this.useContentDocument ? window.frames[this.tagReference.name] : this.tagReference.contentDocument;
			this.tagReferenceForJS = window.frames[this.tagReference.name];
			this.isInitialized = true;
		} catch(accessDeniedError) { /* YOU ARE TRYING TO GO HTTP PARENT TO HTTPS IFRAME, NOT ALLOWED */}
	}
};
iFrameUtility.prototype.clearTimeoutEvent = function() {
	if (exists(this.timeoutId)) {
		window.clearTimeout(this.timeoutId);
		this.timeoutId = null;
	}
};
iFrameUtility.prototype.setSrc = function(src) {
	if (this.isInitialized) {
		this.tagReference.src = src;
	}
};
iFrameUtility.prototype.setWidth = function(width) {
	if (this.isInitialized) {
		this.tagReference.width = width;
	}
};
iFrameUtility.prototype.setHeight = function(height) {
	if (this.isInitialized) {
		this.tagReference.height = height;
	}
};
iFrameUtility.prototype.resize = function(width, height) {
	this.setWidth(height);
	this.setHeight(height);
};
iFrameUtility.prototype.getFullHeight = function() {
	if (this.isInitialized) {
		if (this.isParentToChild) {
			return this.iframePadding + (!this.useContentDocument ? this.documentBody.scrollHeight : this.documentBody.offsetHeight);
		} else {
			return DeltaOverlayUtil.getPageSize().pageHeight;
		}
	}
};
iFrameUtility.prototype.fullySize = function(heightOffset) {
	if (this.isInitialized) {
		this.setWidth("100%");
		this.setHeight(this.getFullHeight() + (arguments[0] ? arguments[0]  : 0));
		this.clearTimeoutEvent();
	}
};
iFrameUtility.prototype.fullySizeByReference = function(iFrameReference, heightOffset) {
	this.setTagReferences(iFrameReference);
	this.fullySize(heightOffset);
	this.clearTimeoutEvent();
	if (exists(this.childObjectToSet)) { this.setJavascriptValue(this.childObjectToSet, this); }
};
iFrameUtility.prototype.runJavascriptFunction = function(functionName, parameters) {
	if (this.isInitialized) {
		if (this.isParentToChild) {
			eval('window.frames["' + this.tagReference.name + '"].' + functionName + '(' + parameters + ');');
		} else {
			eval('window.parent.' + functionName + '(' + parameters + ');');
		}
	}
};
iFrameUtility.prototype.setJavascriptValue = function(variableName, value) {
	if (this.isInitialized) {
		if (this.isParentToChild) {
			this.tagReferenceForJS[variableName] = value;
		} else {
			window.parent[variableName] = value;
		}
	}
};
iFrameUtility.prototype.getJavascriptValue = function(variableName) {
	if (this.isInitialized) {
		if (this.isParentToChild) {
			return this.tagReferenceForJS[variableName];
		} else {
			return window.parent[variableName];
		}
	}
	return null;
};
iFrameUtility.prototype.getFormReference = function(formId, formName) {
	if (this.isParentToChild) {
		return !this.useContentDocument ? this.tagReferenceForForms[formName] : this.tagReferenceForForms.getElementById(formId);
	} else {
		return window.parent.document.getElementById(formId);
	}
};
iFrameUtility.prototype.getFieldReference = function(formId, formName, fieldName) {
	var formReference = this.getFormReference(formId, formName);
	if (exists(formReference)) {
		return formReference[fieldName];
	}
	return null;
};
iFrameUtility.prototype.setFormValue = function(formId, formName, fieldName, value) {
	if (this.isInitialized) {
		var fieldReference = this.getFieldReference(formId, formName, fieldName);
		if (exists(fieldReference) && fieldReference.length > 0) {
			var fieldType = fieldReference[0].type;
			switch(fieldType) {
				case "text":
				case "textarea":
				case "hidden":
					fieldReference[0].value = value;
					break;
				case "checkbox":
					fieldReference[0].checked = true;
					break;
				case "select-one": 
					for (var i=0, j=fieldReference.length; i<j; i++) {
						if (fieldReference[i].value == value) { fieldReference.selectedIndex = i; } 
					}
					break;
				case "radio":
					for (var i=0, j=fieldReference.length; i<j; i++) {
						if (fieldReference[i].value == value) { fieldReference[i].checked = true; } 
					}
					break;
			}
		}
	}
};
iFrameUtility.prototype.getFormValue = function(formId, formName, fieldName) {
	if (this.isInitialized) {
		var fieldReference = this.getFieldReference(formId, formName, fieldName);
		if (exists(fieldReference) && fieldReference.length > 0) {
			var fieldType = fieldReference[0].type;
			switch(fieldType) {
				case "text":
				case "textarea":
				case "hidden":
					return fieldReference[0].value;
				case "checkbox":
					return fieldReference[0].checked ? fieldReference.value : null;
				case "select-one": 
					return fieldReference[0].options[fieldReference[0].selectedIndex].value;
				case "radio":
					for (var i=0, j=fieldReference.length; i<j; i++) {
						if (fieldReference[i].checked) { return fieldReference[i].value; } 
					}
					return null;
			}
		}
	}
	return null;
};
iFrameUtility.prototype.submitForm = function(formName, formId) {
	if (this.isInitialized) {
		var formReference = this.getFormReference(formId, formName);
		if (exists(formReference)) {
			formReference.submit();
		}
	}
};
iFrameUtility.prototype.removeIframe = function() {
	if (this.isInitialized) {
		this.tagReference.parentNode.removeChild(this.tagReference);
	}
}

/** end delta/shared_content/components/js/lib/util.js **/

