

$.fn.image = function (src, f) {return this.each(function () {var i = new Image;i.src = src;i.onload = f;});};
function next_cat() {$("#cat_pro").hide("slide", {direction:"right"}, 1000, function () {x = 0;x = cat_act * 6;if (cat_act + 1 == cat_box) {$("#lcat").css("display", "none");}$("#rcat").show();for (i = 1; i < 6; i++) {if (cat_data[x]) {picitem = "#pcat" + i;texitem = "#tcat" + i;$(picitem).html("<a href=\"sh_cat.php?id=" + cat_data[x][0] + "\"><img src=\"pic/cat/" + cat_data[x][2] + "\" width=\"80\" height=\"90\" border=\"0\"></a>");$(texitem).html(cat_data[x][1]);} else {picitem = "#pcat" + i;texitem = "#tcat" + i;$(picitem).html("&nbsp;");$(texitem).html("&nbsp;");}x++;}});$("#cat_pro").show("slide", {direction:"right"}, 1000, function () {cat_act++;});}

function prev_cat() {$("#cat_pro").hide("slide", {direction:"right"}, 1000, function () {cat_act--;if (cat_act == 1) {$("#rcat").css("display", "none");}if (cat_act != cat_box) {$("#lcat").show();}x = cat_act * 6;for (i = 5; i > 0; i--) {if (cat_data[x - 1]) {picitem = "#pcat" + i;texitem = "#tcat" + i;$(picitem).html("<a href=\"sh_cat.php?id=" + cat_data[x - 1][0] + "\"><img src=\"pic/cat/" + cat_data[x - 1][2] + "\" width=\"80\" height=\"90\"  border=\"0\"></a>");$(texitem).html(cat_data[x - 1][1]);}x--;}});$("#cat_pro").show("slide", {direction:"right"}, 1000);}

function login_mem(){var memusr = $("#mem_user").val();var mempas = $("#mem_pass").val();if ((memusr.length < 6) || (mempas.length < 6)){alert ('نام کاربری و رمز عبور خود را درست وارد کنید');}else{$("#accm").val(memusr);$("#pasm").val(mempas);document.memberform.submit();}}

function paybut() {if (gheymat_item_box == 0) {$("#boxpay").html("<span class='shop_box_red_item'>هیچ محصولی انتخاب ننموده اید</span>");} else {$("#boxpay").html("<a href=\"payreg.php\"><img border=\"0\" src=\"images/shop_box/pay.gif\" width=\"149\" height=\"50\" id=\"btnpay\" style=\"display:none\"></a>");$("#btnpay").fadeIn(500);}}

function dump_item(id) {$.post("dump.php", {items:id});x = "#trshop" + id;order_item = 0;for (i = 1; i <= cnt_sel_item_box; i++) {if (sel_item_box[i]) {if (sel_item_box[i][0] == id) {order_item = i;}}}gheymat_item_box -= parseInt(sel_item_box[order_item][2]) * parseInt(sel_item_box[order_item][3]);$("#gheymatkol").html(gheymat_item_box);paybut();sel_item_box[order_item] = null;$(x).remove();}
function minez(id) {order_item = 0;for (i = 1; i <= cnt_sel_item_box; i++) {if (sel_item_box[i]) {if (sel_item_box[i][0] == id) {order_item = i;}}}if (sel_item_box[order_item][3] > 1) {gheymat_item_box -= parseInt(sel_item_box[order_item][2]);$("#gheymatkol").html(gheymat_item_box);sel_item_box[order_item][3]--;x = "#cnt" + sel_item_box[order_item][0];$(x).html(sel_item_box[order_item][3]);$.post("regm.php", {items:id});}}

