var _xdimposition=0;
		var _ydimposition=0;
		var _dimDiv = null;
		var _underDimDiv = null;
		var _piecesMaxLenth = 4;
		var _lengthMaxLenth = 5;
		var _widthMaxLenth = 5;
		var _heightMaxLenth = 5;
		//Function to display dimensions
		function displayDimensions(oParam,isredraw){
			_isDim = true;
			var tbody;
			var points = getScreenPoint(getElById(oParam.componentId));
			if(_xdimposition==0)
				_xdimposition = 150;
			if(_ydimposition==0)
				_ydimposition = points.y - 150; //tc02449   +15
			var dimx = _xdimposition;
			var dimy = _ydimposition;
			if (dimx<0) dimx=0;
			if (dimy<150) dimy=150;
			if (_dimDiv==null){
				div = createDiv("dvDim","divLOV","absolute",dimx,dimy,"500",null,"710");  //tc02449 500
				_dimDiv = div;
				document.body.appendChild(_dimDiv);
			}
			else{
				div = _dimDiv;
				div.style.left = dimx+"px";
				div.style.top = dimy+"px";
				div.style.visibility = "";
				div.innerHTML = "";
				if(_underDimDiv) _underDimDiv.removeNode(true);
			}
			tb = createTable(null,"tblLov","0","0","0",null,null);
			tbody = document.createElement("tbody");
			tb.appendChild(tbody);
			tHead = getDimHeading(oParam);
			if (tHead){
				tr = document.createElement("tr");
				tbody.appendChild(tr);
				td = createTd(null,null,null,"20","left","top","2")
				tr.appendChild(td);
				td.appendChild(tHead);
			}
			if(oParam.htmlHeader){
				if(oParam.htmlHeader!=""){
					tr = document.createElement("tr");
					tbody.appendChild(tr);
					td = createTd(null,null,null,null,"left","top","2");
					//oParam.htmlHeader="<table width=100% border=2><tr><td align=\"center\"> test </td></tr></table>"
					td.innerHTML=oParam.htmlHeader;
					tr.appendChild(td);
				}
			}
			var tblstr = (isredraw)?getDimensionTable(oParam):getDimensionTable(oParam,true);
			if (tblstr!=""){
				tr = document.createElement("tr");
				tbody.appendChild(tr);
				td = createTd(null,"lovContainerTD",null,null,"left","top","2");
				tr.appendChild(td);
				divdata = createDiv("dvDimData","dvDimData",null,null,null,"501",null,"700");
				divdata.innerHTML=tblstr;
				td.appendChild(divdata);
			}
			tr = document.createElement("tr");
			tbody.appendChild(tr);
			td = createTd(null,"lovContainerBottomTD",null,null,"left","bottom")
			tr.appendChild(td);
			td.appendChild(document.createTextNode(" "));

			td = createTd(null,"lovContainerBottomTD",null,null,"right","bottom");
			//btncl = createButton("btnClear","inputs","Clear Selected Rows","button");
			//btncl.onclick = function(){_resetAllData(oParam)};
			//td.appendChild(btncl);
			//td.appendChild(document.createTextNode(" "));
			btnrm = createButton("btnRemove","inputs","Remove","button");
			btnrm.onclick = function(){removeRow(oParam)};
			if(oParam.readOnly) btnrm.disabled=true;
			td.appendChild(btnrm);
			td.appendChild(document.createTextNode(" "));
			btnad = createButton("btnAdd","inputs","Add","button");
			btnad.disabled=true;
			btnad.onclick = function(){addRow(oParam)};
			td.appendChild(btnad);
			td.appendChild(document.createTextNode(" "));
			btn = createButton("btnClose","inputs","Close","button");
			btn.onclick = function(){_close_dimensions(oParam)};
			td.appendChild(btn);
			td.appendChild(document.createTextNode(" "));
			clbtn = createButton("btnCancel","inputs","Cancel","button");
			clbtn.onclick = function(){_cancel_dimensions(oParam)};
			//tc02449
				//td.appendChild(clbtn);
			//tc02449
			tr.appendChild(td);
			div.appendChild(tb);
			_underDimDiv = createDivIframe(div);
			//if (getElById(div.id).focus) getElById(div.id).focus();
			if(isredraw) _calculateTotals(oParam);
			else _calculateDimGrid(oParam);
		}
		/*------------Dim Heading - Start-----------------------------------*/
		function getDimHeading(oParam){
			var img;
			table = createTable("","dimTitle","0","0","0","100%","");
			table.onmousedown = function(event){dragStart(event,_dimDiv,_underDimDiv);};
			tbody = document.createElement("tbody");
			table.appendChild(tbody);
			tr = document.createElement("tr");
			tbody.appendChild(tr);
			td = createTd(null,null,"95%",null,"left",null,null,null);
			tr.appendChild(td);
			td.appendChild(document.createTextNode(oParam.header));
			td = createTd(null,null,"5%",null,"right",null,null,null);
			tr.appendChild(td);
			img = createImage(null,'images/ico_close.gif',"0",null,null);
			link = createLink("","","",_property.lovClose + " - ("+oParam.header+")","");
			link.appendChild(img);
			link.onclick = function(){_close_dimensions(oParam)};
			td.appendChild(link);
			return table;
		}
		/*------------Dim Heading - End-----------------------------------*/



