
function appendItemToOrder(nItemId,sid){
   document.location="/core/catalog/server.Catalog.php?action=AppendItemToOrder&itemid="+nItemId+"&client=notIE&PHPSESSID="+sid;
}

function compareArticle(id)
{
	window.open('/compare.php?id='+id,'compare','Toolbar=0,Location=0,Directories=0,Status=0,Menubar=0,Scrollbars=1,Resizable=1,Width=800,Height=600');
}

function onAppendingDone(s, oCaller){
        var nWidth = 300;
        var nHeight = 150;
        var sContent = s+"<BR><BR>Успешно Добавлено в Корзину!";
        var sTitle = "Ваш Заказ";
                appendServerDialogContent(nWidth, nHeight, sTitle, sContent);
}

function calculateAmount(nItemId, oObj,frm) {
        var oTarget = xoopsGetElementById("oTDAmount["+nItemId+"]");
        var exchange = xoopsGetElementById("oExchange");
        var nRetail = xoopsGetElementById("oTDRetail["+nItemId+"]").innerHTML*1*exchange.value;
                oTarget.innerHTML = Math.round(nRetail*oObj.value * 100)/100;
                calculateTotalAmount();            
}

function calcDost(nItemId, oObj){
        var oTarget = xoopsGetElementById("oCost");
        var oTargetD = xoopsGetElementById("oDcost");
        var oTargetDu = xoopsGetElementById("oDucost");
        var oTargetDur = xoopsGetElementById("oDcostreal");
                if(oObj.checked){
                        oTarget.innerHTML = oTargetDu.value;
                        oTargetDur.value = oTargetDu.value;
                }
                else {
                        oTarget.innerHTML = oTargetD.value;
                        oTargetDur.value = oTargetD.value;
                }
}

function deleteItemFromOrder(nItemId){
        xoopsGetElementById("oOrderAction").value = "deleteItem";
        xoopsGetElementById("oOrderItemId").value = nItemId;
        xoopsGetElementById("oOrderForm").submit();
}

function calculateTotalAmount() {
        var exchange = xoopsGetElementById("oExchange");
        var oTarget = xoopsGetElementById("oOrderTotal");
        var nTotal = 0;
        var aCells;
        var aRows = xoopsGetElementById("oOrderContent").rows("oDataRow");
        if(aRows.length)
                for(var i=0; i<aRows.length; i++) {
                        aCells = aRows.item(i).cells;
                        nTotal+= aCells[aCells.length-2].innerHTML*1
                }
        else {
                aCells = aRows.cells;
                nTotal+= aCells[aCells.length-2].innerHTML*1
        }
        oTarget.innerHTML = Math.round(nTotal * 100)/100;
}

function submitOrder(sMsg){
                //if (xoopsGetElementById("customerOrderInfo[Phone]").value==""){
                       // alert(sMsg);
                  //      return;
               // }
                //if (xoopsGetElementById("customerOrderInfo[Name]").value==""){
                      //  alert(sMsg);
                     //   return;
               // }
        xoopsGetElementById("oOrderAction").value = "submitOrder";
        xoopsGetElementById("oOrderForm").submit();
}
function onShopWindowTableMouseOver(oObj, sText) {
        oObj.title = (event.srcElement.tagName != 'DIV' ? sText : '');
}
function onShopWindowTableClick(sUrl) {
        if(event.srcElement.tagName != 'DIV')
                document.location.href = sUrl;
}
function onShopWindowDIVMouseEvent(oObj, sClassName) {
        var oDescription, oRetail;
        switch(oObj.id) {
                case "Description":
                        oObj.className = sClassName;
                        oObj.parentNode.parentNode.parentNode.lastChild.firstChild.firstChild.rows.item(0).cells.item(1).firstChild.className = sClassName;
                break;
                case "Retail":
                        oObj.className = sClassName;
                        oObj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes(1).firstChild.firstChild.className = sClassName;
                break;
                case "Detailes":
                        oObj.parentNode.parentNode.childNodes(1).firstChild.className = sClassName;
                        oObj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes(1).firstChild.firstChild.className = sClassName;
                break;
        }
}

function onShopWindowDIVMouseClick(sUrl) {
        document.location.href = sUrl;
}