function getList(path) {
    new Ajax.Updater(   'weinliste', webroot+'inc/ajax.list.inc.php?'+path, { 
                            method:'get', 
                            onComplete: prepareDetails
                        });
}

function prepareDetails() {
    $A($$('.weindetails')).each( function(element) {
        Event.observe(element, 'click', function(el) {
            $("archivdetail").style.top= (Position.cumulativeOffset(element)[1]-20)+"px";
        	$("archivdetail").style.left= (Position.cumulativeOffset(element)[0]+40)+"px";

        	var nextAjax = new Ajax.Request(
        						webroot+"inc/ajax.details.inc.php",
        						{   
        							method:"post",
        							postBody: "id="+element.id,
               						onComplete:show_new_data
        						} );
    	});
        Event.observe(element, 'mouseover', function(el) { element.src=element.src.gsub('purple', 'red');	});
        Event.observe(element, 'mouseout', function(el) { element.src=element.src.gsub('red', 'purple');	});
    });
   Event.observe($("archivleinwand"), 'click', hideArchiv);
   Event.observe($("schliessen"), 'click', hideArchiv);
}


function hideArchiv() {
	new Effect.Fade("archivleinwand");
	$("archivdetail").hide();
	$("detailwrapper").innerHTML = '&nbsp;';
}


function show_new_data(r) {
    $("detailwrapper").innerHTML = r.responseText;
	$("archivleinwand").style.height = (Position.cumulativeOffset($('banner'))[1]+$("archivdetail").getHeight())+"px"; 
    $("archivleinwand").style.width = document.documentElement.clientWidth+"px";
    new Effect.Appear("archivleinwand",{ to:0.45, duration:0.8}); 
    $("archivdetail").show();
    new Draggable("archivdetail", {zindex:9999, handle:'draghandle'});
}

function doBasket(form) {
   var mform = $(form);
   new Ajax.Request(   webroot+'inc/ajax.session.inc.php', { 
   	    method:'post', 
   	    parameters: mform.serialize(true)
    });
    new Effect.Highlight(mform,{duration: 0.5, startcolor:'#FFFFFF', endcolor:'#CC0000'});
    return false;
}

function toggleMeta(m) {
    var imgMeta = m.parentNode.getElementsByTagName('img');
    var ankerMeta = m.parentNode.getElementsByTagName('a');
    var divMeta = m.parentNode.getElementsByTagName('div');
    for(var i=0; i < divMeta.length; i++) { 
        if(ankerMeta[i] == m) {
           Element.toggle(divMeta[i]);
           imgMeta[i].src = (imgMeta[i].src.indexOf('open')>-1)?'images/close.gif':'images/open.gif';
        }
        else  {
            Element.hide(divMeta[i]);
            imgMeta[i].src = 'images/close.gif'
        }
    }
}

