function ImgError(source) {
    source.src = BASE_URL + "uploads/logo.png";
    source.onerror = "";
    return true;
}

function locdau(str) {  
	str= str.toLowerCase();  
	str= str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");  
	str= str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");  
	str= str.replace(/ì|í|ị|ỉ|ĩ/g,"i");  
	str= str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");  
	str= str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");  
	str= str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");  
	str= str.replace(/đ/g,"d");  
	str= str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\#|\[|\]|~|$|_/g,"-"); 
	str= str.replace(/-+-/g,"-"); //thay thế 2- thành 1- 
	str= str.replace(/^\-+|\-+$/g,"-");		
	return str;  
}

<!--CHUYEN ANH -->
function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length,
            a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++)
        if (a[i].indexOf("#") != 0) {
            d.MM_p[j] = new Image;
            d.MM_p[j++].src = a[i];
        }
    }
}
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_findObj(n, d) { //v4.01
    var p, i, x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}
function MM_swapImage() { //v3.0
    var i, j = 0,
        x, a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3)
    if ((x = MM_findObj(a[i])) != null) {
        document.MM_sr[j++] = x;
        if (!x.oSrc) x.oSrc = x.src;
        x.src = a[i + 2];
    }
}
<!--END CHUYEN ANH -->

function viewNewsMore() {
    $('.more').live("click", function () {
        var ID = parseInt($(this).attr("id"));
		var T = parseInt($(this).attr("type"));
        $("#more" + ID).html('<center><img src="' + BASE_URL + 'Views/zenko/images/loading.gif"/></center>');
		$.ajax({
			type: "POST",
			url: BASE_URL + "_phanhoi.php?mode=news_more",
			data: "lastID=" +ID+ "&type=" +T,
			cache: false,
			success: function (html) {
				var $c = $(html);
				if (T == 1) {
					$("#col1_data").append($c.filter('#result').html());
				} else {
					$("#col2_data").append($c.filter('#result').html());
				}
			}
		});
		$(this).remove();
        return false;
    });
}

function menu_hover() {
    $(".btnHover").mouseover(function () {
        var element = $(this);
        var isActive = element.attr("isActive");
        //neu da active thi ko an di nua
        if (isActive == '1') {
            $(".tab-hover").css("display", "none");
        }
        id = $(this).attr("hover");
        $("#tab" + id).css("display", "block");
    });
    $(".tab-hover").mouseout(function () {
        var element = $(this);
        var isActive = element.attr("isActive");
        if (isActive == '0') {
            $(this).css("display", "none");
        }
    });
}

$(document).ready(function () {
	$('.btn').button();
	$(".datepicker").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: 'dd/mm/yy',
			yearRange: '1950:2011'
		}
	);
    viewNewsMore();
	
	$(".btnclose").click(function() {
		$(this).parent().remove();
	});
	
	$(".nav").hover(
		function () {	//In
			if (!$(this).attr('active')) {
				$(this).find('img.nav_hover').css('display','block');
			}
		}, 
		function () {	//Out
			if (!$(this).attr('active')) {
				$(this).find('img.nav_hover').css('display','none');
			}
		}
	);
	
	$(".nav").each(function() {
		if ($(this).attr('active') == 1) {
			$('.nav_hover').css('display','none');
			$(this).find('img.nav_hover').css('display','block');
			return;
		}
	});
	
	$('#folders-detail img').each(function(){
        if($(this).width()>600){
			$(this).css({width:'',height:''});
            $(this).width(600).css('cursor','pointer').click(function(){window.open($(this).attr("src"));});
        }
    });
	
    //$('div#share_social').share();
    //menu_hover();
});
