var ajax = new sack();

function add2basket(id) { // res_id - куда результат подгружать , mes_id - куда прятать поп-ап

    Prototype.Browser.IE6 = Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
    if(Prototype.Browser.IE6) return true;

    ajax.reset();
	ajax.createAJAX();

	ajax.requestFile = '/shop/add.php';
	ajax.method = "GET";
	ajax.setVar('id', id);
	ajax.onCompletion = function () { mas = ajax.response.split('|'); add2basket_complete(mas[0],mas[1],mas[2]); };
	ajax.runAJAX();
    
    return false;
}

function add2basket_complete(type, message, width) {
    if(type=='ADD')
    {
        popup_morph('basket_line',message,width);
        ajax.reset();
    	ajax.createAJAX();
        
    	ajax.element = 'basket_line';
    	ajax.requestFile = '/shop/basket_line.php';
    	ajax.method = "GET";
    	ajax.runAJAX();
    }
}

function popup(string, width) { 
    Dialog.info(string, {width:width, height:30, className: "alphacube"});
    setTimeout(close_popup, 2000);
}

function popup_morph(id, string, width) { 
    obj = document.getElementById(id);
    var effect = new PopupEffect(obj, {className: "popup_effect", duration: 1});
    Dialog.info(string, {width:width, height:30, className: "alphacube", showEffect:effect.show2.bind(effect), hideEffect:effect.hide.bind(effect)});
    setTimeout(close_popup, 2000);
}     

function close_popup() { Dialog.closeInfo() } 

function slide_toggle(id) {
	Effect.toggle(id, 'appear');
}
