$(document).ready(function() {
   $('.item').delay(500).slideDown(500);
   $('#logo').fadeIn(1000,function() {
      if ( !$('#header.mini').html() ) {
          $('#header').fadeIn('fast');
          rotate();
       }
            
      $('#anchor').delay(1500).fadeIn(1000);
      $('#credits').delay(1500).fadeIn(1000);
      $('#contact_phone').delay(500).fadeIn(1000);
   }); 
});

function get_html(ID) {
   $.ajax({
	type: "GET",
	url: "page.php",
	data: { id: ID },
	dataType: "json",
	success: function (data) {
     		$('[id^=menu-]').removeClass('item_selected');
     		$('#menu-' + ID).addClass('item_selected');
		$('#crumbs div anc').text(data['title']);
		$('#pageID').val(ID);
     		if ( ID != 6 ) {
  	     		hide_header(data['data']);
     		} else {
        		show_header(data['data']);
     		}
     }
   });
}

function show_header(html) {
      $('#banner').animate({height:'254px'},1000,function() {
          $('#header').fadeIn('fast');
          rotate();
	  if ( html ) { $('#body_html').fadeOut('fast',function() {
              $('#body_html').html(html).fadeIn('slow');
 	    });
	}
   });
      $('#anchor').switchClass('mini','',1000);
      $('#credits').switchClass('mini','',1000);
      $('#contact_phone').switchClass('mini','',1000);
      $('#logo').fadeIn('fast').animate({top:'30px'});
}

function hide_header(html) {
   $('#header').fadeOut('500',function() {
      rotate('stop');
      $('#banner').animate({height:'125px'},1000,function() {
	if ( html ) { $('#body_html').fadeOut('fast',function() {
             $('#body_html').html(html).fadeIn('fast');
 	    });
 	}
      });
      $('#anchor').switchClass('','mini',1000);
      $('#credits').switchClass('','mini',1000);
      $('#contact_phone').switchClass('','mini',1000);
      $('#logo').animate({top:'0px'});
   });
}

function rotate(Call) {
     $('#rotate').delay(2500).animate({opacity:1},3000,function() {
        $(this).delay(2000).animate({opacity:0},3000,function() {
            if ( Call != "stop" ) { rotate(); }
        });
      });
}

