var bskCount; document.cookie && (bskCount = document.cookie.toString().match(/ShopItem/g)); bskCount = bskCount==undefined? 0 : bskCount.length; //------------------------------ function saveComment(btn) { if(isEmpty(gel('Cname'))) { alert('لطفا نام خود را وارد کنید'); gel('Cname').focus(); return; } if(!isInt(gel('Ctel'),true)) { alert('لطفا تلفن را درست وارد کنید'); gel('Ctel').focus(); return; } if(isEmpty(gel('Ctext'))) { alert('متن خالیست'); gel('Ctext').focus(); return; } gel('ImgLoad01').style.display=''; btn.disabled=true; reGetFromHttpRequest('post','http://www.toosporcelain.com/Responser.aspx','FrmContact',function(){ gel('ImgLoad01').style.display='none'; if(result=="1") alert('درخواست شما ارسال گردید. با تشکر'); else alert('خطا در ارتباط با سرور. لطفا مجددا سعی کنید'); btn.disabled=false; }); } //------------------------------ function addItem(id, x, noeffect) { if(!isPositive(gel('OrderCount'+id+'_'+x))) { alert("تعداد محصول نامعتبر است"); gel('OrderCount'+id+'_'+x).focus(); return; } if(noeffect) addItemToBasket(id, x, false); else { window.scrollTo(0,140); expandBasket('',true); setTimeout(function(){ addItemToBasket(id, x, true); }, 400); } } //------------------------------ function addItemToBasket(id, x, witheffect) { var pVal= new Array(); pVal[0] = gel('Pid'+id+'_'+x).value; pVal[1] = gel('Pname'+id+'_'+x).value; pVal[2] = gel('Price'+id+'_'+x).value; pVal[3] = gel('OrderCount'+id+'_'+x).value; if(gel('ExtraParam'+id+'_'+x)!=null && gel('ExtraParam'+id+'_'+x).value!='' && gel('ExtraParam'+id+'_'+x).value.indexOf('|')!=-1) { var tmp = gel('ExtraParam'+id+'_'+x).value.split('|'); pVal[4] = tmp[0]; pVal[5] = tmp[1]; } else { pVal[4] = '0'; pVal[5] = ''; } pValStr = pVal.join('^'); if(setCookie("ShopItem["+id+"_"+pVal[4]+"]", pValStr, 10, "/")) { if( gel('BskRow'+id+'_'+pVal[4]) ) { var countDiff = pVal[3] - toInt('SpOrdCnt'+id+'_'+pVal[4]); //toInt('BskTotalPrice')-(parseInt(pVal[2]).value)*toInt('SpOrdCnt'+id+'_'+pVal[4])); gel('SpOrdCnt'+id+'_'+pVal[4]).innerHTML = getDigit(pVal[3],'FA'); var tmpTotal = toInt('BskTotalPrice') + (countDiff*parseInt(pVal[2])); gel('BskTotalPrice').innerHTML = getDigit(tmpTotal,'FA'); gel('SpOrdCnt'+id+'_'+pVal[4]).style.backgroundColor='#4C5558'; if(witheffect) setTimeout(expandBasket, 1200); } else { bskCount++; var liRow = document.createElement('li'); liRow.id='BskRow'+id+'_'+pVal[4]; liRow.style.backgroundColor='#EE3915'; liRow.innerHTML = "" + getDigit(bskCount,'FA') + "- " + pVal[1] + " - " + (pVal[4]!='0'? pVal[5] + ' - ' : '') + "" + getDigit(pVal[2],'FA') + " ريال" + " ( تعداد: " + getDigit(pVal[3],'FA') + " )"; gel('BasketItems').appendChild(liRow); if(witheffect) { var effectObj = new Effect('BskRow'+id+'_'+pVal[4], 'expand', true, [50,16,0]); effectObj.afterEffect = function(){ setTimeout(expandBasket, 1400); } effectObj.run(); } gel('BskTotalCount').innerHTML = getDigit(toInt('BskTotalCount')+1,'FA'); var tmpTotal = toInt('BskTotalPrice')+(parseInt(pVal[2])*parseInt(pVal[3])); gel('BskTotalPrice').innerHTML = getDigit(tmpTotal,'FA'); gel('BskTotalCount').style.backgroundColor='#3E434A'; } gel('BskTotalPrice').style.backgroundColor='#3E434A'; var bskBtn = gel('Btn'+id+'_'+pVal[4]); if(bskBtn) { bskBtn.innerHTML && (bskBtn.innerHTML= 'اصلاح'); bskBtn.value && (bskBtn.value = 'اصلاح'); } if(gel('ProdRow'+id+'_'+x)) { var efObj = new Effect('ProdRow'+id+'_'+x,'animColor','background-color',[50,'#FFDC00','#F0F1E5']); efObj.run(); } } else { //window.location='http://www.toosporcelain.com/Responser.aspx?Action=AddToBasket&R=1&q='+escape(pValStr); alert('er'); } } //------------------------------ function toInt(objId) { return parseInt(getDigit(gel(objId).innerHTML,'en')); } //------------------------------ function delFromBsk(id, x) { if(!confirm('آیا مطمئن هستید?')) return; if(!deleteCookie('ShopItem['+id+'_'+x+']')) { // window.location='Responser.aspx?Action=DelFromBasket&R=1&q='+id+'_'+x; return; } gel('BskTotalCount').innerHTML = getDigit(toInt('BskTotalCount')-1,'FA'); var tmpTotal = toInt('BskTotalPrice') - (toInt('SpOrdCnt'+id+'_'+x)*toInt('SpPrice'+id+'_'+x)); gel('BskTotalPrice').innerHTML = getDigit(tmpTotal,'FA'); var efObj = new Effect(gel('BskRow'+id+'_'+x),'fade',false); efObj.afterEffect = function() { gel('BasketItems').removeChild(gel('BskRow'+id+'_'+x)); gel('BskTotalCount').style.backgroundColor='#3E434A'; gel('BskTotalPrice').style.backgroundColor='#3E434A'; var bskBtn = (x!=0? gel('Btn'+id+'_'+x) : gel('Btn'+id)); if(bskBtn) { bskBtn.innerHTML && (bskBtn.innerHTML= 'افزودن به سبد خرید'); bskBtn.value && (bskBtn.value = 'سفارش'); } bskCount--; } efObj.run(); }