//JQUERY
function deletePhotoCommentsJquery(comment_id){
  if(confirm(DELETE_PHOTO)){	   
    var photo_id = document.getElementById('photo_post_id').value;
    var photo_page = document.getElementById('photo_page').value;
    var photo_owner = document.getElementById('photo_owner').value;
    var photo_comment_id = comment_id;
    var postData ='comment_id='+photo_comment_id+'&photo_post_id='+photo_id+'&photo_owner='+photo_owner+'&photo_page='+photo_page;
    var url =  system_base_url+'ajax/photos/_delete_photo_comment/' ;
    jQuery.post(url,postData,callback_delete_photo_comment_jquery); 
    if(env_value == 'Online')
	{
	    pageTracker._trackPageview(url);
	}
 
}
}
function callback_delete_photo_comment_jquery(data){
  document.getElementById("error_photo_comments").innerHTML= '';        
  document.getElementById("photo_landing_comments").innerHTML=data;        
}
function addRemoveFavoritesJquery(photo_id,login_user_id){
  if(login_user_id == '' || isNaN(login_user_id)){
    displayErrorCommon('error_photo_comments',ERROR_LOGIN_REQUIRED);
  }
  else {	 
    var post_data = 'photo_id='+photo_id+'&login_user_id='+login_user_id;
    jQuery.post(system_base_url+'ajax/photos/_favorite_photo/',post_data,callback_photo_favsJquery);
    if(env_value == 'Online')
	{
	    var url = system_base_url+'ajax/photos/_favorite_photo/';
	    pageTracker._trackPageview(url);
	}
    
  }
}
function callback_photo_favsJquery(data){
  if(data == 1001){
    document.getElementById("favorites").innerHTML = ERROR_PHOTO_REMOVE_FROM_FAVS;
  }
  else if(data == 1002){
    document.getElementById("favorites").innerHTML = ERROR_PHOTO_ADD_TO_FAVS;
  }
  else{
    displayErrorCommon('error_photo_comments',data,'notice');
  }
}

jQuery(document).ready(function() {

	var logged_in_user_id = document.getElementById('logged_in_user_id').value;
	if(logged_in_user_id == ''){
	    var view = document.getElementById('view').value;
	    var photo_id = document.getElementById('photo_id').value;
	    var postData = "view="+view+"&photo_id="+photo_id;
	    jQuery.ajax({
		    type: "POST",
			url: system_base_url+"ajax/photos/_update_view",
			data: postData,
			success: function(msg){
			var msg_value = msg.split("|");
			document.getElementById('main_photo_view').innerHTML=msg_value[0];
		    }
		});
	}
	
    $('#hrefDelete').click(function(){
	if(confirm(DELETE_PHOTO)){	   
	  document.getElementById('frmLanding').action = system_base_url+'photos/_delete_photo_main/';
	  $('#frmLanding').submit();
	}
      });
    $('#hrefEdit').click(function(){
	document.getElementById('frmLanding').action = system_base_url+'photos/_show_edit_photo/';                                                                  $('#frmLanding').submit();
      });
    
    $('#btnSubmit').click(function(){
	document.getElementById('error_photo_comments').style.display = 'block';
	document.getElementById('error_photo_comments').innerHTML = '';
	var body_text = document.getElementById('body').value;
	if(body_text == ''){
	  displayErrorCommon('error_photo_comments',ERROR_NO_PHOTO_BODY_TEXT,'error');
	  return false;
	}
	$('#frmcomment').submit(); 
      });
  });