function Regitem(id) {pluscnt = "Y";notFor = "N";if (cnt_sel_item_box == 0) {cnt_sel_item_box = 1;notFor = "Y";paybut();} else {for (i = 1; i <= cnt_sel_item_box; i++) {if (sel_item_box[i]) {if (sel_item_box[i][0] == id) {pluscnt = "N";}}}}$.post("reg.php", {items:id}, function (data) {cnt = data;chk = "N";if (notFor == "N") {for (ii = 1; ii <= cnt_sel_item_box; ii++) {if (sel_item_box[ii]) {if (sel_item_box[ii][0] == id) {cnt++;cnt--;sel_item_box[ii][3] = cnt;x = "#cnt" + sel_item_box[ii][0];$(x).html(cnt);chk = "Y";gheymat_item_box += parseInt(sel_item_box[ii][2]);$("#gheymatkol").html(gheymat_item_box);}}}}if (chk == "N") {if (pluscnt == "Y") {cnt_sel_item_box++;}sel_item_box[cnt_sel_item_box] = new Array(id, $("#nameitem" + id).html(), $("#pricitem" + id).html(), "1");gheymat_item_box += parseInt(sel_item_box[cnt_sel_item_box][2]);$("#gheymatkol").html(gheymat_item_box);$("#mastershop").after("<tr id=\"trshop" + sel_item_box[cnt_sel_item_box][0] + "\"><td height=\"25\" align=\"center\" valign=\"middle\"><img src=\"images/shop_box/del.gif\" width=\"14\" height=\"14\" class=\"cur\" onClick=\"dump_item(" + id + ");\"></td><td width=\"20\" height=\"25\" align=\"center\" valign=\"middle\"><img src=\"images/shop_box/min.gif\" width=\"13\" height=\"14\" class=\"cur\" onClick=\"minez(" + id + ");\"></td><td width=\"20\" height=\"25\" align=\"center\" valign=\"middle\"><img src=\"images/shop_box/add.gif\" width=\"13\" height=\"14\" class=\"cur\" onClick=\"Regitem(" + id + ");\"></td><td width=\"20\" height=\"25\" align=\"center\" valign=\"middle\" class=\"Snmr\" id=\"cnt" + sel_item_box[cnt_sel_item_box][0] + "\">1</td><td style=\"direction:rtl;padding-right:3px\" height=\"25\" align=\"right\" valign=\"middle\" class=\"Snmr\" id=\"nam" + sel_item_box[cnt_sel_item_box][0] + "\"><a style=\"color:#000000;text-decoration:none\" href=\"item.php?id=" + id + "\"> " + sel_item_box[cnt_sel_item_box][1] + "</a></td> </tr>");paybut();}});}

function showpicla(id) {$("body").append("<div id=\"pic_la\" style=\"left:0 ;top:0; z-index: 90; width: 100%; height: 500px; background-color: rgb(0, 0, 0); opacity: 0.8;\"  ></div> <div id=\"pic_load\" style=\"width:100%;z-index:100;position: absolute; text-align:center; display:none;\"><a target=\"_blank\" id=\"linka\" href=''><img id=\"img" + id + "\" width=\"31\" height=\"31\" src=\"images/load.gif\" style=\"display:inline;\" border=\"0\"></a><br><img id=\"close\" width=\"70\" class=\"cur\" onClick=\"finish('" + id + "')\"  height=\"25\" src=\"images/shop_box/clos.png\" ><img width=\"200\" src=\"images/blank.gif\" height=\"25\"></div>");var arrPageSizes = ___getPageSize();$("#pic_la").width(arrPageSizes[0]);$("#pic_la").height(arrPageSizes[1]);$("#pic_la").css("top", "0");$("#pic_la").css("left", "0");$("#pic_la").css("position", "absolute");var arrPageScroll = ___getPageScroll();$("#pic_la").show("scale", {}, 1000, function () {$("#pic_load").css({margin:"0 auto", top:arrPageScroll[1] + arrPageSizes[3] / 10, left:arrPageScroll[0]}).fadeIn(1000);$().image(arr_gaal[id], function () {$("#img" + id).fadeOut(500, function () {$("#img" + id).css("border", "6px solid #FFFFFF");$("#img" + id).attr("src", arr_gaal[id]);document.getElementById("linka").href = arr_gaal[id];$("#img" + id).width(240);$("#img" + id).height(260);$("#img" + id).fadeIn(500);});});});}

function finish(id) {$("#close").fadeOut(500);$("#img" + id).fadeOut(500, function () {$("#pic_load").remove();$("#pic_la").hide("scale", {}, 1000, function () {$("#pic_la").remove();});});}

