function checkForm() {
    var o;
    var check = true;
    o = document.getElementById("Firma");
    if(o.value=="") check = false;
    o = document.getElementById("Name");
    if(o.value=="") check = false;
    o = document.getElementById("Vorname");
    if(o.value=="") check = false;
    o = document.getElementById("Adresse");
    if(o.value=="") check = false;
    o = document.getElementById("PLZ");
    if(o.value=="") check = false;
    o = document.getElementById("Ort");
    if(o.value=="") check = false;
    o = document.getElementById("Telefon");
    if(o.value=="") check = false;
    o = document.getElementById("EMail");
    if(o.value=="") check = false;

    if(!check) {
        alert("Bitte füllen Sie alle Felder korrekt aus, danke.");
    }
    return check;
}

function orderWorkbook() {

        updateImageList();

		LightboxBeforeStart();
		hideSelectBoxes();
		hideFlash();
		
        document.getElementById("outerImageContainer").className = "containerWorkbook";


		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);

		new Effect.Appear('overlay', { duration: overlayDuration, from: 0.0, to: overlayOpacity });
		
				
	    // calculate top and left offset for the lightbox 
		var arrayPageScroll = getPageScroll();
		var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
		var lightboxLeft = arrayPageScroll[0];
		Element.setTop('lightbox', lightboxTop);
		Element.setLeft('lightbox', lightboxLeft);
		
		Element.show('lightbox');


		// hide elements during transition
		if(animate){ Element.show('loading');}
		Element.hide('lightboxImage');
		Element.setSwf('lightboxSwf','<iframe src="/orderWorkbook.html" frameborder="0" width="660" height="490"></iframe>');
		Element.hide('lightboxSwf');
		Element.hide('hoverNav');
		Element.hide('prevLink');
		Element.hide('nextLink');
		Element.hide('imageDataContainer');
		Element.hide('numberDisplay');		
		
		Element.hide('loading');
		
		var imgWidth = 660;
		var imgHeight = 490;
		
		var widthCurrent = Element.getWidth('outerImageContainer');
		var heightCurrent = Element.getHeight('outerImageContainer');

		// get new width and height
		var widthNew = (imgWidth  + (borderSize * 2));
		var heightNew = (imgHeight  + (borderSize * 2));

		// scalars based on change from old to new
		var xScale = ( widthNew / widthCurrent) * 100;
		var yScale = ( heightNew / heightCurrent) * 100;

		// calculate size difference between new and old image, and resize if necessary
		wDiff = widthCurrent - widthNew;
		hDiff = heightCurrent - heightNew;

		if(!( hDiff == 0)){ new Effect.Scale('outerImageContainer', yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
		if(!( wDiff == 0)){ new Effect.Scale('outerImageContainer', xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration,afterFinish: function(){	updateContent(); }}); }

        Element.setWidth( 'imageDataContainer', widthNew);
        
        
        /*Element.show('caption');
        Element.setInnerHTML( 'caption', "Workbook");

        Element.show('numberDisplay');
		var tmp = '<div class="imgnav"><ul>';
		for(var i=0;i<3;i++) {
			tmp += '<li><a';
			if(activeImage==i) {
				tmp += ' class="active"';
			}
			tmp += ' href="javascript:changeWorkbookImage('+i+');"></a></li>';
		}
		tmp += '</ul></div>';
		Element.setInnerHTML( 'numberDisplay', tmp);*/
}

function changeWorkbookImage(index) {
}

function updateImageList() {
	if (!document.getElementsByTagName){ return; }
	var anchors = document.getElementsByTagName('a');
	var areas = document.getElementsByTagName('area');

	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		
		var relAttribute = String(anchor.getAttribute('rel'));
		
		// use the string.match() method to catch 'lightbox' references in the rel attribute
		//if (anchor.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
		//	anchor.onclick = function () {myLightbox.start(this); return false;}
		//}
	}

	// loop through all area tags
	// todo: combine anchor & area tag loops
	for (var i=0; i< areas.length; i++){
		var area = areas[i];
		
		var relAttribute = String(area.getAttribute('rel'));
		
		// use the string.match() method to catch 'lightbox' references in the rel attribute
		if (area.getAttribute('href') && (relAttribute.toLowerCase().match('lightbox'))){
			area.onclick = function () {myLightbox.start(this); return false;}
		}
	}
}

function updateContent() {
    new Effect.Parallel(
			[ new Effect.SlideDown( 'imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }), 
			  new Effect.Appear('imageDataContainer', { sync: true, duration: resizeDuration }) ], 
			{ duration: resizeDuration, afterFinish: function() {
				var arrayPageSize = getPageSize();
				//Element.setHeight('overlay', arrayPageSize[1]);
				}
			} 
		);

        Element.setInnerHTML( 'caption', "");

		Element.show('lightboxSwf');


}
