$(window).resize(function() {
	resize();
});

$(document).ready(function () {
	resize();

    if ($("body div").is("#slideshow")) {

	} else {
        $("body").addClass("not-slideshow");
	}

	$("#icon-menu-smartphone").click(function(){
		if( $(".menu-smartphone").hasClass('menu-active')) {
			$(".menu-smartphone").removeClass('menu-active');
		} else {
			$(".menu-smartphone").addClass('menu-active');
		}
	});

    $( ".child-menu-left a" ).hover(function() {
    	var strId = $(this).attr('id');
		var id = strId.split("-");
		$("#child-menu-left-" + id[0] + " a").removeClass('active');
		$(this).addClass('active');
		$("#child-menu-right-" + id[0] + " .data-menu-child").removeClass('active');
		$("#data-menu-child-" + id[1]).addClass('active');
    });
});

function resize(){
	witdh_window = $(window).width();
	$(".header-menu .menu-cate").width(witdh_window);
}

function hideMessage(){
	$(".webvietError").remove();
	var t=setTimeout('hideMessage()',30000);
}


function getCountSocial(urlSource, data) {
	// var totalOld = data.totalOld;
	// var totalTwOld = data.totalTwOld;
	// var totalHaOld = data.totalHaOld;
	// var dataUpdate = {};

	// FB
	var urlFb = "https://graph.facebook.com/v2.7/?id=" + urlSource + "&access_token=224483731270750|34b82ff4c07368a4c0f5bc5d6737ef5d";
	// totalNew = totalOld;
	// totalTwNew = totalTwOld;
	// totalHaNew = totalHaOld;
	$.ajax({
		url: urlFb,
		type:'GET',
		dataType:'jsonp',
		timeout:3000,
	})
		.done(function(data){
			if ((typeof (data.share) != 'undefined')) {

				var totalNew = data.share.share_count;
				console.log("count" + totalNew);
				$(".share_facebook .facebook").html(totalNew);

				// if (totalNew == 0 || totalNew != totalOld) {
				// 	dataUpdate.total = totalNew;
				// 	$.ajax({
				// 		type: "POST",
				// 		url: "/share/social",
				// 		data: {
				// 			u: urlSource,
				// 			d: JSON.stringify(dataUpdate)
				// 		}
				// 	});
				// }
			} else {
				console.log("khong co count");
				$(".share_facebook .facebook").html(0);
			}
		})
		.fail(function(data){
			$(".share_facebook .facebook").html(0);
		});



}