function GetXmlHttpObject() {
try {
req = new XMLHttpRequest();
} catch(err1) {
  try {
  req = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (err2) {
    try {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (err3) {
      req = false;
    }
  }
}
return req;
}

function submitcomment(){
	var vid=document.formcom.vid.value;
	var disc_name=document.formcom.disc_name.value;
	var disc_body=document.formcom.disc_body.value;
	var threadid=document.formcom.threadid.value;
	disc_name = disc_name.replace(/^\s+|\s+$/g, '');
	disc_body = disc_body.replace(/^\s+|\s+$/g, '');
	disc_body = disc_body.replace(/\n/g, "<br />").replace(/\n\n+/g, '<br /><br />').replace(/(<\/?)script/g,"$1noscript");
	if(disc_name == "") {
		alert('Please enter your name');
		document.formcom.disc_name.value ='';
		document.formcom.disc_name.foucs();
		return false;
	}
	if(disc_body == "") {
		alert('Please enter your comments');
        document.formcom.disc_body.value ='';
		document.formcom.disc_body.foucs();		
		return false;
	}
	var xmlhttp=GetXmlHttpObject();
	document.getElementById('commsg').innerHTML = 'Save...';
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
		    document.getElementById('commsg').innerHTML = xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","insertcomment.php?go=vcomm&vid="+vid+"&disc_name="+disc_name+"&disc_body="+disc_body+"&threadid="+threadid,true);
	xmlhttp.send(null);
	document.formcom.disc_name.value = '';
	document.formcom.disc_body.value = '';
	datafetch(vid,1);
	animatedcollapse.hide('divcomment');
	countcomment(vid,threadid);
}

function send_mail(){
	var vid=document.mailtofriend.vid.value;
	var url=document.mailtofriend.url.value;
	var title=document.mailtofriend.title.value;
	var email=document.mailtofriend.email.value;
	var name=document.mailtofriend.name.value;
	var mess=document.mailtofriend.mess.value;
	var xmlhttp=GetXmlHttpObject();
	document.getElementById('mailmsg').innerHTML = 'Sending...';
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
		    document.getElementById('mailmsg').innerHTML =xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","mailtofriend.php?vid="+vid+"&url="+url+"&title="+title+"&email="+email+"&name="+name+"&mess="+mess,true);
	xmlhttp.send(null);
	document.mailtofriend.email.value = '';
	document.mailtofriend.name.value = '';
	document.mailtofriend.mess.value = '';
	//datafetch(vid,1);
	animatedcollapse.hide('divemail');
}


function countcomment(vid,threadid){
	var xmlhttp=GetXmlHttpObject();
	document.getElementById('countComment').innerHTML = 'Counting...';
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
		    document.getElementById('countComment').innerHTML =xmlhttp.responseText;
		}
	}
	xmlhttp.open("GET","countcomment.php?vid="+vid+"&threadid="+threadid,true);
	xmlhttp.send(null);
}