// JavaScript Document
 function popup(url){
	 popwindow = window.open(url,"Bookmark",
"menubar=no,width=410,height=440,toolbar=no,location=no");
	popwindow.focus();

	 }
	  function popupv(url){
	 popwindow = window.open(url,"Preview",
"menubar=no,width=620,height=540,toolbar=no,location=no");
	popwindow.focus();

	 }
	 
	  
   
	 
$(document).ready(function() {
						   
 $("a.vidtitle").click(function() {
   
	  $.post("/request/views.php", {id: (this.id)}, function(txt) {
	
	   }); 
	  
	window.location = this.href;

return false;
   }); 
						   
   $("a.vote").click(function() {
    
	  $.post("/request/vote_insert.php", {rating: (this.title), vid: (this.id)}, function(txt) {
	 e.preventDefault();
	
	   }); 
	   $(this).parents(".rating").html("Thanks for rating!");
	   document.cookie = (this).id + "-rating=";
	   return false;
   });
   
 
   
   
    $("a.report").click(function() {
    alert('Report dead link?');
	  $.post("/request/report_dead_link.php", {vid: (this.id)}, function(txt) {
	 e.preventDefault();
	
	   }); $(this).html(
         "Thank you!"
       
       );
	   
	   return false;
   });
   
   
   $("a.plin").click(function() {
    
	  $.post("/request/playlist.php", {plin: (this.id)}, function(txt) {
	 e.preventDefault();
	
	   }); $(this).html(
         "Added to quicklist!"
       
       );
	   var nums = $('.plcount').text();
	   var count = nums++;
	   
	   $('.plcount').html(nums);
	   return false;
   });
   
   $("a.plrm").click(function() {
    
	  $.post("/request/playlist.php", {plrm: (this.id)}, function(txt) {
	 e.preventDefault();
	
	   }); $(this).parents("li").html(
         "Removed!"
       
       );
	   var nums = $('.plcount').text();
	   var count = nums--;
	   
	   $('.plcount').html(nums);
	   return false;
   });
   
   $("a.bmrm").click(function() {
    
	  $.post("/request/bookmark.php", {bmrm: (this.id)}, function(txt) {
	 e.preventDefault();
	
	   }); $(this).parents("li").html(
         "Removed!"
       
       );
	 return false;
   });

function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

	 if (get_cookie('adv')=='show'){
	 $("#advoptions").show();
	 $("#advsearch").addClass("adv_hide");
	 }
 
    $("#advsearch").toggle(function(){
	 
     $("#advoptions").show();
	 $("#advsearch").addClass("adv_hide");
	 document.cookie="adv=show";
   },function(){
     $("#advoptions").hide();
	  $("#advsearch").removeClass("adv_hide");
	  document.cookie="adv=";
   });
   

 $(".thumbbtn").click(function() {
    
	$(".list").removeClass("list");
	   $("#results li").addClass("thumbs");
	   document.cookie="view=thumbs";
	   return false;
   });
   $(".listbtn").click(function() {
   
	$(".thumbs").removeClass("thumbs");
	   $("#results li").addClass("list");
	   document.cookie="view=list";
	   return false;
   });
         
		 $("a.show_related").toggle(function(){
	 
	   var get = '/request/getrelated.php?id=' + (this).id;
	  
     $("#related").show('slow'); $("#related").load(get);
	  return false;
   },function(){
     $("#related").hide('slow');
	
   });
		
 $(".advtoggle").toggle(function(){
	$(".adv").show();
	
   },function(){
     
	$(".adv").hide();
	
   });
   
     
	
	 
	 $("a.preview").click(function() {
    
	 


	   $('.bg').show();
	   $('.movie_inner').show();
	   var url = (this).title;
	   var site = (this).id;
	   var get = '/request/getpreview.php?id=' + (this).id;
	  
	   $(".movie_inner").html("<img src='/images/loading_mini.gif' border='0'/>");
	   $(".movie_inner").load(get);
	   
	    //onmouse out hide the shareit box  
 
	   return false;
   });
	  
  $('.bg').click(function() {
  $('.bg').hide();$('.movie_inner').hide();$('.movie_inner').html('');return false;
						  });
 });
						  