/*
 * Default JavaScript Library v1.0
 *
 * @name $Id: common.js
 * @domain: jungfrauregion.ch
 * 
 * @author		Martin Melheritz martin@visioninternet.ch
 * @date created	05/08/2011
 * @last modified	21/09/2011
 * @copyright 		Copyright (C) 2011 Visioninternet Science & Consulting
 *
 * This is a commercial software product, please visit http://www.visioninternet.ch for more information.
 */
 
function openInfoWindow (url) {
	var screen_width, screen_height;
	var win_top, win_left;
	var InfoWindow;
	
	screen_height        = 0;     screen_width      = 0;
	win_top              = 0;     win_left          = 0;
	
	var help_win_width   = 650;
	var help_win_height  = 650;
	
	if (window.innerWidth) screen_width = window.innerWidth;
	if (window.innerHeight) screen_height = window.innerHeight;
	
	win_top  = screen_height - help_win_height - 20;
	win_left = screen_width  - help_win_width  - 20;
	InfoWindow  = window.open(
	            url,
	            'Drucken',
	            'width='+help_win_width+',height='+help_win_height+',top='+win_top+',left='+win_left+',scrollbars=yes,menubar=no'
	);
	InfoWindow.focus();
}

/* 
 * Image gallery click event. Add a trigger event to the actual click event in browsers that don't let you
 * click() directly.
 */
if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.click) {
	HTMLElement.prototype.click=function() {
		var evt = this.ownerDocument.createEvent('MouseEvents');
		evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
		this.dispatchEvent(evt);
	}
}

/* Ken Burns Banner */
jQuery(function($){
	$(".peKenBurns").peKenburnsSlider()
})


$(document).ready(function() {
	
	/* Image & Info description */
	$(".image-info").hover(             
		function() {                 
			$(".image-info-description", this).slideDown('slow');},             
		function() {                 
			$(".image-info-description", this).slideUp('slow');             
		}
	);

	/*Lists & Element Link */
	$(".iframe").colorbox({iframe:true, width:982, height:754});
	$(".iframe-padding").colorbox({iframe:true, width:992,  height:754});
	
	/* Livecam */
	$("a[rel='webcam']").colorbox({slideshow:true, slideshowAuto:false, maxWidth:530, maxHeight:530, scalePhotos:true});
	$(".webcam").colorbox({iframe:true, width:564, height:518, scrolling:false});
	
	/* Hide map elements */
    $('.status-map-options').click(function() {        
		if (this.checked) {           
			$("."+this.value).show();         
		} else {          
			$("."+this.value).hide();   
		}     
	});
	
	/*Tooltip*/
	$(".status-map img[title]").tooltip();
	
	/* Package navigation on start page */
    $('.package-nav').click(function() {        

		var nextPackage = $(this).parents('.wrap-package').next('.wrap-package');
		var name = $(this).attr("title");
		$(this).parents('.wrap-package').hide();
		if(nextPackage.length == 0 ){
			$('.first-wrap-package-'+name).show(); 
		}else{
			$(this).parents('.wrap-package').next('.wrap-package').show();
		}
		 
	});
	
	/* Package navigation on frontend */
    $('.package-nav-freemod').click(function() {        

		var nextPackage = $(this).parents('.package').next('.package');
		var name = $(this).attr("alt");
		$(this).parents('.package').hide();
		if(nextPackage.length == 0 ){
			$('.first-package-'+name).show(); 
		}else{
			$(this).parents('.package').next('.package').show();
		}
		 
	});
	
	/* Event navigation on start page */
    $('.topevent-content-nav').click(function() {        

		var nextPackage = $(this).parents('.wrap-topevent').next('.wrap-topevent');
		$(this).parents('.wrap-topevent').hide();
		if(nextPackage.length == 0 ){
			$('.first-wrap-topevent').show(); 
		}else{
			$(this).parents('.wrap-topevent').next('.wrap-topevent').show();
		}
		 
	});
    $('.excursion-content-nav').click(function() {        

		var nextPackage = $(this).parents('.wrap-excursion').next('.wrap-excursion');
		$(this).parents('.wrap-excursion').hide();
		if(nextPackage.length == 0 ){
			$('.first-wrap-excursion').show(); 
		}else{
			$(this).parents('.wrap-excursion').next('.wrap-excursion').show();
		}
		 
	});
});
