﻿function displayStatus(strStatus)
{
	window.status = strStatus;
}

/*==============================================================================*/
function openwindow(url,width,height)
{
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	/*if((pop!=null)&&(!pop.closed)){
		pop.close();
	}*/
	pop = window.open(url,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no,left=" + left + ", top=" + top + ", width=" + width + ", height=" + height)
}

/*==============================================================================*/
function isEmail(str) {
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
function check(){
	if (document.frm.FullName.value.length ==''){
		alert('Họ tên, tên doanh nghiệp không thể trống!');
		document.frm.FullName.focus();
		return false;		
	}
	
	if (document.frm.Email.value.length==''){
		alert("Email không thể trống!")
		document.frm.Email.focus();
		return false;
	}
	if (!isEmail(document.frm.Email.value)){
		alert("Email không hợp lệ!")
		document.frm.Email.focus();
		return false;
	}
	if (document.frm.Comment.value.length ==''){
		alert('Nội dung không thể trống!');
		document.frm.Comment.focus();
		return false;		
	}
}
function modalDialog(URL,objWindow,width,height){
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	
	return window.showModalDialog(URL, window, "dialogHeight: " + height + "px; dialogWidth: " + width + "px; dialogTop: " + top + "px; dialogLeft: " + left + "px; edge: Raised; center: Yes; help: No; resizable: No; status: No; scroll: yes");
}
/*==============================================================================*/
function bieuquyet(QuestionId){
	var AnswerId = '';
	var height=300;
	var width=600;
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	for (i = 0; i < document.QuestionAndAnswer.rdAnswer.length; i++){
		if (document.QuestionAndAnswer.rdAnswer[i].checked){
			AnswerId=document.QuestionAndAnswer.rdAnswer[i].value;
		}
	}
	if (AnswerId==''){
		alert("Bạn hãy chọn một phương án");
		return false;
		}
	else
	{
		url="/home/vote/?AnswerId="+AnswerId+"&QuestionId="+QuestionId;
		window.open(url,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, left=" + left + ", top=" + top + ", width=" + width + ", height=" + height)
	}
}
/*==========================================================================*/
function xembieuquyet(QuestionId){
	var height=300;
	var width=600;
	var top=(screen.height - height)/2;
	var left=(screen.width - width)/2;
	url="/home/voteview/?QuestionId="+QuestionId;
	window.open(url,"","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, left=" + left + ", top=" + top + ", width=" + width + ", height=" + height)
	return true; 
}
/*==========================================================================*/
