function openWindow(theURL,winName,winWidth,winHeight,sb,rs)
{
	var winLeft	  = ((screen.availWidth - winWidth) / 2);
	var winTop	  = ((screen.availHeight - winHeight) / 2);
	var sb_string = (sb == "no") ? ",scrollbars=no" : ",scrollbars=yes";
	var rs_string = (rs == "no") ? ",resizable=no" : ",resizable=yes";
	
	window.open(theURL,winName,'toolbar=no' + sb_string + ',status=no,menubar=no' + rs_string + ',location=no,dependent=yes,width=' + winWidth + ',height=' + winHeight + ',left=' + winLeft + ',top=' + winTop);
}

function setMenuPosition(element,subNavId)
{
	var offset = Element.positionedOffset(element);
	var fWidth = offset[0];
	var dimens = Element.getDimensions(element);
	var xPos = fWidth+(dimens.width/2);
	
	var subNavDimensions = Element.getDimensions($(subNavId));
	var subNavWidth = subNavDimensions.width;
	var xPosOffset = xPos-(subNavWidth/2);
	
	$(subNavId).setStyle({'left': xPosOffset+'px'});
}

function getWindowSize() {
	var width, height;
    w = window;
    this.width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
    this.height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
    return this;
}

function checkFormRequirements()
{
	var fields = $$('.required');
	for(var i=0;i<fields.length;i++) {
		var field = fields[i];
		var conti = field.up('div');
		if(conti.visible() || conti == false) {
			if(field.value == '') {
				var container = field.up('tr') || field.up();
				new Effect.Highlight(container, {startcolor: '#FF0000', endcolor: '#ffffff'});
				field.focus();
				return false;
			}
		}
	}
	return true;
}

function showToolTip(area)
{
	$('tooltip_default').hide();
	$('tooltip_web').hide();
	$('tooltip_prepress').hide();
	$('tooltip_photo').hide();
	$('tooltip_design').hide();
	$('tooltip_'+area).show();
}

function hideToolTip(area)
{
	$('tooltip_'+area).hide();
}

function showWeb()
{
	$('navWeb').src = '/system/resources/images/point_web2.gif';
}
function hideWeb()
{
	$('navWeb').src = '/system/resources/images/point_web0.gif';
}

function showPrepress()
{
	$('navPrepress').src = '/system/resources/images/point_prepress2.gif';
}
function hidePrepress()
{
	$('navPrepress').src = '/system/resources/images/point_prepress0.gif';
}

function showPhoto()
{
	$('navPhoto').src = '/system/resources/images/point_photo2.gif';
}
function hidePhoto()
{
	$('navPhoto').src = '/system/resources/images/point_photo0.gif';
}

function showDesign()
{
	$('navDesign').src = '/system/resources/images/point_design2.gif';
}
function hideDesign()
{
	$('navDesign').src = '/system/resources/images/point_design0.gif';
}

function tooltipAnimation()
{
	new Effect.Appear('tooltip_default', { duration: 0.9, queue: 'end' });
	new Effect.Fade('tooltip_default', { duration: 0.3, queue: 'end' });
	
	window.setTimeout("showWeb()", 1200);
	
	new Effect.Appear('tooltip_web', { duration: 0.9, queue: 'end' });
	new Effect.Fade('tooltip_web', { duration: 0.3, queue: 'end' });
	
	window.setTimeout("hideWeb()", 2100);
	window.setTimeout("showPrepress()", 2400);
	
	new Effect.Appear('tooltip_prepress', { duration: 0.9, queue: 'end' });
	new Effect.Fade('tooltip_prepress', { duration: 0.3, queue: 'end' });
	
	window.setTimeout("hidePrepress()", 3300);
	window.setTimeout("showPhoto()", 3600);
	
	new Effect.Appear('tooltip_photo', { duration: 0.9, queue: 'end' });
	new Effect.Fade('tooltip_photo', { duration: 0.3, queue: 'end' });
	
	window.setTimeout("hidePhoto()", 4500);
	window.setTimeout("showDesign()", 4800);
	
	new Effect.Appear('tooltip_design', { duration: 0.9, queue: 'end' });
	new Effect.Fade('tooltip_design', { duration: 0.3, queue: 'end' });
	
	window.setTimeout("hideDesign()", 5700);
}

function updateFileInputs(count) {
	for (var i=1; i<=count; i++) {
		Element.show('file_' + i);
	}
	for (; i<=5; i++) {
		Element.hide('file_' + i);
	}
}

function loadGallery(imageIds,imageIdStart)
{
	showBlack();
	new Ajax.Updater('gallery', '/Allgemein/Gallery/View/', {parameters: { image_ids: imageIds, image_id: imageIdStart }});
	$('gallery').show();
}

function showBlack()
{
	$('black').show();
}

function hideBlack()
{
	if($('black').visible()) {
		$('black').hide();
	}
	if($('gallery').visible()) {
		$('gallery').hide();
	}
}

function handleError()
{
    return true;
}

window.onerror=handleError;
