var offsetxpoint=10;
var offsetypoint=20;
var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
var tipobj = null;

function toggletab(id2,id1){
	var obj1 = document.getElementById('brand_content_'+id1);
	var obj2 = document.getElementById('brand_content_'+id2);
	try{
		obj1.style.display = 'none';
		obj2.style.display = '';
	}
	catch(e){
		obj1.style.visibility = 'hidden';
		obj2.style.display = 'visible';
	}
	my_setcookie('movietab',id2,0);
}
function ml_isCheck(obj){
	var TotalBoxes = 0;
	var TotalOn = 0;
	for(var i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		if((e.name != 'allbox') && (e.type=='checkbox')){
			TotalBoxes++;
			if(e.checked){ TotalOn++; }
		}
	}
	if(TotalBoxes == TotalOn){ obj.allbox.checked = true; }
	else { obj.allbox.checked = false; }
}
function ml_validate(but,obj1,obj2){
	if(obj1.value == "" || obj2.value == ""){
		alert(vd_lang_required);
		return false;
	}else{
		but.disabled = true;
		return true;
	}
}
function select_upload(){
	try{ document.theForm.v_poster_url.value = ""; }
	catch(nourl){ return true; }
}
function restore_it(){ document.theForm.v_poster_url.value = ""; }
function select_img(fmobj,url){
	var obj = fmobj.options[fmobj.selectedIndex];
	var img = ipb_var_image_url + '/video_img/no_image.jpg';
	if(obj.value != ''){ img = url + obj.value; }
	document.getElementById('poster').innerHTML = "<a href='" + img + "' target='_blank'><img src='" + img + "' width='150' height='150' border='' alt='' /></a>";
}
function vd_delconfirm(theURL){
	if(confirm(vd_lang_del_1)){ ml_locationjump(theURL); }
	else{ alert(vd_lang_del_2); }
}
function ml_delconfirm(theURL){
	if(confirm(vd_lang_del_1)){ ml_locationjump(theURL); }
	else{ alert(vd_lang_del_2); }
}
function ml_checkAll(obj){
	for(var i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		if((e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled)){ e.checked = obj.allbox.checked; }
	}
}
function vd_isCheck(obj){
	var TotalBoxes = 0;
	var TotalOn = 0;
	for(var i=0;i<obj.elements.length;i++){
		var e = obj.elements[i];
		if((e.name != 'allbox') && (e.type=='checkbox')){
			TotalBoxes++;
			if(e.checked){ TotalOn++; }
		}
	}
	if(TotalBoxes == TotalOn){ obj.allbox.checked = true; }
	else { obj.allbox.checked = false; }
}
function choosecat(){
	var choosebox = document.catfrm.roots.options[document.catfrm.roots.selectedIndex].value;
	window.location = vd_url + 'do=manage&CODE=showcatreorder&cat_id=' + choosebox;
}
function changeToggle(first,last){
	var notoggle = false;
	if(notoggle == true) return;
	toggleview(first);
	toggleview(last);
	notoggle = true;
}
function changeDiv(id,method){
	var itm = null;
	if(document.getElementById){ itm = document.getElementById(id); }
	else if(document.all){ itm = document.all[id]; }
	else if(document.layers){ itm = document.layers[id]; }
	if(itm.style){
		if( method == 'show' ){ itm.style.display = ""; }
		else{ itm.style.display = "none"; }
	}else{ itm.visibility = "show"; }
}
function isValidRadio(obj){
    for(var i=0;i<obj.length;i++){ if(obj[i].checked){ return true; } }
    return false;
}
function emoticon(theSmilie){ doInsert(" " + theSmilie + " ", "", false); }
function doInsert(ibTag,ibClsTag,isSingle){
	var isClose = false;
	var obj_ta = document.comfrm.com_text;
	if( (ua_vers >= 4) && is_ie && is_win){
		if(obj_ta.isTextEdit){
			obj_ta.focus();
			var sel = document.selection;
			var rng = sel.createRange();
			rng.colapse;
			if((sel.type == "Text" || sel.type == "None") && rng != null){
				if(ibClsTag != "" && rng.text.length > 0) ibTag += rng.text + ibClsTag;
				else if(isSingle) isClose = true;
				rng.text = ibTag;
			}
		}else{
			if(isSingle){ isClose = true; }
			obj_ta.value += ibTag;
		}
	}else if(obj_ta.selectionEnd){ 
		var ss = obj_ta.selectionStart;
		var st = obj_ta.scrollTop;
		var es = obj_ta.selectionEnd;
		if(es <= 2){ es = obj_ta.textLength; }
		var start  = (obj_ta.value).substring(0, ss);
		var middle = (obj_ta.value).substring(ss, es);
		var end    = (obj_ta.value).substring(es, obj_ta.textLength);
		if(obj_ta.selectionEnd - obj_ta.selectionStart > 0){ middle = ibTag + middle + ibClsTag; }
		else{ middle = ibTag + middle; if(isSingle){ isClose = true; } }
		obj_ta.value = start + middle + end;
		var cpos = ss + (middle.length);
		obj_ta.selectionStart = cpos;
		obj_ta.selectionEnd   = cpos;
		obj_ta.scrollTop      = st;
	}else{
		if(isSingle){ isClose = true; }
		obj_ta.value += ibTag;
	}
	obj_ta.focus();
	return isClose;
}
function check_all(permtype){
	var checkboxes = document.theForm.getElementsByTagName('input');
	for(var i=0;i<=checkboxes.length;i++){
		var e = checkboxes[i];
		if(e && (e.id != 'SHOW_ALL') && (e.id != 'VIEW_ALL') && (e.id != 'PLAY_ALL') && (e.id != 'UPLOAD_ALL') && (e.id != 'DOWNLOAD_ALL') && (e.id != 'COMMENT_ALL') && (e.type == 'checkbox') && (! e.disabled)){
			var s = e.id;
			var a = s.replace(/^(.+?)_.+?$/,"$1");
			if(a == permtype){ e.checked = true; }
		}
	}
	if(document.getElementById(permtype+'_ALL').checked){
		document.getElementById(permtype+'_ALL').checked = true;
	}else{
		document.getElementById(permtype + '_ALL').checked = false;
	}
	return false;
}
function obj_checked(permtype,pid){
	var totalboxes = 0;
	var total_on   = 0;
	if(pid){
		document.getElementById(permtype+'_'+pid).checked = document.getElementById(permtype+'_'+pid).checked ? true : false;
	}
	var checkboxes = document.theForm.getElementsByTagName('input');
	for(var i=0;i<=checkboxes.length;i++){
		var e = checkboxes[i];
		if(e && (e.id != 'SHOW_ALL') && (e.id != 'VIEW_ALL') && (e.id != 'PLAY_ALL') && (e.id != 'UPLOAD_ALL') && (e.id != 'DOWNLOAD_ALL') && (e.id != 'COMMENT_ALL') && (e.type == 'checkbox') && (! e.disabled)){
			var s = e.id;
			var a = s.replace(/^(.+?)_.+?$/,"$1");
			if(a == permtype){
				totalboxes++;
				if(e.checked) total_on++;
			}
		}
	}
	if(totalboxes == total_on){
		document.getElementById(permtype+'_ALL').checked = true;
	}else{
		document.getElementById(permtype+'_ALL').checked = false;
	}
	return false;
}
function checkcol(permtype,status){
	var checkboxes = document.theForm.getElementsByTagName('input');
	for(var i=0;i<=checkboxes.length;i++){
		var e = checkboxes[i];
		if(e && (e.id != 'SHOW_ALL') && (e.id != 'VIEW_ALL') && (e.id != 'PLAY_ALL') && (e.id != 'UPLOAD_ALL') && (e.id != 'DOWNLOAD_ALL') && (e.id != 'COMMENT_ALL') && (e.type == 'checkbox') && (! e.disabled)){
			var s = e.id;
			var a = s.replace(/^(.+?)_.+?$/,"$1");
			if(a == permtype){
				if(status == 1){
					e.checked = true;
					document.getElementById(permtype+'_ALL').checked = true;
				}else{
					e.checked = false;
					document.getElementById(permtype+'_ALL').checked = false;
				}
			}
		}
	}
	return false;
}
function checkrow(permid,status){
	document.getElementById("SHOW"+'_'+permid).checked = status ? true : false;
	document.getElementById("VIEW"+'_'+permid).checked = status ? true : false;
	document.getElementById("PLAY"+'_'+permid).checked = status ? true : false;
	document.getElementById("UPLOAD"+'_'+permid).checked = status ? true : false;
	document.getElementById("DOWNLOAD"+'_'+permid).checked = status ? true : false;
	document.getElementById("COMMENT"+'_'+permid).checked = status ? true : false;
	obj_checked("SHOW");
	obj_checked("VIEW");
	obj_checked("PLAY");
	obj_checked("UPLOAD");
	obj_checked("DOWNLOAD");
	obj_checked("COMMENT");
	return false;
}
function pv(e,num){	
	var curLink = "";
	var sr = getWindowHeight;
	var srr = getPageScroll;
	var span = document.getElementById('pv' + num);
	if(curLink != ""){ curLink.style.display = 'none'; }
	curLink = span;
	if(!document.all){
		span.style.left = e.pageX + 10 + 'px';
		span.style.top = e.pageY + 5 + 'px';
	}else{
		span.style.pixelLeft = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft + 5 + 'px';
		span.style.pixelTop = e.clientY + document.body.scrollTop	+ document.documentElement.scrollTop + 5 + 'px';
	}
	span.style.display = 'block';
	tipobj = span;
	enabletip=true;
	document.onmousemove = dopv;
	return false;
}
function unpv(num){
	var span = document.getElementById('pv' + num );
	span.style.display = 'none';
	enabletip = false;
	window.onmousemove = null;
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function dopv(e){
	//alert("asda");
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		//if (rightedge<tipobj.offsetWidth)
		//move the horizontal position of the menu to the left by it's width
		if(document.all)
		{
			rightedge =  document.documentElement.clientWidth - event.clientX-offsetxpoint-10;
			bottomedge = document.documentElement.clientHeight - event.clientY-offsetypoint-5;
			if(rightedge < tipobj.offsetWidth) {
				tipobj.style.pixelLeft = 10 + event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft - tipobj.offsetWidth;
				tipobj.style.width = '300px';
			}
			else if(curX<leftedge)
				tipobj.style.pixelLeft = 5;
			else
				tipobj.style.pixelLeft = 10 + event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			if (bottomedge<tipobj.offsetHeight)
				tipobj.style.pixelTop = 10 +event.clientY + document.body.scrollTop	+ document.documentElement.scrollTop - tipobj.offsetHeight;
			else		
				tipobj.style.pixelTop = 10 +event.clientY + document.body.scrollTop	+ document.documentElement.scrollTop;		
			
		}	
		else {
			rightedge = window.innerWidth-e.clientX-offsetxpoint-20;
			bottomedge = 	window.innerHeight-e.clientY-offsetypoint-20;
			if (rightedge < tipobj.offsetWidth)
				tipobj.style.left = window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
					else if (curX<leftedge)
						tipobj.style.left="5px";
					else
						tipobj.style.left=curX+offsetxpoint+"px"
			if (bottomedge<tipobj.offsetHeight)
						tipobj.style.top = window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
			else
						tipobj.style.top=curY+offsetypoint+"px";
		}
		tipobj.style.visibility="visible"
	}
}
function ml_locationjump(url){
	window.location = vd_url+url;
}

