var skipCFmax = 0;

$(document).ready(function() {
    
	$("#webcam").hover(function (){
		    $(this).css( "background-image", "url(fileadmin/mm2010/bilder/button_webcam_aktiv.gif)"); 
    }, function(){ 
        $(this).css( "background-image", "url(fileadmin/mm2010/bilder/button_webcam_inaktiv.gif)"); 
    });

  var heightSC = $(".scrollContent").height();
  if (heightSC == 320) {
    $(".content-element").css("overflow","auto");
   // $(".content-element").css("overflow-y","scroll");
    // alert(heightSC);
  }
  //alert(heightSC);
  $("a[href^='webcam/']").attr('onClick', 'openPage(\"/?id=808\")')
                        .attr('href', '#');

  if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPad/i))) {
  $(".iconflowDetailCF").swipe({
      swipeLeft: function() { skipCFRight(); },
      swipeRight: function() { skipCFLeft(); }
  });
  }

  $("#header").click(function(){
  		  $("#socialBar").css({"display":"block"});
  });
  
  $("#youtube").hover(function(){
  		socialBar("#youtube");	  
  }, function(){
  	  	socialHide("#youtube");	 
  });
  
    $("#facebook").hover(function(){
  		socialBar("#facebook");	  
  }, function(){
  	  	socialHide("#facebook");	 
  });
    
  $("#blog").hover(function(){
  		socialBar("#blog");	  
  }, function(){
  	  	socialHide("#blog");	 
  });
    
      $("#twitter").hover(function(){
  		socialBar("#twitter");	  
  }, function(){
  	  	socialHide("#twitter");	 
  });
      
        $("#xing").hover(function(){
  		socialBar("#xing");	  
  }, function(){
  	  	socialHide("#xing");	 
  });
  	
  	  $("#team").hover(function(){
  		socialBar("#team");	  
  }, function(){
  	  	socialHide("#team");	 
  });
  
  if ($.browser.msie){
  
  	jQuery("body").css({ "line-height" : "115%" });
  
  }	  

  
});

