

///var arrinfo = new Array();
//var special = "";


function submitthis(){
 //document.searcher.submit();
}

function start2(div,media){

var obj_div = window.document.getElementById(div);
obj =  '\'<OBJECT classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="320" height="260"><PARAM NAME="AutoStart" VALUE="True"><PARAM NAME="FileName" VALUE="drm/\'+ media +\'"><PARAM NAME="ShowControls" VALUE=""><PARAM NAME="ShowStatusBar" VALUE="false"><EMBED type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" SRC="drm/\'+ media +\'" name="MediaPlayer1" width="320" height="260" autostart=1 showcontrols=0 showstatusbar=0></EMBED></OBJECT></embed>\';'

 obj_div.innerHTML = obj;
} 

function updaterating(rat,divstars)
{
 //arrinfo[special+"8"] = rat;
 
 
 var dat = " <table border='0'  height='26' cellspacing='0' cellpadding='0'><tr>";
 var strnum = rat; 
 var cal = strnum/2;
 
 if(strnum == 1 || strnum == 3 || strnum == 5 || strnum == 7 || strnum == 9){
    cal = parseInt(cal)+1;
 } 
		  
for(a=0;a<cal;a++){
 dat += " <td width='24' height='25'><img src='../images/star_on.gif' width='24' height='25' /></td> "; 
 } 
 
 cal = 5 - cal;
 for(a=0;a<cal;a++){
 dat += " <td width='24' height='25'><img src='../images/star_off.gif' width='24' height='25' /></td> ";
 }
 var mid = "stars"
 if(divstars != ''){
  mid += divstars;
 }
 
 dat += " </tr></table> ";
 
 var div = window.document.getElementById(mid);
 div.innerHTML = "";
 div.innerHTML = dat;
 div.height = 26;
 
 
}



function makePOSTRequest(cmt, id, rating, opt)
{
	http_request = false;
	//alert("1");
	
	if(window.XMLHttpRequest)
	{ 
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if(http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/html');
		}
	} 
	else if(window.ActiveXObject)
	{ 
		// IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){}
		}
	}
	
	if(!http_request)
	{
	   alert('Cannot create XMLHTTP instance');
           return false;
	}
	
	var url = "../admin_process.php?flg=" + _flag  + "&";
	if(opt == 1){   
	   url += "id=" + id + "&rating=" + rating + "&opt=" + opt + "&cmt=" + cmt;
	}
	if(opt == 2){   
	   url += "id=" + id + "&rating=" + rating + "&opt=" + opt + "&cmt=" + cmt;
	}
	if(opt == 3){   
	   url += "id=" + id + "&opt=" + opt;
	}	
	if(opt == 4){   
	   url += "id=" + id + "&opt=" + opt + "&rating=" + rating;
	}	
	http_request.open("GET", url, true);
	http_request.onreadystatechange = alertContents;
	http_request.send(null);
}


function alertContents()
{
	if(http_request.readyState == 4)
	{
		if (http_request.status == 200)
		{
		  result = http_request.responseText; 
		  	    
		  var jsarr = new Array();
		  var aux = new Array();
		  
		  jsarr = result.split("||");	
		  
		  if(jsarr[3] == "0")
		  {
		  	jsarr = result.split("@#@");	
		  }
		  


		  if(jsarr[4] == 80){
		     document.nextvideo.submit();
		  }
		  
		  if(jsarr[1] == "2"){ 
		       var num_of_cmt = window.document.getElementById('num_cmt'+jsarr[2]);
	           num_of_cmt.innerHTMl = jsarr[3];
		  }
		  
		  if(jsarr[1] == "3"){
		    aux = result.split("|||");		    
		    playMovie(aux[1],'');
		  }	
		  if(jsarr[1] == "4"){		
		    updatecmts(jsarr[2],jsarr[3],jsarr[4]);
		  }	
		  if(jsarr[1] == "5"){		       
		    alert("Email has been sent.");
		    cleardiv(jsarr[2]);					
		  }	
		  if(jsarr[1] == "6"){		       
		    /*var obj = document.getElementById(jsarr[2]);
		    obj.innerHTML = "";
		    obj.innerHTML = jsarr[3];*/
		    //alert("done");
		  }	
		  if(jsarr[1] == "7"){
		  	playMovie(jsarr[2], "");
		  }
		  
		}
		else
		{
		  alert('There was a problem with the request.');
		}
	}
}
function updatecmts(until,text,id)
{
  var a = 0;
  var dat = "";
  var des = new Array();
  var esc = 0;
  var see = "inline";  

  des = text.split("&&&");
 

	for(a = 0;a<des.length*2-1;a++){
	  if(des[a] != null && des[a] != '' && des[a] != 'undefined'){
	    if(esc > 1){
	       see = "none";   
	     }
        dat += "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>";				   
		dat += "<tr><td> ";	     
		
	    dat += "<div  style='display: "+see+";' id='c"+id+esc+"'>";	    
	    dat += "<table width='95%' border='0' align='center' cellpadding='1' cellspacing='1' > ";
        dat += "<tr><td width='379' class='btext'><div align='left' class='commenttext'>"+des[a]+"</div></td></tr>";
	    dat += "<tr><td height='39'><div align='right' class='commentname'>"+des[a+1]+"</div></td></tr>";
	    dat += "</table></div> ";	    
	    dat += "</td></tr><table> ";  
	    a++;
	    esc++;
	  }
	}   
	
	dat += "</div></td></tr></table>";
	
   var  div = window.document.getElementById('comments'+id);
   var  divbt = window.document.getElementById('showcmts'+id);
   var  hidebt = window.document.getElementById('hidecmts'+id);
   div.innerHTML = "";
   div.innerHTML = dat;
   divbt.innerHTML = "";
   divbt.innerHTML = "<a href=\"javascript:showcmts("+until+","+id+")\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../images/more_over.gif',1)\"><img src=\"../images/more.gif\" alt=\"MORE COMMENTS\" name=\"Image9\" width=\"129\" height=\"22\" border=\"0\" id=\"Image9\" /></a>";
   hidebt.innerHTML = "";
   hidebt.innerHTML = "<a href=\"javascript:hidecmts("+until+","+id+")\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('Image9','','../images/more_over.gif',1)\"><img src=\"../images/more.gif\" alt=\"MORE COMMENTS\" name=\"Image9\" width=\"129\" height=\"22\" border=\"0\" id=\"Image9\" /></a>";
  
}


