$(function(){
	//for buy book : team up
	$("body.custom.buy div#forms form:gt(0)").hide();
	$("body.custom.buy select#quatity").change(function(){
		$("body.custom.buy div#forms form").hide();
		var index = $("body.custom.buy select#quatity option:selected").index();
		 $("body.custom.buy div#forms form").eq(index).show();		
	});
	
	//for buy book : SLG
	$("body.custom.buy-s div#forms form:gt(0)").hide();
	$("body.custom.buy-s select#quatity").change(function(){
		$("body.custom.buy-s div#forms form").hide();
		var index = $("body.custom.buy-s select#quatity option:selected").index();
		 $("body.custom.buy-s div#forms form").eq(index).show();		
	});
	
	$("body.custom.media-collection div.player:gt(0)").hide();		
	$("body.custom.media-collection div#media_clips a").click(function(){
		$("body.custom.media-collection div#media_clips a").removeClass("playing");
		
		var index= $("body.custom.media-collection div#media_clips a").index(this);
		$("body.custom.media-collection div.player").hide();
		$("body.custom.media-collection div.player").eq(index).show();
		
		$(this).addClass("playing");			    
		
		return false;				
	});
	

	
	// for home page slideshow
	$(".scrollable").scrollable({
		circular: true,
		keyboard: true,
		easing: 'custom', 
		speed: 1200,
		size: 3,
		items: ".items"
	}).autoscroll({ autoplay: true, interval: 5000 }).navigator();
	
	$.easing.custom = function (x, t, b, c, d) {
		var s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	}
	
	// for speaking page popups
	$("a.play_popup[rel]").overlay({
			mask:{color:'#000',
				loadSpeed:200,
				opacity:0.8
			},
			top:150
	});
	
	//for media collection clips slide effect
	$("#media_clips").tabs("#media_clips div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null});
	
	$.tools.tabs.addEffect("slide", function(i, done) {
		this.getPanes().slideUp();
		this.getPanes().eq(i).slideDown(function()  {
			done.call();
		});
	});
	
	//button hover
    $(".custom input.submit").hover(function() {
        $(this).addClass("hover");          
   },
   function(){
        $(this).removeClass("hover");   
   }) 
   
   //fancybox
   $(".gallery dl dt a").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	true,
		'showNavArrows' :	true,
		'overlayOpacity':	0.6
	});
   
	//wartermark
   $(":input[msg]").each(function(){
	 	$(this).watermark($(this).attr("msg"));
	 });

	
});