//Function to close lov
function _close_dimensions(oParam){
	if(!oParam.readOnly){
		if(!_validateDimensionGrid(oParam)) return;
	}
	if(_dimDiv) getElById(_dimDiv.id).style.visibility = "hidden";
	if(_underDimDiv) _underDimDiv.removeNode(true);
	oParam.datastring = createStringFromArray(oParam);
	try{
		if(!eval("_All_close_dimensions(oParam);")) return;
	}catch(e){}

	try{
		eval("_"+oParam.componentId+"_close_dimensions();");
	}catch(e){}
	if(_dimDiv) getElById(_dimDiv.id).style.visibility = "hidden";
	if(_underDimDiv) _underDimDiv.removeNode(true);
	_xdimposition=0;
	_ydimposition=0;
	_isDim = false;
}

function _cancel_dimensions(oParam){
	oParam.datastring = "";
	if(_dimDiv) getElById(_dimDiv.id).style.visibility = "hidden";
	if(_underDimDiv) _underDimDiv.removeNode(true);
}
function dimensionObject(){
	this.lineno="";
	this.id="";
	this.flag="";
	this.pieces="";
	this.unit="CM";
	this.length="";
	this.breadth="";
	this.height="";
	this.volume="";

	//tc02449
	this.vloumetricWt="";
	this.weight="";
	this.weightUnit="kg";
	//tc02449
}

function modifyArray(arrayIndex,property,obj,oParam,istotal){
	var tempDimensionObject=oParam.dataArray[arrayIndex];
	var val = obj.value;

	if(property=="P"){
		doCaseChange(obj,"NUMBER");
		if(!validateDataType("NUMBER",val)){
			val = "";
			obj.value="";
		}
		tempDimensionObject.pieces=obj.value;
	}
	else{
		if(property!="U" && property!="WU"){
            //Modified as part pf CLI-6451
			//doCaseChange(obj,"DECIMAL4");
			if(!validateDataType("DECIMAL",val)){
				val = "";
				obj.value="";
			}
			else{
				if(parseFloat(val)<=0){
					val = "";
					obj.value="";
				}
			}
		}
	}
	if(property=="U")
		tempDimensionObject.unit=obj.value;
	if(property=="WU")
		tempDimensionObject.weightUnit=obj.value;
	if(property=="W")
		tempDimensionObject.weight=obj.value;
	if(property=="L")
		tempDimensionObject.length=obj.value;
	if(property=="B")
		tempDimensionObject.breadth=obj.value;
	if(property=="H")
		tempDimensionObject.height=obj.value;
	if(property=="V")
		tempDimensionObject.volume=obj.value;
	if(tempDimensionObject.id!="")
		tempDimensionObject.flag="M";
	else
		tempDimensionObject.flag="I";

	tempDimensionObject = dimensionConvertor(tempDimensionObject,oParam.baseUnits);
	var obj = getElById("_txtVol"+arrayIndex);
	if(obj){
		if(parseFloat(tempDimensionObject.volume)<0.000001){
			tempDimensionObject.volume=0;
			}
	//Changes Started By Manish S(s736831)for CR 192A
	else if((parseFloat(tempDimensionObject.volume)>0) && (parseFloat(tempDimensionObject.volume)<0.010000)){
		obj.value = .01
	}else{
		obj.value = tempDimensionObject.volume
	}
	//Changes End By Manish S(s736831)for CR 192A
		 //= (tempDimensionObject.volume>0?tempDimensionObject.volume:"");
		doCaseChange(obj,"DECIMAL2");
		tempDimensionObject.volume=obj.value;

	}
	//tc02449
	var objVolWt = getElById("_txtVolWt"+arrayIndex);
	if(objVolWt){
		if(parseFloat(tempDimensionObject.vloumetricWt)<0.000001){
			tempDimensionObject.vloumetricWt=0;
		}
	//Changes Start By Manish S(s736831)for CR 192A
	else if((parseFloat(tempDimensionObject.vloumetricWt)>0) && (parseFloat(tempDimensionObject.vloumetricWt)<0.010000)){
			objVolWt.value = .01
	}else{
		objVolWt.value = tempDimensionObject.vloumetricWt
	}
	 //Changes End By Manish S(s736831)for CR 192A 
	 //= (tempDimensionObject.vloumetricWt>0?tempDimensionObject.vloumetricWt:"");
		//Changes DECIMAL3 done for CMS-850 
		doCaseChange(objVolWt,"DECIMAL3");
		            tempDimensionObject.vloumetricWt=objVolWt.value;
	}
  //tc02449
	oParam.dataArray[arrayIndex]=tempDimensionObject;
	if(!(istotal))	_calculateTotals(oParam);
}