function cleardiv(id)
{
  var div = window.document.getElementById(id); 
  div.style.display = 'none';
}


function addcomment(id)
{
 var div = window.document.getElementById(id);
 var dat = "";
 var imgid = "add" + id;
 var imgcnl = "cnl" + id; 
 
 dat = "<table width='390'>";
 dat += "<tr><td colspan='2' valign='top'><strong class='btext1'>Add Your Comment</strong</td></tr>";
 dat += "<tr><td colspan='2' valign='top'><textarea id='cmt"+id+"' rows='2' cols='40'></textarea></td></tr>";
 dat += "<tr><td colspan='2' valign='top'><strong class='btext1'>Name</strong></td></tr>";
 dat += "<tr><td valign='top'><input type='text' id='cmtname"+id+"' size='15' /></td>";
 dat += "<td><a href=\"javascript:callaction(2,"+id+",'','')\" onmouseout='MM_swapImgRestore()' onmouseover=\"MM_swapImage('"+imgid+"','','../images/add_over.jpg',1)\"><img src='../images/add.jpg' alt='ADD' name='"+imgid+"' width='68' height='20' border='0' id='"+imgid+"' /></a> ";
 dat += "&nbsp;<a href=\"javascript:cleardiv("+id+")\" onmouseout='MM_swapImgRestore()' onmouseover=\"MM_swapImage('"+imgcnl+"','','../images/cancel_over.jpg',1)\"><img src='../images/cancel.jpg' alt='RATE' name='"+imgcnl+"' width='68' height='20' border='0' id='"+imgcnl+"' /></a></td></tr></table>";

 div.innerHTML = dat;
 div.style.display = 'inline';  
}
function sendto(id)
{
{
 var div = window.document.getElementById(id);
 var dat = "";
 var imgid = "add" + id;
 var imgcnl = "cnl" + id; 
//  var from = document.getElementById('send25').value;
 dat = "<table border='0' width='390'>";
 dat += "<tr><td colspan='3'><strong class='btext1'>Send this ";
 if(_flag==1)
 dat += "video";
 else if(_flag==2)
 dat += "photo";
 dat += " to your Friend</strong</td></tr>";
 dat += "<tr><td align=\"right\"><strong class='btext1'>from: </strong></td><td align=\"left\"><input type='text' id='send25' size='15' ></td><td align=\"right\"><strong class='btext1'>to: </strong></td><td align=\"left\"><input type='text' id='send2' size='15' /></td></tr>";
 dat += "<tr><td colspan=\"2\"><a href=\"javascript:miniax("+id+",'','','',5)\" onmouseout='MM_swapImgRestore()' onmouseover=\"MM_swapImage('"+imgid+"','','../images/send_over.jpg',1)\"><img src='../images/send.jpg' alt='ADD' name='"+imgid+"' width='68' height='20' border='0' id='"+imgid+"' /></a> ";
 dat += "&nbsp;<a href=\"javascript:cleardiv("+id+")\" onmouseout='MM_swapImgRestore()' onmouseover=\"MM_swapImage('"+imgcnl+"','','../images/cancel_over.jpg',1)\"><img src='../images/cancel.jpg' alt='RATE' name='"+imgcnl+"' width='68' height='20' border='0' id='"+imgcnl+"' /></a></td></tr></table>";

 div.innerHTML = dat;
 div.style.display = 'inline';  
}	
}
function callaction(num,id,divstars,shorti)
{

	var obj = "";
	var frmvalue = "";

	var radios = window.document.getElementsByName('R').length;
	var one = window.document.getElementsByName('R');       
	
	if(num == 1){
	  myOption = -1;
	  for (i=radios-1; i > -1; i--) {
	     if (one[i].checked) {
	      myOption = i;       
	     }
	  }

	  if (myOption == -1) {
	       alert("You must select a rate");
	       return false;
	  }else{
	       frmvalue = one[myOption].value
	       makePOSTRequest(divstars,id,frmvalue,1);	
	  }     
	
	}  

	if(num == 2){
		  var cmt = window.document.getElementById('cmt'+id); 
		  var cmtname = window.document.getElementById('cmtname'+id);
		  var flag = 1;
		  if(cmt.value == ""){
		       alert("Please type your Comment");
		       cmt.focus();
			   flag = 0;	
		  }
		  else if(cmtname.value == ""){
		       alert("Please type your Name");
		       cmtname.focus();	  	
			   flag = 0;
		  }
		  if(flag == 1){
			  makePOSTRequest(cmt.value,id,cmtname.value,2);	
			  cleardiv(id); 
			  //callaction(4,id,0,'');
			  makePOSTRequest('',id,0,4);
		 }
	}
	
	if(num == 3){
	  makePOSTRequest('',id,'',3);
	}	
	if(num == 4){
	  makePOSTRequest(shorti,id,divstars,4);
	}	
	
}
function hideExtraTags(min, len)
{
   for (i=min;i<len;i++) {
   	  if(document.getElementById("tag" + i))
       var element = document.getElementById("tag" + i).style.display = "none";
   }
   var element = document.getElementById("showExtraTags").style.display = 'inline';
   var element = document.getElementById("hideExtraTags").style.display = 'none';
}
function showExtraTags(min, len)
{
  for (i=min;i<len;i++) {
  	if(document.getElementById("tag" + i))
     var element = document.getElementById("tag" + i).style.display = "inline";
   }
  var element = document.getElementById("showExtraTags").style.display = 'none';
  var element = document.getElementById("hideExtraTags").style.display = 'inline';
}


