/**
 * FILE AMARU.JS
 *
 * Copyright (c) 2007 Dominik Stucky (http://www.katachrese.com)
 *
 *
 */
 
/**
 * http://www.alistapart.com/articles/prettyaccessibleforms
 *
 * code updated for latest jquery version. Dominik Stucky 2007-10-24
 * form#bestellform -> form, to ensure that all forms are included of the shopping process
 */
if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', bestellform, false );

function bestellform(){
	
	if (jQuery.browser.mozilla) { // nur firefox beruecksichtigen, opera 9.0 ausschliessen
	
		//jQuery.noConflict(); -> used in backoffice_header.tpl
		
		// Hide forms
		jQuery( 'form' ).hide().end(); // latest prototype version and safari 2 does not recognize elements which are set display to hidden (as if they didn't exists)
		// with new jquery version 1.2.1 and noconflict(), it can be used again
		
		/**
		* with latest version of jquery 1.2.1 li/label does not function properly, only label used here
		* jQuery( 'form#bestellform' ).find( 'li/label' ).each( function( i ){
		*/
	  
		// Processing
		jQuery( 'form' ).find( 'label' ).each( function( i ){
		
			//this.css('backgroundColor','#0ff');
		
			var labelContent = this.innerHTML;
			var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
			var labelSpan = document.createElement( 'span' );
				labelSpan.style.display = 'block';
				labelSpan.style.width = labelWidth;
				labelSpan.innerHTML = labelContent;
			this.style.display = '-moz-inline-box';
			this.innerHTML = ""; // statt this.innerHTML = null; fuer opera 9.0
			this.appendChild( labelSpan );
		} ).end();
	  
		// Show forms
		jQuery( 'form' ).show().end();
		
	}//end if
}


/**
 * FUNCTION MM_preloadImages()
 *
 * preload images, mostly used with body-onload
 */
function MM_preloadImages() { //v3.0

	var d=document; 
	if (d.images) { 
		if (!d.MM_p) d.MM_p=new Array();
		
   		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
   		
   		for(i=0; i<a.length; i++) {
  
  			if (a[i].indexOf("#")!=0){ 
  				d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];
  			}//end if
  			
  		}//end for
  		
   }//end if
}//end fn



/* ------------- navigation start -------------- */  
 
 

/**
 * FUNCTION swapBgImageOver()
 *
 * ! make sure that the xhtml elements parent/child aren't separated 
 *   by any character such as line break, space etc. !
 *
 * @param string navElem
 */
function swapBgImageOver(navElem) {

	var newImage1 = "url(/oepfelchasper/share/pics/nav/left_over.gif)";
	
	document.getElementById(navElem).style.backgroundImage = newImage1;
	document.getElementById(navElem).childNodes[0].style.backgroundImage = newImage2;
	
	/*$( 'navigation#' + navElem ).find( 'a' ).each( function( i ){
    	var aContent = this.innerHTML;
    	alert(this);
    	document.defaultView.setComputedStyle( this, '' ).style.backgroundImage = newImage2;
  } ).end();*/
	
}//end fn


/** 
 * FUNCTION swapBgImageOut()
 *
 * ! make sure that the xhtml elements parent/child aren't separated 
 *   by any character such as line break, space etc. !
 *
 * @param string navElem
 */
function swapBgImageOut(navElem) {

	var newImage1 = "url(/oepfelchasper/share/pics/nav/left.gif)";
	
	document.getElementById(navElem).style.backgroundImage = newImage1;
	document.getElementById(navElem).childNodes[0].style.backgroundImage = newImage2;
	
}//end fn



/* ------------- navigation end -------------- */ 


/**
 * order form animation select date picker
 */
function toggleDateSelect(select, target) {
	if (select.value=='') {
		$(target).hide(); 
	} else {
		Effect.Appear(target, { duration: 0.5 }); 
	} // if
} // toggleDateSelect()

