//-----------------------------------------------------------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}


function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function btnOpen_Click(strSrc)
{
    var strNext = "popup.htm?src=" + strSrc;
    var strFeatures = "width=200,height=200,status=no,toolbar=no,menubar=no,location=no,resizable=1,left=100,top=200";
    window.open(strNext, null, strFeatures);
}


function getArg(theStr, theKey)
{
	var i = theStr.indexOf(theKey);
 	if (i==-1) return "";
 	var subStr = theStr.substr(i+theKey.length+1);

	i = subStr.indexOf('&');
	if (i == -1)
	 	i = subStr.indexOf('\n');
 	if (i != -1)
    	return(subStr.slice(0,i));
 	else
    	return(subStr);
}  

function Jump(strNext)
{
    top.window.location.href =  strNext;
}


//Date Operation

//var nMiliDay = 24 * 60 * 60 * 1000;




function ParseDate(strDate, index)
{
    var oD = strDate.split("/");
    if (index == "Y")
        return oD[0];
    else if (index == "M")
        return oD[1];
    else if (index == "D")
        return oD[2];    
}

function CheckMail(value)
{
    var nIndex1 = value.indexOf('@');
    var posA = value.lastIndexOf('@');
    var posDot = value.lastIndexOf('.');
    if (nIndex1 != posA)
    {
      alert(MsgErrMail);
      return (false); 
    }    
    else if (posA <= 0 || posDot <= 0 || posA >= posDot)
    {
      alert(MsgErrMail);
      return (false); 
    }
    return true;
}


function GetFormatedDate(oDate, type)
{
	var y = oDate.getFullYear().toString();
	var mt = (oDate.getMonth() + 1).toString();
	var d = oDate.getDate().toString();
	var h = oDate.getHours().toString();
	var m = oDate.getMinutes().toString();
	var s = oDate.getSeconds().toString();

	if (mt.length == 1) mt = "0" + mt; 
	if (d.length == 1) d = "0"+d; 
	if (h.length == 1) h = "0"+h; 
	if (m.length == 1) m = "0"+m; 
	if (s.length == 1) s = "0"+s; 	
	if (type == "float")
	{
		return (y+mt+d+"."+h+m+s);
	}
	return(oDate.toLocaleString());
}

function checkDate(strDate, bShowErr)
{
	var rtcd = true;
	var a = strDate.split("-");
	if (a.length != 3) rtcd = false;
	else if (isNaN(a[0])) rtcd = false;
	else if (isNaN(a[1])) rtcd = false;
	else if (isNaN(a[2])) rtcd = false;
	
	if (!rtcd)	
	{
		if (bShowErr) alert(MsgErrDate);
		return false;
	}
	else return true;
}

function wmx_check_template(value)
{
	
}