function _resetAllData(oParam){
	if(confirm("This will all selected data.\nPlease click on cancel to proceed..")) return;
	var len = oParam.dataArray.length;
	var hasclear=false;
	for(var i=0;i<len;i++){
		var obj = oParam.dataArray[i];
		var contrl=getElById("editList"+i);
		if(contrl){
			if(contrl.checked){
				obj.id="";
				obj.flag="";
				obj.pieces="";
				obj.unit="CM";
				obj.length="";
				obj.breadth="";
				obj.height="";
				obj.volume="";
				 //tc02449
				obj.vloumetricWt="";
				obj.weight="";
				obj.weightUnit="kg";
				 //tc02449
				oParam.dataArray[i]=obj;
				hasclear=true;
			}
		}
	}
	if(hasclear) displayDimensions(oParam,true);
}

function _validateDimensionGrid(oParam){
	var len = oParam.dataArray.length;
	 var strRMsg="";
	 var strMsg="";
	 var blnFocus=true;
	 var strFocusobj="";

	for(var i=0;i<len;i++){
		var pcontrl = getElById("_txtPcs"+i);
		var lcontrl = getElById("_txtLen"+i);
		var wcontrl = getElById("_txtWid"+i);
		var hcontrl = getElById("_txtHgt"+i);
		var vcontrl = getElById("_txtVol"+i);
		var wtcontrl = getElById("_txtwt"+i);
		if(!((pcontrl)&&(lcontrl)&&(wcontrl)&&(hcontrl)&&(vcontrl))) continue;
		if(parseFloat(pcontrl.value)<=0) pcontrl.value="";
		if(parseFloat(lcontrl.value)<=0) lcontrl.value="";
		if(parseFloat(wcontrl.value)<=0) wcontrl.value="";
		if(parseFloat(hcontrl.value)<=0) hcontrl.value="";
		if(parseFloat(vcontrl.value)<=0) vcontrl.value="";
		if (wtcontrl)
		{
			if(parseFloat(wtcontrl.value)<=0) wtcontrl.value="";
		}
		if(((pcontrl.value=="")&&(lcontrl.value=="")&&(wcontrl.value=="")&&(hcontrl.value=="")&&(vcontrl.value==""))){
			continue;
		}
		if(pcontrl){
			if (pcontrl.value==""){
				strRMsg=strRMsg+" Pieces";
				if (blnFocus){
					strFocusobj = "_txtPcs"+i;
					blnFocus=false;
				}
			}
		}
		if(lcontrl){
			if (lcontrl.value==""){
				strRMsg=strRMsg+((strRMsg!="")?",":"")+" Length ";
				if (blnFocus){
					strFocusobj = "_txtLen"+i;
					blnFocus=false;
				}
			}
		}
		if(wcontrl){
			if (wcontrl.value==""){
				strRMsg=strRMsg+((strRMsg!="")?",":"")+" Width ";
				if (blnFocus){
					strFocusobj = "_txtWid"+i;
					blnFocus=false;
				}
			}
		}
		if(hcontrl){
			if (hcontrl.value==""){
				strRMsg=strRMsg+((strRMsg!="")?",":"")+" Hieght ";
				if (blnFocus){
					strFocusobj = "_txtHgt"+i;
					blnFocus=false;
				}
			}
		}
		if(vcontrl){
			if (vcontrl.value==""){
				strRMsg=strRMsg+((strRMsg!="")?",":"")+" Volume ";
				if (blnFocus){
					strFocusobj = "_txtVol"+i;
					blnFocus=false;
				}
			}
		}

		if(strRMsg!=""){
			strMsg = strMsg + "Row "+ (i+1) + ": " +strRMsg+"\n";
			strRMsg="";
		}
	}
	if(strMsg!=""){
		alert("Please fill the following data.\n"+strMsg);
		if(strFocusobj!=""){
			try{
			eval(strFocusobj+".focus()");
			}catch(ex){}
		}
		return false;
	}
	return true;
}

function _calculateDimGrid(oParam){
	var len = oParam.dataArray.length;
	for(var i=0;i<len;i++){
		var ucontrl = getElById("_txtUnt"+i);
		modifyArray(i,"U",ucontrl,oParam,true);
	}
	_calculateTotals(oParam);
}

