jQuery(document).ready(function(){
	//alert(window.innerWidth);
	
    jQuery('#slider').orbit({
        animation: 'fade', // fade, horizontal-slide, vertical-slide, horizontal-push
        animationSpeed: 800, // how fast animtions are
        timer: true, // true or false to have the timer
        advanceSpeed: 5000, // if timer is enabled, time between transitions 
        pauseOnHover: false, // if you hover pauses the slider
        startClockOnMouseOut: true, // if clock should start on MouseOut
        startClockOnMouseOutAfter: 1000, // how long after MouseOut should the timer start again
        directionalNav: true, // manual advancing directional navs
        captions: true, // do you want captions?
        captionAnimation: 'fade', // fade, slideOpen, none
        captionAnimationSpeed: 800, // if so how quickly should they animate in
        bullets: true, // true or false to activate the bullet navigation
        bulletThumbs: false, // thumbnails for the bullets
        bulletThumbLocation: '', // location from this file where thumbs will be
        afterSlideChange: function(){
        } // empty function 
    });

	cbeTooltip.init(); 
	if( navigator.userAgent.match(/Android/i) ||
 navigator.userAgent.match(/webOS/i) ||
 navigator.userAgent.match(/iPhone/i) ||
 navigator.userAgent.match(/iPad/i) ||
 navigator.userAgent.match(/iPod/i)
 ){
$("#nav-tickets a, #button-buy-tickets").attr('target', '_blank');
} else {

$("#nav-tickets a, #button-buy-tickets").fancybox({
'width' : '8','height' : '85%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe',
'overlayOpacity' : 0.7,
'overlayColor': '#000'
});
}

});


 function autoIframe(frameId){
        try{
            frame = document.getElementById(frameId);
            innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
 
            if (innerDoc == null){
                            // Google Chrome
                frame.height = document.all[frameId].clientHeight + document.all[frameId].offsetHeight + document.all[frameId].offsetTop;
            }
                    else{
                    objToResize = (frame.style) ? frame.style : frame;
                    objToResize.height = innerDoc.body.scrollHeight + 18;
                    }
        }
 
        catch(err){
                alert('Err: ' + err.message);
            window.status = err.message;
        }
    }



var timeout	= 500;
var closeTimerVar	= 0;



cbeTooltip = {
	
	init: function() {
		jQuery('.calendar').each(function(i,calObj) {
			
   				console.log('Load was performed.');
				
				//start pagination
				jQuery(this, calObj).prepend('<div id="calendar-pagination" </div>');
				
				jQuery(this, calObj).pajinate({
					items_per_page: 5,
					item_container_id: '#calendar',
					nav_panel_id: '#calendar-pagination'
					 
				 
				});
								
				
				/*
				jQuery(this, calObj).append('<div id="cbe-tooltip"> </div>');
				
				
				tt = jQuery('#cbe-tooltip');
				
				jQuery('#calendar li').live('mouseover', function(){
					cbeTooltip.cancelTimer();
					offsetBox = jQuery('.calendar').offset();
					offsetBoxTop = offsetBox.top;
					offsetItem = jQuery(this).offset();
					tt.css({
						'top': ''+(((offsetItem.top - offsetBoxTop) /16))+'em'
					});
					
					// getting datas
					eventTitle 	= jQuery(this).attr('data-title');
					eventDate 	= jQuery(this).attr('data-date');
					eventMeta 	= jQuery(this).attr('data-meta');
					eventDetail = jQuery(this).attr('data-detail');
					
					eventLayerContentWrap = jQuery(	'<h3>'+eventTitle+'</h3>'+
										'<span class="metainfos">'+eventMeta+'</span>'+
										'<p>'+eventDetail+'</p>');
					
					tt.html(eventLayerContentWrap);
					
					if (tt.is(':hidden')) {
						jQuery('#cbe-tooltip').fadeIn(500);
					}
					
					
					
				});
				jQuery('#calendar li').live('mouseout', function() {
					cbeTooltip.closeTimer();
				}); */
			
		});
	},
	
	cancelTimer: function() {
		
		if(closeTimerVar) {
			window.clearTimeout(closeTimerVar);
			closeTimerVar = null
		}
		
	},
	
	closeTimer: function() {
		closeTimerVar = window.setTimeout("cbeTooltip.closeLayer()", timeout);
	},
	
	closeLayer: function() {
		jQuery('#cbe-tooltip').fadeOut(500);		
	}
	
	
}

