/* Shop-Steuerung */



/* Warenkorb anzeigen */







/* Laufende Rubrikenbilder */

function spPreLoad(images)
{
    for (var loop = 0; loop < images.length; loop++)
    {
        var buffer = new Image();
        buffer.src = images[loop];
    }
}

function spiconfr( iconid, calltype ) {

	if (document.getElementById(iconid) != null) {

		if (calltype=='start') {
			document.getElementById(iconid).style.backgroundImage='url('+icondata[iconid][1]+')';
			document.getElementById(iconid).style.opacity='1';
			spcurrenticon=1;
			spcurrentrunning = iconid;
			spPreLoad(icondata[iconid]);
			window.setTimeout('spiconfr( \"'+iconid+'\", \"refresh\")',400);
		}
		if ((calltype=='refresh') && (spcurrenticon>0)) {
			spcurrenticon++;
			if (spcurrenticon>=icondata[iconid].length) {
				spcurrenticon=1;
			}
			document.getElementById(iconid).style.backgroundImage='url('+icondata[iconid][spcurrenticon]+')';
			if (spcurrentrunning == iconid) {
				window.setTimeout('spiconfr( \"'+iconid+'\", \"refresh\")',400);
			}
		}
		if (calltype=='stop') {
			spcurrenticon = 0;
		}
	}
}
var spcurrenticon = 0;
var spcurrentrunning = '';








/* Initialisierung */


function spLoaded() {

	if ($('spHopperShort')) { // Warenkorb-Element gefunden

		/* new Ajax.Updater('spHopperShort', '/cgi-wms2/module/sp/hopper.php?action=hopperShort&caller='+encodeURIComponent(document.URL), { method: 'get' }); */
		var url = '/cgi-wms/module/sp/hopper.php?action=hopperShort&caller='+encodeURIComponent(document.URL);
		new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {

		  	var returnText = transport.responseText;

		  	if (returnText.indexOf( '|||||' )-1) {
		  		var commands = returnText.substring( 0, returnText.indexOf( '|||||' ) );
		  		if (commands.indexOf( 'newproduct' ) != -1 ) {

		  			if(typeof window.spNewProduct == 'function') {
						// function exists, so we can now call it
						spNewProduct();
					}
				}

		  		returnText = returnText.substring( returnText.indexOf( '|||||' )+5 );
		  	}
		  	if (returnText != '') {
			  	$('spHopperShort').innerHTML = returnText;
			}
		  }
		});



	} else { // KeinWarenkorb-Element in der Website
		// alert( "kein Warenkorb" );
	}
}



Event.observe(window, 'load', spLoaded);
