var VIDEO_COMMENT_ABUSE = 'Report Abuse';
var AjaxObject = 
{
 handleSuccess_video_comments_abuse:function(o){
	if(o.responseText == 701)
	{
	var abuse_id = 	document.getElementById('abuse_id').value;
	document.getElementById('video_comment_success_title').innerHTML = '<h2>' + VIDEO_COMMENT_ABUSE + '</h2>';
	success_message = 'This Adda video comment has been reported as abusive. It is currently under review.';
	document.getElementById('video_comment_success_message').innerHTML = success_message;
	document.getElementById('video_dialog2_comment').style.display = 'block';
	YAHOO.example.video_container1.video_dialog2_comment.show();
	document.getElementById('abusepopup_'+abuse_id).innerHTML = '<a href="#" class="gray999">Under Review</a>';
	}

	hideVideoCommentsPopup();
    }
}

var callback_video_comments_abuse1 =
{
    success:AjaxObject.handleSuccess_video_comments_abuse,
    scope: AjaxObject
};

function saveVideoCommentsReportAbuse()
{

    var selected_types = '';
    var comma = '';   
    var select_action = false;
    var abuse_types = document.video_comments_abuse_form.abuse_type;
    var login_user_id = document.getElementById('login_user_id').value;
    
    for(var i=0;i<6;i++)
	{
	    if(abuse_types[i].value != '')
		{
		    if(abuse_types[i].checked)
			{
			  selected_types = selected_types + comma + abuse_types[i].value;			    
			  comma = ',';	
			  select_action = true;
			}
		}
	    
	}
    
    if(login_user_id == '' || isNaN(login_user_id))
       {
	 document.getElementById('abuse_comments_error_msg').innerHTML = ERROR_LOGIN_REQUIRED;
	 //displayErrorMessage('error_video_comments',ERROR_LOGIN_REQUIRED);	 
       }
    else if(select_action == false)
      {
	document.getElementById('abuse_comments_error_msg').innerHTML = 'Please select the reason for your complaint.';
      }
    else
	{	 
	    var abuse_id = document.getElementById('abuse_id').value;
	    var abuse_user_id = document.getElementById('abuse_user_id').value;
	    var login_user_id = document.getElementById('login_user_id').value;
	    var postData ='abuse_types='+selected_types+'&abuse_id='+abuse_id+'&abuse_user_id='+abuse_user_id+'&login_user_id='+login_user_id;
	    YAHOO.util.Connect.asyncRequest('POST',system_base_url+'ajax/adda/_abuse_adda_video_comment/', callback_video_comments_abuse1, postData);
	    if(env_value == 'Online')
	{
	    var url = system_base_url+'ajax/adda/_abuse_adda_video_comment/';
	    pageTracker._trackPageview(url);
	}
    
	}

}

YAHOO.namespace("example.video_container1");
function initVideoPopup() {
	// Instantiate the Dialog

	YAHOO.example.video_container1.video_dialog1 = new YAHOO.widget.Dialog("video_dialog1", 
									       { width : "50em",
										 context:["popup_context","tl","bl"],
										 visible : false,
										 modal:true
									       });

	YAHOO.example.video_container1.video_dialog2 = new YAHOO.widget.Dialog("video_dialog2", 
									       { width : "50em",
										 context:["popup_context","tl","bl"],
										 visible : false,
										 modal:true
									       });

	YAHOO.example.video_container1.video_dialog2_comment = new YAHOO.widget.Dialog("video_dialog2_comment", 
									       { width : "50em",
										 context:["popup_context","tl","bl"],
										 visible : false,
										 modal:true
									       });


	YAHOO.example.video_container1.video_dialog3 = new YAHOO.widget.Dialog("video_dialog3", 
									       { width : "50em",
										 context:["popup_context","tl","bl"],
										 visible : false,
										 modal:true
										 });


	YAHOO.example.video_container1.video_dialog1.render();
	YAHOO.example.video_container1.video_dialog1.hide();
	
	YAHOO.example.video_container1.video_dialog2.render();
	YAHOO.example.video_container1.video_dialog2.hide();

	YAHOO.example.video_container1.video_dialog3.render();
	YAHOO.example.video_container1.video_dialog3.hide();

	YAHOO.example.video_container1.video_dialog2_comment.render();
	YAHOO.example.video_container1.video_dialog2_comment.hide();
	
	YAHOO.example.video_container1.manager = new YAHOO.widget.OverlayManager();
	YAHOO.example.video_container1.manager.register([
						   YAHOO.example.video_container1.video_dialog1,
						   YAHOO.example.video_container1.video_dialog2,
						   YAHOO.example.video_container1.video_dialog3,
						   YAHOO.example.video_container1.video_dialog2_comment
						   ]);

}

//call on dom ready - during window load
YAHOO.util.Event.onDOMReady(initVideoPopup);
function showVideoPopup()
{

  var login_user_id = document.getElementById('logged_in_user_id').value;

  if(login_user_id == '' || isNaN(login_user_id) )
    {
      displayErrorMessage('error_video_comments',ERROR_LOGIN_REQUIRED);
      return false;
    }

  document.getElementById('mymedia').style.display='none';
  document.getElementById('video_dialog1').style.display='block';
  YAHOO.example.video_container1.video_dialog1.show();
}
function hideVideoPopup()
{
  document.getElementById('video_dialog1').style.display='none';
  document.getElementById('mymedia').style.display='block';
  YAHOO.example.video_container1.video_dialog1.hide();
  
}
function showAddToPlaylistPopup()
{
  
  var login_user_id = document.getElementById('logged_in_user_id').value;

  if(login_user_id == '' || isNaN(login_user_id) )
    {
      displayErrorMessage('error_video_comments',ERROR_LOGIN_REQUIRED);
      return false;
    }

  document.getElementById('mymedia').style.display='none';
  document.getElementById('video_dialog3').style.display='block';
  YAHOO.example.video_container1.video_dialog3.show();
}
function hideAddToPlaylistPopup()
{
  document.getElementById('mymedia').style.display='block';
  document.getElementById('video_dialog3').style.display='none';
  YAHOO.example.video_container1.video_dialog3.hide();
}

function showVideoCommentsPopup(comment_id,login_user_id,comment_user_id)
{

  if(login_user_id == '' || isNaN(login_user_id) )
    {
      displayErrorMessage('error_video_comments',ERROR_LOGIN_REQUIRED);
      return false;
    }
  else if(login_user_id == comment_user_id)
    {
      displayErrorMessage('error_video_comments',ERROR_REPORT_ABUSE_SAME_USER);
      return false;
    }
  
  document.getElementById('mymedia').style.display='none'; 
  document.getElementById('video_dialog2').style.display='block';
  YAHOO.example.video_container1.video_dialog2.show();
  
  document.getElementById('abuse_id').value = comment_id; 
  document.getElementById('abuse_user_id').value = comment_user_id;
  document.getElementById('login_user_id').value = login_user_id;

}

function hideVideoCommentsPopup()
{
  document.getElementById('video_dialog2').style.display='none';
  YAHOO.example.video_container1.video_dialog2.hide();
}

/* share module overly issue resolved*/
function videoShare()
{

  document.getElementById('mymedia').style.display='none';
  share();

}


function closeVideoCommentPopup()
{
    YAHOO.example.video_container1.video_dialog2_comment.hide();
    document.getElementById('mymedia').style.display='block';
}


