ï»¿ /**************************************************************
 /**************************************************************
			
	»			file                 			indigo.js
	»			project						Club Indigo
	
	»			programmer           		orhn|snmz
	
	»			description			 		Main JavaScript-File

	»			started	          			10.10.2011
	»			finished	          			-
	
	»			to-do		          			-
	
**************************************************************/
	

var slideTimer = setTimeout("slideToNext()", 7500);
var slideAnimRunning = false;
	

 /* jQuery Code */
$(document).ready(function() {

	// Lazy-Load Images
	$(".events-cover-flyer").lazyload({ threshold : 200, effect: "fadeIn" });
	

	// Initialize Map if we are on the Anfahrt - Page
	var page = window.location.href;
	if (page.indexOf("anfahrt") > -1)
		showMap();

		
	// Set the Height of the Background-Stripes to that of the Main-Content
	$('#background-stripes').css('height', (parseInt($('#main-container').css('height')) - 100) + "px");

	// Start the Background-Color-Change-Effect
	changeBackground(30);
	
	
   // Start Countdown-Timer?
   if ($('#countdown-time').text() != "-1")
	countdown(parseInt($('#countdown-time').text()));
   
   
   // Apply Corners where needed
   $('#promo-slideshow-pagination').corner('3px right');
   $('.overlay-showall-link').corner('3px');
   $('.menu-overlay-link').corner('5px');
   
   
   // Slide to the corresponding Picture
   $('#promo-slideshow-pagination img').click( function() { slideToThis( $(this).attr("slide") ); } );
   
   
   // Mouse-over for the Map
   $('#location-map-area').mouseover( function() { $(this).css("opacity", "1.0"); } );
   $('#location-map-area').mouseleave( function() { $(this).css("opacity", "0.5"); } );
   
   
   // Mouse-over for the Location-Menu item
   $('#menu-location').mouseover( function() { $('#location-overlay').show(); } );
   $('#menu-location').mouseleave( function() { $('#location-overlay').hide(); } );
   
   $('#location-overlay').mouseover( function() { $('#menu-location').addClass("top-menu-item-over"); $('#location-overlay').show(); } );
   $('#location-overlay').mouseleave( function() { $('#menu-location').removeClass("top-menu-item-over"); $('#location-overlay').hide(); } );
   
   
   // Mouse-over for the Events-Menu item
   $('#menu-events').mouseover( function() { $('#events-overlay').show(); } );
   $('#menu-events').mouseleave( function() { $('#events-overlay').hide(); } );
   
   $('#events-overlay').mouseover( function() { $('#menu-events').addClass("top-menu-item-over"); $('#events-overlay').show(); } );
   $('#events-overlay').mouseleave( function() { $('#menu-events').removeClass("top-menu-item-over"); $('#events-overlay').hide(); } );
   
   
   // Mouse-over for the Pictures-Menu item
   $('#menu-gallery').mouseover( function() { $('#gallery-overlay').show(); } );
   $('#menu-gallery').mouseleave( function() { $('#gallery-overlay').hide(); } );
   
   $('#gallery-overlay').mouseover( function() { $('#menu-gallery').addClass("top-menu-item-over"); $('#gallery-overlay').show(); } );
   $('#gallery-overlay').mouseleave( function() { $('#menu-gallery').removeClass("top-menu-item-over"); $('#gallery-overlay').hide(); } );
   
   
   // Mouse-over for the Specials-Menu item
   $('#menu-specials').mouseover( function() { $('#specials-overlay').show(); } );
   $('#menu-specials').mouseleave( function() { $('#specials-overlay').hide(); } );
   
   $('#specials-overlay').mouseover( function() { $('#menu-specials').addClass("top-menu-item-over"); $('#specials-overlay').show(); } );
   $('#specials-overlay').mouseleave( function() { $('#menu-specials').removeClass("top-menu-item-over"); $('#specials-overlay').hide(); } );
   
   
   // Mouse-over for the Buttons in the Countdown-Area
   $('#promo-countdown-more').mouseover( function() { this.src = '/img/countdown/moreinfo.over.png'; } );
   $('#promo-countdown-more').mouseleave( function() { this.src = '/img/countdown/moreinfo.png'; } );
   
   $('#promo-countdown-facebook').mouseover( function() { this.src = '/img/countdown/facebook.over.png'; } );
   $('#promo-countdown-facebook').mouseleave( function() { this.src = '/img/countdown/facebook.png'; } );
   
   
   // Mouse-over for the Buttons on the Event-Page
   $('#events-cover-facebook').mouseover( function() { this.src = '/img/countdown/facebook.over.png'; } );
   $('#events-cover-facebook').mouseleave( function() { this.src = '/img/countdown/facebook.png'; } );
   
   $('.events-goto-event').mouseover( function() { this.src = '/img/events/gotoevent.over.png'; } );
   $('.events-goto-event').mouseleave( function() { this.src = '/img/events/gotoevent.png'; } );
   
   $('.events-goto-gallery').mouseover( function() { this.src = '/img/events/gotogallery.over.png'; } );
   $('.events-goto-gallery').mouseleave( function() { this.src = '/img/events/gotogallery.png'; } );
   
   
   // Mouse-over for the Buttons on the Newsletter-Page
   $('#newsletter-subscribe').mouseover( function() { this.src = '/img/newsletter/subscribe.over.png'; } );
   $('#newsletter-subscribe').mouseleave( function() { this.src = '/img/newsletter/subscribe.png'; } );
   
   
   // Mouse-over for the Buttons on the Lottery-Page
   $('#lottery-subscribe').mouseover( function() { this.src = '/img/lottery/subscribe.over.png'; } );
   $('#lottery-subscribe').mouseleave( function() { this.src = '/img/lottery/subscribe.png'; } );
   
   
    // Mouse-over for the Buttons on the Newsletter-Page
   $('#jobs-apply').mouseover( function() { this.src = '/img/jobs/apply.over.png'; } );
   $('#jobs-apply').mouseleave( function() { this.src = '/img/jobs/apply.png'; } );
   
   
   // Mouse-over for the Badges on the Start-Page
   $('#facebook-badge').mouseover( function() { this.src = '/img/badges/facebook.over.png'; } );
   $('#facebook-badge').mouseleave( function() { this.src = '/img/badges/facebook.png'; } );
   
   $('#youtube-badge').mouseover( function() { this.src = '/img/badges/youtube.over.png'; } );
   $('#youtube-badge').mouseleave( function() { this.src = '/img/badges/youtube.png'; } );
   
   
   // Show the Flyer in Full-Size on click
   $('.events-cover-flyer').click( function() { $('#event-flyer-big').css('height', '0px'); $('#event-flyer-big').animate( {height: '650px'}, 250 ); $('#event-flyer-original').fadeIn(); } );
   $('#event-flyer-original').click( function() { $(this).fadeOut(); } );
   
   
   // Show the Job-Formular
   $('#jobs-apply').click( function() { 
   
		$('#job-formular').animate({ height: 'show', opacity: 'show' }, 250);
		$('#job-formular-bg').fadeIn();
		
	} );
	
	
	// Hide the Job-Formular
	$('#job-formular-abort-button').click( function() { 
   
		$('#job-formular').animate({ height: 'hide', opacity: 'hide' }, 250); 
		$('#job-formular-bg').fadeOut();
		
	} );
	
	
	// Show the Newsletter-Subscription-Box
	$('#newsletter-subscribe').click( function() { 
   
		window.scroll(0, 0);
		$('#newsletter-window').animate({ top: '0px' }, 1500, "easeOutBounce", function() {  }); 
		$('#newsletter-formular').animate({ height: 'show', opacity: 'show' }, 500);
		$(this).animate({ opacity: 'hide' }, 500); 
		
		$('#newsletter-form').show();
				
	} );
	
	
	// Show the Lottery-Subscription-Box
	$('#lottery-subscribe').click( function() { 
   
		window.scroll(0, 0);
		$('#newsletter-window').animate({ top: '0px' }, 1500, "easeOutBounce", function() {  }); 
		$('#newsletter-formular').animate({ height: 'show', opacity: 'show' }, 500);
		$(this).animate({ opacity: 'hide' }, 500); 
		
		$('#newsletter-form').show();
				
	} );
	
	
	// Hide Newsletter-Subscription-Box
	$('#newsletter-close-button').click( function() { 
   
		$('#newsletter-window').animate({ top: '-275px' }, 500, "easeOutCirc", function() {  }); 
		$('#newsletter-formular').animate({ height: 'hide', opacity: 'hide' }, 500);
		$('#newsletter-subscribe').animate({ opacity: 'show' }, 500); 
		$('#lottery-subscribe').animate({ opacity: 'show' }, 500); 
				
	} );
	
	
	// Hide Newsletter-Subscription-Box
	$('#newsletter-result-close-button').click( function() { 
   
		$('#newsletter-window').animate({ top: '-275px' }, 500, "easeOutCirc", function() {  }); 
		$('#newsletter-result').animate({ height: 'hide', opacity: 'hide' }, 500);
		$('#newsletter-subscribe').animate({ opacity: 'show' }, 500); 
				
	} );
	
	
	// Reset Text
	$('#newsletter-phone').click( function() { 
   
		$(this).attr("value", "");
		$(this).css("color", "#FFF");
		
				
	} );
	
	
	// Reset Text
	$('#newsletter-email').click( function() { 
   
		$(this).attr("value", "");
		$(this).css("color", "#FFF");
		
				
	} );
	
	
	// Reset Text
	$('#location-map-input').click( function() { 
   
		$(this).attr("value", "");
		$(this).css("color", "#FFF");
		
				
	} );
	
	
	// Show the Gallery-Image in Full-Size
   $('.gallery-thumbnail').click( function() { $('#gallery-picture-big').css('height', '0px'); $('#gallery-picture-big').attr("src", ""); $('#gallery-picture-big').attr("src", $(this).attr("src").replace("thumbs", "fullsize")); ;$('#gallery-picture-big').animate( {height: '650px'}, 250 ); $('#gallery-picture-full').fadeIn(); } );
   $('#gallery-picture-full').click( function() { $(this).fadeOut(); } );
   
});
/* - jQuery Code - */