function switchPage(link, linkbig, id){

  skipCFmax = id;
  
  if (linkbig == 0){
    if(link_status==1){
    
    } else {
   
      if (link=="/?id=808") {
   
      openPage("/?id=808");
   
      } else {
   
        if (link.substr(5,4)=="http") {
                      
          var extLink = link.substr(5,(link.length-5));
          var extLink2 = extLink.substr(0,(extLink.length-4));
          /* document.location.href = extLink; */
          nFenster = window.open(extLink2, "mm100", "width=800,height=900,left=100,top=100");
          nFenster.focus();            
        } else {
          document.location.href = link;
        }
      }
    }
    link_status = 0;
    
  
  } else {
      var closeImage = "button_gallery_close_inaktiv.gif";
      var fHeight = $(window).height();
      var fWidth = $(window).width();
      $("#layer").animate({ width: fWidth+"px", height: fHeight+"px"}, 5 )
               .animate({ opacity: 1 }, 500);
      $("#layer").html("<div id='stageT'></div><div id='stageV' style='top:"+((fHeight-300)/2)+"px; left:"+((fWidth-400)/2)+"px;'><div id='detailBorder'><div class='iconflowDetailCF' style='background-position: center; background-repeat: no-repeat; position: relative; margin: 0 auto; width: 100%; top: 150px; height: 1px; width: 1px; opacity: 1; filter: alpha(opacity = 100);'></div></div><div id='subTitle'>"+subCF[id]+"</div><div id='detailBottom'><div id='arrowLeft' onClick='skipCFLeft();' onMouseover='hoverLeft();' onMouseout='outLeft();'></div><div onClick='closeDetail();' onMouseover='hoverClose();' onMouseout='outClose();' style='position: relative; float: left; left: 23px; width: 36px; height: 26px; top: 0px; background-image: url(typo3conf/ext/tp_test/img/"+closeImage+"); cursor: pointer;'></div><div id='arrowRight' onClick='skipCFRight();' onMouseover='hoverRight();' onMouseout='outRight();'></div></div></div>");
      // $("#layer").html("<div id='stageT'></div><div id='stageV' style='top:"+((fHeight-300)/2)+"px; left:"+((fWidth-400)/2)+"px;'><div id='detailBorder'><div class='iconflowDetail' style='background-position: center; background-repeat: no-repeat; position: relative; margin: 0 auto; width: 100%; top: 150px; height: 1px; width: 1px; opacity: 1; filter: alpha(opacity = 100);'></div></div><div id='subTitle'>"+subIF[id]+"</div><div id='detailBottom'><div id='arrowLeft' onClick='skipLeft();' onMouseover='hoverLeft();' onMouseout='outLeft();'></div><div id='closeDetail' onClick6='closeDetail();' onMouseover='hoverClose();' onMouseout='outClose();' style='position: relative; float: left; left: 23px; width: 36px; height: 26px; top: 0px; background-image: url(/typo3conf/ext/iconflow/img/"+closeImage+"); cursor: pointer;'></div><div id='arrowRight' onClick='skipRight();' onMouseover='hoverRight();' onMouseout='outRight();'></div></div></div>");
      
      $("#stageT").animate({ width: fWidth+"px", height: fHeight+"px"}, 5 )
               .animate({ opacity: 0.9 }, 500);
      $("#detailBorder").css( "background-image", "url(typo3conf/ext/iconflow/img/loading_bar_black.gif)");
      
      for(var lo=0; lo<skipCFend; lo++){
        jQuery.preLoadImages("uploads/tx_tptest/"+jumpCF[lo]);
        // $("#arrowRight").html(lo);
      }
      
      setTimeout(function(){
        $("#detailBorder").css( "background-image", "none");
        $(".iconflowDetailCF").css( "background-image", "url(uploads/tx_tptest/"+linkbig+")");
        $(".iconflowDetailCF").animate({ width: "+=399px", height: "+=299px", top: "-=150px" }, 700);
      }, 2500);
          

  
  }

}

function closeDetail() {
  
  $("#stageT").animate({ opacity: 0 }, 500);
  $("#layer").animate({ opacity: 0 }, 500)
             .animate({ width: "0px", height: "0px"}, 500 )
             .html("");  
  
}

function skipCFLeft(was){
  
  if (skipCFmax <= 1) {
  
  } else {
    skipCFmax--;
    $(".iconflowDetailCF").animate({left: "+=400px", opacity: 0.0}, 400 )
                        .animate({left: "-=400px"}, function() {
                        $(".iconflowDetailCF").css({ "backgroundImage": "url(uploads/tx_tptest/"+jumpCF[skipCFmax]+")" })
                                            .animate({opacity: 1.0});
    });
    $("#subTitle").html(subCF[skipCFmax]);
    
  }
    
}

function skipCFRight(was){
  
  if ((skipCFmax+1) >= skipCFend) {
    
  } else {
    skipCFmax++;
    $(".iconflowDetailCF").animate({left: "-=400px", opacity: 0.0}, 400 )
                        .animate({left: "+=400px"}, function() {
                        $(".iconflowDetailCF").css({ "backgroundImage": "url(uploads/tx_tptest/"+jumpCF[skipCFmax]+")" })
                                            .animate({opacity: 1.0});
    });
    
    $("#subTitle").html(subCF[skipCFmax]);
                        
  }
    
}

function socialBar(bar){
	
	
	$(".sIcon").stop();
	$(".sIcon").css({left: "96px"});
	$(bar).animate({left: "0px"}, 600 );
	
	
}

function socialHide(bar){
	
	
	
	// $("#socialBar").animate({width:"-96px" });
	$(bar).animate({left: "96px"}, 600 );
	
	
}

