var i = 1000;  
var tag = "bilder";
var xx = 1000;
var yy = 2000;
var zz = 3000;
var video = 0;
var audio = 0;
var bilder = 0;
var typ = 0;
var div;
var HTTP_GET_VARS=new Array();
var p;
var v;
var temp;
var ref;
var ref2;
var page;
var modus;

$(document).ready(function(){
  page = document.getElementById("ek_carousel_page");
  page = page.firstChild.id;
  
  modus = document.getElementById("ek_carousel_modus");
  modus = modus.firstChild.id;
  
  strGET=document.location.search.substr(1,document.location.search.length);
  if(strGET!='')
    {
    gArr=strGET.split('&');
    for(p=0;p<gArr.length;++p)
        {
        v='';vArr=gArr[p].split('=');
        if(vArr.length>1){v=vArr[1];}
        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
        }
    }

 ref2 = location.hostname;
 ref2 = "http://"+ref2+"/";
 ref = document.URL;

  
  if(modus=="ek200"){
        //$(".ek_carousel_kasten_vertical").load(ref2+"index.php?eID=tx_ekcarousel&init=4", function (){});
        //$(".ek_carousel_kasten_vertical").animate( { 'marginTop':"100px"}, { queue:true, duration:10000 } );
        //$(".ek_carousel_kasten_vertical").animate( { 'marginTop':"-100px"}, { queue:true, duration:500 } );
         modus2 = document.getElementById("ek_carousel_head");
       	 modus2 = modus2.firstChild.id;
       	 
       	 
       	 modus2 = document.getElementById("ek_carousel_head");
        modus2 = modus2.firstChild.id;
  
        strGET=document.location.search.substr(1,document.location.search.length);
        if(strGET!='')
          {
          gArr=strGET.split('&');
          for(p=0;p<gArr.length;++p)
              {
              v='';vArr=gArr[p].split('=');
              if(vArr.length>1){v=vArr[1];}
              HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
              }
          }
        ref = document.URL;
        bilder = 1;
     
        $("div.ek_carousel_"+tag+"-kasten").show("slow"); 

        $("#ek_carousel_start_"+tag.charAt(0)).load(ref2+"index.php?eID=tx_ekcarousel&gallery=1&page="+page+"&start="+i+"&init=1&typ="+typ+"&id="+HTTP_GET_VARS['did'], function (){aufbauen2(tag);});
       	 
       $('div.ek_carousel_oben').click(function() {  
          hochdrehen();
       }); 
       
       $('div.ek_carousel_unten').click(function() {  
          runterdrehen();
       });       	 
    }else{
 
 
 if(ref.search(/id=1749/) != -1 || ref.search(/typ=2/) != -1){
    i=yy;
    tag = "video";
    typ = 2; 
    video = 1;
    $(".ek_carousel_mehr-button").append('<a href="'+ref2+'index.php?id=1753&typ=2">alle Videos anzeigen</a>');    
 }else if(ref.search(/id=1752/) != -1 || ref.search(/typ=1/) != -1){
    i=zz;
    tag = "audio";
    typ = 1; 
    audio = 1;
    $(".ek_carousel_mehr-button").append('<a href="'+ref2+'index.php?id=1753&typ=1">alle Audio-Dateien anzeigen</a>');
  }else{
    bilder = 1;
    $(".ek_carousel_mehr-button").append('<a href="'+ref2+'index.php?id=1753&typ=0">alle Galerien anzeigen</a>');    
  }
  $("div.ek_carousel_"+tag+"-kasten").show("slow"); 
  $("div.ek_carousel_"+tag+"-button").css({'background-color':"#ABD2F3" , 'color':"#0068a5"});
  $("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&init=3&page="+page+"&typ="+typ+"&start="+(i+4)+"&id="+HTTP_GET_VARS['did']);
  $("#ek_carousel_start_"+tag.charAt(0)).load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&start="+i+"&init=1&typ="+typ+"&id="+HTTP_GET_VARS['did'], function (){aufbauen(tag);});
  
 $('div.ek_carousel_bilder-button').click(function() {
    i=xx;
    tag = "bilder";
    typ = 0;
    if(bilder != 1){
        $("#ek_carousel_start_b").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&start=1000&init=1&typ=0", function (){aufbauen(tag);});
        bilder = 1;
    }
    bildtab();
 });

 $('div.ek_carousel_video-button').click(function() {
    i=yy;
    tag = "video";
    typ = 2;
    if(video != 1){    
        $("#ek_carousel_start_v").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&start=2000&init=1&typ=2", function (){aufbauen(tag);});
        video = 1;
    }
    videotab();
 });

 $('div.ek_carousel_audio-button').click(function() {
    i=zz;
    tag = "audio";
    typ = 1;
    if(audio != 1){
        $("#ek_carousel_start_a").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&start=3000&init=1&typ=1", function (){aufbauen(tag);});
        audio = 1; 
    }
    audiotab();
 }); 

 $('div.ek_carousel_links').click(function() {  
    Linksdrehen();
 }); 
 
 $('div.ek_carousel_rechts').click(function() {  
    Rechtsdrehen();
 }); 
} 
});

