var ajax;

function createRequestObject() {
var ro;
var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
	    ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
	    ro = new XMLHttpRequest();
	}
return ro;
}

var http = createRequestObject();

function ajx_action(action,id_name) {
    ajax = id_name;
    //alert(ajax);

    var browser = navigator.appName;
    /*
	if(browser == "Microsoft Internet Explorer"){
	    http.open('POST', action);
	}else{
	    http.open('GET', action);
	}
	*/

    http.open('GET', action);
    http.onreadystatechange = ajx_handleResponse;
    http.send(null);
}
function ajx_handleResponse() {
    //alert(ajax);
    if(http.readyState == 4){
        var response = http.responseText;
        var idd_name = ajax;
        document.getElementById(idd_name).innerHTML = response;
    }
    return true;
}

function _Binhchon_submit(){
	var i;
	var itemvalue;

	itemvalue=0;
	for (i=0;i<document.vote.VoteItem.length;i++)
	{
		if (document.vote.VoteItem[i].checked)
		{
			itemvalue=document.vote.VoteItem[i].value;
			document.vote.VoteItem[i].checked = false;
			break;
		}
	}
	ngovinh = window.open("vote.asp?image=" + document.vote.VoteID.value + "&VoteItem=" + itemvalue, "Ket_qua_tham_do_du_luan", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=400,height=360");
	ngovinh.focus();

	ngovinh.moveTo((screen.width- 400)/2,(screen.height- 300)/2);
	//window.moveTo((screen.availWidth-1000)>>1,(screen.availHeight-700)>>1);
}

function popup(filename,imageName,imageWidth,imageHeight)
	{
	ngovinh =	window.open(filename + '?image=' + imageName + '','View','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' + imageWidth + ',height=' + imageHeight + '')
	ngovinh.focus();

	ngovinh.moveTo((screen.width- 400)/2,(screen.height- 300)/2);
	}

function winpopup(urlx,param,twidth,theight)
{
	var strurl= urlx + '?param=' + param;

	var ngovinh=window.open(strurl,"format","toolbar=no,width="+ twidth+",height="+ theight+ ",directories=no,status=no,scrollbars=yes,resizable=no, menubar=no")
	ngovinh.focus();
	ngovinh.moveTo((screen.width- 400)/2,(screen.height- 300)/2);
}

function showvncalendar(){
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate = new Date();
myday = mydate.getDay();
mymonth = mydate.getMonth();
myweekday= mydate.getDate();
weekday= myweekday;
myhours = mydate.getHours();
year=mydate.getYear();
if(year < 2000){
	year = year + 1900
}
ampmhour  =  (myhours > 12) ? myhours - 12 : myhours;
ampm =  (myhours >= 12)  ? ' PM' : ' AM';
mytime = mydate.getMinutes();
myminutes =  ((mytime < 10) ? ':0' : ':') + mytime;
if(myday == 0)
day = " Ch&#7911; nh&#7853;t, ";
else if(myday == 1)
day = " Th&#7913; hai, ";
else if(myday == 2)
day = " Th&#7913; ba, ";
else if(myday == 3)
day = " Th&#7913; t&#432;, ";
else if(myday == 4)
day = " Th&#7913; n&#259;m, ";
else if(myday == 5)
day = " Th&#7913; s&#225;u, ";
else if(myday == 6)
day = " Th&#7913; b&#7843;y, ";
if(mymonth == 0) {
month = " th&#225;ng 1 ";}
else if(mymonth ==1)
month = " th&#225;ng 2 ";
else if(mymonth ==2)
month = " th&#225;ng 3 ";
else if(mymonth ==3)
month = " th&#225;ng 4 ";
else if(mymonth ==4)
month = " th&#225;ng 5 ";
else if(mymonth ==5)
month = " th&#225;ng 6 ";
else if(mymonth ==6)
month = " th&#225;ng 7 ";
else if(mymonth ==7)
month = " th&#225;ng 8 ";
else if(mymonth ==8)
month = " th&#225;ng 9 ";
else if(mymonth ==9)
month = " th&#225;ng 10 ";
else if(mymonth ==10)
month = " th&#225;ng 11 ";
else if(mymonth ==11)
month = " th&#225;ng 12 ";

document.write("<div align='center'>")
//document.write(day + "ng&#224;y "+ myweekday + month + " n&#259;m " + year);
document.write(day + myweekday + "/" + (mymonth+1) + "/" + year);
document.write("</div>");
}

function showencalendar(){
var day="";
var month="";
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate = new Date();
myday = mydate.getDay();
mymonth = mydate.getMonth();
myweekday= mydate.getDate();
weekday= myweekday;
myhours = mydate.getHours();
year=mydate.getYear();
ampmhour  =  (myhours > 12) ? myhours - 12 : myhours;
ampm =  (myhours >= 12)  ? ' PM' : ' AM';
mytime = mydate.getMinutes();
myminutes =  ((mytime < 10) ? ':0' : ':') + mytime;
if(myday == 0)
day = " Sunday, ";
else if(myday == 1)
day = " Monday, ";
else if(myday == 2)
day = " Tuesday, ";
else if(myday == 3)
day = " Wednesday, ";
else if(myday == 4)
day = " Thursday, ";
else if(myday == 5)
day = " Friday, ";
else if(myday == 6)
day = " Saturday, ";
if(mymonth == 0) {
month = " January ";}
else if(mymonth ==1)
month = " February ";
else if(mymonth ==2)
month = " March ";
else if(mymonth ==3)
month = " April ";
else if(mymonth ==4)
month = " May ";
else if(mymonth ==5)
month = " June ";
else if(mymonth ==6)
month = " July ";
else if(mymonth ==7)
month = " August ";
else if(mymonth ==8)
month = " September ";
else if(mymonth ==9)
month = " October ";
else if(mymonth ==10)
month = " November ";
else if(mymonth ==11)
month = " December ";

document.write("<font name = 'verdana' size =1 color = '#FFFFFF' >")
document.write(day + " "+ month + " "+ myweekday  +", " + year);
document.write("</font>");
}

function CheckEmail(EmailValue){
	var stremail= EmailValue
	if (stremail == "") {
	alert( "Hãy nhập địa chỉ email.\n" );
	return false ;
	}

	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(stremail))) {
	alert( "Địa chỉ email không đúng!.\n" );
	return false ;
	}
}