function wmx_check(value, oField)
{
// int 1, bit 4, datetime 5, float 8, ntext 11, nvarchar 12
// link 30, migo_image 31, audio_video 32, autocoded	
if (oField.checkFunc != "")
{
	var myCheck = new Function("value", oField.checkFunc);
	alert(myCheck(value));
}

	var a = oField.check.split(";");
	if (a.length < 4) return true;
	var key =oField.fieldID;
	var type,disp,min,max;
	if (a[0] == "") disp = oField.displayName;
	else disp = a[0];
	if (a[1] == "") type = oField.dataType;
	else type = a[1];
	if (a[2] == "") min = "";
	else min = a[2];
	if (a[3] == "") max = "";
	else max = a[3];
	if (oField.classification == "1")
	{
		if (oField.multiSelect == "1")
		{
			for (var i=0;i<oField.options.length;i++)
			{
				if (value.indexOf(oField.options[i].codeID) != -1) return true;
			}

			alert(MsgErrOption+ MsgField + disp);
			return false;
		}
		else
		{
			for (var i=0;i<oField.options.length;i++)
			{
				if (value==oField.options[i].codeID) return true;
			}
			alert(MsgErrOption+ MsgField + disp);
			return false;
		}
	}
	switch(type)
	{
		case "email":
				if (!Check_EMail(value)) 
				{
					alert(MsgErrMail+ MsgField + disp);
					return false;
				}
				return true;
		case "tel":
    		var re = /\d{3}-\d{7,8}/g;
				var tmp = value.match(re);
				if (tmp != null) return true;
				else 
				{
					re = /\d{11}/g;
					tmp = value.match(re);
					if (tmp != null) return true;
					else
					{
						alert(MsgErrTel+ MsgField + disp);
						return false;
					}
				}
		case "mobile":
    		var re = /\d{10}/g;
				var tmp = value.match(re);
				if (tmp != null) return true;
				else
				{
					alert(MsgErrMobile+ MsgField + disp);
					return false;
				}
		case "date":
		case "5":
				if (!Check_Date(value)) 
				{
					alert(MsgErrMail+ MsgField + disp);
					return false;
				}
				return true;
		case "1":
		case "8":
		case "range":
				if (value == "") 
				{
					alert(MsgErrEmpty+ MsgField + disp);
					return false;
				}
				if (isNaN(value))
				{
					alert(MsgErrNaN + MsgField + disp);
					return false; 
				}
				if (min != "")
				{
						if (value<min) 
						{
							alert(MsgErrValueUnder+ MsgField + disp);
							return false; 
						} 
				}
				if (max!="")
				{
						if (value>max) 
						{
							alert(MsgErrValueOver+ MsgField + disp);
							return false; 
						} 
				}
				return true;
		case "length":
		default:
				if (value == "") 
				{
					alert(MsgErrEmpty+ MsgField + disp);
					return false;
				}
				if (min!="")
				{
					if (value.length <min) 
					{
						alert(MsgErrLenUnder+ MsgField + disp);
						return false; 
					} 
				}
				if (max!="")
				{
					if (value.length>max) 
					{
						alert(MsgErrLenOver+ MsgField + disp);
						return false; 
					} 
				}
				return true;
	}
}

function PostData(tagName, oGda, bGetData, oSourceRow)
{
    var tr = document.all(tagName);
    var strXML = "<rowlist>";
    var oRow = new gdaRow();
    for (var i=0;i<tr.all.length;i++)
    {
        if (tr.all(i).tagName == "INPUT" && tr.all(i).name != "")
        {
			if (oGda.schema.item(tr.all(i).name) == null) continue;
            if (tr.all(i).type != "radio" && tr.all(i).type != "checkbox")
			{
				//if (!wmx_check(tr.all(i).value, oGda.schema.item(tr.all(i).name))) return false;
				var oField = oGda.schema.item(tr.all(i).name)
				if (oSourceRow == null || oSourceRow.item(tr.all(i).name) != tr.all(i).value || oField.isPK == 1 )
					oRow.addField(tr.all(i).name,tr.all(i).value);
			}
			else if (tr.all(i).type == "radio" && tr.all(i).checked)
			{
				oRow.addField(tr.all(i).name,tr.all(i).value);					
			}
			else if (tr.all(i).type == "checkbox" && tr.all(i).checked)
			{
				var tmp;
				if (oRow.item(tr.all(i).name) == "")
					tmp = tr.all(i).value;
				else
					tmp = oRow.item(tr.all(i).name)+ "," + tr.all(i).value;
				oRow.addField(tr.all(i).name,tmp); 	
			}
        }
        else if (tr.all(i).tagName == "SELECT" && tr.all(i).name != "")
        {
			if (oGda.schema.item(tr.all(i).name) == null) continue;
            else
			{
				if (tr.all(i).options(tr.all(i).selectedIndex).value != "") {
					if (!wmx_check(tr.all(i).options(tr.all(i).selectedIndex).value, oGda.schema.item(tr.all(i).name))) return false;
					oRow.addField(tr.all(i).name,tr.all(i).options(tr.all(i).selectedIndex).value);
				}
			}
        }
        else if (tr.all(i).tagName == "TEXTAREA" && tr.all(i).name != "")
        {
			if (oGda.schema.item(tr.all(i).name) == null) continue;
            else
			{
				oRow.addField(tr.all(i).name,tr.all(i).value);
			}
        }
    }

	for (var i=0;i<oGda.schema.fields.length;i++)
	{
		if (!wmx_check(oRow.item(oGda.schema.fields[i].fieldID), oGda.schema.fields[i])) return false;
	}
	if (bGetData == true)
		return (oRow);
	else
	{			
    	strXML = strXML + oRow.getXml();

    	strXML += "</rowlist>";
		//alert(strXML);
		var rtcd = oGda.updateData(strXML,1);
		//alert(rtcd);
    	return(rtcd);
	}
}


