/*
    Skischule Alpach Aktiv
    by leuchtfeuer design+technology

    copyright >= 2011 by leuchtfeuer. all rights reserved.

*/

$(document).ready(function(){	

	var mapopen = 0;
	var tt = 0;

	var cntslides = $('.galleryslide li').size();
	if(typeof slidecontent == "undefined") {
		var slidecontent = $('.headerimg').html();
	}
    
	$('.faq p').slideToggle('hide');
	$(".faq h2").click(function () {
		$(this).next('p').slideToggle('hide');
		return false;
	});	

	$('.col_1_4_3')
	.mouseover(function(){
		$(this).addClass('col_1_4_3_hover');		
	})
	.mouseout(function(){
		$(this).removeClass('col_1_4_3_hover');
	})

	$('#googlemap').gMap({	
	            controls: ["GLargeMapControl"],		
	            maptype: G_HYBRID_MAP,
							latitude: 47.408573553097554,
							longitude: 11.927719116210938,
							zoom: 11,
							scrollwheel: true,
							markers: [{ latitude: 47.450706268171004,
										longitude: 11.865046620368958,
										html: GMAP_LOCATION_1 },
										{ latitude: 47.39832559781772,
										longitude: 11.943820416927338,
										html: GMAP_LOCATION_2 },
									  { latitude: 47.372045781340226,
										longitude: 11.928480863571167,
										html: GMAP_LOCATION_3 },
									  { latitude: 47.396421019424764,
										longitude: 11.924135684967041,
										html: GMAP_LOCATION_4 }
									],
							icon: { image: "/assets/templates/images/alpbachicon.png",
									  iconsize: [42, 54],
									  iconanchor: [42,54],
									  infowindowanchor: [12, 0] }
	});		

	$('.showmap').click(function(){		
		if(mapopen == 0) {
			$('.headerimg').fadeOut('slow', function() {
				/*$('.logo').animate({opacity:0},'slow',function(){*/
					$('#googlemap').fadeIn('slow',function(){
						$('.logo').slideUp('slow');		
						$('.closegmap').fadeIn('slow');
					});									   
				/*});*/
			});			
			mapopen = 1;
		} else {
			$('.closegmap').fadeOut('slow');
			$('#googlemap').fadeOut('slow',function() {
				$('.headerimg').fadeIn('slow',function(){
					$('.logo').slideDown('slow',function(){
						alpbach.startSlider( cntslides );							 
					});
				});									
			});
			mapopen = 0;
		}
		return false;
	});	
	
	$('.closegmap a').click(function(){
		$('.closegmap').fadeOut('slow');							 
		$('#googlemap').fadeOut('slow',function() {
			$('.headerimg').fadeIn('slow',function(){
				$('.logo').slideDown('slow',function(){
					alpbach.startSlider( cntslides );							 
				});
			});									
		});
		mapopen = 0;
		return false;
	});

	$("a[rel*=totop]").click(function(){
		$('html, body').animate({scrollTop:0}, 'slow'); 
		return false;

	});	

	$('a.new').click(function(){
		window.open(this.href);
		return false;
	});	

	$('a[rel=colorbox]').colorbox({width:"80%", height:"90%", iframe:true, current: '', previous: '', next: ''});
 	$("a[rel='colorboxSlide']").colorbox({slideshow:true, slideshowSpeed: 10000});
	$('a.widgetweather').colorbox({width:"385", height:"290", iframe:true, current: '', previous: '', next: ''});

	$('.chooselang ul').slideToggle('hide');
	$(".selectlang").click(function () {
		$('.chooselang ul').slideToggle('hide');
		return false;
	});		

	var alpbach = {
			startSlider: function( cntslide ) {
				if(cntslide >= 2) {
					var slider = $('.galleryslide').bxSlider({
						auto: true,
						controls: false,
						pause: 10000
					});
					slider.startShow();
				}					
			}
	}

	alpbach.startSlider( cntslides );
});

/* Cufon Registration */
Cufon.replace('.cufon, .mnu_content h1, #nav .last, .col_1_4_3 a span', { fontFamily: 'Quara' });
Cufon.replace('.teaser1 h1, .teaser2 h1, .teaser3 h1, .teaser4 h1, .teaser h3', { fontFamily: 'Quara' });
Cufon.replace('#leftpanel h1, #leftpanel .details h1, #leftpanel .details h1.nobg', { fontFamily: 'Quara' });
Cufon.replace('#rightpanel h1, #rightpanel .details h1, #rightpanel .details p.h1', { fontFamily: 'Quara' });
Cufon.replace('.teaser4content .left a', { fontFamily: 'ProximaNova' });
