// no conflict
//$.noConflict();

jQuery(document).ready(function($) {
	 
		// activate png fix
		jQuery(document).pngFix();
		
		// configure superfish
        jQuery("ul.categories").superfish({ 
            animation: {width:'show'},   // slide-down effect without fade-in 
            delay:     500 ,              // 1.2 second delay on mouseout 
        	 autoArrows:    false
		}); 
		
		// Init Banner Menu
		initBanner();
		
		// if Banner Chagn is clicked
		jQuery('.banner-menu span').click(function(event){
   			changeBanner(jQuery(this).html());
     	});
		
		// automatically change the banners all 10 seconds
		setInterval(function () {
        changeBanner(); // show next div
    	}, 10 * 1000); // do this every 10 seconds  

		
		/**
		 *	INIT BANNER MENU
		 */ 
		 function initBanner() {
			 content = '';
			 // create content
			 jQuery( ".banner img" ).each(
						function( intIndex ){
							if (intIndex != 0) {
								content += '<span class="no">' + parseInt(intIndex + 1) + '</span>'; 
							} else {
								// give the first one an active state
								content += '<span class="cur">' + parseInt(intIndex + 1) + '</span>'; 
							}
					}
			 );
			jQuery('.banner').append( '<div class="banner-menu"><div class="banner-menu-elem">' + content + '</div></div>');
		 }
		
		/*
		 *	change banner
		 */
		function changeBanner(changeto){
			// if a destination is set
			if (changeto != null) {
					// now show the correct image
					jQuery( ".banner img" ).each(
						function( intIndex ){
							// give the first one an active state
							if ((intIndex + 1) == changeto) {
								jQuery(this).show();
							} else {
								jQuery(this).hide();
							}
				 		}
			 		);
					// now show the correct text
					/*jQuery( ".banner-text div" ).each(
						function( intIndex ){
							// give the first one an active state
							if ((intIndex + 1) == changeto) {
								jQuery(this).show();
							} else {
								jQuery(this).hide();
							}
				 		}
			 		);*/
					// now change to the correct menu item
					jQuery( ".banner-menu .cur" ).removeClass('cur').addClass('no');
					jQuery( ".banner-menu span" ).each(
						function( intIndex ){
							// give the first one an active state
							if ((intIndex + 1) == changeto) {
								jQuery(this).removeClass('no').addClass('cur');
							} 
				 		}
			 		);
					
			} else {
				// just go to the next image
				if (jQuery('.banner img:visible').next().length != 0) {
					jQuery('.banner img:visible').hide().next().show();
					// hide all text
					//jQuery('.banner-text div:visible').hide().next().show();
					// set banner menu
					jQuery( ".banner-menu .cur" ).removeClass('cur').addClass('no').next().removeClass('no').addClass('cur');
				} else {
					// go back to the first banner	
					changeBanner(1);
				}
			}
			
			
			};

});