function _calculateTotals(oParam){
	var len = oParam.dataArray.length;
	var totalPcs=0;
	var totalVol=0;
	//tc02449
	var totalVolWt=0;
	var totalWeight=0;
	//tc02449
	var isempty=false;
	var weightConvartionFactory=new weightConversionMultiplyingFactors();
	for(var i=0;i<len;i++){
		var volcontrl = getElById("_txtVol"+i);
		//
		var volWtContrl=getElById("_txtVolWt"+i);
		var wtControl=getElById("_txtwt"+i);
		var wtUniltControl=getElById("_txtWtUnt"+i);
		//
		if(volcontrl){
			doCaseChange(volcontrl,"DECIMAL2");
			var vol = volcontrl.value;
			if(validateDataType("DECIMAL2",vol)){
				if(parseFloat(vol)>0){
					totalVol = totalVol + parseFloat(vol);
				}
			}
			if(!isempty){
				if(vol=="")	isempty=true;
			}
		}
		//tc02449
		if(volWtContrl){
			doCaseChange(volWtContrl,"DECIMAL3");
			var volwt = volWtContrl.value;
			if(validateDataType("DECIMAL3",volwt)){
				if(parseFloat(volwt)>0){
					totalVolWt = totalVolWt + parseFloat(volwt);
				}
			}
		}
		if(wtControl){
			doCaseChange(wtControl,"DECIMAL2");
			var weight = wtControl.value;
			if(validateDataType("DECIMAL2",weight)){
				if(parseFloat(weight)>0){
					if(wtUniltControl){
						var factorKey=(wtUniltControl.value).toUpperCase()+(oParam.weightBaseUnits).toUpperCase();
						var stringKey="weightConvartionFactory."+factorKey;
						var multiplyingFactor=eval(stringKey);
						if(!(multiplyingFactor)) multiplyingFactor=1;
					 	var weightValue=parseFloat(weight)*multiplyingFactor;
						totalWeight = totalWeight +weightValue;
					}
				}
			}
		}
		//tc02449

		var pcscontrl = getElById("_txtPcs"+i);
		if(pcscontrl){
			var pcs = pcscontrl.value;
			if(validateDataType("NUMBER",pcs)){
				if(parseInt(pcs)>0){
					totalPcs = totalPcs + parseInt(pcs);
				}
				else{
					pcscontrl.value="";
					oParam.dataArray[i].pieces="";
				}
			}
			else{
				pcscontrl.value="";
				oParam.dataArray[i].pieces="";
			}
		}

	}
	var pcstrl = getElById("_txtTotPcs");
	if(pcstrl){
		if(totalPcs>0){
			 pcstrl.value=totalPcs;
		}
		else{
			pcstrl.value="";
		}
		oParam.totalPcs=pcstrl.value;
	}

	//tc02449
	var volwttotal = getElById("_txtTotVolWt");
	if(volwttotal){
		if(totalVolWt>0){
		var tempFormatedVolweight = FormatNRoundNumber(null,-1,50,2,false,10,totalVolWt.toString(),true);
			 volwttotal.value=tempFormatedVolweight;
		}
		else{
			volwttotal.value="";
		}
		doCaseChange(volwttotal,"DECIMAL2");
		// Changes start by Manish CMS-850
		var tempChargableWt = volwttotal.value;
		var totalVolWeight =tempChargableWt;
		oParam.totalVol=totalVolWeight;

	var voltrl = getElById("_txtTotVol");
	if(voltrl){
		if(totalVol>0){
			//Added change as part of CMS-342 by Srinivas(S736050)
			var tempFormatedVolweight = FormatNRoundNumber(null,-1,50,2,false,10,totalVolWt.toString(),true);
			volwttotal.value=tempFormatedVolweight;
			totalVol= parseFloat(volwttotal.value);
			var tempChargableWt = totalVol/166.67; 

	if((tempChargableWt>0) && (tempChargableWt<0.01)){
			tempChargableWt = .01
			voltrl.value= tempChargableWt;
		}else{
		    //Changes done for CMS-850 by manish
			 var totalVolWeightVol =tempChargableWt.toFixed(2);
			 voltrl.value=totalVolWeightVol;
			//tc02449
		    // Changes End by Manish CMS-850
		}
		}
		else{
			voltrl.value="";
		}
		doCaseChange(voltrl,"DECIMAL2");
		oParam.totalVol=voltrl.value;

	}

		

	}

	var weightTotalControl=getElById("_txtTotWt");
	if(weightTotalControl){
		if(totalWeight>0){
			weightTotalControl.value=totalWeight;
			doCaseChange(weightTotalControl,"DECIMAL2");
		}
		else weightTotalControl.value="";
	}
	//tc02449

	if(!isempty){
		var addtrl = getElById("btnAdd");
		if(addtrl) addtrl.disabled=false;
		if(oParam.readOnly)addtrl.disabled=true;
	}

}
function createDimensionTable(oParam){
	var count=3;
	var delCount=0;
	var extraLine=0;
	listTableStr="";
    var displaylineNo=0;

	if(oParam.dataArray.length>=3){
		for(i=0;i<oParam.dataArray.length;i++){
				displayDimensionObject=oParam.dataArray[i];
				if(displayDimensionObject.flag=="D"){
					delCount++;
					continue;
				}
                displaylineNo++;
				listTableStr=listTableStr+getValuedRows(i,displayDimensionObject,oParam,displaylineNo);

		}
		if(delCount>0){
			extraLine=3-(oParam.dataArray.length-delCount);
			for(j=0;j<extraLine;j++){
				var dimensionTempObject=new dimensionObject();
				if(parseInt(oParam.dataArray[oParam.dataArray.length-1].lineno)>0) dimensionTempObject.lineno=(parseInt(oParam.dataArray[oParam.dataArray.length-1].lineno)+1);
				oParam.dataArray[oParam.dataArray.length]=dimensionTempObject;
                displaylineNo++;
				listTableStr=listTableStr+getValuedRows(oParam.dataArray.length-1,dimensionTempObject,oParam,displaylineNo);
			}
		}

	}
	else{
		for(i=0;i<oParam.dataArray.length;i++){
				displayDimensionObject=oParam.dataArray[i];
				if(displayDimensionObject.flag=="D")
					continue;
                displaylineNo++;
				listTableStr=listTableStr+getValuedRows(i,displayDimensionObject,oParam,displaylineNo);
				count--;
		}
		for(j=0;j<count;j++){
                displaylineNo++;
				listTableStr=listTableStr+getValuedRows(j,oParam.dataArray[j],oParam,displaylineNo);
		}
	}
	listTableStr="<table class='"+_cssTb.cssTable+"'>"+getTableHeader(oParam)+listTableStr+getTotalRowHTML(oParam)+"</table>";
	return listTableStr;
}