function Check_EMail(value)
{
    var error = false;
    value = value.replace(/^\s+/,"") ;
    value = value.replace(/\s+$/,"") ;
    
    if (value.length <= 2)
    {
        error = true;
    }   
    else   
    {   
        var posA = value.indexOf('@');
        var posDot = value.lastIndexOf('.');
        var posLS = value.indexOf('<');
        var posGT = value.indexOf('>');
        if (posA < 0 || posDot < 0 || posA > posDot)
        {
            error = true;
        }
        
        if(posLS != -1)
        {
            if(posLS > posGT ||
               posGT !=  value.length-1 ||
               posA < posLS ||
               posDot < posLS ||
               posA > posGT ||
               posDot > posGT )
            error = true;
        }
    }
    
    if (error == true)
    {
        return false;
    }
    return true;
} 


function Check_Date(value)
{

}

function IsInArray(key,theArray)
{
	for (var i=0;i<theArray.length;i++)
	{
		if (key == theArray[i]) return true;
	}
	return false;
}

function BuildHTML(tagName,oGda,width)
{
    var oRow;
	if (width == null) width = "90%";	
	oRow = oGda.rows[0];
	var theFields = oGda.strFields.split(",");
	var strHTML,strRow;
	var bDisabled = "";
	strHTML = "<table align=center width="+width+" border=0 align=center cellspacing=1 bgcolor='737373' cellspacing=0>";
    for (var i=0;i<theFields.length;i++)
    {
		var oField = oGda.schema.item(theFields[i]);
		if (oField == null) continue;
		if (oField.disabled == true) bDisabled = " DISABLED";
		else bDisabled = "";
		strRow = "";
		strRow += "<tr>";
        strRow += "<td align=right width=25% class='tbl-hd-1'>" + oField.displayName+":</td>";
        strRow += "<td class='tbl-txt-1'>";
		if (oField.classification == 1 && oField.multiSelect == 0)
		{
			if (oField.useSelect == true)
			{
					strRow += "<select class=wmax_SelectBox id="+oField.fieldID+" name="+oField.fieldID +bDisabled+" type=select>";
				for (var j=0;j<oField.options.length;j++)
				{
					if (oField.options[j].bShow)
             			strRow += '<option value='+oField.options[j].codeID+'>'+oField.options[j].displayName+'</option>';
				}
          		strRow += "</select>";
			}
			else
			{
				for (var j=0;j<oField.options.length;j++)
				{
					if (oField.options[j].bShow)
             			strRow += '<input type=radio id='+oField.fieldID+' name='+oField.fieldID+' value='+oField.options[j].codeID+'>'+oField.options[j].displayName;
				}
			}
		}
		else if (oField.dataType == 11)
		{
			//if (oField.options[j].bShow)
       		strRow += '<textarea STYLE="overflow:hidden" ROWS=10 COLS=40 id='+oField.fieldID+' name='+oField.fieldID+'></textarea>';
		}
		else if (oField.classification == 1 && oField.multiSelect == 1)
		{
			for (var j=0;j<oField.options.length;j++)
			{
				if (oField.options[j].bShow)
         			strRow += '<input type=checkbox id='+oField.fieldID+' name='+oField.fieldID+' value='+oField.options[j].codeID+'>'+oField.options[j].displayName;
			}
		}
		else if (oField.asImg == true)
		{
			strRow += '<form action="webmax_upload.aspx" method="post" enctype="multipart/form-data" id="photoupload">';
			strRow += '<INPUT id="Client" type="hidden" name="client" value="microsoft">';
			strRow += '<INPUT id="Campaign" type="hidden" name="Campaign" value="clps">';
			strRow += '<INPUT id="RedirectURL" type="hidden" name="RedirectURL" value="">';
			strRow += '<INPUT id="FileNamePrefix" type="hidden" name="FileNamePrefix" value="">';
			strRow += '<INPUT id="File1" class=wmax_InputBox type="file" size="64" name="File1">';
			strRow += '<INPUT style="display:none" id="Submit1" type="submit" value="Submit" name="Submit1">';
			strRow += '</form>';
			strRow += "<input type=hidden class=wmax_InputBox size=48 maxLength="+oField.dataLength+" name="+oField.fieldID+">";					
			strRow += '<img width=400 height=300 name="'+oField.fieldID+'">';
		}
		else
			strRow += "<input type=text class=wmax_InputBox size=48 maxLength="+oField.dataLength+" name="+oField.fieldID+bDisabled+">";

        strRow += "</td></tr>";
		strHTML += strRow;
    }	
	strHTML += "</table>"

	document.all(tagName).innerHTML = strHTML;
}

