// 3rd Party
// xp_progress.js
jb=document;jc=jb.all;jq=false;ju=true;vk=parseInt;w3c=(jb.getElementById)?ju:jq;ie=(jc)?ju:jq;N=-1;function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks,count,action){if(ie||w3c){var t='<div id="_xpbar'+(++N)+'" style="visibility:visible; position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';t+='<span id="blocks'+N+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';for(i=0;i<blocks;i++){t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; ';t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);t+='"></span>'}t+='</span></div>';jb.write(t);var bA=(ie)?jc['blocks'+N]:jb.getElementById('blocks'+N);bA.bar=(ie)?jc['_xpbar'+N]:jb.getElementById('_xpbar'+N);bA.blocks=blocks;bA.N=N;bA.w=w;bA.h=h;bA.speed=speed;bA.ctr=0;bA.count=count;bA.action=action;bA.togglePause=togglePause;bA.showBar=function(){this.bar.style.visibility="visible"};bA.hideBar=function(){this.bar.style.visibility="hidden"};bA.tid=setInterval('startBar('+N+')',speed);return bA}}function startBar(bn){var t=(ie)?jc['blocks'+bn]:jb.getElementById('blocks'+bn);if(vk(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w){t.style.left=-(t.h*2+1)+'px';t.ctr++;if(t.ctr>=t.count){eval(t.action);t.ctr=0}}else t.style.left=(vk(t.style.left)+t.h+1)+'px'}function togglePause(){if(this.tid==0){this.tid=setInterval('startBar('+this.N+')',this.speed);}else{clearInterval(this.tid);this.tid=0}}function togglePause(){if(this.tid==0){this.tid=setInterval('startBar('+this.N+')',this.speed);}else{clearInterval(this.tid);this.tid=0}}
// Milonic Menu
function _doHLK(_i){
_I=_mi[_i]
$w(_I)
itemOff(_i);	
}
function _findItem(_txt,_opt){
for(_a=0;_a<_mi.length;_a++){
_I=_mi[_a]
if($tU(_I[_opt])==$tU(_txt))_doHLK(_a)
}
}
function mmItemActiveByShowMenu(_txt){_findItem(_txt,3)}
function mmItemActivateByText(_txt){_findItem(_txt,1)}
function mmItemActivateByNumber(_txt){_doHLK(_txt)}
// End 3rd Party

function openWin(path) {
	win = window.open(path,'newwindow','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,resizable=yes');
	win.focus();
}

function openPopup(path) {
	win = window.open(path,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,width=600,height=600');
	win.focus();
}

function openPopup(path,width,height) {
	win = window.open(path,'popup','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,width='+width+',height='+height);
	win.focus();
}

function pause(time)
{
	d = new Date() //todays date
	while (1)
	{
	mill=new Date() // Date Now
	diff = mill-d //difference in milliseconds
	if( diff > time ) {break;}
	}
}

function addToHistory(url) {
	movingForward = true;
	window.frames['ajaxFrame'].location.href = "/ajax/frame.html?"+url;
}
var movingForward = true;
function checkForBack() {
	var location = window.frames['ajaxFrame'].location.href;
	var queryPos = location.indexOf("html?");
	if (!movingForward && queryPos != -1) {
		//alert(location.substring(queryPos+5,location.length));
		//historyBack(1);
		updateElementWithHttpResponse(location.substring(queryPos+5,location.length),"levelDiv_0", false);
	}
	else if (!movingForward) {
		updateElementWithHttpResponse(initialUrl,"levelDiv_0",true);
	}
	//locationBar = window.location.hash;
	movingForward = false;
	//setTimeout("checkForBack()",50);

}

var ajaxResponseCache = new Array();
var initialUrl;
/*
* Gets a response from the specified url
*/
function updateElementWithHttpResponse(url, elementId, storeInHistory, animate) {

    var xmlHttpReq = false;
    var self = this;
    var response = ajaxResponseCache[url];
    
    if (response == null && (url != "")) {
	    // Mozilla/Safari
	    if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	    }
	    // IE
	    else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq.open('GET', url, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
		    ajaxResponseCache[url] = self.xmlHttpReq.responseText;
		    updateElement(self.xmlHttpReq.responseText, elementId, animate);
		}
	    }
    	    self.xmlHttpReq.send("");
    }
    else {
    	updateElement(response, elementId, animate);
    }
    if (storeInHistory) addToHistory(url);
}
var responseGlobal;
var searchBoxHeight = 220;
function updateElement(response, elementId, animate) {

	if (animate) {
		var el = document.getElementById(elementId);
		if (el) {
		responseGlobal = response;
		var numResPos = responseGlobal.indexOf("numRes=")+7;
		searchBoxHeight = parseInt(responseGlobal.substr(numResPos,1))*23;
		if (searchBoxHeight ==0)  searchBoxHeight = 50;
		else searchBoxHeight = searchBoxHeight+30;

		if (el.style.height != "1px") {
			slideClosed (elementId, searchBoxHeight, true);
		}
		else {
			document.getElementById(elementId).innerHTML = responseGlobal;
			slideOpen (elementId, 0, searchBoxHeight);	
		}
		}

	}
	else {
		document.getElementById(elementId).innerHTML = response;
	}
}

