function _(id) { return document.getElementById(id); }

function openCenteredWindow(url, n, w, h) {
	var l = (screen.availWidth / 2) - (w / 2);
	var t = (screen.availHeight / 2) - (h / 2);
	return openWindow(url, n, w, h, l, t);
}

function openWindow(url, n, w, h, l, t, s) {
	if(l == undefined) l = 200;
	if(t == undefined) t = 100;
    if(s == undefined) s = 'no';

	var params = new Array();

	if(w > 0) params.push('width='  + w);
	if(h > 0) params.push('height=' + h);
	params.push('left=' + l);
	params.push('top='  + t);

	params.push('location=no');
	params.push('statusbar=no');
	params.push('scrollbars=' + s);

	return window.open(url, n, params.join(','));
}

// Bestellformular abschicken
function action(form, id, action, target)
{
	document.getElementById(id).setAttribute('value', action);
	var frm = document.getElementById(form);
	if(target != undefined) {
		frm.setAttribute('action', target);
	}
	frm.submit();
}

// Produktansicht: Bild austauschen
function swap(id, fullsizeWidth, fullsizeHeight, zoomWidth, zoomHeight)
	{
	document.getElementById('fullsizeImage').src = '/file/file/image/' + id + '?img[w]=' + fullsizeWidth + '&img[h]=' + fullsizeHeight;
	document.getElementById('fullsizeLink1').setAttribute('onclick', 'zoom(' + id + ', ' + zoomWidth + ', ' + zoomHeight + ');');
	document.getElementById('fullsizeLink2').setAttribute('onclick', 'zoom(' + id + ', ' + zoomWidth + ', ' + zoomHeight + ');');
	}

// Produktansicht: Bild aufpoppen
function zoom(id, width, height)
	{
	window.open('/images/' + id + '/' + width + 'x' + height + '.jpg', 'PopUp', 'left=300, top=50,width=' + width + ',height=' + height + ',status=no,scrollbars=no,resizable=yes');
	}

// IE form submit ohne submit-Button fixen
function addInputSubmitEvent(form, input) {
    input.onkeydown = function(e) {
        e = e || window.event;
        if (e.keyCode == 13) {
            form.submit();
            return false;
        }
    }
}

window.onload = function() {
    var forms = document.getElementsByTagName('form');

    for (var i=0;i < forms.length;i++) {
        var inputs = forms[i].getElementsByTagName('input');

        for (var j=0;j < inputs.length;j++)
            addInputSubmitEvent(forms[i], inputs[j]);
    }
}



function myFlash() {

	$('div#content').animate({marginTop: '254px'}, {duration: 900});
	
}


