function openwindow1(url,width,height)
{
	var on_left = (screen.width - width) / 2;
	var on_top  = (screen.height - height) / 2;
    window.open (url, "neww", "height="+height+", width="+width+", left="+on_left +", top="+on_top+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}
function live_chat()
{
    var online = "http://chat.53kf.com/webCompany.php?arg=keatsschool&style=1";
	var on_left = (screen.width - 513) / 2;
	var on_top  = (screen.height - 430) / 2;
    window.open(online, "application", "height=430, width=513, left="+on_left +", top="+on_top+", toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=no");
}
$(document).ready(function(){
						   
//topnav
$('.topnav>a').hover(function(){
    $('.topnav>a').stop().animate({backgroundPosition:'0 0'}, {duration:200});
	$(this).stop().animate({backgroundPosition:'0 -240px'}, {duration:400})
},function(){
    $('.topnav>a').stop().animate({backgroundPosition:'0 0'}, {duration:200});
})

//lang
$('#curlan').click(function(){
  $('.top>ul').toggle('fadeIn');
  $(this).toggleClass('cur');
})
$('.top>ul').hover(
  function(){},
  function(){
    $(this).fadeOut();
	$('#curlan').removeClass();
  }
)

//sub
$('.nav>a').hover(function(){
  $('.nav>a').removeClass().stop().animate({backgroundPosition:'0 0'}, {duration:200});
  $(this).addClass('cur').stop().animate({backgroundPosition:'0 -56px'}, {duration:200})
  if($('.nav>a').index($(this))!=0 && $('.nav>a').index($(this))<4){
	  $('.sub>ul').hide().eq($('.nav>a').index($(this))-1).css('margin-left',$(this).position().left).stop(true,true).fadeIn();
  }  
  if($('.nav>a').index($(this))>4){
	  $('.sub>ul').hide().eq($('.nav>a').index($(this))-2).css('margin-left',$(this).position().left).stop(true,true).fadeIn();
  } 
  },
  function(){
	  $('.sub>ul').stop(true,true).fadeOut()
  });
$('.sub>ul').hover(function(){
	$(this).stop(true,true).show();
  },function(){
    $('.sub>ul').stop(true,true).fadeOut();
  });

//Í¼Æ¬ÇÐ»»
    $('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pager:  '#slidebtn',
		after:   onAfter,
		timeout: 5000,
		prev:   '#prev',
		next:   '#next'
	});
	$('.slideshow>img').hover(function(){$('.prevnext').show()}, function(){$('.prevnext').hide()})
	$('.prevnext').css("opacity","0.5").hover(function(){$(this).show()}, function(){$('.prevnext').hide()})
	function onAfter(curr, next, opts) {
      var index = opts.currSlide;
      $('#prev')[index == 0 ? 'hide' : 'show']();
      $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
    }


//apply
$('.apply>a').hover(function(){
    $('.apply>a').stop().animate({backgroundPosition:'0 0'}, {duration:600});
	$(this).stop().animate({backgroundPosition:'0 -238px'}, {duration:600})
},function(){
    $('.apply>a').stop().animate({backgroundPosition:'0 0'}, {duration:600});
})

//toTop
$("body").append('<span id="toTop"></span>');
var ScrolltoTop=$("#toTop");
    $(ScrolltoTop).hide();
    $(window).scroll(function () {
        if($(window).scrollTop()<=300) {
            $(ScrolltoTop).fadeOut("slow")
        }else {
            $(ScrolltoTop).fadeIn("slow")
        }
    });
    $(ScrolltoTop).click(function(){
        $("html,body").animate({scrollTop:0},500);
		return false
});

})

