
/*
 * -------------------------------------------------------------------------
 * @file 		dom.js
 * @version 	1.0.0
 * @date 		2010-08-24 12:39:52 +0200 (Tue, 24 Aug 2010)
 * @author 		Matthias Mertiens <mail@mertiens.biz>
 * --------------------------------------------------------------------------
 * Copyright (c) 2010 mertiens. ideas for communication <http://mertiens.biz>
 * --------------------------------------------------------------------------
 */



function cycleImages(){
     console.log( 'cycle');
     var $active = $('#portfolio_cycler .active');
      var $next = ($('#portfolio_cycler .active').next().length > 0) ? $('#portfolio_cycler .active').next() : $('#portfolio_cycler img:first');
      $next.css('z-index',2);//move the next image up the pile
	  $active.fadeOut(1500,function(){//fade out the top image
	  $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
      $next.css('z-index',3).addClass('active');//make the next image the top one
      });
    }






$(document).ready(function(){


	//setInterval('cycleImages()', 4000);

/*
	$('#crossfade').css('background-color','#fff');
	bgImageTotal=5;
	randomNumber = Math.round(Math.random()*(bgImageTotal-1))+1;
	imgPath=('/header_visuals/header'+randomNumber+'.jpg');
	$('#crossfade').css('background-image', ('url("'+imgPath+'")'));
*/








	$('li', 'menu').hover(
		function() { $(this).addClass('hover'); },
		function() { $(this).removeClass('hover'); }
		);

	$('.external_link').attr('target','_blank');


/* 	Easy Form Validation   -------------------------------------------------------------					 */
	$('#ContactForm').bind('submit', function(event) {

 			var stopSubmit = true;
			var cf = this;

	 		$('.required',cf).each(function(){

	 			if( $(this).val()=="") {

	 				$(this).addClass("error")
	 					   .change(function() {
	 							$(this).removeClass("error").prev('label').removeClass("error");
	 						})
	 					   .prev('label')
	 					   .addClass("error");

	 				stopSubmit = false;
	 				event.preventDefault();

	 				} // /if
	 			});


			if( stopSubmit===false ) {
	 				if( $('#errormessage').length==0) {
	 					$('<p class="errors" id="errormessage">Bitte füllen Sie alle rot markierten Felder aus!</p>')
	 						.prependTo(this).css("display","none").slideDown(100);
	 						}
	 				}
			});
/* 	--------------------------------------------------------------------------------------					 */

	$("ul","#main_navigation").addClass("lavaLampWithImage").lavaLamp({
                fx: "easeOutBack",
                speed: 700
                //click: function(event, menuItem) {
                //    return false;
                //}
            });

			$("ul","#subnavigation").addClass("lavaLamp2WithImage").lavaLamp({
                fx: "easeOutBack",
                speed: 700
                //click: function(event, menuItem) {
                //    return false;
                //}
            });

/* 	--------------------------------------------------------------------------------------					 */

	$("#accordion").accordion({
		header: 'h2',
		autoHeight: false,
		navigation: true
		});

/* 	--------------------------------------------------------------------------------------					 */

	$('.fancyBox').fancybox({
					'width' : 600,
					'height' : 640,
					'autoDimensions' : false,
					'opacity': true,
					'transitionIn'	:	'elastic',
					'transitionOut'	:	'fade',
					'speedIn'		:	300,
					'speedOut'		:	100,
					'overlayColor'	:	'#000',
					'overlayOpacity':	'0.6',
					'titleShow'		:	false

					});


/*
	$('#crossfade').crossSlide({
		  sleep: 4,
		  fade: 2
		}, [
		  { src: 'http://relaunch.coolride.de/header_visuals/header1.jpg' },
		  { src: 'http://relaunch.coolride.de/header_visuals/header2.jpg'  },
		  { src: 'http://relaunch.coolride.de/header_visuals/header3.jpg'  },
		  { src: 'http://relaunch.coolride.de/header_visuals/header4.jpg'  },
		  { src: 'http://relaunch.coolride.de/header_visuals/header5.jpg'  },
		  { src: 'http://relaunch.coolride.de/header_visuals/header6.jpg'  }
		]);
*/
    $('#crossfade').crossSlide({
        sleep: 4,
        fade: 2
      }, [
        { src: '/header_visuals/header1.jpg' },
        { src: '/header_visuals/header2.jpg'  },
        { src: '/header_visuals/header3.jpg'  },
        { src: '/header_visuals/header4.jpg'  },
        { src: '/header_visuals/header5.jpg'  },
        { src: '/header_visuals/header6.jpg'  }
      ]);


// run every 7s


/*
	var product_buildup_form = $('form','#product_buildup');
	$('select', product_buildup_form).bind('change', function() { product_buildup_form.submit(); });
*/



});