// Hide the second Background-Image
$('#background-02').css('opacity', '0');



// Initialize Map
function showMap() {

		// Reduce the Opacity of the Map-Overlay-BG
		$('#location-map-area').css("opacity", "0.75");
		$('#location-map-area-bg').css("opacity", "1.0");

		// Center on Club Indigo
		var latlng = new google.maps.LatLng( 50.84027, 6.42592 );
		var club = new google.maps.LatLng( 50.84027, 6.42592 );
		
		
		// Set Options for Map
		var myOptions = { zoom: 13, center: club, mapTypeId: google.maps.MapTypeId.ROADMAP, navigationControl: true,  mapTypeControl: false };
		
		
		// Display the Map
		var map = new google.maps.Map( document.getElementById("location-map-area"), myOptions );
		  
		
		// Add Marker of Office to the Map
		var image = 'beachflag.png';
		var marker = new google.maps.Marker( { position: club, map: map, icon: image, title: "Club Indigo | D&uuml;ren" });
		
		marker.setMap(map);  
		
		
		// Display Info-Window
		var infowindow = new google.maps.InfoWindow({ content: '<div style="font-family: Bebas; font-size: 16px;">Club Indigo D&uuml;ren<br/><br/>Roermonderstra&szlig;e 12<br/>52353 D&uuml;ren</div>' });
		google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); });
			
}


