
/* <![CDATA[ */

//alert($(window).width());

function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}




        
Cufon.replace('#navigation ul li a', {
    hover: true
});
Cufon.replace('p', {
    hover: true
});

Cufon.replace('p#imgtext', {
    hover: true
});
var aktid = 1;

$(document).ready(function() {

    $("#arrow_left").hide();
    $("#arrow_right").hide();
    
    $("p#imgtext").hide();
    

    var navwidth = 230;
    
    
    if($(window).width()>1430){
    	
    
      var img_width = 1200;
      var img_height = 800;
      $(".big").css("height","800px");
      $(".big").css("width","1200px");      
      $(".content .big p").css("width","1200px");      
      $("#add").css("top","757px");
      $("#remove").css("top","757px");    
      $("#arrow_left").css("top","400px");   
      $("#arrow_right").css("top","400px");   
      $("#arrow_right").css("left","1180px");   
      $("#pdf").css("top","812px");
      $("#pdf").css("left","1044px");
      
    }else{
      var img_width = 800;
      var img_height = 533;
    }

        // img_width = $(window).width()  - navwidth;

    $(".thumbs img").mouseover(function(){
        var x1 = $(this).position();
        var x2 = $(this).position();
        var lval1 = x1.left - 14;
        var tval1 = x1.top + 140;        
        var lval2 = x2.left + $(this).width() - 10;
        var tval2 = x2.top - 14;        
        $("#layer1").css('top', tval1 + 'px');
        $("#layer1").css('left', lval1 + 'px');
        $("#layer2").css('top', tval2 + 'px');
        $("#layer2").css('left', lval2 + 'px');        
        $("#layer1").show();
        $("#layer2").show();
    });
    

    
    
    /* THUMBNAIL */
    $(".thumbs img").click(function(){  
    	
   	    $("p#imgtext").show();
        $('html, body').animate({scrollTop:0}, 'slow');
        //$(".big").show();
        aktid = $(this).attr("id");
        $("#layer1").hide();
        $("#layer2").hide(); 
        $(".big").slideDown(5);

        var pp = $(this).attr("src");
        pp = pp.replace(225,img_width);
        pp = pp.replace(150,img_height);

        $(".big img.thebigone").hide() //Hide it
         .one('load', function() { //Set something to run when it finishes loading
          $(this).delay(400).fadeIn(1000,function(){
          $("#arrow_left").fadeIn(500);
        	schoninlightbox($("img#" + aktid).attr("name"));
           $("#arrow_right").fadeIn(500);
           }); //Fade it in when loaded
        })
        
        .attr('src', pp) //Set the source so it begins fetching
        .each(function() {
          //Cache fix for browsers that don't trigger .load()
          if(this.complete) $(this).trigger('load');
        });
        
        $("p#imgtext").html($("#" + aktid).attr("alt"));
        Cufon.refresh('p#imgtext'); 

    });

    /* LINKER BUTTON */
    
    $("#arrow_left").click(function(){
        if(aktid > 1){
        	aktid --;
        }else{
        	aktid = $('.thumbs img').last().attr("id");
        }
        
        $("#layer1").hide();
        $("#layer2").hide();
        
        var x1 = $(".thumbs img#" + aktid).position();
        var x2 = $(".thumbs img#" + aktid).position();
        var lval1 = x1.left - 14;
        var tval1 = x1.top + 140;        
        var lval2 = x2.left + $(".thumbs img#" + aktid).width() - 10;
        var tval2 = x2.top - 14;        
        $("#layer1").css('top', tval1 + 'px');
        $("#layer1").css('left', lval1 + 'px');
        $("#layer2").css('top', tval2 + 'px');
        $("#layer2").css('left', lval2 + 'px');        
        $("#layer1").fadeIn(1000);
        $("#layer2").fadeIn(1000);       

        var fo = $("#" + aktid).attr("class");
        if($(window).width()>1430){
		 fo = fo.replace('800c','1200c');
		 fo = fo.replace('533h','800h');		 
        }
        $(".big img.thebigone").attr("src",fo).delay(400).fadeIn(1000);
        $("p#imgtext").html($("#" + aktid).attr("alt"));
        Cufon.refresh('p#imgtext'); 
        schoninlightbox($("img#" + aktid).attr("name"));
    });

    /* RECHTER BUTTON */
    
    $("#arrow_right").click(function(){
    	if($('.thumbs img').last().attr("id") == aktid){
    	aktid = 1;
    	}else{
        aktid++;
    	}
    	
    	$("#layer1").hide();
        $("#layer2").hide();

        var x1 = $(".thumbs img#" + aktid).position();
        var x2 = $(".thumbs img#" + aktid).position();
        var lval1 = x1.left - 14;
        var tval1 = x1.top + 140;        
        var lval2 = x2.left + $(".thumbs img#" + aktid).width() - 10;
        var tval2 = x2.top - 14;        
        $("#layer1").css('top', tval1 + 'px');
        $("#layer1").css('left', lval1 + 'px');
        $("#layer2").css('top', tval2 + 'px');
        $("#layer2").css('left', lval2 + 'px');          
        $("#layer1").fadeIn(1000);
        $("#layer2").fadeIn(1000);           
        
        var fo = $("#" + aktid).attr("class");
        if($(window).width()>1430){
		 fo = fo.replace('800c','1200c');
		 fo = fo.replace('533h','800h');		 
        }        
        $(".big img.thebigone").attr("src",fo).delay(400).fadeIn(1000);
        $("p#imgtext").html($("#" + aktid).attr("alt"));
        Cufon.refresh('p#imgtext'); 
        schoninlightbox($("img#" + aktid).attr("name"));

    });    
    
	 $("#overlay").show();
	$(window).load(function () {
	      $("#overlay").fadeOut(500);
	});    
    
    
});

/* ]]> */