function Linksdrehen(){
    $('div.ek_carousel_links').animate( { 'height':"1px"}, { queue:false, duration:0 } );
    $("#ek_carousel_beschreibung").empty();
    var div = "div.ek_carousel_"+tag+"-kasten #ek_carousel_imgbild";
    $(div+(i+2)).animate( { 'width':"0px", 'marginTop':"0px"}, { queue:false, duration:600 } );
    $(div+(i+3)).animate( { 'width':"70px", 'marginTop':"60px"}, { queue:false, duration:600 } );
    $(div+(i+4)).animate( { 'width':"110px", 'marginTop':"45px"}, { queue:false, duration:600 } );
    $(div+(i+5)).animate( { 'width':"165px", 'marginTop':"18px"}, { queue:false, duration:600 } );    
    $(div+(i+6)).animate( { 'width':"110px", 'marginTop':"45px"}, { queue:false, duration:600 } );
    $(div+(i+7)).animate( { 'width':"70px", 'marginTop':"60px"}, { queue:false, duration:600 } );
    $("div#ek_carousel_"+tag+(i+7)).after("<div id=\"ek_carousel_"+tag+(i+8)+"\" class=\"ek_carousel_"+tag+"\"></div>");
    temp = document.getElementById("ek_carousel_"+tag+(i+5));
    temp = temp.firstChild.id;
    $("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=3&typ="+typ+"&start="+(i+5)+"&id="+temp);
    $("div#ek_carousel_"+tag+(i+8)).load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=2&typ="+typ+"&start="+(i+8));
    $("div#ek_carousel_"+tag+(i+1)).remove();

    if(tag == "bilder")xx=xx+1;
    if(tag == "video") yy=yy+1;
    if(tag == "audio") zz=zz+1;
    $('div.ek_carousel_links').animate( { 'height':"1px"}, { queue:true, duration:700 } );
    $('div.ek_carousel_links').animate( { 'height':"160px"}, { queue:true, duration:0 } );
    i=i+1;          
}

function Rechtsdrehen(){
    $('div.ek_carousel_rechts').animate( { 'height':"1px"}, { queue:false, duration:0 } );
    $("div#ek_carousel_"+tag+(i+7)).remove();
    $("#ek_carousel_beschreibung").empty();
    
    div = "div.ek_carousel_"+tag+"-kasten #ek_carousel_imgbild";
    $(div+(i+1)).animate( { 'width':"70px", 'marginTop': "60px"}, { queue:false, duration:600 } );
    $(div+(i+2)).animate( { 'width':"110px", 'marginTop': "45px"}, { queue:false, duration:600 } );
    $(div+(i+3)).animate( { 'width':"165px", 'marginTop':"18px"}, { queue:false, duration:600 } );
    $(div+(i+4)).animate( { 'width':"110px", 'marginTop': "45px"}, { queue:false, duration:600 } );
    $(div+(i+5)).animate( { 'width':"70px", 'marginTop': "60px"}, { queue:false, duration:600 } );
    $(div+(i+6)).animate( { 'width':"0px", 'marginTop': "0px"}, { queue:false, duration:600 } );
    temp = document.getElementById("ek_carousel_"+tag+(i+3));
    temp = temp.firstChild.id;
    $("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=3&typ="+typ+"&start="+(i+3)+"&id="+temp);
    $("div#ek_carousel_"+tag+(i+1)).before("<div id=\"ek_carousel_"+tag+i+"\" class=\"ek_carousel_"+tag+"\"></div>");
    $("div#ek_carousel_"+tag+i).load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=2&typ="+typ+"&start="+i);
    if(tag == "bilder")xx=xx-1;
    if(tag == "video") yy=yy-1;
    if(tag == "audio") zz=zz-1;  
    $('div.ek_carousel_rechts').animate( { 'height':"1px"}, { queue:true, duration:700 } );  
    $('div.ek_carousel_rechts').animate( { 'height':"160px"}, { queue:true, duration:0 } );
    i=i-1;          
}

