var checkContentHeight = function(){
								if(Browser.Engine.trident)
									return true;
								
								target = $('content');
								sidebar = $('sidebar');
								
								current_height = target.getHeight();
								should_height = target.scrollHeight-20;

								sb_current_height = sidebar.getHeight();
								sb_should_height = sidebar.scrollHeight;

								if(should_height > sb_should_height)
								{
									target.tween('height', should_height);
									sidebar.tween('height', should_height);
									
									//console.log(should_height);
								}	
								else
								{
									target.tween('height', sb_should_height);
									sidebar.tween('height', sb_should_height);
									//console.log(sb_should_height);
								}	
							}
							
checkContentHeight.periodical(5000);

//var loadSidebar = function(url){}

var loadPage = function(url, target, sidebar){
					//theURI = new URI(url);
					//thuURI.setData("ajax", true);
					if(Browser.Engine.trident)
						return true;

					target.chains();
					sidebar.chains();
					
					request = new Request.HTML({ url: url, 
											method: 'get',
											update: target,
											evalScripts: true,
											onRequest: function(){
												target.fade('out');
												target.tween('height', '0');
												target.set('styles', {'overflow': 'hidden'});
												sidebar.fade('out');
												sidebar.tween('height', '0');
												sidebar.set('styles', {'overflow': 'hidden'});
											},
											onSuccess: function() {
												//diff_height = target.getHeight();
												sidebar.set('html', '');
												
												//target.tween('height', target.scrollHeight-diff_height);
												checkContentHeight();
												target.fade('in');
												//sidebar.tween('height', target.scrollHeight-diff_height);
												sidebar.fade('in');
											}
										}).send('ajax=true');
					
					return false;
				}

var imagesToLoad = [          
                     "/images/cbelochde/site/background.png",
                     "/images/cbelochde/site/bg_content.png",
                  //   "/images/cbelochde/site/blue_splat.png",
                     "/images/cbelochde/site/logo_bottom.png",
                     "/images/cbelochde/site/logo_left.png",
                  //   "/images/cbelochde/site/logo_splats.png",
                     "/images/cbelochde/site/logo_top_right.png",
                  //   "/images/cbelochde/site/logo.png",
                     "/images/cbelochde/site/navi_01_left.png",
                     "/images/cbelochde/site/navi_02_news.png",
                     "/images/cbelochde/site/navi_03_about.png",
                     "/images/cbelochde/site/navi_04_portfolio.png",
                     "/images/cbelochde/site/navi_05_tutorials.png"
                  //   "/images/cbelochde/site/orange_splat.png",
                  //   "/images/cbelochde/site/white_splat.png"
                   ];
window.addEvent('domready', function() {
    $("container").set('opacity', 0);
    $("moocessBar").removeClass("disabled");
    // Initialize my MoocessBar Class
    var myBar = new MoogressBar('moocessBar', {
    				bgImage: '/images/progressbar/blue.gif',
    				onFinish: function(){
    					document.id("moocessBar").setStyle('display','none');
    					$("container").set('tween', {duration: 'long'});
    					$("container").tween('opacity', [0, 1]);
    				}
    			});
    
    // Code to load the defined images (see above)
    var loadImages = new Asset.images(imagesToLoad, {
                                                      onProgress: function(counter, index){
                                                          percentage = Math.round(100 / (imagesToLoad.length + 1) * counter);
                                                          
                                                          myBar.setPercentage(percentage);
                                                      },
                                                      
                                                      onComplete: function(){
                                                          // All images loaded? fine, now load the CSS File
                                                          //var myCSS = new Asset.css('/css/cbeloch.css');
                                                          // All files loaded, this means it's done, 100 automatically fades out the bar
                                                          myBar.setPercentage(100);
                                                          
                                                      }
                                                    });
});