﻿/*
$("div.list_container")
.animate({height: "200px"},{duration: 800, complete:function(){
}
});
*/
var $player = {
    buildPlayer: function(opt) {

        $f("plyObj", "player/flowplayer-3.0.7.swf", {
            canvas: {
                backgroundColor: "#000000",
                backgroundGradient: 'none'
            },
            // play button 
            play: {
                url: '../images/play.png',
                width: 83,
                height: 83
            },
            plugins: {
                controls: {
                    durationColor: '#2e2e2e',
                    timeColor: '#ffffff',
                    buttonOverColor: '#8d0000',
                    bufferColor: '#2e2e2e',
                    backgroundColor: '#000000',
                    borderRadius: '0px',
                    backgroundGradient: 'none',
                    sliderColor: '#2e2e2e',
                    bufferGradient: 'none',
                    buttonColor: '#000000',
                    progressColor: '#ffffff',
                    progressGradient: 'none',
                    sliderGradient: 'none',
                    opacity: 1.0,
                    fullscreen: false,
                    autoHide: 'always'
                }
            },
            clip: {
                autoPlay: true,
                autoBuffering: true,
                url: "video/" + opt.data

            }


        });
        $f("plyObj").embed({
            width: 960,
            height: 540,
            index: 0
        });
        $("#plyObj").html($f("plyObj").getEmbedCode(true));
        $player.fadePlayer();

    },
    statePlayer: false,
    fadePlayer: function(opt) {
		if ( $.browser.msie ){
			setTimeout("",1);
			$("#player").css({ display: "block" });
			$("#plyObj").css({ display: "block" });
		}else{
		    $("#player").css({ display: "block" }).animate({ opacity: 1 }, { duration: 1000, complete: function() {
            $("#plyObj").css({ display: "block" });
            $player.statePlayer = true;
        	}
        	});
		}
		

    },
    hidePlayer: function() {
		if ( $.browser.msie ){
			setTimeout("",1);
	        $("#plyObj").css({ display: "none" });
			$("#player").css({ display: "none"});
			$player.rmvPlayer();
			$player.statePlayer = false;
		}else{
	        $("#plyObj").css({ display: "none" });		
			$("#player").animate({ opacity: 0 }, { queue: false, duration: 800, complete: function() {
				$(this).css({ display: "none" });
				$player.rmvPlayer();
				$player.statePlayer = false;
			}
			});
		}
    },
    rmvPlayer: function() {
        $("#plyObj").empty();

    }


}

