$(function () {
	var root = "/kinderen-blog/wp-content/themes/colorfull/";
	/*---Create holders----*/
	$("#etaHolder").wrap('<div id="parEta"></div>');
	$("#parEta").css({top: -400});
	
	$("#parEta").fadeTo(1000,1,function(){
    	$(this).animate({top: -30},{duration: 1000, easing: 'easeOutElastic'});
  	});
  	
	setTimeout(function () {
		$('a#oklyBackTo').animate({ top: 30 }, 500);
	}, 1000);  	
	
	var flashvars = {};
	flashvars.panels = panelItems;
	var params = {};
	params.wmode = "transparent";
	var attributes = {};
	attributes.id = "etaHolder";
	if ($('body').hasClass('home')) {
		swfobject.embedSWF(root+"/swf/admin-header.swf", "etaHolder", "700", "400", "9.0.0", false, flashvars, params, attributes);
	
	}else{
		$("#etaHolder").remove();
	}
	
	
	$('.postBloks').append('<div class="cl"></div>');
	
	
	/*---Set day template----*/
	var time = new Date();
	var hour = time.getHours();
	
	
	/*---Change theme----*/
	if (hour > 20 || hour < 6) {
		$('#bun').addClass('night');
	}else{
		$('#bun').addClass('day');
	}
	
	$('div.day div#header').append('<div class="medCl cloudEl"><img src="'+root+'/images/medium_clouds.gif" alt="medium_clouds" width="116" height="281" /></div>');
	$('div.day div#header').append('<div class="medClmid cloudEl"><img src="'+root+'/images/medium_clouds.gif" alt="medium_clouds" width="116" height="281" /></div>');
	$('div.day div#header').append('<div class="medClsmall cloudEl"><img src="'+root+'/images/smaller.gif" alt="smaller" width="105" height="202" /></div>');
	$('div.day div#header').append('<div class="medCllarge cloudEl"><img src="'+root+'/images/big_cloud.gif" alt="big_cloud" width="216" height="275" /></div>');
	
	
	/*---Set day template----*/
	
	$('div.night div#header').append('<div class="medSt starEl"><img src="'+root+'/images/star-big.gif" alt="star-big" width="92" height="249" /></div>');
	$('div.night div#header').append('<div class="medStmid starEl"><img src="'+root+'/images/moon.gif" alt="moon" width="116" height="123" /></div>');
	$('div.night div#header').append('<div class="medStsmall starEl"><img src="'+root+'/images/star-small.gif" alt="star-small" width="33" height="96" /></div>');
	$('div.night div#header').append('<div class="medStsmallE starEl"><img src="'+root+'/images/star-small.gif" alt="star-small" width="33" height="96" /></div>');
	$('div.night div#header').append('<div class="medStlarge starEl"><img src="'+root+'/images/star-big.gif" alt="star-big" width="92" height="249" /></div>');
	
	
	
	/*---Get TEMP DATA----*/
	$('.medCllarge, .medStlarge').append('<div class="holdCl"></div>').find('div').load(root+'/get_weather.php #tempInfo');
	$('.medClmid, .medStsmallE').append('<div class="holdCl"></div>').find('div').load(root+'/get_weather.php #temp');
	$('.medStmid').append('<div class="holdCl"></div>').find('div').text('Slaap lekker voor zo.');

	
	if ($("#bun").is('.day')) {
		animRight ($('div.medCl'), -50, 700, 20);
		animRight ($('div.medClsmall'), 100, 900, 25);
		animRight ($('div.medClmid'), 300, 900, 20);
		animRight ($('div.medCllarge'), 800, -10, 18);
	}else{
		animRight ($('div.medSt'), -50, 700, 20);
		animRight ($('div.medStsmall'), 100, 900, 60);
		animRight ($('div.medStmid'), 300, 700, 70);
		animRight ($('div.medStlarge'), 800, -10, 48);
		animRight ($('div.medStsmallE'), 900, 100, 48);
		
	}
	
	
	/*--------TWITTER---------------*/
	$("#twitterBer").prepend('<div></div>');
	$("#twitterBer div").getTwitter({
					userName: "okly_sprookjes",
					numTweets: 1,
					loaderText: "Loading tweets...",
					slideIn: false
				});
				
	
	
	
});
/*---FL functions----*/

function animRight (elem, xStart, xEnd, time) {
	$(function(){
		elem.animate({left: xEnd}, time * 1000, 'linear', function () { animLeft(elem, xStart, xEnd, time); });
	});
}

function animLeft (elem, xStart, xEnd, time) {
	$(function(){
		elem.animate({left: xStart}, time * 1000, 'linear', function () { animRight(elem, xStart, xEnd, time); });
	});
}

function closeWindow () {
	$(function (){
		$("#parEta").animate({top: -400},{duration: 1000, easing: 'easeInBack'});
	});
}