// Slide the Promotion-Area to the next Slide
function slideToNext() {

	if ( parseInt($('#scroll-container').css("left")) - 730 <= parseInt($('#scroll-container').css("width")) * -1) {
		
		var i = parseInt($('#scroll-container').css("left")) / 730 * -1;
		
		$('#promo-slideshow-pagination-' + i).animate( { opacity: '0.25' }, 250);
		$('#promo-slideshow-pagination-0').animate( { opacity: '1.0' }, 500);
		
		$('#scroll-container').animate( { left: '0px' }, 1000, 'easeInOutBack' );
		
		}
	
	else {
	
		var i = parseInt($('#scroll-container').css("left")) / 730 * -1;
		
		$('#promo-slideshow-pagination-' + i).animate( { opacity: '0.25' }, 250);
		$('#promo-slideshow-pagination-' + (i + 1)).animate( { opacity: '1.0' }, 500);
		
		$('#scroll-container').animate( { left: '-=730' }, 1000, 'easeInOutBack' );
		
		}

		
	slideTimer = setTimeout("slideToNext()", 7500);
	
}


// Dot has been click, slide to the according Slide
function slideToThis(slide, delayTime) {

	if (slideAnimRunning == false) {
	
		slideAnimRunning = true;
		
		var i = parseInt($('#scroll-container').css("left")) / 730 * -1;
		var newLeft = slide * 730 * -1;

		clearTimeout(slideTimer);
		
		$('#promo-slideshow-pagination-' + i).animate( { opacity: '0.25' }, 250);
		$('#promo-slideshow-pagination-' + slide).animate( { opacity: '1.0' }, 500);
		
		$('#scroll-container').animate( { left: newLeft }, 1000, 'easeInOutBack', function() { slideAnimRunning = false; slideTimer = setTimeout("slideToNext()", 7500); } );
		
		}
	
}