function getTableHeader(oParam){
	var listTableStr="<tr><td colspan='8'>&nbsp;</td></tr><tr>"+
				"<td class='"+_cssTb.cssHead+"' width='15px;' align='center'>&nbsp;</td>"+
				"<td class='"+_cssTb.cssHead+"' width='22px;'>&nbsp;</td>"+
				"<td class='"+_cssTb.cssHead+"' width='108px;'>No. Pcs</td>"+
				"<td class='"+_cssTb.cssHead+"' width='53px;'>Units</td>"+
				"<td class='"+_cssTb.cssHead+"' width='53px;'>Length</td>"+
				"<td class='"+_cssTb.cssHead+"' align='right' width='53px;'>Width</td>"+
				"<td class='"+_cssTb.cssHead+"' width='53px;'>Height</td>";
			//tc02449
			if(oParam.isWeight){
				listTableStr +="<td class='"+_cssTb.cssHead+"' width='53px;'>Weight</td>"+
                "<td class='"+_cssTb.cssHead+"' width='40px;'>Weight Unit</td>";
			}
  			//tc02449
				listTableStr +="<td class='"+_cssTb.cssHead+"' width='96px;'>Volume("+oParam.baseUnits+")</td>";
		//tc02449
				//CMS-850
				//if(oParam.isVolWeight)
				listTableStr +="<td class='"+_cssTb.cssHead+"' width='96px;'>Volumetric weight</td>";
        //tc02449
				listTableStr +="</tr>";
	return listTableStr;
}
function getTotalRowHTML(oParam){
	var listTableStr="<tr>"+
				"<td class=grdNobgHover width='32px;' colspan='2'>&nbsp;</td>"+
				"<td class=grdNobgHover width='108px;'><input type=\"text\" class=\"inputsReadOnly\" readOnly style=\"width:50px;text-align:right;\" name=\"_txtTotPcs\" id=\"_txtTotPcs\"  value=\"\" /></td>"+
				"<td class=grdNobgHover colspan='4'>&nbsp;</td>";

				//tc02449
				if(oParam.isWeight){
					 listTableStr +="<td class=grdNobgHover width='96px;'><input type=\"text\" class=\"inputsReadOnly\" readOnly style=\"width:65px;text-align:right;\" name=\"_txtTotWt\" id=\"_txtTotWt\"  value=\"\" /></td>"+
						 "<td class=grdNobgHover>&nbsp;"+oParam.weightBaseUnits+"</td>";
				}
				//tc02449

				listTableStr +="<td class=grdNobgHover width='96px;'><input type=\"text\" class=\"inputsReadOnly\" readOnly style=\"width:75px;text-align:right;\" name=\"_txtTotVol\" id=\"_txtTotVol\"  value=\"\" /></td>";

				//tc02449
				//CMS-850
				//if(oParam.isVolWeight)
					 listTableStr +="<td class=grdNobgHover width='96px;'><input type=\"text\" class=\"inputsReadOnly\" readOnly style=\"width:75px;text-align:right;\" name=\"_txtTotVolWt\" id=\"_txtTotVolWt\"  value=\"\" /></td>";
				//tc02449

				listTableStr +="</tr>";
	return listTableStr;
}
function getValuedRows(i,displayDimensionObject,oParam,displaylineNo){
	var strclass=(oParam.readOnly)?" class=\"inputsReadOnly\" readOnly ":"class=\"inputs\"";
	var strdisabled=(oParam.readOnly)?"disabled":"";
	//var line = (i+1);
    //alert("line"+line);
	var listTableStr="<tr>"+
				"<td class=grdNobgHover width='15px;' align='center'>"+displaylineNo+"</td>"+
				"<td class=grdNobgHover width='22px;'><input type=\"checkbox\" id=\"editList"+i+"\" name=\"editList"+i+"\" value=\""+i+"\" "+strdisabled+" /></td>"+
				"<td class=grdNobgHover width='108px;'><input type=\"text\" "+strclass+" style=\"width:50px;text-align:right;\" name=\"_txtPcs"+i+"\" id=\"_txtPcs"+i+"\"  maxlength=\""+_piecesMaxLenth+"\" value=\""+displayDimensionObject.pieces+"\" onChange=\"modifyArray("+i+",'P',this,_"+oParam.componentId+");\"/></td>"+
				"<td class=grdNobgHover width='53px;'>"+getSelectedOption(displayDimensionObject.unit,i,oParam)+"</td>"+
				"<td class=grdNobgHover width='53px;'><input type=\"text\" "+strclass+" style=\"width:50px;text-align:right;\" name=\"_txtLen"+i+"\" id=\"_txtLen"+i+"\"  maxlength=\""+_lengthMaxLenth+"\" value=\""+displayDimensionObject.length+"\" onChange=\"modifyArray("+i+",'L',this,_"+oParam.componentId+");\"/></td>"+
				"<td class=grdNobgHover align='right' width='53px;'><input "+strclass+" style=\"width:50px;text-align:right;\" type=\"text\" name=\"_txtWid"+i+"\" id=\"_txtWid"+i+"\"  maxlength=\""+_widthMaxLenth+"\" value=\""+displayDimensionObject.breadth+"\" onChange=\"modifyArray("+i+",'B',this,_"+oParam.componentId+");\"/></td>"+
				"<td class=grdNobgHover width='53px;'><input type=\"text\" "+strclass+" style=\"width:50px;text-align:right;\" name=\"_txtHgt"+i+"\" id=\"_txtHgt"+i+"\"  maxlength=\""+_heightMaxLenth+"\" value=\""+displayDimensionObject.height+"\" onChange=\"modifyArray("+i+",'H',this,_"+oParam.componentId+");\"/></td>";
				//tc02449
				if(oParam.isWeight){
					listTableStr +="<td class=grdNobgHover width='53px;'><input type=\"text\" "+strclass+" style=\"width:65px;text-align:right;\" name=\"_txtwt"+i+"\" id=\"_txtwt"+i+"\"  value=\""+displayDimensionObject.weight+"\" onChange=\"modifyArray("+i+",'W',this,_"+oParam.componentId+");\" maxlength=\"10\" /></td>"+
					"<td class=grdNobgHover width='40px;'>"+getSelectedOptionWeight(displayDimensionObject.weightUnit,i,oParam)+"</td>";
				}
            	//tc02449
				listTableStr +="<td class=grdNobgHover width='96px;'><input type=\"text\" class=\"inputsReadOnly\" readOnly style=\"width:75px;text-align:right;\" name=\"_txtVol"+i+"\" id=\"_txtVol"+i+"\"  value=\""+displayDimensionObject.volume+"\"  /></td>";
				//tc02449
				//CMS-850
				//if(oParam.isVolWeight)					
					//alert('before printing'+displayDimensionObject.vloumetricWt);
					listTableStr +="<td class=grdNobgHover width='96px;'><input type=\"text\" class=\"inputsReadOnly\"  readOnly style=\"width:75px;text-align:right;\" name=\"_txtVolWt"+i+"\" id=\"_txtVolWt"+i+"\"  value=\""+displayDimensionObject.vloumetricWt+"\" /></td>";
				//tc02449
				listTableStr +="</tr>";
	return listTableStr;
}

