Показать сообщение отдельно
  #2 (permalink)  
Старый 25.08.2011, 14:22
Интересующийся
Отправить личное сообщение для Lexxbry Посмотреть профиль Найти все сообщения от Lexxbry
 
Регистрация: 25.08.2011
Сообщений: 10

//Load Data
function imCLoad(sInName) {
var sName = (sInName==""?imName:sInName);
var sGetName = imGetCookie("imName");
if(sGetName != sName)
imCEmptyCart(sName,true);
}

//show cartegory
function imCShowCateg(sKey) {
imCLoad("");
var sBuf = "";
var bFound = false;
for(var i = 0; i < imCProducts.length;i++)
if(imCProducts[i][0] == sKey && imCProducts[i][5] != 0)
bFound = true;
sBuf += "<form name=\"imForm\"><table><tr>";
sBuf += "<th class=\"imName\">" + imLocale["Name"] + "</th>";
sBuf += "<th class=\"imDescr\">" + imLocale["Descr"] + "</th>";
if(bFound)
sBuf += "<th class=\"imOpt\">" + imLocale["Opt"] + "</th>";
sBuf += "<th class=\"imPrice\">" + imLocale["Price"] + "</th>";
sBuf += "<th class=\"imQty\">" + imLocale["Qty"] + "</th>";
sBuf += "<th class=\"imCmd\">&nbsp;</th></tr>";
var j;
for(var i = 0; i < imCProducts.length;i++){
if(imCProducts[i][0] == sKey){
sBuf += "<tr><td class=\"imName\">" + imCProducts[i][2] + "</td>";
sBuf += "<td class=\"imDescr\"> " + imCProducts[i][3] + "</td>";
if(bFound) {
sBuf += "<td class=\"imOpt\">";
if(imCProducts[i][5] != 0) {
sBuf += "<select class=\"imOptField\" name=\"imOpt"+ i + "\">";
for(j = 0; j < imCProducts[i][5].length;j++){
sBuf += "<option value=\"" + (j+1) + "\">" + imCProducts[i][5][j] + "</option>";
}
sBuf += "</select>";
}
sBuf += "</td>";
}
sBuf += "<td class=\"imPrice\">" + imCFormat(imCProducts[i][4],false) + "</td>";
sBuf += "<td class=\"imQty\"><input class=\"imQtyField\" name=\"imQty"+ i + "\" type=\"text\" value=\"1\" size=\"4\" maxlength=\"4\" /></td>";
sBuf += "<td class=\"imCmd\"><img src=\"res/imcartadd.gif\" onclick=\"imCAddProd('" + imCProducts[i][0] + "','" + imCProducts[i][1] + "'," + (imCProducts[i][5] != 0 ? "document.imForm.imOpt"+ i + ".value" : "0") + ",document.imForm.imQty" + i + ".value,false,true);\" /></td>";
sBuf += "</tr>";
}
}
sBuf += "</table></form>";
document.write(sBuf);
}