// Update the Countdown-Timer
function countdown(endtime) {

	var now = Math.round(+new Date()/1000);
	
	var timespan = endtime - now;
	
	var minutes = parseInt(timespan / 60 % 60);
	var hours = parseInt(timespan / 3600 % 24);
	var days = parseInt(timespan / 86400);
	
	
	if (days < 10) days = "0" + days;
	if (hours < 10) hours = "0" + hours;
	if (minutes < 10) minutes = "0" + minutes;
	
	
	if ($('#promo-countdown-days').html() != days)
		$('#promo-countdown-days').html(days).animate( {opacity: '0'}, 100).animate({opacity: '1.0'}, 100).animate( {opacity: '0'}, 100).animate( {opacity: '1.0'}, 100);
		
	if ($('#promo-countdown-hours').html() != hours)
		$('#promo-countdown-hours').html(hours).animate( {opacity: '0'}, 100).animate({opacity: '1.0'}, 100).animate( {opacity: '0'}, 100).animate( {opacity: '1.0'}, 100);
		
	if ($('#promo-countdown-minutes').html() != minutes)
		$('#promo-countdown-minutes').html(minutes).animate( {opacity: '0'}, 100).animate({opacity: '1.0'}, 100).animate( {opacity: '0'}, 100).animate( {opacity: '1.0'}, 100);
		

	setTimeout("countdown(" + endtime + ")", 1000);
	
}


// Background-Effect
function changeBackground( time ) {

	if ( $('#background-02').css('opacity') == '0' )
		$('#background-02').animate( { opacity: '1.0' }, time * 1000, function() { changeBackground( time ); } );
	
	else
		$('#background-02').animate( { opacity: '0' }, time * 1000, function() { changeBackground( time ); } );

}


// Change Page on the Job-Formular
function changePage(oldPage, newPage) {
	
	var switchPage = true;
	
	// Check whether all the Fields have Data
	if (oldPage == "#job-formular-page1" && newPage == "#job-formular-page2") {
	
		if ($('input[name=firstname]').val() == "" || $('input[name=lastname]').val() == "" || $('input[name=street]').val() == "" || $('input[name=postalcode]').val() == ""
				|| $('input[name=city]').val() == "" || $('select[name=gender]').val() == "?" || $('select[name=birthdateDay]').val() == "?" || $('select[name=birthdateMonth]').val() == ""
				|| $('select[name=birthdateYear]').val() == "" || $('input[name=email]').val() == "" || $('input[name=phone]').val() == "" || $('input[name=nationality]').val() == "") {
			
			alert("Bitte fÃ¼lle ALLE Felder aus, da diese sehr entscheidend fÃ¼r deine Job-Anfrage sind!");
			switchPage = false;
			
			}
	
		}
		
	
	if (oldPage == "#job-formular-page2" && newPage == "#job-formular-page3") {
	
		if ($('#checkbox-dj').is(':checked') == false && $('#checkbox-lj').is(':checked') == false && $('#checkbox-technik').is(':checked') == false && $('#checkbox-kasse').is(':checked') == false
				&& $('#checkbox-security').is(':checked') == false && $('#checkbox-garderobe').is(':checked') == false && $('#checkbox-theke').is(':checked') == false
				&& $('#checkbox-cocktailbar').is(':checked') == false && $('#checkbox-service').is(':checked') == false && $('#checkbox-kellner').is(':checked') == false
				&& $('#checkbox-fotograf').is(':checked') == false && $('#checkbox-promotion').is(':checked') == false && $('#checkbox-animation').is(':checked') == false
				&& $('#checkbox-dancer').is(':checked') == false && $('#checkbox-pizza').is(':checked') == false) {
			
			alert("Bitte wÃ¤hle zumindest einen Job aus!");
			switchPage = false;
			
			}
	
		}
	
	if (switchPage) 
		$(oldPage).animate({ width: 'hide' }, 500, function() { $(newPage).animate({ width: 'show' }, 500); }); 
	
	}
	