//--------------------------------- comment -------------------------------------//

function showcmts(len, id)
{  
  var get = 0;
  var h = 150;
  var  div = window.document.getElementById('comments'+id);      
  var i = 0;
  for (i=2;i<len;i++){ 
      var element = document.getElementById("c" + id + i);
      if(element != null && element != ""){
       element.style.display = "inline";
       get++;
      }
  }

  if(get != 0){
   div.style.overflow = 'scroll';
   div.style.height = h + 'px';
   var element = document.getElementById("showcmts"+id).style.display = 'none';
   var element = document.getElementById("hidecmts"+id).style.display = 'inline';
  }else{
   alert("There are no more comments");
  } 
 
}


function hidecmts(len, id)
{
  var i = 0;
  var  div = window.document.getElementById('comments'+id);  
  
  for (i=2;i<len;i++) {
      var element = document.getElementById("c" + id + i);
      if(element != null && element != "")
       element.style.display = "none";
   }
   
  div.style.overflow = 'hidden';
  div.style.height = 'auto'; 
  var element = document.getElementById("showcmts"+id).style.display = 'inline';
  var element = document.getElementById("hidecmts"+id).style.display = 'none';
  
}


//-------------------------------------------------------------------------------------



function tagaction(idtag){
 document.tags.numtag.value = idtag;
 document.tags.submit();
}
function rlink(strlink)
{
  var att = 'scrollbars=yes,menubar=no,height=600,width=800,resizable=yes,toolbar=yes,location=no,status=no';
  var loader = window.open(strlink,'',att);
}
function miniax(one, two, three, four, opt)
{
	http_request = false;	
	if(window.XMLHttpRequest){ 
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if(http_request.overrideMimeType){
		  http_request.overrideMimeType('text/html');
		}
	} 
	else if(window.ActiveXObject)
	{ 
		// IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){}
		}
	}
	
	if(!http_request)
	{
	   alert('Cannot create XMLHTTP instance');
       return false;
	}
	
	var url = "../admin_process.php?flg=" + _flag + "&";
	if(opt == 5){
	    var email = window.document.getElementById('send2');
	    var from = window.document.getElementById('send25');
// 	    alert(from.value);
	    url += "email=" + email.value + "&fname=" +  from.value + "&opt=" + opt + "&categ=" + one;
	    window.document.getElementById(one).style.display = 'none';
	}
	if(opt == 8){ 
	    url += "fname=" + one + "&opt=" + 6;
	}
	if(opt == 7){
	    url += "id=" + one + "&opt=" + opt;	    
	}	
	if(opt == 9){ 
	    url += "fname=" + one + "&opt=" + opt;	    
	}	
		
	http_request.open("GET", url, true);
	http_request.onreadystatechange = alertContents;
	http_request.send(null);

}
function cleanthis()
{
	var text = document.getElementById("textsearch");
	text.value = "";
}
function access(opt){
	if(opt == 1)
	{
		var answer = confirm("Register for FREE to rate this video")
		if (answer){			
			window.location = "../join.php";
		}		
	}else{
		alert("You dont have access to do this!");
	}
}