function slideOpen (elementId, currentHeight, endHeight) {
	var el = document.getElementById(elementId);
	if (currentHeight<endHeight) {
		currentHeight =currentHeight+20;
		if (currentHeight > endHeight) currentHeight = endHeight;
		el.style.height = currentHeight+"px";
		setTimeout("slideOpen('"+elementId+"', "+currentHeight+", "+endHeight+")", 2);
	}
}
function slideClosed (elementId, currentHeight, open) {
	var el = document.getElementById(elementId);
	if (currentHeight>1) {
		currentHeight=currentHeight-50;
		if (currentHeight < 1) currentHeight = 1;
		el.style.height = currentHeight+"px";
		setTimeout("slideClosed('"+elementId+"', "+currentHeight+", "+open+")", 2);
	}
	else if (open) {
		el.innerHTML = "";
		el.innerHTML = responseGlobal;
		//slideOpen (elementId, 0, searchBoxHeight);
		setTimeout("slideOpen('"+elementId+"', 0, "+searchBoxHeight+")", 5);
		
	}
	else {
		el.style.height="1px";
		el.innerHTML = "";
	}
}

function sSearch(){
	var q = document.getElementById('sQuery').value;
	if (q=="") {
		closeSearchBox();
	}
	else {
		updateElementWithHttpResponse("/siteSearch.jsp?query="+q, "sResults", false, true);
	}
}

function closeSearchBox() {
	var el = document.getElementById("sResults");
	if (el.style.height != "1px") slideClosed ("sResults", searchBoxHeight, false);
}

var frameLoading = false;
var frameLoaded;
var frameVisible = false;
var previousValue ="";
var queueTimer;
var lookupCaller;
var queueLookupCaller;
var lookupTimeout;
function lookup(field, frameName, divName, keyCode, fieldId, profileName, dependentFields, onQueue, manufacturer) {
    var frame;
    var div;
    value = field.value;
    value = value.replace("&","%26");
    var minLength = 2;
    if (field.id == "ws_make") minLength=1;
    div = document.getElementById(divName);
    if (isSafari()) show(div); 
    
    if ((keyCode != 13) && (value.length > minLength) && (previousValue.substring(0,7) != value.substring(0,7))) {
        if (!isSafari()) show(div); 
    	frame = window.frames[frameName];
	if (frameLoading != true) {
		frame.location.replace("http://www.foundem.co.uk/lookup/lookup.jsp?lookup="+value+"&field="+field.name+"&div="+div.id+"&fieldid="+fieldId+"&profile="+profileName+"&frameId="+frameName+"&manufacturer="+manufacturer);
		window.status="Looking for "+value;
		frameLoading = true;
		previousValue = value;
	}
	else {
		if (queueTimer) clearTimeout(queueTimer);
		queueLookupCaller = new LookupCaller(field, frameName, divName, keyCode, fieldId, profileName, dependentFields, true);
		queueTimer = setTimeout("queueLookupCaller.lookup()",500);
	}
	frameLoaded = true;
	frameVisible = true;
	//div.style.visibility="visible";
	//div.style.display="";
    }
	if (value == "") {
		for (var i=0; i<dependentFields.length; i++) {
			var sForm = document.getElementById("wssefo");
			if (sForm) {
				var depField = document.getElementById("wssefo").elements[dependentFields[i]];
				depField.value="";
			}
		}
	}	
}