$.extend({
    $currentSite: "work",
    $lastSite: "work",
    $anim: {
        introOut: function() {
            $("#overlay_container").animate({ opacity: 0 }, { duration: 1200, complete:
				function() {
				    $(this).css({ display: "none" });
				    $.$anim.buildUp();
				}
            });
        },
        menuFadeIn: function() {
            $("#menu ul.menu_list").fadeIn(800, function() {
                $("#footer ul.menu_list").fadeIn(800);
                $("div#work").css({ display: "block" }).animate({ opacity: 1 }, { duration: 800, complete: function() {
							$("#showcase_car").flashembed({src: "swf/showcase.swf", wmode: "transparent", height:"480px"});
						    $("div#showcase").css({ display: "block" }).animate({ opacity: 1 }, { duration: 1200 });
						}
						});


            });

        },
        buildUp: function() {
            $("#overlay_container").empty().remove();
            $("#main .logo").fadeIn(1000, function() { $.$anim.menuFadeIn() });

        },
        buildSite: function(opt) {
            //alert("" + opt.site);
            if (opt.site == "work") {
			 	$("#showcase_car").flashembed({src: "swf/showcase.swf", wmode: 'transparent', height:"480px"});
				$("#showcase").animate({ opacity: 1 }, { queue: false, duration: 800 });
				$("#showcase_car").css({ display: "block"})
				
            }
            if (opt.site == "references") {
				
				
	            $("#references" + " .site_title").css({display:"block"});
                $("#references" + " .site_title:eq(0)").fadeIn(800, function() {
						    $("div.line_horz").animate({ width: "100%" }, { queue: false, duration: 1200, complete: function() {
						        //$("div.list_container").animate({height: "200px"},{queue:false,duration: 800});
						        $("#references" + " .site_title:eq(1)")
									.fadeIn(800, function() {
									    $("div.list_container").animate({ height: "200px", opacity: 1 }, { duration: 800 });
									});
						    }
						    });
						}
					);
            }
            if (opt.site == "team") {
                $("#team" + " .site_title:first")
						.fadeIn(800, function() {
						    $("#team" + " .teambox:eq(0)")
								.animate({ width: "260px" }, { duration: 800, complete: function() {
								    $("#team" + " .teambox:eq(1)")
										.animate({ width: "260px" }, { duration: 800, complete: function() {
										    $("#team" + " .teambox:eq(2)")
												.animate({ width: "260px" }, { duration: 800, complete: function() {
												    $("#team" + " .teambox:eq(0)" + " h2").fadeIn(800, function() {
												        $("#team" + " .teambox:eq(0)" + " h3").fadeIn(800);
												        $("#team" + " .teambox:eq(0)" + " p").fadeIn(800, function() {
												            $("#team" + " .teambox:eq(1)" + " h2").fadeIn(800, function() {
												                $("#team" + " .teambox:eq(1)" + " h3").fadeIn(800);
												                $("#team" + " .teambox:eq(1)" + " p").fadeIn(800, function() {
												                    $("#team" + " .teambox:eq(2)" + " h2").fadeIn(800, function() {
												                        $("#team" + " .teambox:eq(2)" + " h3").fadeIn(800);
												                        $("#team" + " .teambox:eq(2)" + " p").fadeIn(800);
												                    });

												                });
												            });

												        });
												    });
												}
												});
										}
										});
								}
								});
						});
            }
            if (opt.site == "contact") {
                $("#" + opt.site + " .site_title:eq(0)")
						.fadeIn(800, function() {
						    $("#contact ul.list_contact:eq(0)").fadeIn(800, function() {
						        $("#contact div.list_contact_container ul.list_contact")
										.animate({ height: "80px", opacity: 1 }, { duration: 800, complete: function() {
										}
										});

						    });
						});
            }
            if (opt.site == "imprint") {
                $("#" + opt.site + " .site_title:eq(0)")
						.fadeIn(800, function() {
						    $("#imprint ul.list_contact:eq(0)").fadeIn(800, function() {
						        $("#imprint div.list_contact_container ul.list_contact")
										.animate({ height: "80px", opacity: 1 }, { duration: 800, complete: function() {
										    $("#imprint div.list_contact_container ul.list_contact_info:eq(0)").animate({ height: "50px" }, 800);
										    $("#imprint div.list_contact_container ul.list_contact_info:eq(1)").animate({ height: "30px" }, 800);
										    $("#imprint div.list_contact_container ul.list_contact_info:eq(2)").animate({ height: "90px" }, 800);
										}
										});

						    });
						});
            }
        },
        resetSite: function(opt) {
			$("#" + $.$lastSite).css({ display: "none" }).removeAttr("style");
			$("#" + $.$lastSite + " div,span,ul,p,h3,h4,img,div.site_title").removeAttr("style");
            $(".menu_list").css({ display: "block" });
			if ( $.browser.msie ){setTimeout("",1);};
            if (opt.complete != 'undefined' && opt.complete != null)
                opt.complete();
            return this;
        }
    }
});

jQuery.fn.extend({
    $fadeToC: function(opt) {

        if ($(this).css("display") == "none") {

            if (opt.complete != null) {

                $(this).css({ "display": "block", filter: "alpha(opacity=0)" }).animate({ opacity: opt.opacity }, { queue: false, duration: opt.duration, complete: opt.complete });
                $("#bkg_container").animate({ opacity: 1 }, { duration: 1200 });
                return false;
            }

            $(this).css({ display: "block", filter: "alpha(opacity=0)" }).animate({ opacity: opt.opacity }, { duration: opt.duration });
			$.$anim.buildSite({ site: $(this).attr("id") });
            if ($(this).attr("id") != "work") { $("#bkg_container").animate({ opacity: 0.4 }, { duration: 1200 }); }
            return this;
        }

        if (opt.complete != null) {
            $(this).animate({ opacity: opt.opacity }, { duration: opt.duration, complete: opt.complete });
            $("#bkg_container").animate({ opacity: 1 }, { duration: 1200 });
            return false;
        }

        $(this).animate({ opacity: opt.opacity }, { duration: opt.duration }).css(opt.css);
        $("#bkg_container").animate({ opacity: 0.4 }, { duration: 1200 });
        return this;
    },
    $setMenu: function() {
        $(".menu_list li.visited").removeClass("visited");
        $(this).parent('li').addClass("visited");
    },
    $switchSite: function(opt) {
		if ( $.browser.msie ){
			if($.$lastSite == "work"){
			$("#showcase_car").empty();
			$("#showcase_car").css({ display: "none" });
			
			}
		}
		$("#" + $.$lastSite).$fadeToC({ opacity: 0, duration: 1200, complete: function() {
		    $.$anim.resetSite(
                jQuery.fn.extend({
                    complete: function() {
                        $("#" + opt.currentSite).$fadeToC({ opacity: 1, duration: 800 });
                        if (opt.complete != "undefined" && opt.complete != null) opt.complete();
                        return this;
                    }
                }, opt)
            );
        }
        });
	
		
        $(this).$setMenu();
        return this;
    },
    $menu: function() {
        $(this).each(function() {
            $(this).click(function(event) {
                var currentSite = this.className.split("_");
                if (currentSite.length >= 3) {
                    $.$lastSite = $.$currentSite;
                    $.$currentSite = currentSite[2];
                    $(this).$switchSite({ currentSite: $.$currentSite });
                }
            });
        });
        return this;
    }
});

            