<!--
/**
 * K-onstruct CMS
 * Copyright (C) 2008-2011 Kevin Kis
 *
 * Formerly known as CECMS Content Management System
 *
 * PHP version 5
 * @copyright  2008-2011 Kevin Kis
 * @author     Kevin Kis <http://www.k-kombinat.de>
 *
 */

/**
 * Load on ready state
 */


$(function() {
    
    // init shadowbox
    Shadowbox.init({
        skipSetup: true
    }, setupShadowBox);
    
    globalStartAnimation();
    
    initGlobalContactHandler();
    initGlobalLogoHandler();
  
});


function globalStartAnimation() {
    
    animateBackgroundcolor(1000);
    
    // load topmenu
    setTimeout(function(){
        animateTopMenu(400);
    },1100);  
    
    // animate contact
    setTimeout(function(){
        animateContact("fast");
    },2000);
    
    // fade backgroundimage
    setTimeout(function(){
        animateBackgroundImage(1200);
    },3000);
    
    // animate macronumber
    setTimeout(function(){
        animateMacroNumber(400)
    },3000);
    
    // animate macronumber
    setTimeout(function(){
        animateLogo();
    },4000);
    
}


// animate backgroundcolor
function animateBackgroundcolor(time) {    
    fadeinbyid('#BackgroundColor', time);
}


// animate backgroundcolor
function animateBackgroundImage(time) {    
    fadeinbyid('#BackgroundImage', time);
}

// animate topmenu
function animateTopMenu(time) {
    $('#TopMenu').animate({
        "top": "+=45px"
    }, time);
}

// animate contact
function animateContact(time) {
    $('#Contact').animate({
        "right": "+=248px"
    }, time);
}

// animate macrobox
function animateMacroNumber(time) {
    $('#MacroNumber').animate({
        "left": "+=430px"
    }, time);
}

function animateMacroLinkName(left) {
    $('#MacroLinkName').animate({
        "left": "+="+left+"px"
    }, 400);
}

// animate logo
function animateLogo(time) {
    fadeinbyid('#Logo', time);
}

// animate gallery
function animateGalleryBox(time) {
    $('#GalleryContainer').animate({
        "right": "+=2064px"
    }, time);
    $('#GalleryInfo').animate({
        "right": "+=2078px"
    }, time);
    $('#GalleryInfoWeb').animate({
        "right": "+=2078px"
    }, time);
}

// animate left menu
function animateLeftMenu(time) {
    $('#MenuLeft').animate({
        "left": "+=55px"
    }, time);
}

// animate left side image
function animateLeftSideImage(time) {
    $('#LeftsideImage').animate({
        "left": "+=567px"
    }, time);
}


function setupShadowBox() {
    
    // init shadow gallery
    Shadowbox.setup('#Gallery a.shadowbox', {
        gallery:        "print",
        continuous:     true,
        counterType:    "skip",
        onFinish:         function() {
            $("#Gallery").trigger("pause");
        },
        onClose:       function() {
            $("#Gallery").trigger("play");
        }
    });
    // init shadow layer
    Shadowbox.setup('a.shadowlayer', {
        width   :   735,
        height  :   479,
        onOpen: function() {
            $('#sb-title-inner').css('display','none');
        }
        
    });
    // init shadow layer
    Shadowbox.setup('a.contactshadowlayer', {
        width   :   700,
        height  :   450,
        gallery:    "contact",
        counterType:    "skip"
        
        
    });
}

// initialize gallery
function initGallery() {
    
    $("#Gallery").carouFredSel({
        auto    :   {
            delay           :   5000,
            duration        :   3500,
            pauseDuration   :   6000,
            items           :   1
        },
        items: {
            visible: 3,
            width: 301,
            height: 303
        },
        scroll  : {
            items   :   2
        },
        prev    :   {   
            button  : "#GalleryPrev",
            key     : "left"
        },
        next    :   {
            button  : "#GalleryNext",
            key     : "right"
        }
    }); 
}

function blink(elm, msec, speed) {
    $(elm).hide();
    $(elm).fadeIn(speed);
    window.setTimeout("blink('" + elm + "', " + msec + ", '" + speed + "')", msec);
}

