$(function() {

	if( $('#teaser').length ) {
        $('#teaser ul.tabs').tabs('#teaser div.panes > div', {
            current: 'current',
    //		history: 'true',
            effect: 'fade',
            fadeInSpeed: 1000,
            fadeOutSpeed: 0,
            rotate: true
        }).slideshow({
            autoplay: true,
            autopause: true,
            interval: 8000,
            clickable: false
        });
    }

    if( $('#teaserMenu').length ) {
        $('#teaserMenu .panel ul > li').hover(
            function() {
                var target_el = $(this).find('ul');
                var target_pos = $('#teaserMenu .panel').index( $(this).closest('.panel') );
                $('#teaserMenu .panelImage:eq('+target_pos+')').stop().animate({ 'opacity': '1' }, 1000);
                target_el.stop().animate({ 'top': '-'+target_el.height()+'px' }, 400);
            }, function() {
                var target_el = $(this).children('ul');
                var target_pos = $('#teaserMenu .panel').index( $(this).closest('.panel') );
                $('#teaserMenu .panelImage:eq('+target_pos+')').stop().animate({ 'opacity': '0' }, 500);
                target_el.stop().animate({ 'top': '0' }, 400);
            }
        );
    }

    if( $('#flash .flash').length ) {
        $('#flash .flash').live('click', function() {
            $(this).fadeOut(200);
        });
    }

    if( $('#subnavi.scrollable').length ) {
        $('#subnavi.scrollable').stickyPanel();

        $(window).scroll(function() {
            /*
            if( $(this).scrollTop() > 578 ) {
                $('#subnavi.scrollable').css({ 'position': 'fixed', 'left': '853px' });
            } else {
                $('#subnavi.scrollable').css({ 'position': 'absolute', 'left': '640px' });
            }
            */

            $('#subnavi.scrollable li a').each(function() {
                if ( $(window).scrollTop()+150 > $( $(this).attr('href') ).offset().top && $(this).attr('href') != "#create-form" ) {
                    $('#subnavi.scrollable li a').removeClass('current');
                    $(this).addClass('current');
                };
            });
        });

        $('#subnavi.scrollable li a').live('click', function(e) {
            e.preventDefault();
            $('#subnavi.scrollable li a').removeClass('current');
            $(this).addClass('current');
            var target = $(this).attr('href');
            $('html, body').animate({scrollTop: $(target).offset().top-30}, 1000);
        });

        $('.publisherPricingTable a.btnContact').live('click', function(e) {
            e.preventDefault();
            $('#subnavi a[href="#contact"]').click();
        });
    }

    $("a.fancybox").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	300,
		'speedOut'		:	200,
		'overlayShow'	:	true
	});


	$('.link-katso-video').fancybox({
		'padding': '0',
		'margin': '0',
		'opacity': true, //When true, transparency of content is changed for elastic transitions
		'modal': false, //When true, 'overlayShow' is set to 'true' and 'hideOnOverlayClick', 'hideOnContentClick', 'enableEscapeButton', 'showCloseButton' are set to 'false'
		'cyclic': false, //When true, galleries will be cyclic, allowing you to keep pressing next/back.
		'scrolling': 'no', //Set the overflow CSS property to create or hide scrollbars. Can be set to 'auto', 'yes', or 'no'
		'width': 640, //Width for content types 'iframe' and 'swf'. Also set for inline content if 'autoDimensions' is set to 'false'
		'height': 385, //Height for content types 'iframe' and 'swf'. Also set for inline content if 'autoDimensions' is set to 'false'
		'autoScale': false, //If true, FancyBox is scaled to fit in viewport
		'autoDimensions': false, //For inline and ajax views, resizes the view to the element recieves. Make sure it has dimensions otherwise this will give unexpected results
		'centerOnScroll': true, //When true, FancyBox is centered while scrolling page
		'swf': {wmode: 'transparent'}, //Params to put on the swf object
		'hideOnOverlayClick': true, //Toggle if clicking the overlay should close FancyBox
		'hideOnContentClick': false, //Toggle if clicking the content should close FancyBox
		'overlayShow': true, //Toggle overlay
		'overlayOpacity': 0.6, //Opacity of the overlay (from 0 to 1; default - 0.3)
		'overlayColor': '#000', //Color of the overlay
		'transitionIn': 'fade',
		'transitionOut': 'fade', //The transition type. Can be set to 'elastic', 'fade' or 'none'
		'speedIn': 300,
		'speedOut': 200, //Speed of the fade and elastic transitions, in milliseconds
		'changeSpeed': 300, //Speed of resizing when changing gallery items, in milliseconds
		'changeFade': 'fast', //Speed of the content fading while changing gallery items
		'easingIn': 'swing',
		'easingOut': 'swing', //Easing used for elastic animations
		'showCloseButton': true, //Toggle close button
		'showNavArrows': true, //Toggle navigation arrows
		'enableEscapeButton': true, //Toggle if pressing Esc button closes FancyBox
		'type': 'inline' //Forces content type. Can be set to 'image', 'ajax', 'iframe', 'swf' or 'inline'
	});

	$('.link-login').fancybox({
		'padding': '0', //Space between FancyBox wrapper and content
		'margin': '0', //Space between viewport and FancyBox wrapper
		'opacity': true, //When true, transparency of content is changed for elastic transitions
		'modal': false, //When true, 'overlayShow' is set to 'true' and 'hideOnOverlayClick', 'hideOnContentClick', 'enableEscapeButton', 'showCloseButton' are set to 'false'
		'cyclic': false, //When true, galleries will be cyclic, allowing you to keep pressing next/back.
		'scrolling': 'no', //Set the overflow CSS property to create or hide scrollbars. Can be set to 'auto', 'yes', or 'no'
//		'width': 560, //Width for content types 'iframe' and 'swf'. Also set for inline content if 'autoDimensions' is set to 'false'
//		'height': 340, //Height for content types 'iframe' and 'swf'. Also set for inline content if 'autoDimensions' is set to 'false'
		'autoScale': false, //If true, FancyBox is scaled to fit in viewport
		'autoDimensions': true, //For inline and ajax views, resizes the view to the element recieves. Make sure it has dimensions otherwise this will give unexpected results
		'centerOnScroll': true, //When true, FancyBox is centered while scrolling page
//		'ajax': { }, //Ajax options
//		'Note': '',//'error' and 'success' will be overwritten by FancyBox
//		'swf': {wmode: 'transparent'}, //Params to put on the swf object
		'hideOnOverlayClick': true, //Toggle if clicking the overlay should close FancyBox
		'hideOnContentClick': false, //Toggle if clicking the content should close FancyBox
		'overlayShow': true, //Toggle overlay
		'overlayOpacity': 0.6, //Opacity of the overlay (from 0 to 1; default - 0.3)
		'overlayColor': '#000', //Color of the overlay
		'titleShow': false, //Toggle title
		'titlePosition': 'outside', //The position of title. Can be set to 'outside', 'inside' or 'over'
//		'titleFormat': null, //Callback to customize title area. You can set any html - custom image counter or even custom navigation
		'transitionIn': 'fade',
		'transitionOut': 'fade', //The transition type. Can be set to 'elastic', 'fade' or 'none'
		'speedIn': 300,
		'speedOut': 200, //Speed of the fade and elastic transitions, in milliseconds
		'changeSpeed': 300, //Speed of resizing when changing gallery items, in milliseconds
		'changeFade': 'fast', //Speed of the content fading while changing gallery items
		'easingIn': 'swing',
		'easingOut': 'swing', //Easing used for elastic animations
		'showCloseButton': true, //Toggle close button
		'showNavArrows': true, //Toggle navigation arrows
		'enableEscapeButton': true, //Toggle if pressing Esc button closes FancyBox
/*		'onStart': null, //Will be called right before attempting to load the content
		'onCancel': null, //Will be called after loading is canceled
		'onComplete': null, //Will be called once the content is displayed
		'onCleanup': null, //Will be called just before closing
		'onClosed': null, //Will be called once FancyBox is closed	
*/
		'type': 'inline' //Forces content type. Can be set to 'image', 'ajax', 'iframe', 'swf' or 'inline'
/*		'href': '', //Forces content source
		'title': '', //Forces title
		'content': '', //Forces content (can be any html data)
		'orig': '', //Sets object whos position and dimensions will be used by 'elastic' transition
		'index': '' //Custom start index of manually created gallery (since 1.3.1)
*/
	});

});