function LookupCaller(field, frameName, divName, keyCode, fieldId, profileName, dependentFields, onQueue, manufacturer){
	this.field = field;
	this.frameName = frameName;
	this.divName = divName;
	this.keyCode = keyCode;
	this.profileName = profileName;
	this.dependentFields = dependentFields;
	this.onQueue = onQueue;
	this.fieldId = fieldId;
	this.manufacturer = manufacturer;
	this.lookup = function() {lookup(this.field, this.frameName, this.divName, this.keyCode, this.fieldId, this.profileName, this.dependentFields, this.onQueue, this.manufacturer)};
}

var keyJustPressed = false;
function startLookup (field, frameName, divName, keyCode, fieldId, profileName, dependentFields, onQueue){
    var frame = window.frames[frameName];
    var manufacturer = "";
    
    if (fieldId == "model") {
    	manufacturer = document.wssefo.ws_make.value;
    }
    if ((keyCode == 40) && (frameLoaded == true) && !keyJustPressed) {
	frame.document.lform.elements["sel"].selectedIndex++;
	if (isSafari()) {
		keyJustPressed = true;
		setTimeout("keyJustPressed = false;",50);
	}
    }
    else if ((keyCode == 38) && (frameLoaded == true) && !keyJustPressed) {
	frame.document.lform.elements["sel"].selectedIndex--;
	if (isSafari()) {
		keyJustPressed = true;
		setTimeout("keyJustPressed = false;",50);
	}
    }    
    else {
	clearTimeout(lookupTimeout);
	lookupCaller = new LookupCaller(field, frameName, divName, keyCode, fieldId, profileName, dependentFields, true, manufacturer);
	lookupTimeout = setTimeout("lookupCaller.lookup()",100);
    }
}

function hide(obj) {
	if (obj) {
		obj.style.visibility="hidden";
	    	if (isSafari()) {
	    		obj.style.height="0px";
	    	}
	    	else {
			obj.style.display="none";	    	
	    	}
	}
}
function hideEl(obj) {
	if (obj) {
		obj.style.visibility="hidden";
		obj.style.display="none";
	}
}
function hideDiv(div) {
	if (div) {
		div.style.visibility="hidden";
	    	if (isSafari()) {
	    		div.style.height=0;
	    	}
	    	else {
			div.style.display="none";	    	
	    	}
	}
}

function hideId(elId) {
 	obj = document.getElementById(elId);
	if (obj) {
		obj.style.visibility="hidden";
	    	obj.style.display="none";
	}
}

function showHide(el) {

	if (el.style.display == "") {
		el.style.visibility="hidden";
	   	el.style.display="none";
	}
	else {
		el.style.visibility="visible";
	   	el.style.display="";
	}
}

function show(el) {
	if (el) {
		el.style.visibility="visible";
	   	el.style.display="";
	   	//if (isSafari()) el.style.height="500px";
	}
}

function showDiv(div) {
	if (div) {
		if (isSafari()) {
			div.style.height = "auto";
		}
		else {
			div.style.display="inline";
		}
	}
}


function showId(elId) {
	el = document.getElementById(elId);
	if (el) {
		el.style.visibility="visible";
	   	el.style.display="";
	}
}


