function _setBigImage(ImageName){
	_('imageBig').src = '/i2cmsdata/059/images/d2go/m/' + ImageName;
}

function showArtDetail(artnr, tab, ref) {
	if (!ref) {
		ref = '';
	}
	
	_('artikel_popup').setAttribute('src', '/d2go/ajax/artikeldetail/index.html?t_ArtikelNr=' + artnr.encode() + '&t_ref=' + ref);
	_popup('artikel_popup', function() {
		Event.bind(document, 'keydown', esc);
		_hide('title');
		if (tab) {
			loadTab(_(tab));
		} else {
			loadTab(_('tabs').getElementsByTagName('a')[0]);
		}
	});
}
function hideArtDetail() {
	_popdown('artikel_popup');
}

function loadTab(tab, onComplete) {
	new Ajax.Request(tab.href, {
		onSuccess: function(tp) {
			if (_hasClassName(tab, 'canCache')) {
				_('artikel_subcontent').innerHTML = _tabCache[tab.href] = tp.responseText;
			} else {
				_('artikel_subcontent').innerHTML = tp.responseText;
			}
				
			/* Hier werden alle HTML-Elemente mit class="nice_title" neu initialisiert */
			NiceTitle.update();
			
			(onComplete ? onComplete : P.emptyFunction)();
		}
	});
	
	_A(_('tabs').getElementsByTagName('a')).each(function(t) {
		if (t == tab) {
			t.parentNode.className = 'current';
		} else {
			t.parentNode.className = '';
		}
	});
	
	tab.blur();
}


function esc(ev) {
	if (Event.getKey(ev) == Event.KEY_ESC) hideArtDetail();
}

function toggleImage() {
	_toggle('AD_close');
	var img = _('image_AD');
	img.src = img.src.indexOf('/m/') === -1 ? img.src.replace('/b/', '/m/') : img.src.replace('/m/', '/b/');
	if (img.src.indexOf('/m/') === -1) {
		img.style.width = '600px';
		img.style.height = '430px';
		img.style.paddingTop = img.style.paddingBottom = '80px';
		img.style.paddingLeft = img.style.paddingRight = '69px';
		img.style.backgroundColor = '#FFF';
		_hide('maximize_AD');
		var t = _('minimize_AD');
		_show(t);
		t.style.position = 'absolute';
		t.style.marginLeft = 600 - t.offsetWidth + 69 + 69 - 5 + 'px';
		t.style.marginTop = 430 - t.offsetHeight + 80 + 80 - 5 + 'px';
		t.style.marginRight = '0px';
		t.style.marginBottom = '0px';
		t.style.cssFloat = '';
		Event.unbind(document, 'keydown', esc);
		Event.bind(document, 'keydown', toggleImage);
	} else {
		img.style.width = '224px';
		img.style.height = '201px';
		img.style.paddingTop = img.style.paddingBottom = '0px';
		img.style.paddingLeft = img.style.paddingRight = '0px';
		_show('maximize_AD');
		_hide('minimize_AD');
		Event.unbind(document, 'keydown', toggleImage);
		Event.bind(document, 'keydown', esc);
	}
}

function generatePDF(artnr) {
	window.open('/d2go/pdf/artikeldetail/index.html?t_ArtikelNr=' + artnr + '&t_PDF=1');
}


