(function($){
	

	$(function(){
	// initialize all
	
		
		if($.browser.msie) {
			$.fx.off = true;
			//window.alert ("in EXplorer");
			}
			
		 else if ($.browser.mozilla) {     //If Mozilla's Firefox
			//window.alert ("in mozilla"); 
		 }

 		var footeropen = false;
		//window.alert("footer status " + footeropen);
		
		$('#movefoot').click (function (event) {
		// move footer
		event.preventDefault();
		switch (footeropen) {
			
			case (true) : $('#footer').animate({
				height: '30' }, 500, function() {
				// function when animation complete.
					footeropen = false;
	
			}); // end Animate
			break;
			
			
			case (false) : $('#footer').animate({
				height: '180' }, 400, function() {
				// function when animation complete.
					footeropen = true;
				
			}); // end Animate
			break;
			
		} // end switch
		  
		$('#movefoot' ).toggleClass ('movedownfooter')
			
		}) // end click
		
	}) // end JQ function 
	

	$(window).bind("load", function() { 
		   
		   var footerHeight = 0,
			   footerTop = 0,
			   $footer = $("#footer");
			   
		   positionFooter();
		   
		   function positionFooter() {
		   
					footerHeight = $footer.height();
					footerTop = ($(window).scrollTop()+$(window).height()-footerHeight -35)+"px";

					
					/* DEBUGGING STUFF
					
					console.log("Document height: ", $(document.body).height());
					console.log("Window height: ", $(window).height());
					console.log("Window scroll: ", $(window).scrollTop());
					console.log("Footer height: ", footerHeight);
					console.log("Footer top: ", footerTop);
					console.log("-----------")
					
					*/
		   
				   if ( ($(document.body).height()+footerHeight) < $(window).height()) {
					   $footer.css({
							position: "absolute"
					   }).stop().animate({
							top: footerTop
						})
				   } else {
					   $footer.css({
							position: "static"
					   })
				   }
				   
		   } // end positionFooter
	
			
		   $(window)
		   // perform reposition with scroll and resize
				   .scroll(positionFooter)
				   .resize(positionFooter)
				   
				   
	});

	
/*	$(window)
		.bind("resize", function(e){
		
			    if ( $(window).height() > $(document.body).height() ) {
					if ( $.browser.msie ) {
						window.alert ("in IE");             //If Microsoft's IE
						$('#opencloserow').height( $('#opencloserow').height() + ( $(window).height() - $(document.body).height()) - 0);
					} else if ($.browser.mozilla) {     //If Mozilla's Firefox
						
						$('#opencloserow').height( $('#opencloserow').height() + ( $(window).height() - $(document.body).height()) - 17);
					} else if ($.browser.safari) {      //If Apple's Safari *or* Google's Chrome
						$('#opencloserow').height( $('#opencloserow').height() + ( $(window).height() - $(document.body).height()) - 58);
					} else {                            //Any other browser, default to 'standard' implementation
						$('#opencloserow').height( $('#opencloserow').height() + ( $(window).height() - $(document.body).height()) - 0);
					};
    			};
			

		})
*/		
		
})(jQuery);