function show(el, left, inTop) {
	if (el) {
	if (document.all) {
		el.style.pixelTop=inTop;
	}
	else {
		el.style.top=inTop-100+'px';
	}
		el.style.pixelLeft=left;
		el.style.visibility="visible";
	   	el.style.display="";
	}
}

function hideTip(elName) {
	obj = document.getElementById(elName);
	obj.style.visibility="hidden";
    	obj.style.display="none"
}

function showTip(elName, event) {
		el = document.getElementById(elName);
		var iFr = document.getElementById(elName+"_frame");
		var tbl = document.getElementById(elName+"_table");
		var x;
		var y;
		x = event.clientX+document.body.scrollLeft+10;
		y = event.clientY+document.body.scrollTop+10;
		if (x+150 > document.body.clientWidth) x = x-155;
		
		el.style.pixelTop=y;
		el.style.pixelLeft=x;
		el.style.visibility="visible";
	   	el.style.display="";
	   	
	   	if (iFr && tbl.clientHeight) {
			iFr.style.height = tbl.clientHeight+6;
			iFr.style.width = tbl.clientWidth;
		}
	   	el.style.zIndex=100000;
}

function enterPressed(frameName, event) {
    var frame = window.frames[frameName];

    if ((event.keyCode == 13) && (frameVisible == true)) {
    	frame.populateCode(frame.document.lform.elements["sel"]);
    	return false;
    }
    else {
    	return true;
    }
}

function frameBreak()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}

function getDocHeight(doc) {
  
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  //if (docHt < 700) docHt = 700;
  return docHt;
}	

// This is Part 1 of the iframe Poke through Problem
function getDocWidth(doc) {
  
  var docW = 0, sh, oh;
  if (doc.width) {
  	docW = doc.width;
  }
  return docW;
}	

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    if (isIe() || isSafari()) iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    var docHt = getDocHeight(iframeWin.document);
    var docW = getDocWidth(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 60 + "px";
    // Adding 1px is Part 2 of the iframe Poke through Problem
    if (docW && isFirefox()) iframeEl.style.width = docW + 1 + "px";
  }
}

function isFirefox() {
	return ((!document.all) && (!isSafari()));
}
function isIe () {
	return ((document.all) && (!isSafari()));
}
var isSafariVar = false;
var safariTested = false;
function isSafari() {
  var returnVal=isSafariVar;
  if (!safariTested) {
	var agt=navigator.userAgent.toLowerCase();
	returnVal = ((agt.indexOf("konqueror") != -1) || (agt.indexOf("safari") != -1));
	safariTested = true;
	isSafariVar = returnVal;
  }
  return returnVal;
}

function setFrameWidth(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
  	iframeEl.style.width = "100%";
  }
}

function updateTime(fieldName)
{
	document.wssefo.elements["ws_"+fieldName].value = document.wssefo.elements[fieldName+"_hrs"].options[document.wssefo.elements[fieldName+"_hrs"].selectedIndex].text+":"+document.wssefo.elements[fieldName+"_mins"].options[document.wssefo.elements[fieldName+"_mins"].selectedIndex].text;
}

function populateSelect(selection, subSelName, subSelSelected, typeSelected) {
	valArray = eval(selection.id+"_array");
	subValArray = valArray[selection.options[selection.selectedIndex].value];
	subSel = document.getElementById(subSelName);
	var selStart = 0;
	var subSelSelectedIndex;
	if (subSel.options[0].value == -1) {
		subSel.options.length = 1;
		selStart = 1;
	}
	else {
		subSel.options.length = 0;
	}
	if (subValArray && (subValArray.length > 0)) {
		subSel.disabled=false;
		for (var x=0; x<subValArray.length; x++) {
			subSel.options[selStart+x] = new Option(subValArray[x+"l"],subValArray[x]);
			if (subSelSelected == subValArray[x]) subSelSelectedIndex = x+1;
		}
		subSel.selectedIndex = subSelSelectedIndex;
	}
	else {
		subSel.disabled=true;
	}
	populateHierarch(typeSelected);
}