function Render(tagName,oGda,idx)
{
	var index;
	var oRow;
	if (typeof(idx) == "object") oRow = idx;
	else {
		if (oGda.rows.length == 0) return;
		if (idx == null) {index = 0; oRow = oGda.rows[index];}
		else {index = idx; oRow = oGda.rows[index];}
	}
	var theElement;
	if (tagName == "") theElement = document.all;
	else theElement = document.all(tagName);
	var oArray = oRow.getArray();
	for (var i=0;i<oArray.length;i++)
	{

		try{
			if (oGda.schema.item(oArray[i].key).dataType == 5) 
				oArray[i].value = oArray[i].value.slice(0,10) +" "+ oArray[i].value.slice(11,19);
			var dspFormat = oGda.schema.item(oArray[i].key).dspFormat;
			oArray[i].value = formatData(oArray[i].value,dspFormat);
		}
		catch(e) {}
		
		var elements, element;
		var col = new Array();
		elements = theElement.all(oArray[i].key);
		if (elements == null) continue;
		if (elements.length >= 2) 
			col = elements;
		else
		  col[0] = elements;
		for (var j=0;j<col.length;j++)
		{
			element = col[j];
			if (element.tagName == "INPUT" &&  element.type == "radio")
			{
				if (element.value == oArray[i].value) element.checked = true;
				if (oGda.schema.item(oArray[i].key).disabled == "true") element.disabled = true;
			}
			else if (element.tagName == "OPTION" || element.tagName == "select")
			{
				if (element.value == oArray[i].value) element.selected = true;
				if (oGda.schema.item(oArray[i].key).disabled== "true") element.disabled = true;
			}	
			else if (element.tagName == "INPUT" &&  element.type == "checkbox")
			{
				var theOpt = oArray[i].value.split(",");
				for (var k=0;k<theOpt.length;k++){
					if (element.value == theOpt[k]) {element.checked = true; break;}
				}
				if (oGda.schema.item(oArray[i].key).disabled == "true") element.disabled = true;
			}		
			else if (element.tagName == "INPUT")
			{
				element.value = oArray[i].value;
				if (oGda.schema.item(oArray[i].key).disabled== "true") element.disabled = true;
			}
			else if (element.tagName == "TEXTAREA")
			{
				element.innerHTML = ToHTML(oArray[i].value);
				if (oGda.schema.item(oArray[i].key).disabled== "true") element.disabled = true;
			}
			else if (element.tagName == "IMG")
			{
				if (oArray[i].value == "") element.style.display = "none";
				else element.src = oArray[i].value;			
			}
		}
	}
}