function _getSelected(str1,str2){
	if(str1==str2) return "selected";
	return "";
}
function getSelectedOptionWeight(selectedParam,i,oParam){
	var strdisabled=(oParam.readOnly)?"disabled":"";
	selectedOptionHTML="<select name=\"_txtWtUnt"+i+"\" id=\"_txtWtUnt"+i+"\"  "+strdisabled+" class=\"inputs\" onchange=\"modifyArray("+i+",'WU',this,_"+oParam.componentId+");\">"+
						"<option value=\"kg\" "+_getSelected("kg",selectedParam)+">kg</option>"+
						"<option value=\"lb\" "+_getSelected("lb",selectedParam)+">lb</option>"+
						"</select>";
	return selectedOptionHTML;
}
function getSelectedOption(selectedParam,i,oParam){
	var strdisabled=(oParam.readOnly)?"disabled":"";
	selectedOptionHTML="<select name=\"_txtUnt"+i+"\" id=\"_txtUnt"+i+"\"  "+strdisabled+" class=\"inputs\" onchange=\"modifyArray("+i+",'U',this,_"+oParam.componentId+");\">"+
						"<option value=\"CM\" "+_getSelected("CM",selectedParam)+">Centimetres</option>"+
						//"<option value=\"FT\" "+_getSelected("FT",selectedParam)+">Feet</option>"+
						"<option value=\"IN\" "+_getSelected("IN",selectedParam)+">Inches</option>"+
						//"<option value=\"MM\" "+_getSelected("MM",selectedParam)+">Millimetres</option>"+
						//"<option value=\"MT\" "+_getSelected("MT",selectedParam)+">Meters</option>"+
						"</select>";
	return selectedOptionHTML;
}

