function getBaseUrl()
{
	var offset = -1;
	var pos = 0;
	while (1)
	{
		offset = document.location.href.indexOf('/', offset+1);
		if (offset < 0)
			return document.location.href.substring(0, pos + 1);
		pos = offset;
	}
	return false;
}

function ajax_add_to_cart(form, dont_show_ibox)
{
	var params = $(form).serialize();
	var url = getBaseUrl() + 'ajax_add_to_cart.php?' + params;
	
	if (!dont_show_ibox) {
        //	tb_show(null, url + '&height=70&width=400', null);//&modal=true
	    iBox.showURL(url);
	} else {
	    //alert(url);
	    
	    $.post(url, function() {
	        location.href = getBaseUrl() + 'cart.php?mode=checkout';
	    });
	}
}

function ajax_buy_inst(form)
{
	var params = $(form).serialize();
	var url = getBaseUrl() + 'ajax_buy_inst.php?' + params;
//	tb_show(null, url + '&height=70&width=400', null);//&modal=true
	iBox.showURL(url);
}