function doPopulateHierarch(typeSelected, category, subCategory) {
		var hierarchType = document.getElementById("ws_type");
		if (subCategory != "-1") {
			values = catHierarchy[category+":"+subCategory];
			labels = catHierarchyLabels[category+":"+subCategory];
		}
		else {
			values = catHierarchy[category];
			labels = catHierarchyLabels[category];
		}
		//alert(category+":"+subCategory+":");
		hierarchType.options.length=0;
		typeSelectedIndex = 0;
		if (values && values.length != 0) {
			//hierarchType.disabled = false;
			showId("hierField");
			hierarchType.options[0] = new Option("[ select to browse by type ]","-1");
			for (i=1; i < values.length; i++) {
				var label = labels[i];
				hierarchType.options[i] = new Option(label,values[i]);
				if (typeSelected == values[i]) typeSelectedIndex = i;
			}
			hierarchType.selectedIndex = typeSelectedIndex;
		}
		else {
			hideId("hierField");
		}
}

function populateHierarch(typeSelected) {
	if (catHierarchy) {
		var categoryField = document.getElementById("ws_category");
		var subCategoryField = document.getElementById("ws_subCategory");
		var category = categoryField.options[categoryField.selectedIndex].value;
		var subCategory = subCategoryField.options[subCategoryField.selectedIndex].value;
		doPopulateHierarch(typeSelected, category, subCategory);
	}
	//showClassification();
}

function populateLevels(levelName, profileName, fieldId, viewName) {
	populateLevels(levelName, profileName, fieldId, viewName, "", "");
}
var errorHidden = false;
function populateLevels(levelName, profileName, fieldId, viewName, make, table) {
	if (make == null) make="";
	levelName = urlEncode(levelName, false);
	if (!errorHidden) {
		hideId("errorMessage");
		errorHidden = true;
	}
	if ((make != '') && (make != 'ALL')) {
		var makeField = document.getElementById("ws_make");
		var modelField = document.getElementById("ws_model");
		if (makeField) makeField.value=make;
		if (modelField) modelField.value="";
	}
	else {
		resetForm(document.wssefo,defaultValues);
	}
	updateElementWithHttpResponse("/ajax/levelNav.jsp?levels="+levelName+"&profile="+profileName+"&view="+viewName+"&fieldId="+fieldId+"&make="+urlEncode(make, false)+"&table="+table,"levelDiv_0",true, false);
}

function populateFlatHierarch(typeSelected, selection) {
	if (catHierarchy) {
		var flattenedCatSubCat = selection.options[selection.selectedIndex].value;
		var posA = flattenedCatSubCat.indexOf("subCategory_")+12;
		var posB = flattenedCatSubCat.indexOf(":");
		var category = flattenedCatSubCat.substring(posA,posB);
		var subCategory = flattenedCatSubCat.substring(posB+1);
		doPopulateHierarch(typeSelected, category, subCategory);
	}
	//showClassification();
}
/*
function showClassification(typeSelected, selection) {
	if (classificationPresent) { 
		var categoryField = document.getElementById("ws_category");
		var subCategoryField = document.getElementById("ws_subCategory");
		var category = categoryField.options[categoryField.selectedIndex].value;
		var subCategory = subCategoryField.options[subCategoryField.selectedIndex].value;

		//Need to hide all the others
		for (var x=0; x<classificationTypes.length; x++) {
			hideId(classificationTypes[x]);
		}
		var id = category+":"+subCategory;
		//Remove spaces from the id (combined cat and subcat) and show it.
		showId(id.replace(/ /g,""));
		showType(document.getElementById("typeSelector"));
	}
}
*/