function ShowHTML(tagName,oGda,nWidth,nCol)
{
    var oRow;
	var nCount = 0;
	if (!nCol) nCol = 1;
	
	var theFields = oGda.strFields.split(",");
	if (oGda.rows.length == 0)
		oRow = new gdaRow();
	else oRow = oGda.rows[0];
	var strHTML,strRow;
	strHTML = "<table align=left width="+nWidth+" border=0 align=center cellspacing=1 bgcolor='737373' cellspacing=0>";
    for (var i=0;i<oGda.schema.fields.length;i++)
    {
		var oField = oGda.schema.fields[i];
		if (!IsInArray(oField.fieldID,theFields)) continue;
		var value = oRow.item(oField.fieldID);
		if (oGda.rows.length == 0) value = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
		strRow = "";
		if (nCol == 1) 	strRow += "<tr>";
		else if (!(nCount%2)) strRow += "<tr>";

        strRow += "<td width=25% align=right class='tbl-hd-1'>" + oField.displayName+":</td>";
        strRow += "<td  class='tbl-txt-1'>";
        if (oField.classification == 1 && oField.multiSelect == 0)
		{
			for (var j=0;j<oField.options.length;j++)
			{
				if (value == oField.options[j].codeID)
				{
    				strRow += oField.options[j].displayName;
					break;
				}
			}
		}
		else if (oField.dataType == 11)
    		strRow += value;
		else if (oField.classification == 1 && oField.multiSelect == 1)
		{
			var theA = value.split(",");
			for (var j=0;j<oField.options.length;j++)
			{
				if (theA[j] != "")
         			strRow += oField.options[j].displayName+",";
			}
		}
		else if (oField.asImg == true)
			strRow += "<img src="+value+">"
		else
			strRow += value;
		strRow += "</td>";
		if (nCol == 1) 	strRow += "</tr>";
		else if ((nCount%2)) strRow += "</tr>";
		else if (nCount == theFields.length && !(nCount%2)) strRow += "</tr>";
		strHTML += strRow;
		nCount++;
    }	

	strHTML += "</table>"
	if (nWidth == 0)
			return strHTML;
	else
		document.all(tagName).innerHTML = strHTML;
}

function ShowTable(tabID, oGda,nWidth)
{  		
	var theFields = oGda.strFields.split(",");
	var theTable = document.all(tabID);
	var oR = theTable.insertRow();
	var oD;
	var oField;
	for (var i=0;i<theFields.length;i++)
	{
		oD = oR.insertCell();
		oD.innerHTML = oGda.schema.item(theFields[i]).displayName;
		oD.className = "tbl-hd-1";
	}
	for (var i=0;i<oGda.rows.length;i++)
	{
		oR = theTable.insertRow();
		for (var j=0;j<theFields.length;j++)
		{
			oD = oR.insertCell();
			oField = oGda.schema.item(theFields[j]);
			var value = oGda.rows[i].item(oField.fieldID);
			if (oField.dataType == 4) {
				if (value == "true") value = 1;
				else value = 0;
			}
	        if (oField.classification == 1 && oField.multiSelect == 0)
			{
				for (var k=0;k<oField.options.length;k++)
				{

					if (value == oField.options[k].codeID)
					{
	    				oD.innerHTML = oField.options[k].displayName;
						break;
					}
				}
			}
			else if (oField.dataType == 11)
	    		oD.innerHTML = value;
			else if (oField.dataType == 5)
	    		oD.innerHTML = value.substr(0,10);
			else if (oField.classification == 1 && oField.multiSelect == 1)
			{
				var theA = value.split(",");
				for (var k=0;k<oField.options.length;k++)
				{
					if (theA[k] != "")
	         			oD.innerHTML = oField.options[k].displayName+",";
				}
			}
			else if (oField.asImg == true)
				oD.innerHTML = "<img src="+value+">"
			else
				oD.innerHTML = value;
			oD.className = "tbl-txt-"+(parseInt(i%2)+1);
		}		
	}
}



function GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function DelCookie(sName)
{
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

function ToXML(strData)
{
	var sTmp;
	var leftB = new RegExp("&lt;","g");  
	var rightB = new RegExp("&gt;","g");  
	sTmp = strData.replace(leftB,"<");
	sTmp = sTmp.replace(rightB,">");
	return sTmp;
}

function ToHTML(strData)
{
	var sTmp;
	var leftB = new RegExp("<","g");  
	var rightB = new RegExp(">","g");  
	sTmp = strData.replace(leftB,"&lt");
	sTmp = sTmp.replace(rightB,"&gt");
	return sTmp;
}

function myAlert(strData)
{
	var sTmp;
	var leftB = new RegExp("<","g");  
	var rightB = new RegExp(">","g");  
	sTmp = strData.replace(leftB,"&lt");
	sTmp = sTmp.replace(rightB,"&gt");
	document.all("MyAlert").innerHTML = "<pre>"+sTmp +"</pre>";	
}

function RenderTxt(tagName,oGda,idx)
{
	var index;
	var oRow;
	if (typeof(idx) == "object") oRow = idx;
	else {
		if (oGda.rows.length == 0) return;
		if (idx == null) {index = 0; oRow = oGda.rows[index];}
		else {index = idx; oRow = oGda.rows[index];}
	}
	var theElement;
	if (tagName == "") theElement = document.all;
	else theElement = document.all(tagName);
	var oArray = oRow.getArray();
	for (var i=0;i<oArray.length;i++)
	{
		if (oArray[i].key == "gda_regtime" || oArray[i].key == "gda_lastupdate") continue;
		var oDs = theElement.all(oArray[i].key);
		if (oDs == null) continue;
		var oD;
		if (oDs.length > 1) oD = oDs[0];
		else oD = oDs;
		oField = oGda.schema.item(oArray[i].key);
		var dspFormat = oField.dspFormat;
		var value = formatData(oRow.item(oArray[i].key),dspFormat);
		if (oField.dataType == 4) {
			if (value == "true") value = 1;
			else value = 0;
		}
		if (oField.classification == 1 && oField.multiSelect == 0) {
			for (var k=0;k<oField.options.length;k++) {
				if (value == oField.options[k].codeID) {
					if (oD.length > 1) {
						for (q=0;q<oD.length;q++) oD[q].innerHTML = oField.options[k].displayName;
					}
					else oD.innerHTML = oField.options[k].displayName;
					break;
				}
			}
		}
		else if (oField.classification == 1 && oField.multiSelect == 1) {
			if (value.indexOf(",") < 0) {value = value + ",";}
			var theA = value.split(","); 
			for (var k=0;k<oField.options.length;k++) {
				for (var l=0;l<theA.length;l++){
					if (theA[l] == oField.options[k].codeID) {
         				oD.innerHTML += oField.options[k].displayName+",";
					}
				}
			}
			if (oD.innerHTML.lastIndexOf(",") == oD.innerHTML.length-1) {							
				oD.innerHTML = oD.innerHTML.slice(0,oD.innerHTML.length-1);
			}
		}
		else if (oField.asImg == true)
			oD.innerHTML = "<img src="+value+">"
		else if (oField.dataType == 5){
			oD.innerHTML = value.substr(0,10);
		}
		else {
			oD.innerHTML = decodeURIComponent(ToHTML(value.toString()));			
		}
		if (oDs.length > 1){
			for (var k=0;k<oDs.length;k++) oDs[k].innerHTML = oDs[0].innerHTML;
		}
	}
}

function formatData(value, format)
{
	if (format == "") return value;
	if (!isNaN(value)) value = value.toString();
	var sF,sE;
	if (format.charAt(0) == "F"){
		var len = format.charAt(1);
		if (isNaN(len)) len = 0;
		sF = value.substr(0,len);
	}
	if (format.charAt(2) == "E"){
		var len = format.charAt(3);
		if (isNaN(len)) len = 0;
		sE = value.slice(value.length-len);
	}
	return(sF+"*****"+sE);
}
