var adblock = true;

var cloudMoved = false;

var ww = 0;		
var fac_w = 0;
var fac_px = 0;

$(function(){
	ww = screen.width;
	ww = $('body').width();
	

			
	fac_w = ww/1280;
	$(window).resize(function() {
		$("#facebook").css("right", "0");
	});

	$("img").hide();
	$.PfeLoader.start({onStart:function(){

		},onChange:function(){
			var text = "<span id='loaded'>"+this.loaded + " von "+ this.count + " geladen " + (parseInt((this.loaded+this.timeout) / this.count*100)-5) + "%";
			text+= "</span><br /><br /><br />"
			$(".progress-bar-text").prepend(text);
			
			
			$(".progress-bar-before").css("width", parseInt(parseInt((this.loaded+this.timeout)/this.count*100) - 5)+"%" )
		},onDone:function(){
			var foo = (ww-1000)/2;
			if ($(document).height() > $(window).height()) {
				var mleft = ww-foo-317;	
			}else{
				var mleft = ww-foo-301;	
			}
	
			var fposition = $("#container").position().left;  
			$("#phone").css("margin-left", fposition-ww+1000);
			
		 $(window).resize(function() {
		   	ww = $('body').width();
      	fppx = $("#container").position().left;  
      	$("#phone").css("margin-left", fppx-ww+1000);
      });  
	
			$("#preload").fadeOut();
			$("img").fadeIn("slow");
			setTimeout("place()", 2500);
			
			cloudMove();
		}});
		
		
		$("body").click(function(){
	    $('#lst').css("display","none");
     	$('#ref').css("display","none");
		$('#abt').css("display","none");
     	$('#blg').css("display","none");
});

$('#place1').toggle(
    
    function() {
        $('#abt').show('fade', { direction: 'vertical' }, 500);
     	$('#lst').css("display","none");
     	$('#ref').css("display","none");
     	$('#blg').css("display","none");
		
    },
	function() {
        $('#abt').hide('fade', { direction: 'vertical' }, 1000);
    }
);
$('#place2').toggle(
    function() {
        $('#lst').show('fade', { direction: 'vertical' }, 500);
		$('#abt').css("display","none");
     	$('#ref').css("display","none");
     	$('#blg').css("display","none");
		
  },
	function() {
        $('#lst').hide('fade', { direction: 'vertical' }, 1000);
    }
);
$('#place3').toggle(
    
    function() {
        $('#ref').show('fade', { direction: 'vertical' }, 500);
		$('#lst').css("display","none");
     	$('#abt').css("display","none");
     	$('#blg').css("display","none");
		
      },
	function() {
        $('#ref').hide('fade', { direction: 'vertical' }, 1000);
    }
);
$('#place4').toggle(
    
    function() {
        $('#blg').show('fade', { direction: 'vertical' }, 500);
		$('#lst').css("display","none");
     	$('#ref').css("display","none");
     	$('#abt').css("display","none");
		
      },
	function() {
        $('#blg').hide('fade', { direction: 'vertical' }, 1000);
    }
);

$(".place").append('<img class="shadow" src="/images/shadow.png" width="58" height="34" alt="" />');

// Animate buttons, shrink and fade shadow

$(".place").hover(function() {
	var e = this;
	$(e).find("a").stop().animate({ marginTop: "-14px" }, 250, function() {
		$(e).find("a").animate({ marginTop: "-10px" }, 250);
	});
	$(e).find("img.shadow").stop().animate({ width: "80%", height: "20px", marginLeft: "8px", opacity: 0.25 }, 250);
},function(){
	var e = this;
	$(e).find("a").stop().animate({ marginTop: "4px" }, 250, function() {
		$(e).find("a").animate({ marginTop: "0px" }, 250);
	});
	$(e).find("img.shadow").stop().animate({ width: "100%", height: "27px", marginLeft: "0", opacity: 1 }, 250);
});


Cufon.replace('h1');
Cufon.replace('h2');
Cufon.replace('h3');
Cufon.replace('h4');
		
		
});



function cloudMove(){
	if (!cloudMoved){
		$("#clouds")
			.css("left", $("#clouds").offset().left)
	}
	$("#clouds").animate({
		left: $("#sky").width()
			},
			cloudMoved ? 180000 : 150000,
			"linear",
			function()
			{
				$(this)
					.css("left", -parseInt($(this).css("width")))
				cloudMoved = true;
				cloudMove();
			}
		)
}

function place(){
	$("#place1").stop().animate({top:'405px'},{queue:false, duration:6000, easing: 'easeOutBounce'});
	$("#place2").stop().animate({top:'147px'},{queue:false, duration:7000, easing: 'easeOutBounce'});
	$("#place3").stop().animate({top:'258px'},{queue:false, duration:8000, easing: 'easeOutBounce'});
	$("#place4").stop().animate({top:'314px'},{queue:false, duration:9000, easing: 'easeOutBounce'});	
}