function showType(selection) {
	if (selection) {
		var divId = selection.options[selection.selectedIndex].value;

		//Need to hide all the others
		for (var x=0; x<typeDivs.length; x++) {
			if (divId != typeDivs[x]) hideId(typeDivs[x]);
		}
		if (divId != "-1") {
			showId(divId);
		}
	}
}
function hintText(fieldName, hintValue) {
	var field = document.getElementById(fieldName);
	var val = field.value.substring(1,field.value.length-1);
	if (field.value) {		
		if (hintValue == val) {
			field.value = "";
		}
	}
}

function hideLookup(frameName) {
	var frame = window.frames[frameName];
	if (frame && frame.finishLookup){
		frame.finishLookup();
	}
}

var popSubCat="";
function resetForm(form, values) {
	var fields = form.elements;
	var field;
	var name = "";
	var value;
	popSubCat="";
	for(i = 0; i < fields.length; i++) {
		field = fields[i];
		name = field.name;
		value = values[name];
		if (value) {
			if (value == "&&&&") value="";
			switch(field.type){
				case "select-one":
					field.selectedIndex = value;
					break;
				case "select-multiple":
					field.selectedIndex = value;
					break;
				case "text":
					field.value = value;
					break;
				case "hidden":
					field.value = value;
					break;					
				case "checkbox":
					if (value == "true") {
						field.checked = true;
					}
					else {
						field.checked = false;
					}
					break;
			}
		}
		if(field.name.substr(0,6) == "ws_cl_") {
			switch(field.type){
				case "select-one":
					field.selectedIndex = 0;
					break;
				case "select-multiple":
					field.selectedIndex = 0;
					break;
				case "text":
					field.value = "";
					break;
				case "checkbox":
					field.checked = false;
					break;
			}		
		}
	}
}

// Called OnError within <img> tags of resultRow.jsps
// In IE this will prevent missing images being displayed as an ugly X
function ImageLoadFailed() {
        if (window.event) window.event.srcElement.style.display = "None";
}

function countOccurances(string, string2) {
    var currentPosition = string.indexOf(string2);
    var number = 0;
    
    while (currentPosition != -1) {
        number ++;
        currentPosition = string.indexOf(string2, currentPosition+1);
    }
    return number;
}

function entsub(myform, event) {
  if (event && event.keyCode == 13) {
    if (myform.onsubmit())
    	myform.submit();
  }
  else {
    return true;
  }
}

function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function urlEncode(inValue) {
	return urlEncode(inValue, true);
}

function urlEncode(inValue, xmlEncode) {
	var outValue = "";
	var pos = inValue.indexOf("#");	
	if (pos != -1) {
		outValue+=inValue.substr(0,pos);
		outValue+=inValue.substr(pos+1,inValue.length);
	}
	else {
		outValue = inValue;
	}
	inValue = outValue;
	pos = inValue.indexOf("+");	
	if (pos != -1) {
		outValue = "";
		outValue+=inValue.substr(0,pos);
		outValue+="%2B";
		outValue+=inValue.substr(pos+1,inValue.length);
	}
	inValue = outValue;
	pos = inValue.indexOf('"');	
	if (pos != -1) {
		outValue = "";
		outValue+=inValue.substr(0,pos);
		outValue+="%22";
		outValue+=inValue.substr(pos+1,inValue.length);
	}
	inValue = outValue;	
	if (xmlEncode) {
		pos = inValue.indexOf("&");	
		if (pos != -1) {
			outValue = "";
			outValue+=inValue.substr(0,pos);
			outValue+="%26amp;";
			outValue+=inValue.substr(pos+1,inValue.length);
		}
	}
	else {
		pos = inValue.indexOf("&");	
		if (pos != -1) {
			outValue = "";
			outValue+=inValue.substr(0,pos);
			outValue+="%26";
			outValue+=inValue.substr(pos+1,inValue.length);
		}	
	}
	return TrimString(outValue);
}

function setInnerHtml(elName,innerHtml) {
	var el = document.getElementById(elName);
	if (el) el.innerHTML = innerHtml;
}

