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 add_comment(){
var name_post = document.formcomment.name_post;
var email_post = document.formcomment.email_post;
var comment_post= document.formcomment.comment_post;
var security = document.formcomment.security;
//document.getElementById("submit_from").type = 'button';
if(name_post.value =='')
{
alert('ใส่ชื่อที่จะ Post ด้วยครับ');
name_post.focus();
return false;
}else if(email_post.value =='' || !isEmail(email_post.value)){
alert('ใส่ E-mail ที่ถูกต้องด้วยครับ');
email_post.focus();
return false;
}else if(comment_post.value ==''){
alert('แสดงความคิดเห็นด้วยครับ');
comment_post.focus();
return false;
}else if(security.value ==''){
alert('ใส่ตัวเลขที่มองเห็นด้วยครับ');
security.focus();
return false;
}else{
addcomment();
return false;
}
}
//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
var xmlHttp;
function createXMLHttpRequest()
{
if (window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}else if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
}
///////////////////
function addcomment()
{
createXMLHttpRequest();
var pForm = document.formcomment;
var pBody = getRequestBody(pForm);
xmlHttp.open("post","http://www.duclipvideo.com/addcommment.php", true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
document.getElementById("comment").innerHTML='
';
xmlHttp.onreadystatechange = function ()
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
divshow_comment(xmlHttp.responseText);
} else {
divshow_comment("พบข้อผิดพลาด " + xmlHttp.statusText);
}
}
};
xmlHttp.send(pBody);
}
///////////////////////
function getRequestBody(pForm)
{
var nParams = new Array();
for (var i=0 ; i < pForm.elements.length; i++)
{
var pParam = encodeURIComponent(pForm.elements[i].name);
pParam += "=";
pParam += encodeURIComponent(pForm.elements[i].value);
nParams.push(pParam);
}
return nParams.join("&");
}
function divshow_comment(pMessage)
{
var divStatus = document.getElementById("comment");
divStatus.innerHTML =pMessage;
}
/////////////////
function delpage(report,idcomment) {
//////////////////////////
document.getElementById(report).innerHTML='กำลังโหลด...
';
createXMLHttpRequest();
var url= "http://www.duclipvideo.com/del_comment.php?id="+idcomment;
xmlHttp.open("get",url, true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
displayInfo(xmlHttp.responseText);
} else {
displayInfo("พบข้อผิดพลาด: " + xmlHttp.statusText);
}
}
};
xmlHttp.send(null);
function displayInfo() {
document.getElementById(report).innerHTML = xmlHttp.responseText;
}
}
////////////////////
function commemt_page(idmovie,page) {
document.getElementById('comment').innerHTML='
';
createXMLHttpRequest();
var url= "http://www.duclipvideo.com/page.php?p="+page+"&id="+idmovie;
xmlHttp.open("get",url, true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
displayInfo(xmlHttp.responseText);
} else {
displayInfo("พบข้อผิดพลาด: " + xmlHttp.statusText);
}
}
};
xmlHttp.send(null);
function displayInfo() {
document.getElementById('comment').innerHTML = xmlHttp.responseText;
}
}
////////////////////////////////
function playlist(idmovie) {
//document.getElementById("videolist").innerHTML='
';
createXMLHttpRequest();
var url= "http://www.duclipvideo.com/playlist.php?&id="+idmovie;
xmlHttp.open("get",url, true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
displayInfo(xmlHttp.responseText);
} else {
displayInfo("พบข้อผิดพลาด: " + xmlHttp.statusText);
}
}
};
xmlHttp.send(null);
function displayInfo() {
document.getElementById("videolist").innerHTML = xmlHttp.responseText;
}
}
////////////////////////////////////////
function vote(id,vote)
{
document.getElementById('vote_video').innerHTML='';
createXMLHttpRequest();
var url= "http://www.duclipvideo.com/addvote.php?id="+id+"&vote="+vote;
xmlHttp.open("get",url, true);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
displayInfo(xmlHttp.responseText);
} else {
displayInfo("พบข้อผิดพลาด: " + xmlHttp.statusText);
}
}
};
xmlHttp.send(null);
function displayInfo() {
document.getElementById('vote_video').innerHTML = xmlHttp.responseText;
}
}