function chkShoutbox(){
  	if (document.shoutbox.yourname.value==""){
		alert("Ban chua nhap Ho Ten !");
		document.shoutbox.yourname.focus();
		return false;
	}
    if (document.shoutbox.content.value==""){
		alert("Ban chua nhap noi dung !");
		document.shoutbox.content.focus();
		return false;
	}
    if (document.shoutbox.email.value==""){
		alert("Dia chi Email khong co !")
		document.shoutbox.email.focus();
		return false;
	}
 var testresults
 var str=document.shoutbox.email.value
 var filter=/^.+@.+\..{2,3}$/

 	if (filter.test(str)){
    	testresults=true
	 }else {
	    alert("Dia chi Email khong dung !")
	    document.shoutbox.email.focus();
    	return false;
	}

        return true;
}

function popupWindow(url) {
	popup_window = window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=422,height=586,screenX=0,screenY=0,top=0,left=0')
	popup_window.focus(); 
	if (!popup_window.opener) popup_window.opener=self;
	}

	function popupWindow_gallery(url) { 
	popup_window = window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=553,height=415,screenX=0,screenY=0,top=0,left=0')
	popup_window1.focus(); 
	if (!popup_window.opener) popup_window.opener=self;
	}
function popupWindow_poster(url) { 
	popup_window = window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=570,height=650,screenX=0,screenY=0,top=0,left=0')
	popup_window1.focus(); 
	if (!popup_window.opener) popup_window.opener=self;
	}
function popupWindow_box(url) { 
	popup_window = window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=548,screenX=0,screenY=0,top=0,left=0')
	popup_window1.focus(); 
	if (!popup_window.opener) popup_window.opener=self;
	}

//Ajax Object

function makeObject(){
    var x;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    x = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
    x = new XMLHttpRequest();
    }
    return x;
}

    var request = makeObject();

    function do_loadpage(link){
    link = link + "&__=" + encodeURIComponent((new Date()).getTime());
    request.open('get', 'loadpage.php?act='+link);

    request.onreadystatechange = parseInfo;

    request.send('');
    }

      function parseInfo(){
      if(request.readyState == 1){
      document.getElementById('main').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
      }
      if(request.readyState == 4){
      var answer = request.responseText;
      document.getElementById('main').innerHTML = answer;        
	  var player = document.getElementById('Player');
		if (player!=undefined || player!=null){
			player.controls.stop();
		}		
		document.getElementById('divVideo').innerHTML= "";
		document.getElementById('divVideo').style.display= "none";
      }
      }

      function do_loadthumb(page){
      request.open('get', 'code/view_thumbgallery.php?page='+page);

      request.onreadystatechange = parseImage;

      request.send('');
      }

      function parseImage(){
      if(request.readyState == 1){
      document.getElementById('thumb_gallery').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
      }
      if(request.readyState == 4){
      var answer = request.responseText;
      document.getElementById('thumb_gallery').innerHTML = answer;

      }
      }
      //doan script dua hinh anh large ra ngoai
      function do_loadimage(id){
      request.open('get', 'code/view_gallery.php?id_hinhanh='+id);

      request.onreadystatechange = parseImage1;

      request.send('');
      }

      function parseImage1(){
      if(request.readyState == 1){
      document.getElementById('gallery').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
      }
      if(request.readyState == 4){
      var answer = request.responseText;
      document.getElementById('gallery').innerHTML = answer;
      }
      }
// Doan scipt xu ly trang kich ban

function do_loadnghesi(id){
request.open('get', 'code/view_nghesi.php?id_nghesi='+id);

request.onreadystatechange = info_nghesi;

request.send('');
}

function info_nghesi(){
if(request.readyState == 1){
document.getElementById('kichban').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
}
if(request.readyState == 4){
var answer = request.responseText;
document.getElementById('kichban').innerHTML = answer;
}
}


function do_loaddoanphim(){
request.open('get', 'templates/doanphim.tpl');

request.onreadystatechange = info_doanphim;

request.send('');
}

function info_doanphim(){
if(request.readyState == 1){
document.getElementById('kichban').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
}
if(request.readyState == 4){
var answer = request.responseText;
document.getElementById('kichban').innerHTML = answer;
}
}

function do_news(img, page){
request.open('get', 'code/news.php?img=' + img + '&page=' + page);

request.onreadystatechange = info_news;

request.send('');
}

function info_news(){
if(request.readyState == 1){
document.getElementById('main').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
}
if(request.readyState == 4){
var answer = request.responseText;
document.getElementById('main').innerHTML = answer;
}
}

function showVideo(idVideo,image){
	//id_nghesi = id_nghesi + "&__=" + encodeURIComponent((new Date()).getTime());
    document.getElementById('divVideo').style.display= "block";
    document.getElementById('divFlash').innerHTML= "";
    var player = document.getElementById('Player');
	if (player!=undefined || player!=null){
        player.controls.stop();
	}
    request.open('Get', 'code/view_video.php?video='+idVideo+'&image='+image);
	request.onreadystatechange = processShowVideo;
	request.send('');
}

function processShowVideo(){
	if(request.readyState == 1){
		document.getElementById('divVideo').innerHTML ="<br><center><table width=300><tr><td><img src=\"../images/loading.gif\" align=\"left\"><b>Please wait... </b><br>The page is being downloaded.</td></tr></table></center>";
	}
	if(request.readyState == 4){
		var answer = request.responseText;
        document.getElementById('divVideo').innerHTML = answer;
	}
}




//	window.status="::Chống Save As::";
document.onmouseover = function ( e ) {
if ( !e ) e = window.event;
var el = e.target ? e.target : e.srcElement;
while ( el != null && el.tagName != "A" ) el = el.parentNode;
if ( el == null ) return;   
if ( e.preventDefault ) e.preventDefault();   
else e.returnValue = true;};

var clickmessage="Hinh anh ko cho phep Save As!";
function disableclick(e) {
 if (document.all) {
 if (event.button==2||event.button==3) {
 if (event.srcElement.tagName=="IMG"){
 alert(clickmessage);
 return false;
 }
 }
 }
 else if (document.layers) {
 if (e.which == 3) {
 alert(clickmessage);
 return false;
 }
 }
 else if (document.getElementById){
 if (e.which==3&&e.target.tagName=="IMG"){
 alert(clickmessage)
 return false
 }
 }
 }function associateimages(){
 for(i=0;i<document.images.length;i++)
 document.images[i].onmousedown=disableclick;
 }
if (document.all)
 document.onmousedown=disableclick
 else if (document.getElementById)
 document.onmouseup=disableclick
 else if (document.layers)
 associateimages()