function dumpItem(id) {if (!confirm("\xD8\xA2\xDB\x8C\xD8\xA7 \xD8\xA7\xD8\xB2 \xD8\xAD\xD8\xB0\xD9\x81 \xD8\xA7\xDB\x8C\xD9\x86 \xDA\xA9\xD8\xA7\xD9\x84\xD8\xA7 \xD9\x85\xD8\xB7\xD9\x85\xD8\xA6\xD9\x86 \xD9\x87\xD8\xB3\xD8\xAA\xDB\x8C\xD8\xAF \xD8\x9F")) {} else {$.post("dump.php", {items:id});prc = $("#pric" + id).html();cnt = $("#cnt" + id).html();wig = $("#wig" + id).html();jamkols = $("#jamkol").html();jamkols -= parseInt(prc) * parseInt(cnt);$("#jamkol").html(jamkols);vaznkol = $("#vzn").html();vaznkol -= parseInt(wig) * parseInt(cnt);$("#vzn").html(vaznkol);$("#tr" + id).css("background", "#FFFF66");$("#delitem" + id).css("display", "none");$("#min" + id).css("display", "none");$("#add" + id).css("display", "none");$("#pric" + id).html("<s>" + prc + "</s>");$("#cnt" + id).html("<s>" + cnt + "</s>");$("#wig" + id).html("<s>" + wig + "</s>");prickols = $("#prickol" + id).html();$("#prickol" + id).html("<s>" + prickols + "</s>");names = $("#name" + id).html();$("#name" + id).html("<s>" + names + "</s>");}}

function addItem(id) {$.post("facman.php", {add:id});cnt = $("#cnt" + id).html();cnt++;$("#cnt" + id).html(cnt);prics = $("#pric" + id).html();jam = $("#prickol" + id).html();jam = parseInt(jam) + parseInt(prics);$("#prickol" + id).html(jam);jamkols = $("#jamkol").html();jamkols = parseInt(jamkols) + parseInt(prics);$("#jamkol").html(jamkols);vaznkol = $("#vzn").html();wig = $("#wig" + id).html();vaznkol = parseInt(vaznkol) + parseInt(wig);$("#vzn").html(vaznkol);}

function minItem(id) {cnt = $("#cnt" + id).html();if (cnt > 1) {$.post("facman.php", {minz:id});cnt--;$("#cnt" + id).html(cnt);prics = $("#pric" + id).html();jam = $("#prickol" + id).html();jam = parseInt(jam) - parseInt(prics);$("#prickol" + id).html(jam);jamkols = $("#jamkol").html();jamkols = parseInt(jamkols) - parseInt(prics);$("#jamkol").html(jamkols);vaznkol = $("#vzn").html();wig = $("#wig" + id).html();vaznkol = parseInt(vaznkol) - parseInt(wig);$("#vzn").html(vaznkol);}}

function next_new() {$("#loadgif").show(500);$("#new_item").hide("blind", {direction:"horizontal"}, 1000, function () {new_act_item = act_item_box * 4;for (i = 1; i < 5; i++) {if (new_item_data[new_act_item + i]) {$("#new" + i).html("<img id=\"lgif\"" + i + " src=\"images/load.gif\" width=\"24\" height=\"24\">");} else {$("#new" + i).html("&nbsp;");}}});$("#new_item").show("blind", {direction:"horizontal"}, 1000, function () {$("#loadgif").hide(200, function () {for (i = 1; i < 5; i++) {if (new_item_data[new_act_item + i]) {$("#lgif" + i).hide();nameitem = new_act_item + i;nameitem = "id" + nameitem;$("#new" + i).html("<a href=\"item.php?id=" + new_item_data[nameitem] + "\"><img border=\"0\" name=\"" + new_item_data[nameitem] + "\" id=\"newimage" + i + "\" src=\"pic/pro/" + new_item_data[new_act_item + i] + "\" width=\"70\" height=\"80\"></a>");}}act_item_box++;if (new_item_box == act_item_box) {$("#nxtnew").hide(500);}$("#prvnew").show(500);});});}

function perv_new() {$("#loadgif").show(500);$("#new_item").hide("blind", {direction:"horizontal"}, 1000, function () {for (i = 1; i < 5; i++) {$("#new" + i).html("<a href=\"item.php?id=" + new_item_data["id" + i] + "\" > <img border=\"0\" name=\"" + new_item_data["id" + i] + "\" id=\"newimage" + i + "\" src=\"pic/pro/" + new_item_data[i] + "\" width=\"70\" height=\"80\"></a>");}});$("#new_item").show("blind", {direction:"horizontal"}, 1000, function () {$("#loadgif").hide(500);$("#prvnew").hide(500);$("#nxtnew").show(500);});act_item_box = 1;}

