function jsuAll(p_oRoot, p_sValue) {
var oRoot, sValue;
oRoot = null;
if (p_sValue == undefined) return document.getElementById(p_oRoot);
if(String(p_oRoot).indexOf("[object") == 0){
oRoot = p_oRoot;
}else{
oRoot = document.getElementById(p_oRoot);
}
if (oRoot == undefined) return null;
if (oRoot == null) return null;
var ar1 = new Array();
var ar2 = null;
var i, j;
for(var i = 0; i < oRoot.childNodes.length; i++) {
xChild = oRoot.childNodes[i];
if (xChild) {
if(xChild.id == p_sValue || xChild.name == p_sValue || p_sValue == "") ar1[ar1.length] = xChild;
if(xChild.childNodes.length > 0) ar2 = jsuAll(xChild, p_sValue);
if(ar2 != null) {
if (ar2[0] == undefined) {
ar1[ar1.length] = ar2;
}else {
for( j = 0; j < ar2.length; j++) {
ar1[ar1.length] = ar2[j];
}
}
ar2 = null;
}
}
}
if(ar1.length == 0) return null;
if(ar1.length == 1) ar1 = ar1[0];
return ar1;
}
function jsuAFSResizeImage(p_oImage) {
if(p_oImage.style == undefined) return;
p_oImage.style.display = "none";
var max = 75;
var h = p_oImage.height;
var w = p_oImage.width;
if (w>max) {
p_oImage.height=h*max/w;
p_oImage.width=max;
}
p_oImage.style.display = "";
};
function jsuAFSCheckout() {
if(document.all) { //IE
if(window != top) {
document.location = "uStore.Checkout.asp";
} else {
AFSStoreFrame.document.location = "Store/uStore.Checkout.asp"
}
} else { // FF
if(window != top) {
document.location = "uStore.Checkout.asp";
} else {
AFSStoreFrame.src = "Store/uStore.Checkout.asp"
}
}
/*
if(window != top && document.all) {
document.location = 'uStore.Checkout.asp';
} else {
document.location = 'Store/uStore.Checkout.asp';
}
*/
}
function jsuAFSAddCheckoutItemCase(p_sUID) {
var oTD, oTB, oCell, i, sUID;
var oPrice, oTitle, oType, oTax, oModel, oAvailable, oMSKU, oImage, oUnits, oShipping, oOrigin, oWeight, oCaseUnits;
var sPrice, sTitle, sType, sTax, sModel, sAvailable, sMSKU, sImage, sUnits, sShipping, sOrigin, sWeight, sCaseUnits;
oPrice = oTitle = oType = oTax = oModel = oAvailable = oMSKU = oImage = oUnits = oShipping = oOrigin = oWeight = null;
sPrice = sTitle = sType = sTax = sModel = sAvailable = sMSKU = sImage = sUnits = sShipping = sOrigin = sWeight = "";
oTB = jsuAll(p_sUID);
if(oTB != null) {
oPrice = jsuAll(oTB, "uItem.uCommerce.CasePrice.Value");
oCaseUnits = jsuAll(oTB, "uItem.uCommerce.CaseUnits.Value");
oTitle = jsuAll(oTB, "uItem.uDisplay.uMedia.Title.Value");
oType = jsuAll(oTB, "uItem.uDetails.ItemType.Value");
oTax = jsuAll(oTB, "uItem.uInventory.Tax.Value");
oModel = jsuAll(oTB, "uItem.uCommerce.Model.Value");
oAvailable = jsuAll(oTB, "uItem.uInventory.Available.Value");
oMSKU = jsuAll(oTB, "uItem.uInventory.MSKU.Value");
oImage = jsuAll(oTB, "uItem.uDisplay.uMedia.Image.Icon.Value");
oUnits = jsuAll(document.body, "trUnitsMeasure");
if(oCaseUnits) sCaseUnits = oCaseUnits.innerHTML;
oShipping = "";
oOrigin = jsuAll(oTB, "uItem.uInventory.OriginZip.Value");
oWeight = jsuAll(oTB, "uItem.uCommerce.Weight.Value");
if(oOrigin) sOrigin = oOrigin.innerHTML;
if(oWeight) sWeight = oWeight.innerHTML;
sWeight = Number(sCaseUnits) * Number(sWeight);
if(oUnits) oUnits = oUnits.cells[0];
if(oUnits) sUnits = oUnits.innerHTML + " ( " + sCaseUnits + " Units )";
if(oPrice) sPrice = oPrice.innerHTML;
if(oTitle[0]) sTitle = oTitle[0].innerHTML;
if(oTax) sTax = oTax.innerHTML;
if(oType) sType = oType.innerHTML;
if(oModel) sModel = oModel.innerHTML;
if(oAvailable) sAvailable = oAvailable.innerHTML;
if(oMSKU) sMSKU = oMSKU.innerHTML;
if(oImage) sImage = oImage.innerHTML;
sUID = p_sUID + "-CASE";
top.jsuAFSAddCheckoutData(sUID , 1, sPrice, sTax, sTitle + "-CASE", sModel + "-CASE", sMSKU + "-CASE", sImage , sUnits, sShipping, sOrigin, sWeight, sType);
}
}
function jsuAFSAddCheckoutItemSample(p_sUID) {
var oTD, oTB, oCell, i, sUID;
var oPrice, oTitle, oType, oTax, oModel, oAvailable, oMSKU, oImage, oUnits, oShipping, oOrigin, oWeight, oCaseUnits;
var sPrice, sTitle, sType, sTax, sModel, sAvailable, sMSKU, sImage, sUnits, sShipping, sOrigin, sWeight, sCaseUnits;
oPrice = oTitle = oType = oTax = oModel = oAvailable = oMSKU = oImage = oUnits = oShipping = oOrigin = oWeight = null;
sPrice = sTitle = sType = sTax = sModel = sAvailable = sMSKU = sImage = sUnits = sShipping = sOrigin = sWeight = "";
oTB = jsuAll(p_sUID);
if(oTB != null) {
oPrice = jsuAll(oTB, "uItem.uCommerce.SamplePrice.Value");
oTitle = jsuAll(oTB, "uItem.uDisplay.uMedia.Title.Value");
oTax = jsuAll(oTB, "uItem.uInventory.Tax.Value");
oType = jsuAll(oTB, "uItem.uDetails.ItemType.Value");
oModel = jsuAll(oTB, "uItem.uCommerce.Model.Value");
oAvailable = jsuAll(oTB, "uItem.uInventory.Available.Value");
oMSKU = jsuAll(oTB, "uItem.uInventory.MSKU.Value");
oImage = jsuAll(oTB, "uItem.uDisplay.uMedia.Image.Icon.Value");
oUnits = jsuAll(document.body, "trUnitsMeasure");
oShipping = "";
oOrigin = jsuAll(oTB, "uItem.uInventory.OriginZip.Value");
oWeight = jsuAll(oTB, "uItem.uCommerce.Weight.Value");
if(oOrigin) sOrigin = oOrigin.innerHTML;
if(oWeight) sWeight = oWeight.innerHTML;
if(oUnits) oUnits = oUnits.cells[0];
if(oUnits) sUnits = oUnits.innerHTML;
sUnits = "SAMPLE";
if(oPrice) sPrice = oPrice.innerHTML;
if(oTitle[0]) sTitle = oTitle[0].innerHTML;
if(oType) sType = oType.innerHTML;
if(oTax) sTax = oTax.innerHTML;
if(oModel) sModel = oModel.innerHTML;
if(oAvailable) sAvailable = oAvailable.innerHTML;
if(oMSKU) sMSKU = oMSKU.innerHTML;
if(oImage) sImage = oImage.innerHTML;
sUID = p_sUID + "-SAMPLE";
top.jsuAFSAddCheckoutData(sUID , 1, sPrice, sTax, sTitle + "-SAMPLE", sModel + "-SAMPLE", sMSKU + "-SAMPLE", sImage , sUnits, sShipping, sOrigin, sWeight, sType);
}
}
function jsuAFSAddCheckoutItemIcon(p_sUID, p_oTable) {
var oTD, oTB, oCell, i;
var oPrice, oTitle, oType, oTax, oModel, oAvailable, oMSKU, oImage, oUnits, oShipping, oOrigin, oWeight, oCaseUnits;
var sPrice, sTitle, sType, sTax, sModel, sAvailable, sMSKU, sImage, sUnits, sShipping, sOrigin, sWeight, sCaseUnits;
oPrice = oTitle = oType = oTax = oModel = oAvailable = oMSKU = oImage = oUnits = oShipping = oOrigin = oWeight = null;
sPrice = sTitle = sType = sTax = sModel = sAvailable = sMSKU = sImage = sUnits = sShipping = sOrigin = sWeight = "";
oTB = jsuAll(p_sUID);
var iii = 0;
if(oTB != null) {
oPrice = jsuAll(oTB, "uItem.uCommerce.Price.Value");
oTitle = jsuAll(oTB, "uItem.uDisplay.uMedia.Title.Value");
oType = jsuAll(oTB, "uItem.uDetails.ItemType.Value");
oTax = jsuAll(oTB, "uItem.uInventory.Tax.Value");
oModel = jsuAll(oTB, "uItem.uCommerce.Model.Value");
oAvailable = jsuAll(oTB, "uItem.uInventory.Available.Value");
oMSKU = jsuAll(oTB, "uItem.uInventory.MSKU.Value");
oImage = jsuAll(oTB, "uItem.uDisplay.uMedia.Image.Icon.Value");
oUnits = jsuAll(p_oTable, "trUnitsMeasure");
oShipping = "";
oOrigin = jsuAll(oTB, "uItem.uInventory.OriginZip.Value");
oWeight = jsuAll(oTB, "uItem.uCommerce.Weight.Value");
if(oOrigin) sOrigin = oOrigin.innerHTML;
if(oWeight) sWeight = oWeight.innerHTML;
if(oUnits) oUnits = oUnits.cells[0];
if(oUnits) sUnits = oUnits.innerHTML;
if(oPrice) sPrice = oPrice.innerHTML;
if(oTitle[0]) sTitle = oTitle[0].innerHTML;
if(oType) sType = oType.innerHTML;
if(oTax) sTax = oTax.innerHTML;
if(oModel) sModel = oModel.innerHTML;
if(oAvailable) sAvailable = oAvailable.innerHTML;
if(oMSKU) sMSKU = oMSKU.innerHTML;
if(oImage) sImage = oImage.innerHTML;
top.jsuAFSAddCheckoutData( p_sUID, 1, sPrice, sTax, sTitle, sModel, sMSKU, sImage , sUnits, sShipping, sOrigin, sWeight, sType);
//top.jsuAFSAddCheckoutData( p_sUID, 1, oPrice.innerHTML, oTax.innerHTML, oTitle[0].innerHTML, oModel.innerHTML, oMSKU.innerHTML, oImage.innerHTML , oUnits.innerHTML);
}
}
function jsuAFSAddCheckoutItem(p_sUID) {
return jsuAFSAddCheckoutItemQty(p_sUID, 1);
}
function jsuAFSAddCheckoutItemQty(p_sUID, p_Qty) {
var oTD, oTB, oCell, i;
var oPrice, oTitle, oType, oTax, oModel, oAvailable, oMSKU, oImage, oUnits, oShipping, oOrigin, oWeight, oCaseUnits;
var sPrice, sTitle, sType, sTax, sModel, sAvailable, sMSKU, sImage, sUnits, sShipping, sOrigin, sWeight, sCaseUnits;
oPrice = oTitle = oType = oTax = oModel = oAvailable = oMSKU = oImage = oUnits = oShipping = oOrigin = oWeight = null;
sPrice = sTitle = sType = sTax = sModel = sAvailable = sMSKU = sImage = sUnits = sShipping = sOrigin = sWeight = "";
oTB = jsuAll(p_sUID);
if(oTB != null) {
oPrice = jsuAll(oTB, "uItem.uCommerce.Price.Value");
oTitle = jsuAll(oTB, "uItem.uDisplay.uMedia.Title.Value");
oTax = jsuAll(oTB, "uItem.uInventory.Tax.Value");
oType = jsuAll(oTB, "uItem.uDetails.ItemType.Value");
oModel = jsuAll(oTB, "uItem.uCommerce.Model.Value");
oAvailable = jsuAll(oTB, "uItem.uInventory.Available.Value");
oMSKU = jsuAll(oTB, "uItem.uInventory.MSKU.Value");
oImage = jsuAll(oTB, "uItem.uDisplay.uMedia.Image.Icon.Value");
oUnits = jsuAll(document.body, "trUnitsMeasure");
oShipping = "";
oOrigin = jsuAll(oTB, "uItem.uInventory.OriginZip.Value");
oWeight = jsuAll(oTB, "uItem.uCommerce.Weight.Value");
if(oOrigin) sOrigin = oOrigin.innerHTML;
if(oWeight) sWeight = oWeight.innerHTML;
if(oUnits) oUnits = oUnits.cells[0];
if(oUnits) sUnits = oUnits.innerHTML;
if(oPrice) sPrice = oPrice.innerHTML;
if(oTitle[0]) sTitle = oTitle[0].innerHTML;
if(oType) sType = oType.innerHTML;
if(oTax) sTax = oTax.innerHTML;
if(oModel) sModel = oModel.innerHTML;
if(oAvailable) sAvailable = oAvailable.innerHTML;
if(oMSKU) sMSKU = oMSKU.innerHTML;
if(oImage) sImage = oImage.innerHTML;
top.jsuAFSAddCheckoutData( p_sUID, p_Qty, sPrice, sTax, sTitle, sModel, sMSKU, sImage , sUnits, sShipping, sOrigin, sWeight, sType);
//top.jsuAFSAddCheckoutData( p_sUID, 1, oPrice.innerHTML, oTax.innerHTML, oTitle[0].innerHTML, oModel.innerHTML, oMSKU.innerHTML, oImage.innerHTML , oUnits.innerHTML);
}
}
function jsuAFSAddCheckoutItemDetails(p_UID, p_dQty, p_dPrice, p_dTax, p_Description, p_sModel, p_sMSKU, p_sImage, p_sUnits, p_sShipping, p_sOrigin, p_Weight, p_Type, p_bLookup) {
// Walk Data Table extracing Values
var oTD, oTB, oCell, i;
var oPrice, oTitle, oTax, oModel, oMSKU, oImage, oUnit, oType;
var sPrice, sTitle, dTax, sModel, sMSKU, sImage, sUnits, dQty, sOrigin, sShipping, sType;
dQty = p_dQty;
sPrice = p_dPrice;
sTitle = p_Description;
dTax = p_dTax;
sModel = p_sModel;
sMSKU = p_sMSKU;
sImage = p_sImage;
sUnits = p_sUnits;
sType = p_Type
//p_sUnits, p_sShipping, p_sOrigin
sOrigin = p_sOrigin
sShipping = p_sShipping;
//sWeight = String(Number(p_dQty) * Number(p_Weight));
sWeight = String(Number(p_Weight));
if(p_bLookup) {
oPrice = oTitle = oTax = oModel = oMSKU = oImage = null;
oTB = jsuAll(p_sUID);
if(oTB != null){
if(dQty <= 0) dQty = 1;
if(sPrice.length == 0) {
oPrice = jsuAll(oTB, "uItem.uCommerce.Price.Value");
if(oPrice != null) sPrice = oPrice.innerHTML;
}
if(sTitle.length == 0) {
oTitle = jsuAll(oTB, "uItem.uDisplay.uMedia.Title.Value");
if(oTitle != null) sTitle = oTitle[0].innerHTML;
}
if(dTax == 0) {
oTax = jsuAll(oTB, "uItem.uInventory.Tax.Value");
if(oTax != null) dTax = oTax.innerHTML;
}
if(sType.length == 0) {
oType = jsuAll(oTB, "uItem.uDetails.ItemType.Value");
if(oType != null) sType = oType.innerHTML;
}
if(sModel.length == 0) {
oModel = jsuAll(oTB, "uItem.uCommerce.Model.Value");
if(oModel != null) sModel = oModel.innerHTML;
}
if(sMSKU.length == 0) {
oMSKU = jsuAll(oTB, "uItem.uInventory.MSKU.Value");
if(oMSKU != null) sMSKU = oMSKU.innerHTML;
}
if(sImage.length == 0) {
oImage = jsuAll(oTB, "uItem.uDisplay.uMedia.Image.Icon.Value");
if(oImage != null) sImage= oImage.innerHTML;
}
if(sUnits.length == 0) {
oUnit = jsuAll(oTB, "trUnitsMeasure");
if(oUnit != null) sUnits= oUnit.innerHTML;
}
}
}
top.jsuAFSAddCheckoutData(dQty, sPrice, dTax, sTitle, sModel, sMSKU, p_sUID, sImage, sUnits, sShipping, sOrigin, sShipping, sOrigin, sWeight, sType);
}
function jsuAFSImportTemplateDataType(p_oDisplayCell, p_oDataTable, p_sTemplateType) {
var oTmpl = top.document.getElementById(p_sTemplateType + "Template");
var oWork = top.document.getElementById("dvAFSStoreTemplatesWorkArea");
var sDataTemp = "";
var sUIDItem = (p_oDataTable.id);
//top.window.status = sUIDItem;
//alert(p_oDataTable.outerHTML);
var oTblClone = null;
if(oTmpl && oWork) {
oWork.innerHTML = "";
oTblClone = oTmpl.cloneNode(true);
oWork.appendChild(oTblClone);
// Switch to iFrame Data Doc
p_oDisplayCell.innerHTML = oWork.innerHTML;
oWork = p_oDisplayCell;
oTblClone = oWork.firstChild;
//alert(oTblClone.innerHTML);
//var oTablesGroup = null;
var oRows = oTblClone.rows;
var oCells = null;
var xCell = null;
var xDCell = null;
var oNode = null;
var oAnchor = null;
var oImage = null;
var sNodeName = "";
var sNodeData = "";
var sAnchorData = "";
var sAnchorDataClose = "";
var sDataType = "";
var s0, s1, s2, iFactor, dValue, i, j;
//alert(oRows.length);
var xAnchor = null;
//var xImage = document.getElementById("uItem.uDisplay.uMedia.Image.Value");
if(p_sTemplateType != "Item") {
xAnchor = jsuAll(p_oDataTable, "uItem.uDisplay.uMedia.Anchor.Value");
if(xAnchor.length != undefined) xAnchor = xAnchor[0];
if(document.all) {
sAnchorData = "";
} else {
sAnchorData = "";
}
sAnchorDataClose = "";
}
var oChildTables = oTblClone.getElementsByTagName("TABLE");
for(k = 0; k < oChildTables.length + 1; k++) {
if (k ==0) {
oRows = oTblClone.rows;
} else {
oRows = oChildTables[k-1].rows;
}
for(j = 0; j < oRows.length; j++) {
oCells = oRows[j].cells;
for(i = 0; i < oCells.length; i++) {
xCell = oCells[i];
if (xCell.getAttribute("UPRType") != null || xCell.getAttribute("uprtype") != null) {
sDataType = (xCell.getAttribute("UPRType") || xCell.getAttribute("uprtype") );
sNodeName = xCell.innerHTML;
xDCell = jsuAll(p_oDataTable, sNodeName);
if(xDCell) {
if(xDCell.length == undefined) {
sNodeData = xDCell.innerHTML;
oNode = xDCell;
} else {
sNodeData = xDCell[0].innerHTML;
oNode = xDCell[0];
}
if(sDataType == "Image") {
if(p_sTemplateType == "Item" && xDCell.length > 1) sNodeData = xDCell[1].innerHTML;
try {
//oImage = oNode.parentNode.children[2].firstChild;
//oImage = oNode.parentNode.childNodes[2].childNodes[0];
//oImage = oNode.parentNode.childNodes[2].childNodes[0].cloneNode(false);
oImage = oNode.parentNode.childNodes[2].childNodes[0];
//oImage = oNode.parentNode.childNodes[2];
//oNode.parentNode.childNodes[2].removeChild(oNode.parentNode.childNodes[2].childNodes[0]);
if (oImage) {
oImage = oImage.parentElement;
//alert(oImage.src);
/*
xCell.innerHTML = "";
if(xAnchor) {
oAnchor = document.createElement("A");
oAnchor.target = "AFSStoreFrame";
oAnchor.href = xAnchor.innerHTML;
xCell.appendChild(oAnchor);
oAnchor.appendChild(oImage);
} else {
xCell.appendChild(oImage);
}
*/
xCell.innerHTML = "";
if(xAnchor && xCell.getAttribute("UPRAnchor") != "False" ) {
oAnchor = document.createElement("A");
oAnchor.target = "AFSStoreFrame";
oAnchor.href = xAnchor.innerHTML;
xCell.appendChild(oAnchor);
//oAnchor.appendChild(oImage);
oAnchor.innerHTML = oImage.innerHTML;
} else {
//xCell.appendChild(oImage);
xCell.innerHTML = oImage.innerHTML;
}
}
} catch(e) { oImage = null; }
if(oImage == null) {
//alert(top.gblAFSDomainLocation);
if(String(sNodeData).length == 0) {
xCell.innerHTML = "
";
//xCell.innerHTML = "";
} else {
if(document.all) {
xCell.innerHTML = sAnchorData + "
" + sAnchorDataClose;
} else {
xCell.innerHTML = sAnchorData + "
" + sAnchorDataClose;
}
}
}
} else {
if(sNodeName.indexOf("Title.Value") != -1) {
xCell.innerHTML = sAnchorData + sNodeData + sAnchorDataClose;
} else {
sValue = xCell.getAttribute("UPRFactor");
if(sValue != null && sValue != undefined) {
iFactor = parseInt(sValue, 10);
dValue = iFactor * Number(sNodeData);
sNodeData = String(dValue);
i = sNodeData.indexOf(".");
if(i == -1) {
sNodeData += ".00";
} else {
sNodeData += "00";
sNodeData = sNodeData.substr(0, i+3);
}
}
//if(oParent.getAttribute("uprshow")) alert(oParent["uprshow"]);
sValue = xCell.getAttribute("UPRShow");
if (sValue != null && sValue != undefined ) {
if (sValue == "Always") xCell.style.display = "";
else if (sValue == "Never") oParent.style.display = "none";
else if ( sValue == "Sometimes" && sNodeData.length > 0) xCell.style.display = "";
else if ( sValue == "Conditional" && xCell.getAttribute("UPRCondition") == sNodeData) xCell.style.display = "";
else if ( sValue == "Comparison" && String(xCell.getAttribute("UPRCompare")).indexOf(sNodeData) != -1) if(xCell.style.display == "") { xCell.style.display = "none"; jsuAFScRemoveNode(xCell) } else { xCell.style.display = ""; }
}
oParent = xCell.parentNode;
sValue = oParent.getAttribute("UPRShow");
if (sValue != null && sValue != undefined ) {
if (sValue == "Always") oParent.style.display = "";
else if (sValue == "Never") oParent.style.display = "none";
else if ( sValue == "Sometimes" && sNodeData.length > 0) oParent.style.display = ""; //if(oParent.style.display == "") { oParent.style.display = "none"; oParent.removeNode(true); } else { oParent.style.display = ""; }
else if ( sValue == "Conditional" && oParent.getAttribute("UPRCondition") == sNodeData) oParent.style.display = "";
else if ( sValue == "Comparison" && String(oParent.getAttribute("UPRCompare")).indexOf(sNodeData) != -1) if(oParent.style.display == "") { oParent.style.display = "none"; jsuAFScRemoveNode(oParent); } else { oParent.style.display = ""; }
}
if(String(sNodeData).length > 0) {
sValue = xCell.getAttribute("UPRPrefix");
if( sValue != null && sValue != undefined ) sNodeData = sValue + sNodeData;
sValue = xCell.getAttribute("UPRSuffix");
if( sValue != null && sValue != undefined ) sNodeData += sValue;
}
xCell.innerHTML = sNodeData;
}
/*
if(sNodeName.indexOf("Title.Value") != -1) {
xCell.innerHTML = sAnchorData + sNodeData + sAnchorDataClose;
} else {
if( (sNodeName.indexOf("Price.Value") != -1) || ( sNodeName.indexOf("Suggested.Value") != -1) ) sNodeData = "$" + sNodeData;
xCell.innerHTML = sNodeData;
}
*/
}
} else {
xCell.innerHTML = "REMOVED";
oParent = xCell.parentNode.parentNode;
if(oParent) {
oParent.removeChild(xCell.parentNode);
j--;
}
}
}
}
}
}
//UIDTemplateCurrent
//sUIDItem
sDataTemp = oWork.innerHTML;
i = 0;
while(i++ < 100 && sDataTemp.indexOf("UIDTemplateCurrent") != -1) {
//if(sDataTemp.indexOf("UIDTemplateCurrent") != -1)
sDataTemp = sDataTemp.replace("UIDTemplateCurrent", sUIDItem);
}
p_oDisplayCell.innerHTML = sDataTemp;
//p_oDisplayCell.innerHTML = oWork.innerHTML;
}
return null;
}
function jsuAFSCurrency(p_sNumber) {
var dValue, sValue, iPos, sOut;
dValue = iPos = 0;
sValue = String( Math.round ( Number( p_sNumber ) * 100 ) / 100 );
if( sValue.indexOf( "." ) == -1) sValue += ".";
sValue += "00";
iPos = sValue.indexOf(".") + 3;
sOut = String(sValue.substr(0, iPos));
//alert(String(p_sNumber) + " :: "+ String(sOut));
return sOut;
}
function jsUPREncode(pData) {
if (!pData) return;
var sOut = new String();
var sDat = "";
sOut = "UNC::";
for(var i = 0; i < pData.length; i++) {
sOut += pData.charCodeAt(i).toString(16);
}
if (sOut.length != pData.length * 2 + 5) {
sOut = "UNC::";
for(var i = 0; i < pData.length; i++) {
sDat = "0" + pData.charCodeAt(i).toString(16);
sOut += sDat.substr(sDat.length - 2, 2)
}
}
if (sOut.length != pData.length * 2 + 5) {
alert("Message Rejected CRC Error\n\nThe Message has been discarded.");
return false;
}
return sOut;
}
function jsUPRDecode(pData) {
if (!pData) return;
if (pData.lastIndexOf("UNC::") != 0) return;
var sOut = new String();
sOut = "";
for(var i = 5; i < pData.length - 1; i+=2) sOut += String.fromCharCode(Number("0x" + pData.substr(i, 2)).toString(10));
if (sOut.length != (pData.length - 5) / 2 ) {
alert("Message Rejected CRC Error\n\nThe Message has been discarded.");
return false;
}
return sOut;
}
//SearchGroups
function jsuSearchEncodeGroups() {
var oForm = document.forms["frmAFSSearch"];
var sSearch, sKey;
sSearch = sKey = "";
if(oForm.chkItemType) {
for(var i = 0; i < oForm.chkItemType.length; i++) {
xNode = oForm.chkItemType[i];
if (xNode.checked) {
sKey = String(xNode.value).toLowerCase();
if(sKey != "undefined" && sKey.length > 0) sSearch += sKey + " "
}
}
}
if(oForm.SearchCriteria) {
if(String(oForm.SearchCriteria.value).length > 0) {
//sSearch += jsUPREncode(String(frmAFSSearch.SearchCriteria.value).toLowerCase()) + " "
sSearch += jsUPREncode(String(oForm.SearchCriteria.value)) + " "
}
sSearch = sSearch.replace("UNC::", "");
}
return sSearch;
/*
var sSearch, sKey;
sSearch = sKey = "";
alert("a");
if(frmAFSSearch.chkItemType) {
for(var i = 0; i < frmAFSSearch.chkItemType.length; i++) {
xNode = frmAFSSearch.chkItemType[i];
if (xNode.checked) {
sKey = String(xNode.value).toLowerCase();
if(sKey != "undefined" && sKey.length > 0) sSearch += sKey + " "
}
}
}
if(frmAFSSearch.SearchCriteria) {
if(String(frmAFSSearch.SearchCriteria.value).length > 0) {
//sSearch += jsUPREncode(String(frmAFSSearch.SearchCriteria.value).toLowerCase()) + " "
sSearch += jsUPREncode(String(frmAFSSearch.SearchCriteria.value)) + " "
}
sSearch = sSearch.replace("UNC::", "");
}
alert("z");
return sSearch;
*/
}
function jsuSearchEncode() {
var oForm = document.forms["frmAFSSearch"];
var sSearch, sKey;
sSearch = sKey = "";
if(oForm.inpKeywords) {
sKey = String(oForm.inpKeywords.value).toLowerCase();
if(sKey != "undefined" && sKey.length > 0) sSearch += sKey + " "
}
if(oForm.inpPattern) {
sKey = String(oForm.inpPattern.value).toLowerCase();
if(sKey != "undefined" && sKey.length > 0) sSearch += sKey + " "
}
if(oForm.selBookName) {
sKey = String(oForm.selBookName.value);
if(sKey != "undefined" && sKey.length > 0) sSearch += jsUPREncode(sKey) + " " + "426F6F6B" + " ";
}
if(oForm.selStyleDesigner) {
sKey = String(oForm.selStyleDesigner.value);
if(sKey != "undefined" && sKey.length > 0) sSearch += String(sKey) + " "
}
if(oForm.selCategory) {
sKey = String(oForm.selCategory.value);
if(sKey != "undefined" && sKey.length > 0) sSearch += String(sKey) + " "
}
if(oForm.selManufacturer) {
sKey = String(oForm.selManufacturer.value);
if(sKey != "undefined" && sKey.length > 0) sSearch += String(sKey) + " "
}
if(oForm.selDesign) {
sKey = String(oForm.selDesign.value);
if(sKey != "undefined" && sKey.length > 0 && sKey.indexOf("All Designs") == -1) sSearch += String(sKey) + " "
}
if(oForm.selColor) {
sKey = String(oForm.selColor.value);
if(sKey != "undefined" && sKey.length > 0 && sKey.indexOf("All Colors") == -1) sSearch += String(sKey) + " "
}
sSearch = sSearch.replace("UNC::", "");
return sSearch;
}
function jsuSearchString(p_sString) {
var oForm = document.forms["frmAFSSearch"];
oForm.Search.value = p_sString;
oForm.SearchGroups.value = jsuSearchEncodeGroups();
oForm.submit();
}
function jsuSearchGroupedString(p_sGroup, p_sString) {
var oForm = document.forms["frmAFSSearch"];
oForm.Search.value = p_sString;
oForm.SearchGroups.value = p_sGroup;
oForm.submit();
}
function jsuSearchSubmit() {
var oForm = document.forms["frmAFSSearch"];
oForm.Search.value = jsuSearchEncode();
oForm.SearchGroups.value = jsuSearchEncodeGroups();
oForm.submit();
}
/* *********************************************************** */
/* Fire Fox / Internet Explorer Compatibility Functions */
/* *********************************************************** */
function jsuAFScRemoveNode(p_Object) {
jsuAFScRemoveNodeEx(p_Object, true);
}
function jsuAFScRemoveNodeEx(p_Object, p_Content) {
if(document.all) {
p_Object.removeNode(p_Content);
} else {
p_Object.parentNode.removeChild(p_Object);
}
}