function toggle_sid(sid){
	saved = new Array(); clean = new Array(); add = 1;
	tmp = document.theForm.selectedsids.value;
	saved = tmp.split(",");
	for(i = 0 ; i < saved.length; i++){
		if(saved[i] != ""){ if(saved[i] == sid){ add = 0; }else{ clean[clean.length] = saved[i]; } }
	}
	if(add){
		clean[clean.length] = sid;
		eval("document.img"+sid+".src=vd_selected_btn");
	}else{
		eval("document.img"+sid+".src=vd_unselected_btn");
	}
	newvalue = clean.join(',');
	document.theForm.selectedsids.value = newvalue;
	newcount = stacksize(clean);
	if( document.getElementById('gobutton') ){ document.theForm.gobutton.value = newcount ? vd_go_btn + '(' + newcount + ')' : vd_go_btn; }
	return false;
}
function link_to_item(url){ temp = prompt(vd_lang_tt_prompt, url); return false; }
function ml_disabled(error){ alert(error); return false; }
function vd_add_file(){
	document.getElementById('video_files').innerHTML += create_field(++document.theForm.totalfile.value);
	var total = document.theForm.totalfile.value ;
	var new_opt = new Option(total,total);
	for(var i=1;i<total;i++){
		var opt_arr = eval("document.theForm.position_"+i);
		opt_arr.options[total-1] = new Option(total,total);
	}
}
function video_files_init(){
	var field_total = document.theForm.totalfile.value ;
	if(document.theForm.CODE.value == 'donew' || document.theForm.CODE.value == 'doadd'  ){
		var obj 	= document.getElementById('video_files');
		if(total_file <= field_total){
			for(var i=total_file;i<=field_total;i++){
				obj.innerHTML += create_field(i);
			}
		}
	}
	else{
		for(var i=1;i<=field_total;i++){
			var opt_arr = eval("document.theForm.position_"+i);
			var opt_len = opt_arr.options.length;//3
			if(opt_len < field_total){
				for(var j=opt_len ; j < field_total ; j++){
					opt_arr.options[j] = new Option(j+1,j+1);
				}			
			}
		}
	}
}
function create_field(num){
	var html = '';
	var opt = '';
	var field_total = document.theForm.totalfile.value ;
	var field = html_field;
	if(typeof(document.theForm.f) != 'undefined'){
		field = field.replace('<%value%>',document.theForm.f[num-1].value);
	}else{
		field = field.replace('<%value%>','');
	}
	for(var i=1;i<=field_total;i++){
		opt += "<option value='"+i+"'";
		if(i==num)
			opt += " selected='selected'";
		opt += ">"+i+"</option>";
	}
	field = field.replace('<%i>',num-1);
	html += "<tr>";
	html += "<td>"+html_title+': '+num+"</td>";
	html += "<td>";
	html += "<a href='#' onclick='vd_remove_file(this);return false;' style='text-decoration:none'><b>[x]</b></a>";
	html += field;
	html += "</td>";
	html += "<td>";
	html += "<select name='position_"+num+"' style='margin:0px;'/>";
	html += opt;
	html += "</select>";
	html += "</td>";
	html += "</tr>";
	return html;
}
function show_video_loading(){
	changeDiv('loading-layer','show');
}
function hide_video_loading(){
	changeDiv('loading-layer','none')
}
function vd_remove_file(obj){
	var table = document.getElementById('video_files');
	var cell  = obj.parentNode.parentNode;
	var f_id = obj.id.match(/\d{1,}/);
	if(document.theForm.CODE.value == 'doeditvideo'){
		var url = vd_url + 'do=post&CODE=delfile&host=1&f_id=' + f_id + "&xmlout=1";
		if(confirm("Do you want to delete this file in host ?")){
			if(confirm(vd_lang_del_1)){
			  do_request_function = function(){
			  	if ( ! xmlobj.readystate_ready_and_ok() ){return;}
				 	var html = xmlobj.xmlhandler.responseText;
				 	if(html=='okie')
				 	{
						table.deleteRow(cell.rowIndex);
				  	document.theForm.totalfile.value--;
				  	alert("Files Sucessfully remove from host and database");
				  }
				}
				xmlobj = new ajax_request();
			  xmlobj.onreadystatechange( do_request_function );
			  var xmlreturn = xmlobj.process( url );
			}
			else{
				alert(vd_lang_del_2);
			}
		}
		else{
		 	if(confirm(vd_lang_del_1)){
		 		table.deleteRow(cell.rowIndex);
		 		document.theForm.totalfile.value--;
		 		alert("Files Sucessfully remove from database");
			}
		 	else{
		 		alert(vd_lang_del_2);
		 	}
		}	
	}
	else{
		table.deleteRow(cell.rowIndex);
		document.theForm.totalfile.value--;
	}
}
function field_change(elem){
	var fid = elem.id.match(/\d{1,}/);
}
var playscr;
function play_video(f_id){
	var url = vd_url + 'playid=' + f_id + "&xmlout=1";	
  do_request_function = function(){
		if ( ! xmlobj.readystate_ready_and_ok() ){xmlobj.show_loading(); return;}
		xmlobj.hide_loading();
	 	var html = xmlobj.xmlhandler.responseText;
	 
		if ( html == 'no_permission' ){
			alert("Incorrect use of one of the board files.");
			return false;
		}
		if ( html == 'invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
		playscr = html; 
	  document.getElementById( 'play-screen' ).innerHTML =  html;
	}

  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
  var xmlreturn = xmlobj.process( url );
  return false;
}

function play_part(f_id){
	var url = vd_url + 'do=play&CODE=playmovie&part=' + f_id + "&movieid=" + movie_id + "&xmlout=1";	
  do_request_function = function(){
		if ( ! xmlobj.readystate_ready_and_ok() ){xmlobj.show_loading(); return;}
		xmlobj.hide_loading();
	 	var html = xmlobj.xmlhandler.responseText;
	 
		if ( html == 'no_permission' ){
			alert("Incorrect use of one of the board files.");
			return false;
		}
		if ( html == 'invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
	  document.getElementById( 'play-screen' ).innerHTML =  html;
	  playscr = html; 
	}

  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
  var xmlreturn = xmlobj.process( url );
  return false;
}
function do_rate(v_id,vote){
	var url = vd_url + 'do=post&CODE=dovote&xmlout=1&v=' + vote + '&v_id=' + v_id;
  do_request_function = function(){
  	if(! xmlobj.readystate_ready_and_ok()){ return; }
 		var html = xmlobj.xmlhandler.responseText;
		if ( html == 'no-guest' ){
			alert(lang_no_guest);
			return false;
		}
		if ( html == 'no-permission' ){
			alert(lang_no_permission);
			return false;
		}
		if ( html == 'no-flood' ){
			alert(lang_flood);
			return false;
		}
		if ( html == 'no-vote' ){
			alert(lang_no_vote);
			return false;
		}
		if ( html == 'no-video' ){
			alert(lang_no_id);
			return false;
		}

		var content = new Array();
		content = html.split('|');
					
		document.getElementById('r_star').innerHTML = content[0];
		document.getElementById('r_text').innerHTML = content[1];
	}

  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
  var xmlreturn = xmlobj.process( url );
  return false;
}
function add_fav(v_id)
{
	var url = vd_url + 'do=view&CODE=addfav&xmlout=1&v_id=' + v_id;
  do_request_function = function(){
	  if ( ! xmlobj.readystate_ready_and_ok() ){ return; }
		var html = xmlobj.xmlhandler.responseText;
		if ( html == 'no_guests' ){
			alert("Sorry, but this function isn't available to guests");
			return false;
		}
		else if ( html == 'vd_fav_exists' ){
			alert("This song is already in your favorites");
			return false;
		}
		else if ( html == 'vd_invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
		else{
			var go_to = confirm('This song was Added To your Favorites . Do you Want to go to your Favorites');
			if(go_to)	
				self.location.href = vd_url + 'do=view&CODE=viewfav';
			else
				return false;
		}
	}
	
  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
 	var xmlreturn = xmlobj.process( url );
  return false;
}
function add_com(){
	ShowHide('comform');
}
function do_add_com(v_id){
	var url = vd_url + 'do=post&CODE=addcom&xmlout=1&v_id' + v_id;
	var fields = new Array();
	
	fields['v_id']  		= v_id ; 
	fields['do']    		= 'post';
	fields['CODE']   		= 'addcom';
	fields['com_title'] = document.comfrm.com_title.value ;
	fields['com_text']  = document.comfrm.com_text.value ;

  do_request_function = function(){
    if ( ! xmlobj.readystate_ready_and_ok() ){
    	xmlobj.show_loading();
      return;
    }
		xmlobj.hide_loading();

 		var html = xmlobj.xmlhandler.responseText;
						
		if ( html == 'vd_invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
		else if ( html == 'no_guests' || html == 'no_permission' ){
			alert("Sorry ! You have not permission to use this feature. ");
			return false;
		}
		else if ( html == 'vd_long_text' || html == 'vd_no_text'){
			alert("You Comments is too long or no content.");
			return false;
		}
    else
    {
    	document.getElementById( 'video-comment' ).innerHTML =  html;
    }
  }
  
  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
       
  var xmlreturn = xmlobj.process( url ,'POST', xmlobj.format_for_post(fields) );
 	ShowHide('comform');
 	document.comfrm.com_title.value = null;
 	document.comfrm.com_text.value = null;
  return false;
}
function do_edit_com(c_id,v_id,obj){
	var url = vd_url + 'do=post&CODE=editcom&xmlout=1&com_id=' + c_id;
	var fields = new Array();
	
	fields['do']    		= 'post';
	fields['CODE']   		= 'editcom';
	fields['v_id']  		= v_id;
	fields['com_id']  		= c_id;
	fields['com_text']  = obj.com_text.value ;

  do_request_function = function(){
    if ( ! xmlobj.readystate_ready_and_ok() ){
    	xmlobj.show_loading();
      return;
    }
		xmlobj.hide_loading();
 		var html = xmlobj.xmlhandler.responseText;
		if ( html == 'vd_invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
		else if ( html == 'no_guests' || html == 'no_permission' ){
			alert("Sorry ! You have not permission to use this feature. ");
			return false;
		}
		else if ( html == 'vd_long_text' || html == 'vd_no_text'){
			alert("You Comments is too long or no content.");
			return false;
		}else {
	    document.getElementById( 'video-comment' ).innerHTML =  html;
  	}  
  }
  
  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
       
  var xmlreturn = xmlobj.process( url ,'POST', xmlobj.format_for_post(fields) );
      
  return false;
}
function do_del_com(c_id,v_id){
	var url = vd_url + 'do=post&CODE=delcom&xmlout=1&v_id='+v_id+'&com_id=' + c_id;

  do_request_function = function(){
    if ( ! xmlobj.readystate_ready_and_ok() ){
    	xmlobj.show_loading();
      return;
    }
		xmlobj.hide_loading();

 		var html = xmlobj.xmlhandler.responseText;
					
		if ( html == 'vd_invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
		if ( html == 'no_guests' || html == 'no_permission' ){
			alert("Sorry ! You have not permission to use this feature. ");
			return false;
		}
    
    document.getElementById( 'video-comment' ).innerHTML =  html;
    
  }
  
  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
       
  var xmlreturn = xmlobj.process( url );
      
  return false;
}
function show_com(v_id,pp){
	var url = vd_url + 'do=post&CODE=showcom&xmlout=1&v_id='+v_id+'&st=' + pp;

  do_request_function = function(){
    if ( ! xmlobj.readystate_ready_and_ok() ){
    	xmlobj.show_loading();
      return;
    }
		xmlobj.hide_loading();

 		var html = xmlobj.xmlhandler.responseText;
					
		if ( html == 'vd_invalid_id' ){
			alert("We could not find any record matching the ID or the VALUE that you entered. Please double check the URL, or the data you entered into the form.");
			return false;
		}
		else if ( html == 'no_guests' || html == 'no_permission' ){
			alert("Sorry ! You have not permission to use this feature. ");
			return false;
		}
    else {
    	document.getElementById( 'video-comment' ).innerHTML =  html;
    }
  }
  
  xmlobj = new ajax_request();
  xmlobj.onreadystatechange( do_request_function );
       
  var xmlreturn = xmlobj.process( url );
     
  return false;
}

function getPageScroll(){
	var yScroll;	
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getWindowHeight() {
 var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}