$(document).ready(function(){
	$(".wrap-bottom-deal-img").hover(function(){
			$(this).find('img').addClass("wrap-bottom-deal-img-hover");
			$(this).find('.block-2-home').css('display', 'block');
			$(this).find('.wrap-bottom-deal-hidden-name').css('display', 'block');
			$(this).find('.wrap-bottom-deal-numberbuy').css('display', 'block');
			//$(this).find('.wrap-bottom-deal-numbersuccess').css('display', 'block');
			$(this).find('.wrap-bottom-deal-numbersave').css('display', 'block');
         $(this).find('.wrap-bottom-deal-set_gifts').css('display', 'block');
         $(this).find('.wrap-bottom-deal-percent').css('display', 'none');
         $(this).find('.wbd-number-buy').css('display', 'none');
         $(this).parent().find('.wrap-bottom-deal-buyed').css('display', 'none');
			var link_value	=	$(this).find('input.link_value').val();
			var like = $(this).find('.like-block-bottom');
			if(!like.hasClass('loaded')){
				like.html('<iframe src="//www.facebook.com/plugins/like.php?href=cucre.vn'+link_value+'&amp;send=false&amp;layout=button_count&amp;width=85&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:21px;" allowTransparency="true"></iframe>').addClass('loaded');
			}else{
				like.show();
			} 
			$(this).find('.wrap-bottom-deal-buynow').css('display', 'block');
			
		}, function(){
			$(this).find('img').removeClass("wrap-bottom-deal-img-hover");
			$(this).find('.wrap-bottom-deal-buynow').css('display', 'none');
			$(this).find('.wrap-bottom-deal-numberbuy').css('display', 'none');
			//$(this).find('.wrap-bottom-deal-numbersuccess').css('display', 'none');
			$(this).find('.wrap-bottom-deal-numbersave').css('display', 'none');
			$(this).find('.like-block-bottom').hide();
			$(this).find('.block-2-home').css('display', 'none');
			$(this).find('.wrap-bottom-deal-hidden-name').css('display', 'none');
         $(this).find('.wrap-bottom-deal-set_gifts').css('display', 'none');
         $(this).find('.wrap-bottom-deal-percent').css('display', 'block');
         $(this).parent().find('.wrap-bottom-deal-buyed').css('display', 'block');
         $(this).find('.wbd-number-buy').css('display', 'block');
		})
	
	$(".wrap-top-deal-img").hover(function(){
		$(this).find('img').addClass("wrap-bottom-deal-img-hover");
		$(this).find('.wrap-top-deal-shortname-two').css('display', 'block');
		//$(this).find('.wrap-top-deal-numberbuy').css('display', 'block');
		$(this).find('.wrap-top-deal-numbersave').css('display', 'block');
		$(this).find('.wrap-top-deal-numberorder').css('display', 'block');
		$(this).find('.wrd_total_send').css('display', 'block');
		var link_value	=	$(this).find('input.link_value').val();
		var like = $(this).find('.like-block-top');
			if(!like.hasClass('loaded_like')){
				like.html('<iframe src="//www.facebook.com/plugins/like.php?href=cucre.vn'+link_value+'&amp;send=false&amp;layout=button_count&amp;width=85&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:85px; height:21px;" allowTransparency="true"></iframe>').addClass('loaded_like');
			}else{
				like.show();
			} 
		$(this).find('.wrap-top-deal-buynow').css('display', 'block');
		$(this).find('.wrap-top-deal-loantin').css('display', 'block');
		$(this).find('.event_marth_gif').css('display', 'block');
		$(this).find('.wrap-top-deal-percent').css('display', 'none');		
	}, function(){
		$(this).find('img').removeClass("wrap-bottom-deal-img-hover");
		$(this).find('.wrap-top-deal-shortname-two').css('display', 'none');
		$(this).find('.wrap-top-deal-numbersave').css('display', 'none');
		//$(this).find('.wrap-top-deal-numberbuy').css('display', 'none');
		$(this).find('.wrap-top-deal-numberorder').css('display', 'none');
		$(this).find('.wrd_total_send').css('display', 'none');
		$(this).find('.wrap-top-deal-buynow').css('display', 'none');
		$(this).find('.like-block-top').hide();
		$(this).find('.wrap-top-deal-loantin').css('display', 'none');	
		$(this).find('.event_marth_gif').css('display', 'none');	
		$(this).find('.wrap-top-deal-percent').css('display', 'block');
	})
	
	$('.wbdi_pha_type').hover(function(){
		$(this).find('span').css('display', 'block');
	}, function(){
		$(this).find('span').css('display', 'none');
	})
	
	$('.header_in_out_login').click(function(){
		$('#login-form').css('display', 'block');
	})
	$('#close_login').click(function(){
		$('#login-form').css('display', 'none');
	})
	
	$('.header_in_out ul li:last').addClass('li-last-child');
	
	$('#nav-deal ul li').hover(function(){
		if(!$(this).hasClass('nav_deal_li_active')){
			$(this).addClass('nav_deal_li_hover');
		}
	}, function(){
			$(this).removeClass('nav_deal_li_hover');
	})
	
	$('.wrap-bottom-select').hover(function(){
		$('#list-cat-filter').css('display', 'block');
	}, function(){
		$('#list-cat-filter').css('display', 'none');
	})
	
	$('.header_in_out_name').hover(function(){
		$('.header_in_out_info').css('display', 'block');
	},function(){
		$('.header_in_out_info').css('display', 'none');
	})
	
	$('.hlch_bottom_list').hover(function(){
		$(this).addClass('hlch_bottom_list_hover');
	}, function(){
		$(this).removeClass('hlch_bottom_list_hover');
	})
   /* back to top script*/

   $(window).scroll(function(){
      if($(window).scrollTop() >200){
         $("#BackToTop").show();   
      }else{
         $("#BackToTop").hide();
      };
   });
   
   //function showgifts
   $(".wrap-bottom-deal-set_gifts").mouseover(function(){
      $(".wrap-bottom-deal-set_gifts").mousemove(function(e){
        var x = e.pageX;
        var y = e.pageY;
        if (y < 70){
        	var dtop = y + "px";
        }else{
        	var dtop = y - 35 + "px";
        }
        var widthleft = $(window).width() - x ;
        if(widthleft > 300){
	        $(".view_gifts").css({
	         "display":"block",
	         left: x + 20 +"px",
	         top: dtop, 
	         })
         }else{
         	$(".view_gifts").css({
	         "display":"block",
	         left: x - 272 +"px",
	         top: dtop, 
	         })
         }
      })      
   });
   $(".wrap-bottom-deal-set_gifts").mouseout(function(){
      $(".view_gifts").css("display","none");
   });
   
	backtotop	= '<div id="BackToTop" class="backtotop" onclick="this.style.display=\'none\';">';
	backtotop	+= '<a href="#"><img src="/images/cucre_v4/backtotop.png" /></a>';
	backtotop	+= '</div>';
	
	$("body").append(backtotop);
})