stopblinkbyopacity = false;
function blinkbyopacity(elm, scale, speed) { 
    
    if(stopblinkbyopacity === false) {
    
        $(elm).animate({
            "opacity": "-="+scale
        }, speed);
        $(elm).animate({
            "opacity": "+="+scale
        }, speed);

        setTimeout(function(){
            blinkbyopacity(elm, scale, speed);
        },2*speed);   
    
    }
}



function easemenuover(id) {
    
    $('#'+id).animate({
        "margin-top": -2,
        "height":54
    }, {
        queue: false, 
        duration: 500, 
        easing: 'easeOutBack'
    });
        
    $('#'+id+ ' a').css({
        "color":"#000000"
    })
    
}

function easemenuout(id) {
    
    $('#'+id).animate({
        "margin-top": -15
    }, {
        queue: false, 
        duration: 500, 
        easing: 'easeOutBounce'
    })
        
    $('#'+id+ ' a').css({
        "color":"#FFF"
    })
    
}

function lmeasemenuover(id) {
    
    $('#'+id).animate({
        "margin-left": 0,
        "width":59
    }, {
        queue: false, 
        duration: 500, 
        easing: 'easeOutBack'
    });
        
    $('#'+id+ ' a').css({
        "color":"#000000"
    })
    
}

function lmeasemenuout(id) {
    
    $('#'+id).animate({
        "margin-left": -10
    }, {
        queue: false, 
        duration: 500, 
        easing: 'easeOutBounce'
    })
        
    $('#'+id+ ' a').css({
        "color":"#FFF"
    })
    
}

function initContactHandler() {
    
    $('#Contact').mouseover(
    
        function() {
            $('#Contact').animate({
                "margin-right": 30
            }, {
                queue: false, 
                duration: 500, 
                easing: 'easeOutBack'
            });
        })
    
}

function initGlobalContactHandler() {
    
    $('#Contact').mouseover(
    
        function() {
            $('#Contact').animate({
                "margin-right": 30
            }, {
                queue: false, 
                duration: 500, 
                easing: 'easeOutBack'
            });
            
        }).mouseout(
    
        function() {
            $('#Contact').animate({
                "margin-right": -30
            }, {
                queue: false, 
                duration: 500, 
                easing: 'easeOutBounce'
            });
        })
}

function initGlobalLogoHandler(){
    
    $('#Logo').ready(
        
        function() {
            $('#Logo').animate({
                "opacity": 0.8
            });
            
        }).mouseover(
    
        function() {
            $('#Logo').animate({
                "opacity": 1
            });
            
        }).mouseout(
    
        function() {
            $('#Logo').animate({
                "opacity": 0.8
            });
        })
}


function showbyid(id){
    $(id).show();
}


function fadeinbyid(id, timeout) {
    $(id).fadeIn(timeout);
}

function fadeoutbyid(id, timeout) {
    $(id).fadeOut(timeout);
}


function setmenuposition (id, margin, color) {
    $('#'+id+ ' a').css({
        'margin-top':margin, 
        'color': color
    });
}

function setleftmenuposition (id, margin, color) {
    $('#'+id+ ' a').css({
        'padding-left':margin, 
        'color': color
    });
}

function togglebyid(id, time) {
    $(id).toggle(time)
}

function showbyid(id, time) {
    $(id).show(time)
}

function hidebyid(id, time) {
    $(id).hide(time)
}

function initStandardToggleInfo() {
    
    $("#GalleryInfo").click().toggle(function() {
        $('#GalleryText').animate({
            height: 'show',
            opacity: 'show'
        }, 'slow');
        $('#InfoButtonDown').show();
        $('#InfoButtonUp').hide();
    }, function() {
        $('#GalleryText').animate({
            height: 'hide',
            opacity: 'hide'
        }, 'slow');
        $('#InfoButtonDown').hide();
        $('#InfoButtonUp').show();
    });
}

function setLayerContentHeight() {
    
    var height = $(window).height()-69;
    $('#Content').css('height', height) ;
}

-->