function createArrayFromString(oParam){
	var str = oParam.datastring;
	oParam.dataArray= new Array();
	if(str!=""){
				var rowsData=str.split("|");
				var colsStr;
				var colsData;
				var dimensionTempObject;
				for(i=0;i<rowsData.length;i++){
						colsStr=rowsData[i];
						if(colsStr=="") continue;
						colsData=colsStr.split("~");
						if(colsData.length<8) continue;
						dimensionTempObject=new dimensionObject();
						dimensionTempObject.lineno=colsData[0];
						dimensionTempObject.id=colsData[1];
						dimensionTempObject.flag=colsData[2];
						dimensionTempObject.pieces=colsData[3];
						dimensionTempObject.unit=(colsData[4]!="")?colsData[4]:dimensionTempObject.unit;
						dimensionTempObject.length=colsData[5];
						dimensionTempObject.breadth=colsData[6];
						dimensionTempObject.height=colsData[7];
						dimensionTempObject.volume=colsData[8];
						//tc02449
						dimensionTempObject.vloumetricWt=colsData[9];
						dimensionTempObject.weight=colsData[10];
						dimensionTempObject.weightUnit=(colsData[11]!="")?colsData[11]:dimensionTempObject.weightUnit;
						//tc02449
						oParam.dataArray[oParam.dataArray.length]=dimensionTempObject;
				}
	}
	if(oParam.dataArray.length<3){
		var len = (3-oParam.dataArray.length);
		for(i=0;i<len;i++){
			var dimenObject=new dimensionObject();
			if(oParam.dataArray.length>0){
				if(parseInt(oParam.dataArray[oParam.dataArray.length-1].lineno)>0) dimenObject.lineno=(parseInt(oParam.dataArray[oParam.dataArray.length-1].lineno)+1);
			}
			oParam.dataArray[oParam.dataArray.length]=dimenObject;
		}
	}
}

function createStringFromArray(oParam){
		var dimensionTempObject;
		var finalString="";
		var count=1;
		for(i=0;i<oParam.dataArray.length;i++){
			dimensionTempObject=oParam.dataArray[i];
			if(dimensionTempObject.id=="" && dimensionTempObject.flag=="D") continue;
			if(dimensionTempObject.pieces=="" || dimensionTempObject.length=="" ||dimensionTempObject.breadth=="") continue;

			dimensionTempObject.lineno=(parseInt(dimensionTempObject.lineno)>0)?dimensionTempObject.lineno:count++;
			finalString=finalString+"|"+dimensionTempObject.lineno+"~"+dimensionTempObject.id+"~"+dimensionTempObject.flag+"~"+dimensionTempObject.pieces+
			"~"+dimensionTempObject.unit+"~"+dimensionTempObject.length+"~"+dimensionTempObject.breadth+
			"~"+dimensionTempObject.height+"~"+dimensionTempObject.volume+
				 //tc02449  "~"+dimensionTempObject.vloumetricWt
			"~"+dimensionTempObject.vloumetricWt+"~"+dimensionTempObject.weight+"~"+dimensionTempObject.weightUnit;
		}
		finalString=finalString+"|";
		//alert(finalString);
		return finalString;
}
function getDimensionTable(oParam,first){

	if(first) createArrayFromString(oParam);

	if(oParam.baseUnits=="") oParam.baseUnits=="CM";
	tableHtml=createDimensionTable(oParam);
	return tableHtml;
}

function removeRow(oParam){
	var len = oParam.dataArray.length;
	for(var i=0;i<len;i++){
		if(getElById("editList"+i)){
			if(getElById("editList"+i).checked){
				var dto = oParam.dataArray[i];
				if(dto.flag=="I"){
					var obj = new dimensionObject();
					obj.flag = "D";
					if(parseInt(dto.lineno)>0) obj.lineno=dto.lineno;
					oParam.dataArray[i]=obj;
				}
				else{
					dto.flag = "D";
					oParam.dataArray[i] = dto;
				}
			}
		}
	}
	displayDimensions(oParam,true);
}
function addRow(oParam){
	var dimensionTempObject=new dimensionObject();
	if(parseInt(oParam.dataArray[oParam.dataArray.length-1].lineno)>0) dimensionTempObject.lineno=(parseInt(oParam.dataArray[oParam.dataArray.length-1].lineno)+1);
	oParam.dataArray[oParam.dataArray.length]=dimensionTempObject;
	displayDimensions(oParam,true);
}

function conversionMultiplyingFactors(){
	this.MMCL=1;
	this.MMCM=0.000000001;
	this.MMCC=0.001;
	this.MMCI=0.0000610237441;
	this.MMCF=0.0000000353146667;
	this.MMCBM=0.000000001;
	this.CMCC=1;
	this.CMCF=0.000035314666721488586;
	this.CMCI=0.06102374409473228;
	this.CMCM=0.000001;
	this.CMCL=1000;
	this.CMCBM=0.000001;
	this.MTCC=1000000;
	this.MTCM=1;
	this.MTCL=1000000000;
	this.MTCF=35.31466672148859;
	this.MTCI=61023.74409473229;
	this.MTCBM=1;
	this.INCI=1;
	this.INCC=16.387064;
	this.INCF=0.0005787037037037037;
	this.INCM=0.000016387064;
	this.INCL=16387.064 ;
	this.INCBM=0.000016387064;
	this.FTCF=1;
	this.FTCC=28316.846592;
	this.FTCI=1728.0000000000002;
	this.FTCM=0.028316846592;
	this.FTCL=28316846.6;
	this.FTCBM=0.028316846592;
}
//1 pound = 0.45359237 kilograms
//1 kilogram = 2.20462262 pound
function weightConversionMultiplyingFactors(){
	this.KGLB=2.20462262;
    this.LBKG=0.45359237;
	this.KGKG=1;
	this.LBLB=1;
}