// Send the Job-Application	
function sendApplication() {

	var sendIt = true;
	
	if ($('select[name=currentjob]').val() == "" || $('input[name=learnedjob]').val() == "" || $('input[name=employer]').val() == "" || $('select[name=driverslicense]').val() == ""
				|| $('select[name=hascar]').val() == "") {
			
			alert("Bitte fÃ¼lle ALLE Felder aus, da diese sehr entscheidend fÃ¼r deine Job-Anfrage sind!");
			sendIt = false;
			
			}

			
	if (sendIt) {
	
		$.post('/sendApplication.php', $('#job-form').serialize() , function(data) {
												  
												if (data == "OKAY")
													$('#job-formular-pagecontainer').html( "<img src='/img/jobs/send_success.png' class='job-formular-result' />" );

												else
													$('#job-formular-pagecontainer').html( "<img src='/img/jobs/send_failure.png' class='job-formular-result' />" );
												  
												});

		}
		
}


// Subscribe to the Newsletter
function newsletterSubscribe() {

	if ( ($('#newsletter-phone').attr( "value" ) == "" || $('#newsletter-phone').attr( "value" ) == "Telefonnummer ..") && ($('#newsletter-email').attr( "value" ) == "" || $('#newsletter-email').attr( "value" ) == ".. oder E-Mail Adresse") ) {
	
		alert("Hey, hast du da nicht etwas vergessen?");
		
		
	
		}

	else {
	
		$.post('/newsletterSubscribe.php', $('#newsletter-form').serialize() , function(data) {
												  
												if (data == "OKAY")
													$('#newsletter-result-message').attr( "src", "/img/newsletter/success.png" );

												else
													$('#newsletter-result-message').attr( "src", "/img/newsletter/failure.png" );
												  
												 
												$('#newsletter-result').show();
												$('#newsletter-formular').hide();
												$('#newsletter-form').hide();
												
												$('#newsletter-window').animate({ top: '-60px' }, 500, "easeOutCirc", function() {  }); 
												
												});
											
	}

}


// Subscribe to the Lottery
function lotterySubscribe() {

	if ( ($('#newsletter-phone').attr( "value" ) == "" || $('#newsletter-phone').attr( "value" ) == "Vorname + Nachname") || ($('#newsletter-email').attr( "value" ) == "" || $('#newsletter-email').attr( "value" ) == ".. und E-Mail Adresse") ) {
	
		alert("Bitte fÃ¼lle BEIDE Felder aus, sonst kannst du leider am Gewinnspiel nicht teilnehmen!");
		
		
	
		}

	else {
	
		$.post('/lotterySubscribe.php', $('#newsletter-form').serialize() , function(data) {
												  
												if (data == "OKAY")
													$('#newsletter-result-message').attr( "src", "/img/newsletter/success.png" );

												else
													$('#newsletter-result-message').attr( "src", "/img/newsletter/failure.png" );
												  
												 
												$('#newsletter-result').show();
												$('#newsletter-formular').hide();
												$('#newsletter-form').hide();
												
												$('#newsletter-window').animate({ top: '-60px' }, 500, "easeOutCirc", function() {  }); 
												
												});
											
	}

}
