

$(document).ready(function() {
			swfobject.embedSWF("/bacher/flash/header.swf", "nav-box", "600", "160", "9.0.0", "/bacher/flash/expressInstall.swf" ,null, { wmode:"transparent" });
	

	
			// initialise plugins
			$('ul.sf-menu').superfish({
				speed: 'fast'
			}).find('ul').bgIframe({opacity:false});
			
			$('#couch img').tooltip({ 
				 track: false, 
				 delay: 200, 
				 showURL: false, 
				 showBody: " - ", 
				 fixPNG: true, 
				 left: -60
			});		
			
			$('#couch_small img').tooltip({ 
				 track: false, 
				 delay: 200, 
				 showURL: false, 
				 showBody: " - ", 
				 fixPNG: true, 
				 left: -60
			});	
			
			$("#menubar").css('display','block');
			
			
			$("#bookingform3").validate({
				errorContainer: $("div.form-error")
			});	
			
			$("#contactform").validate({
				errorContainer: $("div.form-error")
			});				
			
			$('#ex2').jqm({ajax: '/agb-2/popup/', trigger: 'a.ex2trigger'});	
			
			
			$.each($('#checkboxes li'),function(idx, value){
				$(this).prepend('<input type="checkbox" name="chk[]" value="' + $(this).text() +'" />');
			})
			
			$('body.page-cat4 #primary table tbody tr').not('.spacer').mouseover(function(){
					$(this).css('background-color','#E9E9E9');
			});
			
			$('body.page-cat4 #primary table tbody tr').not('.spacer').mouseout(function(){
					$(this).css('background-color','#FFFFFF');
			});
});


function getFullCouch() {	
	$('#couch').load('/home/ajax_getCouch/5',null,function(){
		$(this).fadeIn(1500);
		$('#couch div.couch div.spacer img').tooltip({ 
			 track: false, 
			 delay: 200, 
			 showURL: false, 
			 showBody: " - ", 
			 fixPNG: true, 
			 left: -60
		});								
	});
}


function getRandom( min, max ) {
		/** Get a Random nummer from min to max **/
        if( min > max ) {
                return( -1 );
        }

        if( min == max ) {
                return( min );
        }

        return( min + parseInt( Math.random() * ( max-min+1 ) ) );
}


function courseInfo(val,i,dateid){
	// Get Dates for selected Course
	$('#course-date_' + i).load('/buchung/ajax_getDates/' + val,function(){
		if(dateid>0){
			$('#course-date_'+ i).val(dateid);
		}
	});
	
	// Get Info for selected course
	$('#course-info_' + i).load('/buchung/ajax_getCourseDetail/' + val);
	
	// Get Packages with this course, if any
	$('#course-package_' + i).load('/buchung/ajax_getPackage/' + val);
}

function addCourse(){
	var id = $('#courses div.course:last').attr('id');
	
	$.get('/buchung/ajax_addCourse/'+id, function(data){
		$('#courses').append(data);
	},'html');
}

function copyCourse(i){
	var nextid = $('#courses div.course:last').attr('id');
	
	//alert($('#bookingform').serialize());
	
	$.post('/buchung/ajax_copyCourse/'+i+'/'+nextid+'/', $('#bookingform').serialize(), function(data){
			$('#courses').append(data);
	},'html');
}

function addParticipant(i){
	var id = $('#participants_' + i + ' div.participant:last').attr('id');

	
	$.get('/buchung/ajax_addParticipant/'+ id +'/'+ i, function(data){
		$('#participants_'+i).append(data);		
	},'html');
}

function checkForm(){	
	// Formvalidation
	$("#bookingform").validate({
		errorContainer: $("div.form-error")
	});		
	
	$('#bookingform').submit();
}

function checkForm2(){	
	var same = $('#bookingform2 #same:checked').val()
	if(same == 1){
		$('#firm2').val($('#firm').val());
		$('#street2').val($('#street').val());
		$('#zip2').val($('#zip').val());
		$('#city2').val($('#city').val());
	}
	
	// Formvalidation
	$("#bookingform2").validate({
		errorContainer: $("div.form-error")
	});		
	
	$('#bookingform2').submit();
}

/*!
 * jQuery Konami code trigger v. 0.1
 *
 * Copyright (c) 2009 Joe Mastey
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Usage:
 *  // konami code unlocks the tetris
 *  $('#tetris').konami(function(){
 *     $(this).show();
 *  });
 * 
 *
 *  // enable all weapons on 'idkfa'.
 *  // note that each weapon must be unlocked by its own code entry
 *  $('.weapon').konami(function(){
 *     $(this).addClass('enabled');
 *  }, {'code':[73, 68, 75, 70, 65]});
 *
 *
 *  // listens on any element that can trigger a keyup event.
 *  // unlocks all weapons at once
 *  $(document).konami(function(){
 *     $('.weapon').addClass('enabled');
 *  }, {'code':[73, 68, 75, 70, 65]});
 *
 *
 */
(function($){
    $.fn.konami             = function( fn, params ) {
        params              = $.extend( {}, $.fn.konami.params, params );
        this.each(function(){
            var tgt         = $(this);
            tgt.bind( 'konami', fn )
               .bind( 'keyup', function(event) { $.fn.konami.checkCode( event, params, tgt ); } );
        });
        return this;
    };
    
    $.fn.konami.params      = {
        'code'      : [38, 38, 40, 40, 37, 39, 37, 39, 66, 65],
        'step'      : 0
    };
    
    $.fn.konami.checkCode   = function( event, params, tgt ) {
        if(event.keyCode == params.code[params.step]) {
            params.step++;
        } else {
            params.step     = 0;
        }
        
        if(params.step == params.code.length) {
            tgt.trigger('konami');
            params.step     = 0;
        }
    };
})(jQuery);


var authordiv ='<div id="author" style="display:none; color:black; padding:15px; border: 1px solid #323232; background-color:white; position:absolute; bottom:0px; z-index:100; left:0px; width:290px; height:180px"><div style="width:290px; text-align:center;"><a href="http://www.mira4.com" target="_blank"><img src="http://www.mira4.com/img/m4_logo.gif" /></a><br>07/2009</div><p style="color:black">Konzept, PM: Alexander Weiß<br>Koordination: Priska Pieczara<br>Layout/Design: derStaud<br>HTML: Volker Eckl<br>SilverStripe: Ludwig Ruderstaller</p></div>';

$(document).konami(function(){
	$('body').append(authordiv);
	$('#author').show('slow');
});
