function motto()
{

  $(".motto-ram").attr("id", "anime_running");
  
  $(".motto-ram").animate({ 
    width: "350px"
  }, 1000 ).delay(3000).animate({ 
    width: "0px"
  }, 1000, function() {
    $(".motto-ram").attr("id", "anime_stop");
  });
 
  
  $(".motto-text").animate({ 
    width: "350px"
  }, 1000 ).delay(3000).animate({ 
    width: "0px"
  }, 1000 );
  
}

function flip() {
  
  	$("#pageflip img").stop()
	 	 .animate({ 
			 width: '40px',
			 height: '40px'
		  }, 250, function() {
		  
		  $("#pageflip img")
		  .animate({
			 width: '25px',
			 height: '27px'
		  }, 250); });
		  
		  $(".msg_block").stop()
	 	 .animate({ 
			 width: '38px',
			 height: '38px'
		  }, 250, function() {
		  
		  $(".msg_block")
		  .animate({
			 width: '25px',
			 height: '25px'
		  }, 220);

  });

}

function doubleflip() {
  
  flip();
  setTimeout ( "flip()", 550 );
  
}

function fliploop() {
  
  doubleflip();
  setTimeout( "fliploop()", 30000 +  Math.floor(Math.random() * 60000));
  
  
}


$(document).ready(function(){ 
  
  $("#open_course_detail").colorbox({width:"50%", inline:true, href:"#course_detail"});

  setTimeout ( "fliploop()", 15000 + Math.floor(Math.random() * 15000));

  $("#pageflip").hover(function() { //On hover...
  	$("#pageflip img , .msg_block").stop()
	 	 .animate({ 
			width: '307px',
			height: '319px'
		  }, 500);
	 } , function() {
	 $("#pageflip img").stop() 
		  .animate({
			 width: '25px',
			 height: '27px'
		  }, 220);
	 $(".msg_block").stop() 
		  .animate({
			 width: '25px',
			 height: '25px'
		  }, 200); 
  });

    $(".head img").removeAttr("alt");  
    $(".head a").removeAttr("title");
 
    $(".cat_show").mouseenter(function(){
      $(this).css("text-decoration", "underline") ;
    }).mouseleave(function(){
      $(this).css("text-decoration", "none");
    });
    

    $(".head a").mouseover(function(){    
    
      if( $(".motto-ram").attr("id") != "anime_running"  ) {
    
      $(".motto-ram").stop();
      $(".motto-text").stop();
      $(".motto-ram").animate({  width: "350px" }, 1000 - (1000 / (350 / parseInt($(".motto-ram").css("width")))) );
      $(".motto-text").animate({  width: "350px" }, 1000 - (1000 / (350 / parseInt($(".motto-ram").css("width")))) );
      
      }
      
    }).mouseout(function(){
    
    if( $(".motto-ram").attr("id") != "anime_running"  ) {
    
      $(".motto-ram").stop();
      $(".motto-text").stop();
      $(".motto-ram").animate({  width: "0px" }, 1000 / (350 / parseInt($(".motto-ram").css("width"))) );
      $(".motto-text").animate({  width: "0px" }, 1000 / (350 / parseInt($(".motto-text").css("width"))) );
      
      }

    });






    
    $('.cat_show').click(function() {
      
      var menuId = $(this).attr("id").substring(3);
      
      if($("#cat" + menuId).css("display") == "none")
      {

        $.ajax({
          type: "GET",
          url: URLprefix + "ajax/menu.php?show=on&cat=" + menuId
        });

        $("#cat" + menuId).slideDown('slow');

      } else {
        
        $.ajax({
          type: "GET",
          url: URLprefix + "ajax/menu.php?show=off&cat=" + menuId
        });

        $("#cat" + menuId).slideUp('slow');

      }
      

    });
    
});






