// BEGIN auto open external link
	$(document).ready(function(){
		$('a[rel="_blank"]').click(function(){ window.open( $(this).attr('href') ); return false; });
		$('a[class="download"],a[href^="http://www.alexa.com"]').attr('target','_blank');
		$("a[href^='http:']").not("[href*='" + window.location.host + "']").attr('target','_blank');
	})
// Preloading page
$(document).ready(function(){
$("a[href^='http']").click(function(){
	var hostname = "http://" + window.location.host;
  var strHref = $(this).attr('href').indexOf(hostname);
  if (!(strHref == '-1') && ($(this).attr('target') != "_blank")){
    $("#preloading").show("normal");
  }
  $(this).keyup(function(event){
    if (event.keyCode == '17') {
      setTimeout('$("#preloading").hide()', 300);
    }
  });
 });
 	$("input[type=button]").click(function(){
		$("#preloading").show("normal");
	});
	$("form").keyup(function(e){
		if(e.keyCode == 13) {
		$("#preloading").show("normal");
		}
	});
 	$('#preloading').click(function() {
		setTimeout('$("#preloading").hide()', 300);
	});
});
//Resize image size with img in div id = "postcontent"
 $(document).ready(function() {
    var MaxImageWidth = 530;
	var MaxImageHeight;
    $("#content img").each(function() {
        if($(this).width() > MaxImageWidth) {
            MaxImageHeight=$(this).height()*(MaxImageWidth/$(this).width());
            $(this).attr({height : MaxImageHeight });
            $(this).attr({width : MaxImageWidth});
        }
    });
})
$(function() {
	$('.detail_order img').animate({"opacity": .8 });
	$('.detail_order img').hover(function() {
		$(this).stop().animate({ "opacity": 1 });
	}, function() {
		$(this).stop().animate({ "opacity": .8 });
	});
});
function toggle_visibility(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }

function showhide(divID1,divID2) {
 var item = document.getElementById(divID1);
 var item2 = document.getElementById(divID2);
 if (item) {
 item.className=(item.className=='hidden')?'unhidden':'hidden';
  item2.className=(item2.className=='unhidden')?'hidden':'unhidden';
 }
 }
 
function keywordc(form){if(form.keyword.value==""){alert("BẠN CHƯA NHẬP TỪ KHÓA TÌM KIẾM!");return false}else{if(form.keyword.value.length<3){alert("Từ khóa phải có độ dài từ 3 ký tự trở lên!");return false}}return true}
function openWin(pageUrl,w,h){width=w;height=h;top_val=(screen.height-height)/2-30;if(top_val<0){top_val=0}left_val=(screen.width-width)/2;window.open(pageUrl,null,"toolbar=0,location=0,status=1,menubar=0,scrollbars=0,resizable=0,width="+width+",height="+height+", top="+top_val+",left="+left_val)}
function pageloading(){document.getElementById("imgLOAD").style.display="none";document.getElementById("wholepage").style.display=""}
window.onload = pageloading;