function volumeWeightConversionMultiplyingFactors(){
	this.KGCBM=166.67;
    this.KGCC=0.000167;
}

function dimensionConvertor(obj,baseUnit){
	//alert("dimension converter line no 815");
	var factorKey;
	var multiplyingFactor;
	var volWtMultiplyingFactor;
	var volWtStringKey;
	var conversionMultFactors=new conversionMultiplyingFactors();
	var volumeWtMultFactors=new volumeWeightConversionMultiplyingFactors();
	if(obj!="" && obj!=null){
		selctedUnit=obj.unit;
		if(selctedUnit!="" && baseUnit!="")
			factorKey=selctedUnit.toUpperCase()+baseUnit.toUpperCase();
		var stringKey="conversionMultFactors."+factorKey;

		try{
			volWtStringKey="volumeWtMultFactors.KG"+baseUnit.toUpperCase();
		//alert("volWtStringKey 830"+volWtStringKey);
			volWtMultiplyingFactor=eval(volWtStringKey);
		}catch(e){}

		multiplyingFactor=eval(stringKey);
		if(!(multiplyingFactor)) multiplyingFactor=1;
		if(parseInt(obj.pieces)<1) obj.pieces="";
		if(parseFloat(obj.length)<=0) obj.length="";
		if(parseFloat(obj.breadth)<=0) obj.breadth="";
		if(parseFloat(obj.height)<=0) obj.height="";
		if(obj.pieces!="" && obj.length!="" && obj.breadth!="" && obj.height!=""){
			obj.volume=obj.pieces*obj.length*obj.breadth*obj.height*multiplyingFactor;
		//Changes Start By Manish S(s736831)for CR 192A
	 	if((obj.volume>0) && (obj.volume<0.01)){
			obj.volume = .01
		}else{
  		  	var currVol;
			currVol = obj.volume;
			var tempVol =	currVol.toFixed(2);
			obj.volume = tempVol;
	    }
		//Changes End By Manish S(s736831)for CR 192A
		//tc02449
			obj.vloumetricWt=(obj.length*obj.breadth*obj.height/6000)*obj.pieces;//obj.volume*((volWtMultiplyingFactor)?volWtMultiplyingFactor:166.67);
		if((obj.vloumetricWt>0) && (obj.vloumetricWt<0.01)){
			obj.vloumetricWt = .01
		}else{
		//	Changes done for CMS-850 by manish
			var vloumetricWt =obj.vloumetricWt.toFixed(3);
			obj.vloumetricWt = vloumetricWt;
			//alert('after fixed decimal'+obj.vloumetricWt)
			//tc02449
		}
		}
		else{
			obj.volume="";
			//tc02449
			obj.vloumetricWt="";
			//tc02449
		}
	}
	return obj;
}

// CLI-4739 : Robert Rosary
function getTotalPieces(oParam) {
	createArrayFromString(oParam);
	var len = oParam.dataArray.length;
	var totalPieces = 0;
	for (var i=0; i < len; i++) {
		var dimObject = oParam.dataArray[i];
		var pcs = parseInt(dimObject.pieces);
		if(!isNaN(pcs)){
			if(pcs > 0){
				totalPieces = pcs + totalPieces;
			}
		}
	}
	return totalPieces;
}

//Added by Ream(s389422) as part of CLI-6677 - Start
function isDimDataExist(oParam){
    var isDataAvailable = false;
    var str = oParam.datastring;
	oParam.dataArray= new Array();
	if(str!=""){
				var rowsData=str.split("|");
				var colsStr;
				var colsData;
				var dimensionTempObject;
				for(i=0;i<rowsData.length;i++){
						colsStr=rowsData[i];
						if(colsStr=="") continue;
						colsData=colsStr.split("~");
						if(colsData.length<8) continue;
						dimensionTempObject=new dimensionObject();
						dimensionTempObject.lineno=colsData[0];
						dimensionTempObject.id=colsData[1];
						dimensionTempObject.flag=colsData[2];
						dimensionTempObject.pieces=colsData[3];
						dimensionTempObject.unit=(colsData[4]!="")?colsData[4]:dimensionTempObject.unit;
						dimensionTempObject.length=colsData[5];
						dimensionTempObject.breadth=colsData[6];
						dimensionTempObject.height=colsData[7];
						dimensionTempObject.volume=colsData[8];
						dimensionTempObject.vloumetricWt=colsData[9];
						dimensionTempObject.weight=colsData[10];
						dimensionTempObject.weightUnit=(colsData[11]!="")?colsData[11]:dimensionTempObject.weightUnit;
						oParam.dataArray[oParam.dataArray.length]=dimensionTempObject;
                        if(dimensionTempObject.pieces != "" || dimensionTempObject.length != "" || dimensionTempObject.breadth != "" || dimensionTempObject.height != ""){
                            isDataAvailable = true;
                            break;
                        }
				}
	}
    return isDataAvailable;
}
//CLI-6677 - End

