/*
  Scripts | © 2011 by ea-st.de
____________________________________________ */

$(window).load(function(){

//-------------------- ON LOAD -------------------------
	$("#shell").fadeIn(375,function(){
    $("#sLogo").fadeIn(450,function(){
      setTimeout( function() {
        $("#sLeft").animate({
          width: '488px',
          left: '0'
        },375);
        $("#sRight").animate({
          width: '488px',
          right: '0'
        },375,function(){
          $("#sLeftHandleArea,#sRightHandleArea").css('display','block');
          $("#section").mouseover(function(){
            $("#sLogo").css('display','none');
          }).mouseleave(function(){
            $("#sLogo").css('display','block');
          });
        });
      }, 2000);
    });
  });
  
});

$(window).bind("unload",function(){});

$(function (){
	$.fn.ScreenJS = function() {
	
//-------------------- HANDLE AREA -------------------------
    function handleArea(haTrigger,haSelector,haLogo,haLogoHorizontal,haTitle){
      $(haTrigger).hover( function () {
  			$(haSelector).addClass("active").stop().animate({
          width: '585px'
        },225,function(){
          if(haTrigger == '#sLeftHandleArea') {
            $(haTitle).stop().animate({
              left: '0'
            },375,'easeInOutCubic',function(){
              $(haLogo).stop().animate({
                left: haLogoHorizontal
              },375,'easeInOutCubic');
            });
          } else {
            $(haTitle).stop().animate({
              right: '0'
            },375,'easeInOutCubic',function(){
              $(haLogo).stop().animate({
                right: haLogoHorizontal
              },375,'easeInOutCubic');
            });
          }
        });
      }, function() {
        $(haSelector).stop().animate({
          width: '488px'
        },225,function(){
    			$(haSelector).removeClass("active");
        });
        if(haTrigger == '#sLeftHandleArea') {
          $(haTitle).stop().animate({
            left: '-780px'
          },150,'swing',function(){
            $(haLogo).stop().animate({
              left: '-525px'
            },150,'swing');
          });
        } else {
          $(haTitle).stop().animate({
            right: '-780px'
          },150,'swing',function(){
            $(haLogo).stop().animate({
              right: '-525px'
            },150,'swing');
          });
        }
      });
    };

    handleArea('#sLeftHandleArea','#sLeft','#sLeftLogo','61px','#sLeftTitle');
    handleArea('#sRightHandleArea','#sRight','#sRightLogo','61px','#sRightTitle');

  };
  $("html").ScreenJS();
});