function hochdrehen(){
	if(i<1004){
    $('div.ek_carousel_oben').animate( { 'height':"1px"}, { queue:false, duration:0 } );
//    $("#ek_carousel_beschreibung").empty();
    var div = "div.ek_carousel_"+tag+"-kasten #ek_carousel_imgbild";
    
    $(div+(i+2)).animate( { 'width':"0px"}, { queue:false, duration:600 } );
    $(div+(i+3)).animate( { 'width':"80px"}, { queue:false, duration:600 } );
    $(div+(i+4)).animate( { 'width':"100px"}, { queue:false, duration:600 } );
    $(div+(i+5)).animate( { 'width':"120px"}, { queue:false, duration:600 } );    
    $(div+(i+6)).animate( { 'width':"100px"}, { queue:false, duration:600 } );
    $(div+(i+7)).animate( { 'width':"80px"}, { queue:false, duration:600 } );

    $(".beschreibung"+(i+2)).animate( { 'margin':"0px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+3)).animate( { 'margin':"-18px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+4)).animate( { 'margin':"-20px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+5)).animate( { 'margin':"-27px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+6)).animate( { 'margin':"-20px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+7)).animate( { 'margin':"-18px auto auto auto"}, { queue:false, duration:600 } );    
    
    /*$(".beschreibung"+(i+2)).css("margin-top","0px");
    $(".beschreibung"+(i+3)).css("margin-top","-31px");
    $(".beschreibung"+(i+4)).css("margin-top","-40px");
    $(".beschreibung"+(i+5)).css("margin-top","-48px");
    $(".beschreibung"+(i+6)).css("margin-top","-40px");
    $(".beschreibung"+(i+7)).css("margin-top","-31px");*/                    
    
	var tttt = "ek_carousel_"+tag+(i+2);
	$("#ek_carousel_"+tag+(i+2)).removeClass('ek_carousel_bilder');
    $(".beschreibung"+(i+2)).hide();
    $(".beschreibung"+(i+7)).show();
	$("#ek_carousel_"+tag+(i+7)).addClass('ek_carousel_bilder');
    
//    $("div#ek_carousel_"+tag+(i+7)).after("<div id=\"ek_carousel_"+tag+(i+8)+"\" class=\"ek_carousel_"+tag+"\"></div>");
//    temp = document.getElementById("ek_carousel_"+tag+(i+5));
//    temp = temp.firstChild.id;
    //$("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&gallery=1&page="+page+"&init=3&typ="+typ+"&start="+(i+5)+"&id="+temp);
//    var tempurl = ref2+"index.php?eID=tx_ekcarousel&gallery=1&page="+page+"&init=2&typ="+typ+"&start="+(i+8); 
//    $("div#ek_carousel_"+tag+(i+8)).load(tempurl,function(){});
//    $("div#ek_carousel_"+tag+(i+1)).remove();

/*    if(tag == "bilder")xx=xx+1;
    if(tag == "video") yy=yy+1;
    if(tag == "audio") zz=zz+1;*/
    $('div.ek_carousel_oben').animate( { 'height':"1px"}, { queue:true, duration:700 } );
    $('div.ek_carousel_oben').animate( { 'height':"27px"}, { queue:true, duration:0 } );
    i=i+1;          
	}
}

function runterdrehen(){
	if(i>999){
    $('div.ek_carousel_unten').animate( { 'height':"1px"}, { queue:false, duration:0 } );
//    $("div#ek_carousel_"+tag+(i+7)).remove();
//    $("#ek_carousel_beschreibung").empty();
    
    div = "div.ek_carousel_"+tag+"-kasten #ek_carousel_imgbild";
    $(div+(i+1)).animate( { 'width':"80px"}, { queue:false, duration:600 } );
    $(div+(i+2)).animate( { 'width':"100px"}, { queue:false, duration:600 } );
    $(div+(i+3)).animate( { 'width':"120px"}, { queue:false, duration:600 } );
    $(div+(i+4)).animate( { 'width':"100px"}, { queue:false, duration:600 } );
    $(div+(i+5)).animate( { 'width':"80px"}, { queue:false, duration:600 } );
    $(div+(i+6)).animate( { 'width':"0px"}, { queue:false, duration:600 } );

    $(".beschreibung"+(i+1)).animate( { 'margin':"-18px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+2)).animate( { 'margin':"-20px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+3)).animate( { 'margin':"-27px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+4)).animate( { 'margin':"-20px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+5)).animate( { 'margin':"-18px auto auto auto"}, { queue:false, duration:600 } );
    $(".beschreibung"+(i+6)).animate( { 'margin':"0px auto auto auto"}, { queue:false, duration:600 } );    

    /*$(".beschreibung"+(i+1)).css("margin-top","-31px");
    $(".beschreibung"+(i+2)).css("margin-top","-40px");
    $(".beschreibung"+(i+3)).css("margin-top","-48px");
    $(".beschreibung"+(i+4)).css("margin-top","-40px");
    $(".beschreibung"+(i+5)).css("margin-top","-31px");
    $(".beschreibung"+(i+6)).css("margin-top","0px");*/  

	$("#ek_carousel_"+tag+(i+6)).removeClass('ek_carousel_bilder');	       
    $(".beschreibung"+(i+6)).hide();
    $(".beschreibung"+(i+1)).show(); 
	$("#ek_carousel_"+tag+(i+1)).addClass('ek_carousel_bilder');	   
    
/*    temp = document.getElementById("ek_carousel_"+tag+(i+3));
    temp = temp.firstChild.id;
    //$("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&gallery=1&page="+page+"&init=3&typ="+typ+"&start="+(i+3)+"&id="+temp);
    $("div#ek_carousel_"+tag+(i+1)).before("<div id=\"ek_carousel_"+tag+i+"\" class=\"ek_carousel_"+tag+"\"></div>");
    $("div#ek_carousel_"+tag+i).load(ref2+"index.php?eID=tx_ekcarousel&gallery=1&page="+page+"&init=2&typ="+typ+"&start="+i);
    if(tag == "bilder")xx=xx-1;
    if(tag == "video") yy=yy-1;
    if(tag == "audio") zz=zz-1;  */
    $('div.ek_carousel_unten').animate( { 'height':"1px"}, { queue:true, duration:700 } );  
    $('div.ek_carousel_unten').animate( { 'height':"34px"}, { queue:true, duration:0 } );
    i=i-1;  
	}
}

function bildtab(){
    $("div.ek_carousel_bilder-button").css({'background-color':"#ABD2F3" , 'color':"#0068a5"});
    $("div.ek_carousel_audio-button").css({'background-color':"#0068a5" , 'color':"#FFF"});   
    $("div.ek_carousel_video-button").css({'background-color':"#0068a5" , 'color':"#FFF"});   
    $("div.ek_carousel_video-kasten").hide("slow");
    $("div.ek_carousel_audio-kasten").hide("slow");
    $("div.ek_carousel_bilder-kasten").show("slow");
    $("div.ek_carousel_video-kasten").hide("slow");
    $("#ek_carousel_beschreibung").empty();
    $("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=3&typ="+typ+"&start="+(i+4));
    $(".ek_carousel_mehr-button").empty();
    $(".ek_carousel_mehr-button").append('<a href="'+ref2+'index.php?id=1753&typ=0">alle Galerien anzeigen</a>');
    tag = "bilder";
    i = xx;
}

function videotab(){
    $("div.ek_carousel_video-button").css({'background-color':"#ABD2F3" , 'color':"#0068a5"});
    $("div.ek_carousel_audio-button").css({'background-color':"#0068a5" , 'color':"#FFF"});
    $("div.ek_carousel_bilder-button").css({'background-color':"#0068a5" , 'color':"#FFF"});
    $("div.ek_carousel_bilder-kasten").hide("slow");
    $("div.ek_carousel_audio-kasten").hide("slow");
    $("div.ek_carousel_video-kasten").show("slow");
    $("#ek_carousel_beschreibung").empty();
    $("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=3&typ="+typ+"&start="+(i+4));
    $(".ek_carousel_mehr-button").empty();
    $(".ek_carousel_mehr-button").append('<a href="'+ref2+'index.php?id=1753&typ=2">alle Videos anzeigen</a>');        
    tag = "video";   
    i = yy;
}

function audiotab(){
    $("div.ek_carousel_audio-button").css({'background-color':"#ABD2F3" , 'color':"#0068a5"});
    $("div.ek_carousel_video-button").css({'background-color':"#0068a5" , 'color':"#FFF"});
    $("div.ek_carousel_bilder-button").css({'background-color':"#0068a5" , 'color':"#FFF"});
    $("div.ek_carousel_bilder-kasten").hide("slow");
    $("div.ek_carousel_video-kasten").hide("slow");
    $("div.ek_carousel_audio-kasten").show("slow");
    $("#ek_carousel_beschreibung").empty();
    $("#ek_carousel_beschreibung").load(ref2+"index.php?eID=tx_ekcarousel&page="+page+"&init=3&typ="+typ+"&start="+(i+4));
    $(".ek_carousel_mehr-button").empty();
    $(".ek_carousel_mehr-button").append('<a href="'+ref2+'index.php?id=1753&typ=1">alle Audio-Dateien anzeigen</a>');   
    tag = "audio";
    i = zz;
}

function aufbauen(tag){
    div = "div.ek_carousel_"+tag+"-kasten #ek_carousel_imgbild";
    $(div+(i+2)).animate( { 'width':"70px", 'marginTop':"60px"}, { queue:false, duration:600 } );
    $(div+(i+3)).animate( { 'width':"110px", 'marginTop':"45px"}, { queue:false, duration:600 } );
    $(div+(i+4)).animate( { 'width':"165px", 'marginTop':"18px"}, { queue:false, duration:600 } );    
    $(div+(i+5)).animate( { 'width':"110px", 'marginTop':"45px"}, { queue:false, duration:600 } );
    $(div+(i+6)).animate( { 'width':"70px", 'marginTop':"60px"}, { queue:false, duration:600 } );
}

function aufbauen2(tag){
    div = "div.ek_carousel_"+tag+"-kasten #ek_carousel_imgbild";
    $(div+(i+2)).animate( { 'width':"80px"}, { queue:false, duration:600 } );
    $(div+(i+3)).animate( { 'width':"100px"}, { queue:false, duration:600 } );
    $(div+(i+4)).animate( { 'width':"120px"}, { queue:false, duration:600 } );    
    $(div+(i+5)).animate( { 'width':"100px"}, { queue:false, duration:600 } );
    $(div+(i+6)).animate( { 'width':"80px"}, { queue:false, duration:600 } );
                       
    $(".beschreibung"+(i+2)).show();
    $(".beschreibung"+(i+3)).show();
    $(".beschreibung"+(i+4)).show();
    $(".beschreibung"+(i+5)).show();
    $(".beschreibung"+(i+6)).show();

    $(".beschreibung"+(i+1)).css("margin","0px auto auto auto");
    $(".beschreibung"+(i+2)).css("margin","-18px auto auto auto");
    $(".beschreibung"+(i+3)).css("margin","-20px auto auto auto");
    $(".beschreibung"+(i+4)).css("margin","-27px auto auto auto");
    $(".beschreibung"+(i+5)).css("margin","-20px auto auto auto");
    $(".beschreibung"+(i+6)).css("margin","-18px auto auto auto");      
}

function GET(v)
{
if(!HTTP_GET_VARS[v]){return 'undefined';}
return HTTP_GET_VARS[v];
}

