window.onerror = null;
frontend_ajax = {
	request : Object(),
        AJAXscript : '/frontend_ajax.php?method=ajax',
	sortField: '',
	sortDirection: '',
	tableIssues: null,
	init : function(sortCol,sortDirection){
		if(typeof(sortCol) == 'undefined') sortCol = 'sort';
		if(typeof(sortDirection) == 'undefined') sortDirection = 'asc';
		frontend_ajax.sortField = sortCol;
		frontend_ajax.sortDirection = sortDirection;
		frontend_ajax.tableIssues = typeof tableIssues != 'undefined' ? tableIssues : new Array('itemRow');
	},
	send : function(arr,method){
		ajaxSender.send('frontend_ajax', arr, method, false);
	},

	d : function(o, e, a){
      if (o.addEventListener) return o.addEventListener(e, a, false);
      else if (o.attachEvent) return o.attachEvent("on" + e, a);
      else return false;
    },

    onlineOrder: function(action,id){
        if(action=='send'){
            var post=new Array();
            $("input[name^='firstname'],input[name^='lastname'],input[name^='captcha'],input[name^='email_address'],input[name^='phone'],textarea[name^='message_body']").each(function(i,el){
                post[$(el).attr('name')]=$(el).val();
            });
            this.send({'action':action,'post':post,'id':id},'onlineOrder');
        }else{
            this.send({'action':'','id':id},'onlineOrder');
        }
    },
    ansonlineOrder: function(data){
        if(data.send){
            $.fn.colorbox({title:txt_title_OnlineOrder,width:"470px",height:"135px",html:txt_OnlineOrder_send});
        }else{
            $.fn.colorbox({title:txt_title_OnlineOrder,width:"470px",height:"680px",html:data.html});
        }
    },


    onlineСonsultation: function(action){
        if(action=='send'){
            var post=new Array();
            $("input[name^='name'],input[name^='qemail'],input[name^='tel'],textarea[name^='message_body']").each(function(i,el){
                post[$(el).attr('name')]=$(el).val();
            });
            this.send({'action':action,'post':post},'onlineСonsultation');
        }else{
            this.send({'action':''},'onlineСonsultation');
        }
    },

    ansonlineСonsultation: function(data){
        if(data.send){
            $.fn.colorbox({title:txt_title_OnlineConsultatuon,width:"470px",height:"125px",html:txt_OnlineConsultatuon_send});
        }else{
            $.fn.colorbox({title:txt_title_OnlineConsultatuon,width:"450px",height:"460px",html:data.html});
        }
    }

//    inCart: function(pID,param){
//        var id=new Array();
//        $("input[name^='id['],select[name^='id[']").each(function(i,el){
//            key=(($(el).attr('name')).replace('id[','')).replace(']','');
//            id[key]=$(el).val();
//        });
//        qty=$("input[name^='products_qty']").val();
//        if(qty==0)qty=1;
//        $.fn.colorbox({title:"В корзине:",width:"445px",height:"450px",html:'<div id="ajax_shopping_cart"></div>'});
//        this.send({'pID':pID,'param':param,'qty':qty,'id':id},'inCart');
//
//
//    },
//    ansinCart: function(data){
//         $.fn.colorbox({width:"80%",title:"В корзине:",html:data});
//    },
//
//    updateCart:function(param){
//
//        var post=new Object();
//        post.products_id=new Array();
//        post.cart_quantity=new Array();
//        post.old_qty=new Array();
//        post.id=new Array();
//        post.cart_delete=new Array();
//        $("input[name^='products_id[']").each(function(i,el){
//        key=(($(el).attr('name')).replace('products_id[','')).replace(']','');
//        post.products_id[key]=$(el).val();
//        });
//
//        $("input[name^='cart_quantity[']").each(function(i,el){
//            key=(($(el).attr('name')).replace('cart_quantity[','')).replace(']','');
//            post['cart_quantity'][key]=$(el).val();
//        });
//
//        $("input[name^='old_qty[']").each(function(i,el){
//            key=(($(el).attr('name')).replace('old_qty[','')).replace(']','');
//            post['old_qty'][key]=$(el).val();
//        });
//
//        $("input[name^='cart_delete[']").each(function(i,el){
//            key=(($(el).attr('name')).replace('cart_delete[','')).replace(']','');
//            if($(el).is(':checked'))
//                post['cart_delete'][key]=$(el).val();
//        });
//
//        $("input[name^='id[']").each(function(i,el){
//            key=($(el).attr('name')).replace('id[','');
//            post['id'][key]=$(el).val();
//        });
//
//
//
//        this.send({'param':param,'post':post},'inCart');
//    },
//
//    ansupdateCart:function(data){
//         $.fn.colorbox({width:"80%",title:"В корзине:",html:data});
//    },
//
//    buynowCart: function(pID,param){
//        $.fn.colorbox({title:"В корзине:",width:"445px",height:"450px",html:'<div id="ajax_shopping_cart"></div>'});
//        this.send({'pID':pID,'param':param},'inCart');
//
//
//    },
//    ansbuynowCart: function(data){
//         $.fn.colorbox({width:"80%",title:"В корзине:",html:data});
//    }


}