//get all cart products
function imCGetCart(bReport) {
imCLoad("");
var sBuf = "";
var iTotal = 0;
var i,j;
var bFound = false;
var sCart = imGetCookie("imOrder");
var aCart = "";
if(sCart != null && sCart != "")
aCart = sCart.split("|");
else
aCart = new Array();
for(i = 0;i < aCart.length && !bFound;i++) {
aCartProd = aCart[i].split(":");
if(aCartProd[2] != 0)
bFound = true;
}
sBuf += "<table><tr>";
sBuf += "<th class=\"imDescr\">" + imLocale["Descr"] + "</th>";
if(bFound)
sBuf += "<th class=\"imOpt\">" + imLocale["Opt"] + "</th>";
sBuf += "<th class=\"imPrice\">" + imLocale["Price"] + "</th>";
sBuf += "<th class=\"imQty\">" + imLocale["Qty"] + "</th>";
sBuf += "<th class=\"imPrice\">" + imLocale["SubTot"] + "</th>";
if(!bReport)
sBuf += "<th class=\"imCmd\">&nbsp;</th></tr>";
if(aCart.length == 0)
sBuf += "<tr><td colspan=\"5\">" + imLocale["Err_EmptyCart"] + "</td></tr>";
else
for(i = 0;i < aCart.length;i++){
aCartProd = aCart[i].split(":");
aProd = imCGetProduct(aCartProd[0],aCartProd[1]);
sBuf += "<tr><td class=\"imDescr\">" + aProd[2] + " - " + aProd[3] + "</td>";
if(bFound) {
sBuf += "<td class=\"imOpt\">";
if(aProd[5] != 0 && !bReport) {
sBuf += "<select name=\"imOpt"+ i + "\" class=\"imOptField\" onchange=\"imCDelProd('" + aCartProd[0] + "','" + aCartProd[1] + "','" + aCartProd[2] + "',false); imCAddProd('" + aCartProd[0] + "','" + aCartProd[1] + "',this.value,imGetLayer('imQty" + i + "').value,false,true);\">";
for(j = 0; j < aProd[5].length; j++)
sBuf += "<option value=\"" + (j+1) + "\"" + (j+1 == parseInt(aCartProd[2]) ? " selected=\"selected\"" : "") + ">" + aProd[5][j] + "</option>";
sBuf += "</select>";
}
else if(aProd[5] != 0 && bReport)
sBuf += aProd[5][aCartProd[2]-1];
sBuf += "</td>";
}
sBuf += "<td class=\"imPrice\"> " + imCFormat(aProd[4],false) + "</td>";
sBuf += "<td class=\"imQty\">" + (bReport ? aCartProd[3] : "<input type=\"text\" id=\"imQty" + i + "\" class=\"imQtyField\" onchange=\"imCAddProd('" + aCartProd[0] + "','" + aCartProd[1] + "','" + aCartProd[2] + "',this.value,true,true);\" onkeypress=\"if(imIsEnter(event)) {imCAddProd('" + aCartProd[0] + "','" + aCartProd[1] + "','" + aCartProd[2] + "',this.value,true,true); return false;}\" value=\"" + aCartProd[3] + "\" size=\"4\" />") + "</td>";
sBuf += "<td class=\"imPrice\"> "+ imCFormat(aProd[4]*aCartProd[3],false) + "</td>";
iTotal += aProd[4]*aCartProd[3];
if(!bReport)
sBuf += "<td class=\"imCmd\"><img onclick=\"imCDelProd('" + aCartProd[0] + "','" + aCartProd[1] + "','" + aCartProd[2] + "',true);\" src=\"res/imcartdel.gif\" /></td>";
sBuf += "</tr>";
}
if(!bReport){
if(aCart.length != 0) {
sBuf += "<tr><td colspan=\"" + (bFound ? 4 : 3) + "\" style=\"text-align: right; \">" + imLocale["Total"] + ":</td>";
sBuf += "<td style=\"text-align: right; \"><b>" + imCFormat(iTotal,false) + "</b></td></tr>";
}
}
else {
iShipmentType = imGetCookie("imShipment");
if(iShipmentType == null)
iShipmentType = 0;
sBuf += "<tr><td colspan=\"" + (bFound ? 4 : 3) + "\">" + imCShipment[iShipmentType][0] + "</td>";
sBuf += "<td style=\"text-align: right;\"> " + imCFormat(imCShipment[iShipmentType][2],false) + "</td></tr>";
sBuf += "<tr><td colspan=\"" + (bFound ? 4 : 3) + "\" style=\"text-align: right; border: none; \">" + imLocale["Total"] + ":</td>";
sBuf += "<td style=\"text-align: right; border: none; \"><b>" + imCFormat(iTotal+Number(imCShipment[iShipmentType][2]),false) + "</b></td></tr>";
if (imVAT != 0) {
sBuf += "<tr><td colspan=\"" + (bFound ? 4 : 3) + "\" style=\"text-align: right; border: none; \">" + imLocale["TotalVAT"] + " (" + imVAT + "%)" + ":</td>";
sBuf += "<td style=\"text-align: right; border: none; \"><b>" + imCFormat((iTotal+Number(imCShipment[iShipmentType][2]))*Number(1+imVAT/100),false) + "</b></td></tr>";
}
}
sBuf += "</table>";
document.write(sBuf);
}

//Show Shipment options
function imCShowShipment(){
var sBuf = "";
var sCart = imGetCookie("imOrder");
if(sCart == null)
sCart = "";
var iShipmentType = imGetCookie("imShipment");
if(iShipmentType == null)
iShipmentType = 0;
for(var i = 0;i < imCShipment.length;i++)
sBuf += "<p class=\"imShipItem\"><label for=\"imOption" + i + "\"><input name=\"imOption\" id=\"imOption" + i + "\" type=\"radio\" " + ( (i == iShipmentType) ? "checked=\"checked\"" : "" ) + "/><b>" + imCShipment[i][0] + "</b>" + (imCShipment[i][2] != 0 ? " (" + imCFormat(imCShipment[i][2],false) + ")" : "") + "<br />" + imCShipment[i][1] + "</label></p>";
sBuf += "<p class=\"imAlign_center\"><input type=\"button\" class=\"imCartButton\" value=\"" + imLocale["GoShop"] + "\" onclick=\"imOpenLocation('" + imShopPage + "')\" /><input type=\"button\" class=\"imCartButton\" value=\"" + imLocale["EmptyCart"] + "\" onclick=\"imCEmptyCart('',false);\" />";
if(sCart != "")
sBuf += "<input type=\"submit\" class=\"imCartButton\" value=\"" + imLocale["GoNext"] + "\" />";
document.write(sBuf);
}
//add shipment cost
function imCCheckout(){
var i = 0;
var bTrov = false;
for(var j = 0;j < document.frmShipment.length && !bTrov; j++)
if(document.frmShipment[j].name == "imOption"){
if(document.frmShipment[j].checked==true){
iShipmentType = i;
bTrov = true;
}
i++;
}
imSetCookie("imShipment",iShipmentType,imExpireDay s);
imOpenLocation("imform.html");
}

//get user info
function imCGetUserData() {
var j = 0;
var sUserData = imGetCookie("imData");
if(sUserData != null && sUserData != "") {
var aUserData = sUserData.split("|");
sUserData = "";
for(var i = 0;i < document.imFormTableDat.elements.length;i++) {
if(document.imFormTableDat.elements[i].name == "imTxtDat") {
if(aUserData[j] == "")
document.imFormTableDat.elements[i].value="";
else
document.imFormTableDat.elements[i].value=aUserData[j];
aUserData[j] = imCLabels[j] + "::" + aUserData[j];
j++;
}
}
}
return aUserData.join("||");
}
Ответить с цитированием